View Issue Details

IDProjectCategoryView StatusLast Update
0000937ScribusUser Interfacepublic2006-04-26 18:53
Reporterjo-hannes Assigned Tosubik  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
PlatformAMD Athlon 1000MHzOSSuse LinuxOS Version9.1
Fixed in Version1.3.4cvs 
Summary0000937: highlight guideline when clicking on one in the guide line manager
Descriptionwhen i have a lot of lines in my doc i find it useful when the i can open the manager, click on one line and that line gets highlighted in the doc, blinking, other color, or so.
TagsNo tags attached.
Patch

Relationships

child of 0002935 acknowledgedsubik Metabug: Guide Dialog 

Activities

jb

2005-05-12 09:26

reporter   ~0004599

Last edited: 2005-05-12 09:26

Attached is a patch against 1.3 cvs which fixes the issue. It turns the guides dialog into a semi-modal dialog. It then redraws the page each time a guide is changed, so that all created guides are then shown in real time on the page, and the highlighted one is of a different color.

Maybe there is a smarter/faster approach, but on my computer (2.8Ghz), I can see the guides moving quite smoothly.

Please note that the patch also include the one included in feature request 1973 (create rows&columns in selected area), since I am also working on it & didn't find an easy way to separate them...

2005-05-12 09:28

 

realtimeguide.diff (15,806 bytes)   
? guide.diff
? guidemove.diff
? guides2.diff
? realrimeguide.diff
? dtd/Makefile
? dtd/Makefile.in
? libabout/.deps
? libabout/.libs
? libabout/Makefile
? libabout/Makefile.in
? libabout/about.lo
? libabout/about.moc
? libabout/libabout.la
? libpdf/pdflib.loT
? libprefs/.deps
? libprefs/.libs
? libprefs/Makefile
? libprefs/Makefile.in
? libprefs/libpreferences.la
? libprefs/prefs.lo
? libprefs/prefs.moc
? plugins/libchar/.deps
? plugins/libchar/.libs
? plugins/libchar/Makefile
? plugins/libchar/Makefile.in
? plugins/libchar/charselect.lo
? plugins/libchar/charselect.moc
? plugins/libchar/libcharselect.la
Index: guidemanager.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/guidemanager.cpp,v
retrieving revision 1.22.2.6
diff -u -3 -p -u -r1.22.2.6 guidemanager.cpp
--- guidemanager.cpp	9 May 2005 18:23:01 -0000	1.22.2.6
+++ guidemanager.cpp	12 May 2005 11:10:43 -0000
@@ -40,11 +40,15 @@
  * - added the esc key
  ***************************************************************************/
 
+
+#include <qradiobutton.h>
 #include "guidemanager.h"
 #include "guidemanager.moc"
 
+
 #include "units.h"
 
