r15236 by cbradney - #7981: Allow reverse distribution when distributing by a set value

scribus-commit scribus-commit at lists.scribus.net
Sun Jun 20 01:00:29 CEST 2010


Revision: 15236
Author: cbradney
Date: 2010-06-19T22:56:26.104834Z
Commit message: #7981: Allow reverse distribution when distributing by a set value

Changeset: 
M  /branches/Version135/Scribus/scribus/aligndistribute.cpp
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 15235)
+++ scribus/aligndistribute.ui	(revision 15236)
@@ -1,63 +1,55 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>AlignDistribute</class>
- <widget class="ScrPaletteBase" native="1" name="AlignDistribute" >
-  <property name="enabled" >
+ <widget class="ScrPaletteBase" name="AlignDistribute">
+  <property name="enabled">
    <bool>true</bool>
   </property>
-  <property name="geometry" >
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>251</width>
-    <height>218</height>
+    <width>288</width>
+    <height>272</height>
    </rect>
   </property>
-  <property name="minimumSize" >
+  <property name="minimumSize">
    <size>
     <width>0</width>
     <height>0</height>
    </size>
   </property>
-  <layout class="QVBoxLayout" >
-   <property name="margin" >
-    <number>6</number>
-   </property>
-   <property name="spacing" >
+  <layout class="QVBoxLayout">
+   <property name="spacing">
     <number>5</number>
    </property>
+   <property name="margin">
+    <number>6</number>
+   </property>
    <item>
-    <widget class="QTabWidget" name="tabWidget" >
-     <property name="currentIndex" >
+    <widget class="QTabWidget" name="tabWidget">
+     <property name="currentIndex">
       <number>0</number>
      </property>
-     <widget class="QWidget" name="tabAlign" >
-      <attribute name="title" >
+     <widget class="QWidget" name="tabAlign">
+      <attribute name="title">
        <string>Align</string>
       </attribute>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
+      <layout class="QVBoxLayout">
+       <property name="margin">
         <number>0</number>
        </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
        <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
-          <number>6</number>
-         </property>
+        <layout class="QHBoxLayout">
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -66,72 +58,66 @@
           </spacer>
          </item>
          <item>
-          <layout class="QGridLayout" >
-           <property name="margin" >
-            <number>0</number>
-           </property>
-           <property name="spacing" >
-            <number>6</number>
-           </property>
-           <item row="1" column="0" >
-            <widget class="QLabel" name="alignGuideLabel" >
-             <property name="text" >
+          <layout class="QGridLayout">
+           <item row="1" column="0">
+            <widget class="QLabel" name="alignGuideLabel">
+             <property name="text">
               <string>&amp;Selected Guide:</string>
              </property>
-             <property name="wordWrap" >
+             <property name="wordWrap">
               <bool>false</bool>
              </property>
-             <property name="buddy" >
+             <property name="buddy">
               <cstring>alignGuideLineEdit</cstring>
              </property>
             </widget>
            </item>
-           <item row="0" column="0" >
-            <widget class="QLabel" name="alignRelativeToLabel" >
-             <property name="text" >
+           <item row="0" column="0">
+            <widget class="QLabel" name="alignRelativeToLabel">
+             <property name="text">
               <string>&amp;Relative To:</string>
              </property>
-             <property name="wordWrap" >
+             <property name="wordWrap">
               <bool>false</bool>
              </property>
-             <property name="buddy" >
+             <property name="buddy">
               <cstring>alignRelativeToCombo</cstring>
              </property>
             </widget>
            </item>
-           <item row="1" column="1" >
-            <widget class="QLineEdit" name="alignGuideLineEdit" />
+           <item row="1" column="1">
+            <widget class="QLineEdit" name="alignGuideLineEdit"/>
            </item>
-           <item row="0" column="1" >
-            <widget class="QComboBox" name="alignRelativeToCombo" />
+           <item row="0" column="1">
+            <widget class="QComboBox" name="alignRelativeToCombo"/>
            </item>
