r18889 by fschmid - Add the long overdue vertical alignment for Textframes.
scribus-commit
scribus-commit at lists.scribus.net
Sun Mar 9 09:22:39 UTC 2014
Author: fschmid
Date: Sun Mar 9 09:22:38 2014
New Revision: 18889
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18889
Log:
Add the long overdue vertical alignment for Textframes.
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem.h
trunk/Scribus/scribus/pageitem_textframe.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/ui/propertywidget_distance.cpp
trunk/Scribus/scribus/ui/propertywidget_distance.h
trunk/Scribus/scribus/ui/propertywidget_distancebase.ui
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Mar 9 09:22:38 2014
@@ -293,6 +293,7 @@
MaxChars(0), // since the layout is invalid now
m_sampleItem(false),
m_textDistanceMargins(other.m_textDistanceMargins),
+ verticalAlign(other.verticalAlign),
m_ItemType(other.m_ItemType),
AnName(other.AnName),
gradientVal(other.gradientVal),
@@ -488,6 +489,7 @@
CurX = 0;
CurY = 0;
m_textDistanceMargins=m_Doc->itemToolPrefs().textDistances;
+ verticalAlign = 0;
firstChar = 0;
MaxChars = 0;
m_sampleItem = false;
@@ -1594,6 +1596,18 @@
undoManager->action(this, ss);
}
ColGap = gap;
+}
+
+int PageItem::verticalAlignment()
+{
+ return verticalAlign;
+}
+
+void PageItem::setVerticalAlignment(int val)
+{
+ if (val == verticalAlign)
+ return;
+ verticalAlign = val;
}
void PageItem::setCornerRadius(double newRadius)
Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Sun Mar 9 09:22:38 2014
@@ -705,6 +705,7 @@
double columnGap() const { return ColGap; }
double gridOffset() const;
double gridDistance() const;
+ int verticalAlignment();
void setTextToFrameDistLeft(double);
void setTextToFrameDistRight(double);
void setTextToFrameDistTop(double);
@@ -713,6 +714,7 @@
void setColumnGap(double);
void setGridOffset(double);
void setGridDistance(double);
+ void setVerticalAlignment(int);
FirstLineOffsetPolicy firstLineOffset()const;
void setFirstLineOffset(FirstLineOffsetPolicy);
/**
@@ -1604,6 +1606,7 @@
uint MaxChars;
bool m_sampleItem; ///< Used to not draw the frame for sample items
MarginStruct m_textDistanceMargins; ///< Left, Top, Bottom, Right distances of text from the frame
+ int verticalAlign;
/**
* @brief Frame Type, eg line, text frame, etc.
*
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Sun Mar 9 09:22:38 2014
@@ -72,7 +72,7 @@
unicodeInputCount = 0;
unicodeInputString = "";
m_origAnnotPos = QRectF(xPos(), yPos(), width(), height());
-
+ verticalAlign = 0;
connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
}
@@ -85,7 +85,7 @@
unicodeInputString = "";
m_notesFramesMap.clear();
m_origAnnotPos = QRectF(xPos(), yPos(), width(), height());
-
+ verticalAlign = 0;
connect(&itemText,SIGNAL(changed()), this, SLOT(slotInvalidateLayout()));
}
@@ -3043,6 +3043,24 @@
}
}
MaxChars = itemText.length();
+ if ((verticalAlign > 0) && (NextBox == NULL))
+ {
+ int vertAlign = verticalAlign;
+ double topDist = m_textDistanceMargins.Top;
+ double hAdjust = 0;
+ if (verticalAlign == 1)
+ hAdjust = (height() - (m_textDistanceMargins.Bottom + lineCorr) - maxY) / 2.0;
+ else if (verticalAlign == 2)
+ hAdjust = (height() - (m_textDistanceMargins.Bottom + lineCorr) - maxY);
+ if (hAdjust > 0)
+ {
+ m_textDistanceMargins.Top += hAdjust;
+ verticalAlign = 0;
+ layout();
+ m_textDistanceMargins.Top = topDist;
+ verticalAlign = vertAlign;
+ }
+ }
invalid = false;
if (!isNoteFrame() && (!m_Doc->notesList().isEmpty() || m_Doc->notesChanged()))
{ //if notes are used
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Sun Mar 9 09:22:38 2014
@@ -4952,6 +4952,7 @@
attrs.valueAsDouble("REXTRA", 0.0),
attrs.valueAsDouble("TEXTRA", 0.0),
attrs.valueAsDouble("BEXTRA", 0.0));
+ currItem->setVerticalAlignment(attrs.valueAsInt("VAlign", 0));
currItem->setFirstLineOffset(static_cast<FirstLineOffsetPolicy>(attrs.valueAsInt("FLOP")));
currItem->PLineArt = Qt::PenStyle(attrs.valueAsInt("PLINEART", 0));
@@ -5588,6 +5589,7 @@
tAtt.valueAsDouble("TextDistTop", 0.0),
tAtt.valueAsDouble("TextDistBottom", 0.0),
tAtt.valueAsDouble("TextDistRight", 0.0));
+ newItem->setVerticalAlignment(tAtt.valueAsInt("TextVertAlign", 0));
newItem->setFirstLineOffset(static_cast<FirstLineOffsetPolicy>(tAtt.valueAsInt("Flop")));
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Sun Mar 9 09:22:38 2014
@@ -2255,6 +2255,7 @@
docu.writeAttribute("TextDistTop", textFrame->textToFrameDistTop());
docu.writeAttribute("TextDistBottom", textFrame->textToFrameDistBottom());
docu.writeAttribute("TextDistRight", textFrame->textToFrameDistRight());
+ docu.writeAttribute("TextVertAlign", textFrame->verticalAlignment());
docu.writeAttribute("Flop", textFrame->firstLineOffset());
QString cstyle = cell.style();
@@ -2634,6 +2635,7 @@
docu.writeAttribute("TEXTRA",item->textToFrameDistTop());
docu.writeAttribute("BEXTRA",item->textToFrameDistBottom());
docu.writeAttribute("REXTRA",item->textToFrameDistRight());
+ docu.writeAttribute("VAlign", item->verticalAlignment());
docu.writeAttribute("FLOP",item->firstLineOffset()); // here I think this FLOP "cher à mon cÅur" is legitimate!
docu.writeAttribute("PLTSHOW", item->PoShow ? 1 : 0);
docu.writeAttribute("BASEOF", item->BaseOffs);
Modified: trunk/Scribus/scribus/ui/propertywidget_distance.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/ui/propertywidget_distance.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_distance.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_distance.cpp Sun Mar 9 09:22:38 2014
@@ -149,6 +149,7 @@
}
showTextDistances(textItem->textToFrameDistLeft(), textItem->textToFrameDistTop(), textItem->textToFrameDistBottom(), textItem->textToFrameDistRight());
+ verticalAlign->setCurrentIndex(textItem->verticalAlignment());
connectSignals();
}
@@ -162,6 +163,7 @@
connect(rightDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()), Qt::UniqueConnection);
connect(bottomDistance, SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()), Qt::UniqueConnection);
connect(tabsButton , SIGNAL(clicked()) , this, SLOT(handleTabs()), Qt::UniqueConnection);
+ connect(verticalAlign , SIGNAL(activated(int)) , this, SLOT(handleVAlign()), Qt::UniqueConnection);
}
void PropertyWidget_Distance::disconnectSignals()
@@ -174,6 +176,7 @@
disconnect(rightDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
disconnect(bottomDistance, SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
disconnect(tabsButton , SIGNAL(clicked()) , this, SLOT(handleTabs()));
+ disconnect(verticalAlign , SIGNAL(activated(int)) , this, SLOT(handleVAlign()));
}
void PropertyWidget_Distance::configureWidgets(void)
@@ -343,6 +346,23 @@
int index = columnGapLabel->currentIndex();
columnGap->setToolTip((index == 0) ? tr( "Distance between columns" ) : tr( "Column width" ));
+}
+
+void PropertyWidget_Distance::handleVAlign()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ PageItem *textItem = m_item;
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+ if (textItem != NULL)
+ {
+ textItem->setVerticalAlignment(verticalAlign->currentIndex());
+ textItem->update();
+ if (m_doc->appMode == modeEditTable)
+ m_item->asTable()->update();
+ m_doc->regionsChanged()->update(QRect());
+ }
}
void PropertyWidget_Distance::handleTabs()
@@ -413,6 +433,13 @@
{
columnsLabel->setText( tr("Colu&mns:"));
+ int oldAliLabel = verticalAlign->currentIndex();
+ verticalAlign->clear();
+ verticalAlign->addItem( tr("Top"));
+ verticalAlign->addItem( tr("Middle"));
+ verticalAlign->addItem( tr("Bottom"));
+ verticalAlign->setCurrentIndex(oldAliLabel);
+
int oldcolgapLabel = columnGapLabel->currentIndex();
columnGapLabel->clear();
columnGapLabel->addItem( tr("Gap:"));
Modified: trunk/Scribus/scribus/ui/propertywidget_distance.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/ui/propertywidget_distance.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_distance.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_distance.h Sun Mar 9 09:22:38 2014
@@ -57,6 +57,7 @@
void handleColumnGap();
void handleGapSwitch();
void handleTabs();
+ void handleVAlign();
void handleTextDistances();
};
Modified: trunk/Scribus/scribus/ui/propertywidget_distancebase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18889&path=/trunk/Scribus/scribus/ui/propertywidget_distancebase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_distancebase.ui (original)
+++ trunk/Scribus/scribus/ui/propertywidget_distancebase.ui Sun Mar 9 09:22:38 2014
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>210</width>
- <height>165</height>
+ <width>186</width>
+ <height>223</height>
</rect>
</property>
<property name="windowTitle">
@@ -20,30 +20,65 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
- <property name="margin">
+ <property name="leftMargin">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <property name="bottomMargin">
<number>5</number>
</property>
<property name="spacing">
<number>2</number>
</property>
<item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Vertical Alignment</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="verticalAlign">
+ <item>
+ <property name="text">
+ <string>Top</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Middle</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Bottom</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
<widget class="QLabel" name="columnsLabel">
<property name="text">
<string>Colu&mns:</string>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="1" column="1">
<widget class="ScrSpinBox" name="columns">
<property name="minimum">
- <number>1</number>
+ <double>1.000000000000000</double>
</property>
<property name="maximum">
- <number>3000</number>
+ <double>3000.000000000000000</double>
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="ScComboBox" name="columnGapLabel">
<item>
<property name="text">
@@ -57,50 +92,50 @@
</item>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="ScrSpinBox" name="columnGap"/>
</item>
- <item row="2" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="topLabel">
<property name="text">
<string>To&p:</string>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="3" column="1">
<widget class="ScrSpinBox" name="topDistance"/>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="bottomLabel">
<property name="text">
<string>&Bottom:</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="ScrSpinBox" name="bottomDistance"/>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="leftLabel">
<property name="text">
<string>&Left:</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="ScrSpinBox" name="leftDistance"/>
</item>
- <item row="5" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="rightLabel">
<property name="text">
<string>&Right:</string>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<widget class="ScrSpinBox" name="rightDistance"/>
</item>
- <item row="6" column="0" colspan="2">
+ <item row="7" column="0" colspan="2">
<widget class="QToolButton" name="tabsButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
More information about the scribus-commit
mailing list