+
 extern QPixmap loadIcon(QString nam);
 
 GuideManager::GuideManager(
@@ -53,13 +57,13 @@ GuideManager::GuideManager(
 			QValueList<double> YGuides,
 			double PageW,
 			double PageH,
-			double topM,
-			double bottomM,
-			double leftM,
-			double rightM,
+			FPoint MarginTL,
+			FPoint MarginBR,
+			FPoint SelectionTL,
+			FPoint SelectionBR,
 			bool GuideLock,
 			int Einh
-		) : QDialog(parent, "GuideManager", true, 0)
+		) : QDialog(parent, "GuideManager", true, WDestructiveClose)
 {
 	QString tmp;
 	setCaption(tr("Manage Guides"));
@@ -72,13 +76,29 @@ GuideManager::GuideManager(
 
 	LocHor = YGuides; // in page XGuides and YGuides are inverted
 	LocVer = XGuides;
+
+	LocHorBackup = YGuides;
+	LocVerBackup = XGuides;
+	
 	LocPageWidth = PageW;
 	LocPageHeight = PageH;
 	LocLocked = GuideLock;
-	LocTop=topM;
-	LocBottom=bottomM;
-	LocRight=rightM;
-	LocLeft=leftM;
+
+	LocLeft=MarginTL.x();
+	LocTop=MarginTL.y();
+	LocRight=MarginBR.x();
+	LocBottom=MarginBR.y();
+
+	bool selected=true;
+
+	if (SelectionBR!=FPoint(0,0))
+	{
+		gy=SelectionTL.y();
+		gx=SelectionTL.x();
+		gw=SelectionBR.x();
+		gh=SelectionBR.y();
+	}
+	else selected=false;
 
 	selHor = selVer = -1;
 
@@ -201,8 +221,16 @@ GuideManager::GuideManager(
 	Layout9->addWidget(ColSet);
 
 	Layout10 = new QHBoxLayout(0, 0, 6, "Layout10");
-	Marg = new QCheckBox( tr( "&Follow Margins" ), HorGroup2, "marg");
-	Layout10->addWidget(Marg);
+	BGroup=new QHButtonGroup(HorGroup2,"bgroup");
+	BGroup->setFrameStyle(QFrame::NoFrame);
+	QLabel *TextLabel10 = new QLabel(tr("Refer to:"), HorGroup2, "TextLabel10");
+	Layout10->addWidget(TextLabel10);
+	QRadioButton *fPage = new QRadioButton( tr( "&Page" ), BGroup, "fpage"); 
+	fPage->setChecked(true);
+	(void) new QRadioButton( tr( "&Margins" ), BGroup, "fmargin");
+	QRadioButton *fSelect = new QRadioButton( tr( "&Selection" ), BGroup, "fselect");
+	fSelect->setEnabled(selected);
+	Layout10->addWidget(BGroup);
 
 	QSpacerItem* spacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
 	Layout10->addItem(spacer2);
@@ -236,14 +264,14 @@ GuideManager::GuideManager(
 	UnitChange();
 
 	// Create signals and slots connections
-	connect( OK, SIGNAL(clicked()), this, SLOT(accept() ));
-	connect( Cancel, SIGNAL(clicked()), this, SLOT(reject()));
+	connect( OK, SIGNAL(clicked()), this, SLOT(SlotAccept()));
+	connect( Cancel, SIGNAL(clicked()), this, SLOT(SlotCancel()));
 	connect(HorList, SIGNAL(highlighted(QListBoxItem*)), this, SLOT(selHorIte(QListBoxItem*)));
 	connect(VerList, SIGNAL(highlighted(QListBoxItem*)), this, SLOT(selVerIte(QListBoxItem*)));
 	connect(HorSet, SIGNAL(clicked()), this, SLOT(AddHorVal()));
 	connect(RowSet, SIGNAL(clicked()), this, SLOT(AddRows()));
 	connect(ColSet, SIGNAL(clicked()), this, SLOT(AddCols()));
-
+	
 	connect(HorDel, SIGNAL(clicked()), this, SLOT(DelHorVal()));
 	connect(HorSpin, SIGNAL(valueChanged(int)), this, SLOT(ChangeHorVal()));
 	connect(VerSet, SIGNAL(clicked()), this, SLOT(AddVerVal()));
@@ -276,6 +304,19 @@ GuideManager::GuideManager(
 		}
 	}
 }
+
+void GuideManager::SlotCancel()
+{
+emit RestoreValues(LocVerBackup,LocHorBackup);
+reject();
+}
+
+void GuideManager::SlotAccept()
+{
+emit ApplyChanges(Lock->isChecked());
+accept();
+}
+
 void GuideManager::DelHorVal()
 {
 	QValueList<double>::Iterator it;
@@ -288,6 +329,7 @@ void GuideManager::DelHorVal()
 	if (selHor == -1)
 		HorDel->setEnabled(false);
 	UpdateHorList();
+	emit YGuideMoved(LocHor,selHor);
 }
 
 void GuideManager::DelVerVal()
@@ -302,6 +344,7 @@ void GuideManager::DelVerVal()
 	if (selVer == -1)
 		VerDel->setEnabled(false);
 	UpdateVerList();
+	emit XGuideMoved(LocVer,selVer);
 }
 
 void GuideManager::AddHorVal()
@@ -331,11 +374,16 @@ void GuideManager::AddRows()
 	double offset = 0;
 	double NewPageHeight = LocPageHeight;
 
-	if (Marg->isChecked())
+	if (BGroup->selectedId ()==1)
 	{
 		NewPageHeight = LocPageHeight - LocTop - LocBottom;
 		offset = LocTop;
 	}
+	else if (BGroup->selectedId ()==2) 
+	{
+	offset=gy;
+	NewPageHeight=gh;
+	}
 
 	double spacing = NewPageHeight / n;
 	int selHor = 0;
@@ -347,7 +395,7 @@ void GuideManager::AddRows()
 		int m = n;
 		double curHor = offset + spacing * i;
 
-		if (LocHor.contains(curHor))
+		if (LocHor.contains(curHor) || curHor<0 || curHor>LocPageHeight)
 			continue;
 
 		for (int i = n - 1; i > 0; i--)
@@ -368,6 +416,9 @@ void GuideManager::AddRows()
 		}
 	}
 	UpdateHorList();