-           <item row="2" column="0" >
-            <widget class="QLabel" name="alignMoveOrResizeLabel" >
-             <property name="text" >
+           <item row="2" column="0">
+            <widget class="QLabel" name="alignMoveOrResizeLabel">
+             <property name="text">
               <string>&amp;Align Sides By:</string>
              </property>
-             <property name="wordWrap" >
+             <property name="wordWrap">
               <bool>false</bool>
              </property>
-             <property name="buddy" >
+             <property name="buddy">
               <cstring>alignMoveOrResizeCombo</cstring>
              </property>
             </widget>
            </item>
-           <item row="2" column="1" >
-            <widget class="QComboBox" name="alignMoveOrResizeCombo" />
+           <item row="2" column="1">
+            <widget class="QComboBox" name="alignMoveOrResizeCombo"/>
            </item>
           </layout>
          </item>
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -142,22 +128,16 @@
         </layout>
        </item>
        <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
-          <number>6</number>
-         </property>
+        <layout class="QHBoxLayout">
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -166,79 +146,73 @@
           </spacer>
          </item>
          <item>
-          <layout class="QGridLayout" >
-           <property name="margin" >
-            <number>0</number>
-           </property>
-           <property name="spacing" >
-            <number>6</number>
-           </property>
-           <item row="1" column="3" >
-            <widget class="QToolButton" name="alignBottomInToolButton" >
-             <property name="text" >
+          <layout class="QGridLayout">
+           <item row="1" column="3">
+            <widget class="QToolButton" name="alignBottomInToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="1" >
-            <widget class="QToolButton" name="alignTopInToolButton" >
-             <property name="text" >
+           <item row="1" column="1">
+            <widget class="QToolButton" name="alignTopInToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="1" >
-            <widget class="QToolButton" name="alignLeftInToolButton" >
-             <property name="text" >
+           <item row="0" column="1">
+            <widget class="QToolButton" name="alignLeftInToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="3" >
-            <widget class="QToolButton" name="alignRightInToolButton" >
-             <property name="text" >
+           <item row="0" column="3">
+            <widget class="QToolButton" name="alignRightInToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="4" >
-            <widget class="QToolButton" name="alignBottomOutToolButton" >
-             <property name="text" >
+           <item row="1" column="4">
+            <widget class="QToolButton" name="alignBottomOutToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="0" >
-            <widget class="QToolButton" name="alignTopOutToolButton" >
-             <property name="text" >
+           <item row="1" column="0">
+            <widget class="QToolButton" name="alignTopOutToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="2" >
-            <widget class="QToolButton" name="alignCenterVerToolButton" >
-             <property name="text" >
+           <item row="1" column="2">
+            <widget class="QToolButton" name="alignCenterVerToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="0" >
-            <widget class="QToolButton" name="alignLeftOutToolButton" >
-             <property name="text" >
+           <item row="0" column="0">
+            <widget class="QToolButton" name="alignLeftOutToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="4" >
-            <widget class="QToolButton" name="alignRightOutToolButton" >
-             <property name="text" >
+           <item row="0" column="4">
+            <widget class="QToolButton" name="alignRightOutToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="2" >
-            <widget class="QToolButton" name="alignCenterHorToolButton" >
-             <property name="text" >
+           <item row="0" column="2">
+            <widget class="QToolButton" name="alignCenterHorToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
@@ -247,13 +221,13 @@
          </item>
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -265,50 +239,38 @@
        </item>
        <item>
         <spacer>
-         <property name="orientation" >
+         <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeType" >
+         <property name="sizeType">
           <enum>QSizePolicy::Expanding</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0">
           <size>
            <width>20</width>
-           <height>40</height>
+           <height>0</height>
           </size>
          </property>
         </spacer>
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="tabDistribute" >
-      <attribute name="title" >
+     <widget class="QWidget" name="tabDistribute">
+      <attribute name="title">
        <string>Distribute</string>
       </attribute>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
