r15219 by cbradney - #8392: Apply patch to allow resize for alignment
scribus-commit
scribus-commit at lists.scribus.net
Fri Jun 18 00:40:30 CEST 2010
Revision: 15219
Author: cbradney
Date: 2010-06-17T22:38:36.956407Z
Commit message: #8392: Apply patch to allow resize for alignment
Changeset:
M /branches/Version135/Scribus/scribus/aligndistribute.cpp
M /branches/Version135/Scribus/scribus/aligndistribute.h
M /branches/Version135/Scribus/scribus/scribusdoc.cpp
M /branches/Version135/Scribus/scribus/aligndistribute.ui
M /branches/Version135/Scribus/scribus/scribusdoc.h
Diffs:
Index: scribus/aligndistribute.ui
===================================================================
--- scribus/aligndistribute.ui (revision 15218)
+++ scribus/aligndistribute.ui (revision 15219)
@@ -105,6 +105,22 @@
<item row="0" column="1" >
<widget class="QComboBox" name="alignRelativeToCombo" />
</item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="alignMoveOrResizeLabel" >
+ <property name="text" >
+ <string>&Align Sides By:</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>false</bool>
+ </property>
+ <property name="buddy" >
+ <cstring>alignMoveOrResizeCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QComboBox" name="alignMoveOrResizeCombo" />
+ </item>
</layout>
</item>
<item>
Index: scribus/aligndistribute.h
===================================================================
--- scribus/aligndistribute.h (revision 15218)
+++ scribus/aligndistribute.h (revision 15219)
@@ -99,11 +99,13 @@
void distributeTop();
void alignToChanged(int);
+ void alignMethodChanged(int);
private:
void init();
UndoManager *undoManager;
ScribusDoc::AlignTo currAlignTo;
+ ScribusDoc::AlignMethod currAlignMethod;
QList<AlignObjs> *alignObjects;
ScribusDoc *currDoc;
qreal unitRatio;
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp (revision 15218)
+++ scribus/scribusdoc.cpp (revision 15219)
@@ -7948,9 +7948,68 @@
regionsChanged()->update(QRectF());
}
+void ScribusDoc::itemSelection_AlignItemRight(int i, double newX, AlignMethod how)
+{
+ double diff=newX-AObjects[i].x2;
+ double width=AObjects[i].x2-AObjects[i].x1;
+ bool resize = (how == alignByResizing && diff > -width);
+ for (int j = 0; j < AObjects[i].Objects.count(); ++j)
+ if (!AObjects[i].Objects.at(j)->locked()) {
+ if (resize) {
+ AObjects[i].Objects.at(j)->resizeBy(diff, 0.0);
+ AObjects[i].Objects.at(j)->updateClip();
+ }
+ else AObjects[i].Objects.at(j)->moveBy(diff, 0.0);
+ }
+}
-void ScribusDoc::itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignItemLeft(int i, double newX, AlignMethod how)
{
+ double diff=newX-AObjects[i].x1;
+ double width=AObjects[i].x2-AObjects[i].x1;
+ bool resize = (how == alignByResizing && -diff > -width);
+ for (int j = 0; j < AObjects[i].Objects.count(); ++j)
+ if (!AObjects[i].Objects.at(j)->locked()) {
+ AObjects[i].Objects.at(j)->moveBy(diff, 0.0);
+ if (resize) {
+ AObjects[i].Objects.at(j)->resizeBy(-diff, 0.0);
+ AObjects[i].Objects.at(j)->updateClip();
+ }
+ }
+}
+
+void ScribusDoc::itemSelection_AlignItemBottom(int i, double newY, AlignMethod how)
+{
+ double diff=newY-AObjects[i].y2;
+ double height=AObjects[i].y2-AObjects[i].y1;
+ bool resize = (how == alignByResizing && diff > -height);
+ for (int j = 0; j < AObjects[i].Objects.count(); ++j)
+ if (!AObjects[i].Objects.at(j)->locked()) {
+ if (resize) {
+ AObjects[i].Objects.at(j)->resizeBy(0.0, diff);
+ AObjects[i].Objects.at(j)->updateClip();
+ }
+ else AObjects[i].Objects.at(j)->moveBy(0.0, diff);
+ }
+}
+
+void ScribusDoc::itemSelection_AlignItemTop(int i, double newY, AlignMethod how)
+{
+ double diff=newY-AObjects[i].y1;
+ double height=AObjects[i].y2-AObjects[i].y1;
+ bool resize = (how == alignByResizing && -diff > -height);
+ for (int j = 0; j < AObjects[i].Objects.count(); ++j)
+ if (!AObjects[i].Objects.at(j)->locked()) {
+ AObjects[i].Objects.at(j)->moveBy(0.0, diff);
+ if (resize) {
+ AObjects[i].Objects.at(j)->resizeBy(0.0, -diff);
+ AObjects[i].Objects.at(j)->updateClip();
+ }
+ }
+}
+
+void ScribusDoc::itemSelection_AlignLeftOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
+{
if (!startAlign())
return;
uint alignObjectsCount=AObjects.count();
@@ -7982,17 +8041,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newX-AObjects[i].x2;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(diff, 0.0);
- }
+ itemSelection_AlignItemRight(i, newX, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignLeftIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8025,17 +8079,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newX-AObjects[i].x1;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(diff, 0.0);
- }
+ itemSelection_AlignItemLeft(i, newX, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignCenterHor(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8089,7 +8138,7 @@
}
-void ScribusDoc::itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignRightIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8124,17 +8173,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newX-AObjects[i].x2;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(diff, 0.0);
- }
+ itemSelection_AlignItemRight(i, newX, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignRightOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8169,17 +8213,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newX-AObjects[i].x1;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(diff, 0.0);
- }
+ itemSelection_AlignItemLeft(i, newX, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignTopOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8212,17 +8251,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newY-AObjects[i].y2;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(0.0, diff);
- }
+ itemSelection_AlignItemBottom(i, newY, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignTopIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8255,17 +8289,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newY-AObjects[i].y1;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(0.0, diff);
- }
+ itemSelection_AlignItemTop(i, newY, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignCenterVer(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8319,7 +8348,7 @@
}
-void ScribusDoc::itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignBottomIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8354,17 +8383,12 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newY-AObjects[i].y2;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(0.0, diff);
- }
+ itemSelection_AlignItemBottom(i, newY, currAlignMethod);
endAlign();
}
-void ScribusDoc::itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition)
+void ScribusDoc::itemSelection_AlignBottomOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition)
{
if (!startAlign())
return;
@@ -8399,12 +8423,7 @@
break;
}
for (int i = loopStart; i <= loopEnd; ++i)
- {
- double diff=newY-AObjects[i].y1;
- for (int j = 0; j < AObjects[i].Objects.count(); ++j)
- if (!AObjects[i].Objects.at(j)->locked())
- AObjects[i].Objects.at(j)->moveBy(0.0, diff);
- }
+ itemSelection_AlignItemTop(i, newY, currAlignMethod);
endAlign();
}
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h (revision 15218)
+++ scribus/scribusdoc.h (revision 15219)
@@ -775,6 +775,7 @@
void updateAllItemQColors();
//! @brief Some internal align tools
typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
+ typedef enum {alignByMoving, alignByResizing } AlignMethod;
void buildAlignItemList(Selection* customSelection=0);
bool startAlign();
void endAlign();
@@ -1172,16 +1173,20 @@
void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
- void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
- void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
+ void itemSelection_AlignItemLeft(int i, double newX, AlignMethod how);
+ void itemSelection_AlignItemRight(int i, double newX, AlignMethod how);
+ void itemSelection_AlignItemTop(int i, double newY, AlignMethod how);
+ void itemSelection_AlignItemBottom(int i, double newY, AlignMethod how);
+ void itemSelection_AlignLeftOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignRightOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignBottomIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignRightIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignBottomOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignCenterHor(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignLeftIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignCenterVer(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignTopOut(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
+ void itemSelection_AlignTopIn(AlignTo currAlignTo, AlignMethod currAlignMethod, double guidePosition);
void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
void itemSelection_DistributeAcrossPage(bool useMargins=false);
void itemSelection_DistributeRight();
Index: scribus/aligndistribute.cpp
===================================================================
--- scribus/aligndistribute.cpp (revision 15218)
+++ scribus/aligndistribute.cpp (revision 15219)
@@ -102,6 +102,13 @@
alignRelativeToCombo->setCurrentIndex(alignComboValue);
alignRelativeToCombo->setToolTip( tr( "<qt>Align relative to the:<ul><li>First selected item</li><li>Second Selected Item</li><li>The current page</li><li>The margins of the current page</li><li>A Guide</li><li>The selection</ul></qt>" ) );
alignToChanged(alignComboValue);
+ alignMoveOrResizeLabel->setText( tr( "&Align Sides By:" ) );
+ int alignMethodValue=alignMoveOrResizeCombo->currentIndex();
+ alignMoveOrResizeCombo->clear();
+ alignMoveOrResizeCombo->addItem( tr("Moving (Preserve Size)") );
+ alignMoveOrResizeCombo->addItem( tr("Resizing (Preserve Opposite Side)") );
+ alignMoveOrResizeCombo->setToolTip( tr( "<qt>When aligning one side of an item:<ul><li>Always move the other side too (preserve existing width and height), or </li><li>Keep the other side fixed (resize the item instead of moving it) whenever possible</li></ul></qt>" ));
+ alignMethodChanged(alignMethodValue);
alignGuideLineEdit->setToolTip( tr( "The location of the selected guide to align to" ) );
alignLeftOutToolButton->setText( QString::null );
alignLeftOutToolButton->setToolTip( tr( "Align right sides of items to left side of anchor" ) );
@@ -224,7 +231,9 @@
alignRelativeToCombo->setCurrentIndex(0);
alignToChanged(0);
+ alignMethodChanged(0);
connect(alignRelativeToCombo, SIGNAL(activated(int)), this, SLOT(alignToChanged(int)));
+ connect(alignMoveOrResizeCombo, SIGNAL(activated(int)), this, SLOT(alignMethodChanged(int)));
unitRatio=1.0;
guideDirection=-1;
@@ -256,63 +265,63 @@
void AlignDistributePalette::alignLeftOut()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignLeftOut(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignLeftOut(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignLeftIn()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignLeftIn(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignLeftIn(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignCenterHor()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignCenterHor(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignCenterHor(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignRightIn()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignRightIn(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignRightIn(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignRightOut()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignRightOut(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignRightOut(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignTopOut()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignTopOut(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignTopOut(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignTopIn()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignTopIn(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignTopIn(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignCenterVer()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignCenterVer(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignCenterVer(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignBottomIn()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignBottomIn(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignBottomIn(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::alignBottomOut()
{
if (currDoc!=NULL)
- currDoc->itemSelection_AlignBottomOut(currAlignTo, guidePosition);
+ currDoc->itemSelection_AlignBottomOut(currAlignTo, currAlignMethod, guidePosition);
}
void AlignDistributePalette::distributeLeft()
@@ -407,6 +416,11 @@
currAlignTo = ScribusDoc::AlignTo(newAlignTo);
enableGuideButtons();
}
+void AlignDistributePalette::alignMethodChanged(int newAlignMethod)
+{
+ currAlignMethod = ScribusDoc::AlignMethod(newAlignMethod);
+ enableGuideButtons();
+}
void AlignDistributePalette::setGuide(int direction, qreal position)
{
More information about the scribus-commit
mailing list