+	HorList->setCurrentItem(0);
+	HorList->setSelected(0,true);
+	UpdateHorGuide();
 }
 
 void GuideManager::AddCols()
@@ -376,11 +427,17 @@ void GuideManager::AddCols()
 	double offset = 0;
 	double NewPageWidth = LocPageWidth;
 
-	if (Marg->isChecked())
+
+	if (BGroup->selectedId ()==1)
 	{
 		NewPageWidth=LocPageWidth-LocLeft-LocRight;
 		offset=LocLeft;
 	}
+	else if (BGroup->selectedId ()==2) 
+	{
+	offset=gx;
+	NewPageWidth=gw;
+	}
 
 	double spacing = NewPageWidth/n;
 	int selVer = 0;
@@ -392,7 +449,7 @@ void GuideManager::AddCols()
 		int m = n;
 		double curVer = offset + spacing * i;
 
-		if (LocVer.contains(curVer))
+		if (LocVer.contains(curVer) || curVer<0 || curVer>LocPageWidth)
 			continue;
 
 		for (int i = n - 1; i > 0; i--)
@@ -413,6 +470,9 @@ void GuideManager::AddCols()
 		}
 	}
 	UpdateVerList();
+	VerList->setCurrentItem(0);
+	VerList->setSelected(0,true);
+	UpdateVerGuide();
 }
 
 
@@ -453,6 +513,7 @@ void GuideManager::selHorIte(QListBoxIte
 	HorSpin->setEnabled(true);
 	HorSpin->setValue(LocHor[selHor] * docUnitRatio);
 	connect(HorSpin, SIGNAL(valueChanged(int)), this, SLOT(ChangeHorVal()));
+	UpdateHorGuide();
 }
 
 void GuideManager::selVerIte(QListBoxItem *c)
@@ -466,6 +527,7 @@ void GuideManager::selVerIte(QListBoxIte
 	VerSpin->setEnabled(true);
 	VerSpin->setValue(LocVer[selVer] * docUnitRatio);
 	connect(VerSpin, SIGNAL(valueChanged(int)), this, SLOT(ChangeVerVal()));
+	UpdateVerGuide();
 }
 
 void GuideManager::ChangeHorVal()
@@ -494,6 +556,7 @@ void GuideManager::ChangeHorVal()
 		LocHor.insert(it,curHor);
 	}
 	UpdateHorList();
+	UpdateHorGuide();
 }
 
 void GuideManager::ChangeVerVal()
@@ -522,6 +585,7 @@ void GuideManager::ChangeVerVal()
 		LocVer.insert(it,curVer);
 	}
 	UpdateVerList();
+	UpdateVerGuide();
 }
 
 void GuideManager::UnitChange()
@@ -534,6 +598,16 @@ void GuideManager::UnitChange()
 	VerSpin->setDecimals(decimals);
 }
 