+      <layout class="QVBoxLayout" name="verticalLayout">
        <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
-          <number>6</number>
-         </property>
+        <layout class="QHBoxLayout">
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>63</width>
              <height>20</height>
@@ -317,133 +279,127 @@
           </spacer>
          </item>
          <item>
-          <layout class="QGridLayout" >
-           <property name="margin" >
-            <number>0</number>
-           </property>
-           <property name="spacing" >
-            <number>6</number>
-           </property>
-           <item row="0" column="3" >
-            <widget class="QToolButton" name="distributeDistHToolButton" >
-             <property name="text" >
+          <layout class="QGridLayout">
+           <item row="0" column="3">
+            <widget class="QToolButton" name="distributeDistHToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="2" >
-            <widget class="QToolButton" name="distributeTopToolButton" >
-             <property name="text" >
+           <item row="1" column="2">
+            <widget class="QToolButton" name="distributeTopToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="1" >
-            <widget class="QToolButton" name="distributeCenterVToolButton" >
-             <property name="text" >
+           <item row="1" column="1">
+            <widget class="QToolButton" name="distributeCenterVToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="2" >
-            <widget class="QToolButton" name="distributeRightToolButton" >
-             <property name="text" >
+           <item row="0" column="2">
+            <widget class="QToolButton" name="distributeRightToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="3" column="0" >
-            <widget class="QToolButton" name="toolButtonDummy1" >
-             <property name="text" >
+           <item row="3" column="0">
+            <widget class="QToolButton" name="toolButtonDummy1">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="2" column="2" >
-            <widget class="QToolButton" name="distributeAcrossMarginsToolButton" >
-             <property name="enabled" >
+           <item row="2" column="2">
+            <widget class="QToolButton" name="distributeAcrossMarginsToolButton">
+             <property name="enabled">
               <bool>true</bool>
              </property>
-             <property name="text" >
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="0" >
-            <widget class="QToolButton" name="distributeLeftToolButton" >
-             <property name="text" >
+           <item row="0" column="0">
+            <widget class="QToolButton" name="distributeLeftToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="2" column="0" >
-            <widget class="QToolButton" name="distributeAcrossPageToolButton" >
-             <property name="enabled" >
+           <item row="2" column="0">
+            <widget class="QToolButton" name="distributeAcrossPageToolButton">
+             <property name="enabled">
               <bool>true</bool>
              </property>
-             <property name="text" >
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="3" column="1" >
-            <widget class="QToolButton" name="distributeDistValueHToolButton" >
-             <property name="text" >
+           <item row="3" column="1">
+            <widget class="QToolButton" name="distributeDistValueHToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="2" column="3" >
-            <widget class="QToolButton" name="distributeDownMarginsToolButton" >
-             <property name="enabled" >
+           <item row="2" column="3">
+            <widget class="QToolButton" name="distributeDownMarginsToolButton">
+             <property name="enabled">
               <bool>true</bool>
              </property>
-             <property name="text" >
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="0" column="1" >
-            <widget class="QToolButton" name="distributeCenterHToolButton" >
-             <property name="text" >
+           <item row="0" column="1">
+            <widget class="QToolButton" name="distributeCenterHToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="3" column="3" >
-            <widget class="QToolButton" name="toolButtonDummy2" >
-             <property name="text" >
+           <item row="3" column="3">
+            <widget class="QToolButton" name="toolButtonDummy2">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="2" column="1" >
-            <widget class="QToolButton" name="distributeDownPageToolButton" >
-             <property name="enabled" >
+           <item row="2" column="1">
+            <widget class="QToolButton" name="distributeDownPageToolButton">
+             <property name="enabled">
               <bool>true</bool>
              </property>
-             <property name="text" >
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="3" column="2" >
-            <widget class="QToolButton" name="distributeDistValueVToolButton" >
-             <property name="text" >
+           <item row="3" column="2">
+            <widget class="QToolButton" name="distributeDistValueVToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="3" >
-            <widget class="QToolButton" name="distributeDistVToolButton" >
-             <property name="text" >
+           <item row="1" column="3">
+            <widget class="QToolButton" name="distributeDistVToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
            </item>
-           <item row="1" column="0" >
-            <widget class="QToolButton" name="distributeBottomToolButton" >
-             <property name="text" >
+           <item row="1" column="0">
+            <widget class="QToolButton" name="distributeBottomToolButton">
+             <property name="text">
               <string>...</string>
              </property>
             </widget>
@@ -452,13 +408,13 @@
          </item>
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>62</width>
              <height>20</height>
@@ -469,22 +425,16 @@
         </layout>
        </item>
        <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
-          <number>6</number>
-         </property>
+        <layout class="QHBoxLayout">
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -493,32 +443,26 @@
           </spacer>
          </item>
          <item>
-          <layout class="QHBoxLayout" >
-           <property name="margin" >
-            <number>0</number>
-           </property>
-           <property name="spacing" >
-            <number>6</number>
-           </property>
+          <layout class="QHBoxLayout">
            <item>
-            <widget class="QLabel" name="distributeDistLabel" >
-             <property name="text" >
+            <widget class="QLabel" name="distributeDistLabel">
+             <property name="text">
               <string>&amp;Distance:</string>
              </property>
-             <property name="wordWrap" >
+             <property name="wordWrap">
               <bool>false</bool>
              </property>
-             <property name="indent" >
+             <property name="indent">
               <number>-1</number>
              </property>
-             <property name="buddy" >
+             <property name="buddy">
               <cstring>distributeDistSpinBox</cstring>
              </property>
             </widget>
            </item>
            <item>
-            <widget class="ScrSpinBox" name="distributeDistSpinBox" >
-             <property name="minimumSize" >
+            <widget class="ScrSpinBox" name="distributeDistSpinBox">
+             <property name="minimumSize">
               <size>
                <width>50</width>
                <height>24</height>
@@ -530,13 +474,13 @@
          </item>
          <item>
           <spacer>
-           <property name="orientation" >
+           <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
-           <property name="sizeType" >
+           <property name="sizeType">
             <enum>QSizePolicy::Expanding</enum>
            </property>
-           <property name="sizeHint" >
+           <property name="sizeHint" stdset="0">
             <size>
              <width>40</width>
              <height>20</height>
@@ -547,17 +491,54 @@
         </layout>
        </item>
        <item>
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="reverseDistributionCheckBox">
+           <property name="text">
+            <string>Reverse Distribution</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer_2">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </item>
+       <item>
         <spacer>
-         <property name="orientation" >
+         <property name="orientation">
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeType" >
+         <property name="sizeType">
           <enum>QSizePolicy::Expanding</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0">
           <size>
            <width>20</width>
-           <height>16</height>
+           <height>0</height>
           </size>
          </property>
         </spacer>
@@ -568,7 +549,7 @@
    </item>
   </layout>
  </widget>
- <layoutdefault spacing="6" margin="11" />
+ <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
   <customwidget>
    <class>ScrSpinBox</class>
@@ -583,9 +564,9 @@
   </customwidget>
  </customwidgets>
  <includes>
-  <include location="local" >scrpalettebase.h</include>
-  <include location="local" >scrpalettebase.h</include>
-  <include location="local" >scrspinbox.h</include>
+  <include location="local">scrpalettebase.h</include>
+  <include location="local">scrpalettebase.h</include>
+  <include location="local">scrspinbox.h</include>
  </includes>
  <resources/>
  <connections/>
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(revision 15235)
+++ scribus/scribusdoc.cpp	(revision 15236)
@@ -8575,7 +8575,7 @@
 }
 
 