+void GuideManager::UpdateHorGuide()
+{
+if (selHor != -1) emit (YGuideMoved(LocHor,LocHor[selHor]));
+}
+
+void GuideManager::UpdateVerGuide()
+{
+if (selVer != -1) emit (XGuideMoved(LocVer,LocVer[selVer]));
+}
+
 void GuideManager::UpdateHorList()
 {
 	disconnect(HorList, SIGNAL(highlighted(QListBoxItem*)), this, SLOT(selHorIte(QListBoxItem*)));
Index: guidemanager.h
===================================================================
RCS file: /cvs/Scribus/scribus/guidemanager.h,v
retrieving revision 1.5.2.5
diff -u -3 -p -u -r1.5.2.5 guidemanager.h
--- guidemanager.h	9 May 2005 18:23:01 -0000	1.5.2.5
+++ guidemanager.h	12 May 2005 11:10:43 -0000
@@ -10,6 +10,8 @@
 #include <qcheckbox.h>
 #include <qlayout.h>
 #include <qtooltip.h>
+#include <qhbuttongroup.h>
+
 #include "mspinbox.h"
 #include "page.h"
 
@@ -25,10 +27,10 @@ public:
 			QValueList<double> YGuides,
 			double PageB,
 			double PageH,
-			double topM,
-			double bottomM,
-			double leftM,
-			double rightM,
+			FPoint MarginTL,
+			FPoint MarginBR,
+			FPoint SelectionTL,
+			FPoint SelectionBR,
 			bool GuideLock,
 			int Einh
 		);
@@ -36,6 +38,9 @@ public:
 
 	QValueList<double> LocHor;
 	QValueList<double> LocVer;
+	
+	QValueList<double> LocHorBackup;
+	QValueList<double> LocVerBackup;
 	bool LocLocked;
 
 private:
@@ -45,6 +50,8 @@ private:
 	double LocBottom;
 	double LocRight;
 	double LocLeft;
+	double gx, gy, gw, gh;
+
 	int docUnitIndex;
 
 	int selHor;
@@ -66,7 +73,7 @@ private:
 
 	QSpinBox* ColSpin;
 	QSpinBox* RowSpin;
-	QCheckBox* Marg;
+	QHButtonGroup *BGroup;
 
 	QCheckBox* Lock;
 
@@ -115,6 +122,16 @@ private slots:
 	void ChangeVerVal();
 	void AddRows();
 	void AddCols();
+	void UpdateHorGuide();
+	void UpdateVerGuide();
+	void SlotCancel();
+	void SlotAccept();
+
+signals:
+	void YGuideMoved(QValueList<double>,double);
+	void XGuideMoved(QValueList<double>,double);
+	void RestoreValues(QValueList<double>,QValueList<double>);
+	void ApplyChanges(bool isLocked);
 };
 
 #endif // GUIDEMANAGER_H
Index: page.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/page.cpp,v
retrieving revision 1.209.2.13
diff -u -3 -p -u -r1.209.2.13 page.cpp
--- page.cpp	4 May 2005 23:27:10 -0000	1.209.2.13
+++ page.cpp	12 May 2005 11:10:43 -0000
@@ -37,6 +37,8 @@ Page::Page(double x, double y, double b,
 	PageNam = "";
 	XGuides.clear();
 	YGuides.clear();
+	HYGuide=-1;
+	HXGuide=-1;
 	FromMaster.clear();
 	undoManager = UndoManager::instance();
 }
Index: page.h
===================================================================
RCS file: /cvs/Scribus/scribus/page.h,v
retrieving revision 1.53.2.12
diff -u -3 -p -u -r1.53.2.12 page.h
--- page.h	4 May 2005 23:27:10 -0000	1.53.2.12
+++ page.h	12 May 2005 11:10:43 -0000
@@ -49,6 +49,8 @@ public:
 	QString PageNam;
 	QValueList<double> XGuides;
 	QValueList<double> YGuides;
+	double HYGuide;
+	double HXGuide;
 	QPtrList<PageItem> FromMaster;
 	void setPageNr(int pageNr);
 	uint getPageNr();
Index: scribus.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/scribus.cpp,v
retrieving revision 1.228.2.299
diff -u -3 -p -u -r1.228.2.299 scribus.cpp
--- scribus.cpp	9 May 2005 20:46:51 -0000	1.228.2.299
+++ scribus.cpp	12 May 2005 11:10:48 -0000
@@ -9587,31 +9587,85 @@ void ScribusApp::ManageGuides()
 {
 	if (HaveDoc)
 	{
+		FPoint SelectionTopLeft=FPoint(0,0);
+		FPoint SelectionBottomRight=FPoint(0,0);
+		FPoint MarginTopLeft(doc->pageMargins.Top,doc->pageMargins.Bottom);
+		FPoint MarginBottomRight(doc->pageMargins.Left,doc->pageMargins.Right);
+
+		if (view->SelItem.count() > 1)
+			{
+			SelectionTopLeft.setXY(view->GroupX-doc->ScratchLeft, view->GroupY-doc->ScratchTop);
+			SelectionBottomRight.setXY(view->GroupW,view->GroupH);
+			}
+		else if (view->SelItem.count() == 1)
+			{
+			PageItem *currItem = view->SelItem.at(0);
+			SelectionTopLeft.setXY(currItem->BoundingX-doc->ScratchLeft,currItem->BoundingY-doc->ScratchTop);
+			SelectionBottomRight.setXY(currItem->BoundingW,currItem->BoundingH);
+			}
+		
 		GuideManager *dia = new GuideManager(
 					this,
 					doc->currentPage->XGuides,
 					doc->currentPage->YGuides,
 					doc->currentPage->Width,
 					doc->currentPage->Height,
-					doc->pageMargins.Top,
-					doc->pageMargins.Bottom,
-					doc->pageMargins.Left,
-					doc->pageMargins.Right,
+					MarginTopLeft,
+					MarginBottomRight,
+					SelectionTopLeft,
+					SelectionBottomRight,
 					doc->GuideLock,
 					doc->docUnitIndex
 					);
-		if (dia->exec())
-		{
-			doc->currentPage->addXGuides(dia->LocVer);
-			doc->currentPage->addYGuides(dia->LocHor);
-			doc->lockGuides(dia->LocLocked);
-			view->DrawNew();
-//			slotDocCh();
-		}
-		delete dia;
+		
+		if (doc->currentPage->YGuides.count()>0) RefreshYGuides(doc->currentPage->YGuides,doc->currentPage->YGuides[0]);
+		else if (doc->currentPage->XGuides.count()>0) RefreshXGuides(doc->currentPage->XGuides,doc->currentPage->XGuides[0]);
+
+		connect(dia, SIGNAL(YGuideMoved(QValueList<double>,double)), this, SLOT(RefreshYGuides(QValueList<double>,double)));
+		connect(dia, SIGNAL(XGuideMoved(QValueList<double>,double)), this, SLOT(RefreshXGuides(QValueList<double>,double)));
+		connect(dia, SIGNAL(ApplyChanges(bool)), this, SLOT(CloseGuide(bool)));
+
+		connect(dia, SIGNAL(RestoreValues(QValueList<double>,QValueList<double>)), this, SLOT(RestoreGuides(QValueList<double>,QValueList<double>)));
+		
+		dia->show();
 	}
 }
 