-void ScribusDoc::itemSelection_DistributeDistH(bool usingDistance, double distance)
+void ScribusDoc::itemSelection_DistributeDistH(bool usingDistance, double distance, bool reverseDistribute)
 {
 	if (!startAlign())
 		return;
@@ -8593,6 +8593,7 @@
 	uint left=X1sorted.begin().value();
 	uint right=X2sorted[X2sorted.keys().back()];
 	double minX=AObjects[left].x2;
+	double maxX=AObjects[right].x2;
 	double separation=0.0;
 	if (!usingDistance)
 	{
@@ -8613,21 +8614,48 @@
 	}
 	else
 		separation=value2pts(distance, unitIndex());
-	double currX=minX;
-	for ( QMap<double,uint>::Iterator it = X1sorted.begin(); it != X1sorted.end(); ++it )
+	if (!reverseDistribute)
 	{
-		if (it.value()==left)
-			continue;
-		if (it.value()==right && !usingDistance)
-			continue;
-		currX+=separation;
+		double currX=minX;
+		for ( QMap<double,uint>::Iterator it = X1sorted.begin(); it != X1sorted.end(); ++it )
+		{
+			if (it.value()==left)
+				continue;
+			if (it.value()==right && !usingDistance)
+				continue;
+			currX+=separation;
 
-		double diff=currX-AObjects[it.value()].x1;
-		for (int j = 0; j < AObjects[it.value()].Objects.count(); ++j)
-			if (!AObjects[it.value()].Objects.at(j)->locked())
-				AObjects[it.value()].Objects.at(j)->moveBy(diff, 0.0);
-		currX+=AObjects[it.value()].width;
+			double diff=currX-AObjects[it.value()].x1;
+			for (int j = 0; j < AObjects[it.value()].Objects.count(); ++j)
+				if (!AObjects[it.value()].Objects.at(j)->locked())
+					AObjects[it.value()].Objects.at(j)->moveBy(diff, 0.0);
+			currX+=AObjects[it.value()].width;
+		}
 	}
+	else
+	{
+		QMapIterator<double,uint> it(X1sorted);
+		it.toBack();
+		double currX=maxX;
+		while (it.hasPrevious())
+		{
+			it.previous();
+			if (it.value()==right)
+			{
+				currX-=AObjects[it.value()].width;
+				continue;
+			}
+			if (it.value()==left && !usingDistance)
+				continue;
+			currX-=separation;
+
+			double diff=currX-AObjects[it.value()].x2;
+			for (int j = 0; j < AObjects[it.value()].Objects.count(); ++j)
+				if (!AObjects[it.value()].Objects.at(j)->locked())
+					AObjects[it.value()].Objects.at(j)->moveBy(diff, 0.0);
+			currX-=AObjects[it.value()].width;
+		}
+	}
 	endAlign();
 }
 
@@ -8752,7 +8780,7 @@
 }
 
 