+void ScribusApp::RefreshYGuides(QValueList<double> YList,double YGuide)
+{
+doc->currentPage->addYGuides(YList);
+doc->currentPage->HYGuide=YGuide;
+doc->currentPage->HXGuide=-1;
+view->DrawNew();
+}
+
+void ScribusApp::CloseGuide(bool isLocked)
+{
+doc->currentPage->HYGuide=-1;
+doc->currentPage->HXGuide=-1;
+doc->lockGuides(isLocked);
+view->DrawNew();
+}
+
+void ScribusApp::RefreshXGuides(QValueList<double> XList,double XGuide)
+{
+doc->currentPage->addXGuides(XList);
+doc->currentPage->HXGuide=XGuide;
+doc->currentPage->HYGuide=-1;
+view->DrawNew();
+}
+
+void ScribusApp::RestoreGuides(QValueList<double> XList,QValueList<double> YList)
+{
+doc->currentPage->addXGuides(XList);
+doc->currentPage->addYGuides(YList);
+doc->currentPage->HYGuide=-1;
+doc->currentPage->HXGuide=-1;
+view->DrawNew();
+}
+
+
+
 void ScribusApp::setItemFillTransparency(double t)
 {
 	if (HaveDoc)
Index: scribus.h
===================================================================
RCS file: /cvs/Scribus/scribus/scribus.h,v
retrieving revision 1.60.2.91
diff -u -3 -p -u -r1.60.2.91 scribus.h
--- scribus.h	9 May 2005 20:46:51 -0000	1.60.2.91
+++ scribus.h	12 May 2005 11:10:49 -0000
@@ -455,6 +455,12 @@ public slots:
 	void setUndoMode(bool isObjectSpecific);
 	void insertSampleText();
 
+private slots:
+void CloseGuide(bool isLocked);
+void RefreshYGuides(QValueList<double> YList,double YGuide);
+void RefreshXGuides(QValueList<double> XList,double XGuide);
+void RestoreGuides(QValueList<double> XList,QValueList<double> YList);
+
 signals:
 	void TextISize(int);
 	void TextIFont(QString);
Index: scribusview.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/scribusview.cpp,v
retrieving revision 1.76.2.188
diff -u -3 -p -u -r1.76.2.188 scribusview.cpp
--- scribusview.cpp	9 May 2005 14:46:21 -0000	1.76.2.188
+++ scribusview.cpp	12 May 2005 11:10:53 -0000
@@ -696,6 +696,7 @@ void ScribusView::DrawPageItems(ScPainte
 	painter->setZoomFactor(z);
 }
 
+
 void ScribusView::DrawPageMarks(ScPainter *p, Page *page, QRect)
 {
 	double lw = 1.0 / Scale;
@@ -783,6 +784,17 @@ void ScribusView::DrawPageMarks(ScPainte
 			for (uint yg = 0; yg < page->YGuides.count(); ++yg)
 				p->drawLine(FPoint(0, page->YGuides[yg]), FPoint(page->Width, page->YGuides[yg]));
 		}
+		// draw highlighted guides
+		if (Doc->currentPage->HXGuide!=-1)
+		{
+		p->setPen(Doc->guidesSettings.minorColor, lw, DotLine, FlatCap, MiterJoin);
+		p->drawLine(FPoint(page->HXGuide,0), FPoint(page->HXGuide,page->Height));
+		}
+		else if (Doc->currentPage->HYGuide!=-1)
+		{
+		p->setPen(Doc->guidesSettings.minorColor, lw, DotLine, FlatCap, MiterJoin);
+		p->drawLine(FPoint(0, page->HYGuide), FPoint(page->Width, page->HYGuide));
+		}
 	}
 	p->restore();
 	p->setZoomFactor(z);
realtimeguide.diff (15,806 bytes)   

subik

2006-04-26 14:33

manager   ~0010487

guides are rewritten. highlighting on-the-fly works now.

Issue History

Date Modified Username Field Change
2004-08-06 19:55 jo-hannes New Issue
2005-05-12 09:26 jb Note Added: 0004599
2005-05-12 09:26 jb Note Edited: 0004599
2005-05-12 09:28 jb File Added: realtimeguide.diff
2005-12-29 20:34 subik Status new => assigned
2005-12-29 20:34 subik Assigned To => subik
2005-12-30 08:57 subik Relationship added child of 0002935
2006-04-26 14:33 subik Status assigned => resolved
2006-04-26 14:33 subik Fixed in Version => 1.3.4cvs
2006-04-26 14:33 subik Resolution open => fixed
2006-04-26 14:33 subik Note Added: 0010487
2006-04-26 18:53 mhanski Status resolved => closed