-void ScribusDoc::itemSelection_DistributeDistV(bool usingDistance, double distance)
+void ScribusDoc::itemSelection_DistributeDistV(bool usingDistance, double distance, bool reverseDistribute)
 {
 	if (!startAlign())
 		return;
@@ -8770,6 +8798,7 @@
 	uint top=Y1sorted.begin().value();
 	uint bottom=Y2sorted[Y2sorted.keys().back()];
 	double minY=AObjects[top].y2;
+	double maxY=AObjects[bottom].y2;
 	double separation=0.0;
 	if (!usingDistance)
 	{
@@ -8790,21 +8819,48 @@
 	}
 	else
 		separation=value2pts(distance, unitIndex());
-	double currY=minY;
-	for ( QMap<double,uint>::Iterator it = Y1sorted.begin(); it != Y1sorted.end(); ++it )
+	if (!reverseDistribute)
 	{
-		if (it.value()==top)
-			continue;
-		if (it.value()==bottom && !usingDistance)
-			continue;
-		currY+=separation;
+		double currY=minY;
+		for ( QMap<double,uint>::Iterator it = Y1sorted.begin(); it != Y1sorted.end(); ++it )
+		{
+			if (it.value()==top)
+				continue;
+			if (it.value()==bottom && !usingDistance)
+				continue;
+			currY+=separation;
 
-		double diff=currY-AObjects[it.value()].y1;
-		for (int j = 0; j < AObjects[it.value()].Objects.count(); ++j)
-			if (!AObjects[it.value()].Objects.at(j)->locked())
-				AObjects[it.value()].Objects.at(j)->moveBy(0.0,diff);
-		currY+=AObjects[it.value()].height;
+			double diff=currY-AObjects[it.value()].y1;
+			for (int j = 0; j < AObjects[it.value()].Objects.count(); ++j)
+				if (!AObjects[it.value()].Objects.at(j)->locked())
+					AObjects[it.value()].Objects.at(j)->moveBy(0.0,diff);
+			currY+=AObjects[it.value()].height;
+		}
 	}
+	else
+	{
+		QMapIterator<double,uint> it(Y1sorted);
+		it.toBack();
+		double currY=maxY;
+		while (it.hasPrevious())
+		{
+			it.previous();
+			if (it.value()==bottom)
+			{
+				currY-=AObjects[it.value()].height;
+				continue;
+			}
+			if (it.value()==top && !usingDistance)
+				continue;
+			currY-=separation;
+
+			double diff=currY-AObjects[it.value()].y2;
+			for (int j = 0; j < AObjects[it.value()].Objects.count(); ++j)
+				if (!AObjects[it.value()].Objects.at(j)->locked())
+					AObjects[it.value()].Objects.at(j)->moveBy(0.0, diff);
+			currY-=AObjects[it.value()].height;
+		}
+	}
 	endAlign();
 	usingDistance=false;
 }
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(revision 15235)
+++ scribus/scribusdoc.h	(revision 15236)
@@ -1189,12 +1189,12 @@
 	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_DistributeDistH(bool usingDistance=false, double distance=0.0, bool reverseDistribute=false);
 	void itemSelection_DistributeAcrossPage(bool useMargins=false);
 	void itemSelection_DistributeRight();
 	void itemSelection_DistributeBottom();
 	void itemSelection_DistributeCenterH();
-	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0, bool reverseDistribute=false);
 	void itemSelection_DistributeDownPage(bool useMargins=false);
 	void itemSelection_DistributeLeft();
 	void itemSelection_DistributeCenterV();
Index: scribus/aligndistribute.cpp
===================================================================
--- scribus/aligndistribute.cpp	(revision 15235)
+++ scribus/aligndistribute.cpp	(revision 15236)
@@ -165,7 +165,7 @@
 
 	distributeDistLabel->setText( tr( "&Distance:" ) );
 	distributeDistSpinBox->setToolTip( tr( "Distribute the items with the distance specified" ) );
-	
+	reverseDistributionCheckBox->setToolTip( tr("When distributing by a set distance, reverse the direction of the distribution of items") );
 	guideInfoTextNone = tr("None Selected");
 }
 
@@ -345,7 +345,7 @@
 void AlignDistributePalette::distributeDistH(bool usingDistance)
 {
 	if (currDoc!=NULL)
-		currDoc->itemSelection_DistributeDistH(usingDistance, distributeDistSpinBox->value());
+		currDoc->itemSelection_DistributeDistH(usingDistance, distributeDistSpinBox->value(), reverseDistributionCheckBox->isChecked());
 }
 
 void AlignDistributePalette::distributeDistValH()
@@ -401,7 +401,7 @@
 void AlignDistributePalette::distributeDistV(bool usingDistance)
 {
 	if (currDoc!=NULL)
-		currDoc->itemSelection_DistributeDistV(usingDistance, distributeDistSpinBox->value());
+		currDoc->itemSelection_DistributeDistV(usingDistance, distributeDistSpinBox->value(), reverseDistributionCheckBox->isChecked());
 }
 
 void AlignDistributePalette::distributeDistValV()




More information about the scribus-commit mailing list