r17760 by jghali - #3865: Lock first line to baseline grid
scribus-commit
scribus-commit at lists.scribus.net
Wed Aug 22 13:01:51 UTC 2012
Author: jghali
Date: Wed Aug 22 13:01:51 2012
New Revision: 17760
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17760
Log:
#3865: Lock first line to baseline grid
Modified:
trunk/Scribus/scribus/pageitem_textframe.cpp
trunk/Scribus/scribus/sctextstruct.h
trunk/Scribus/scribus/ui/propertiespalette_text.cpp
trunk/Scribus/scribus/ui/propertywidget_flop.cpp
trunk/Scribus/scribus/ui/propertywidget_flop.h
trunk/Scribus/scribus/ui/propertywidget_flopbase.ui
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17760&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Wed Aug 22 13:01:51 2012
@@ -1347,7 +1347,7 @@
QList<ParagraphStyle::TabRecord> tTabValues;
tTabValues.clear();
- bool DropCmode = false;
+ bool DropCmode = false, FlopBaseline = false;
double desc=0, asce=0, realAsce=0, realDesc = 0, offset = 0;
double maxDY=0, maxDX=0;
double DropCapDrop = 0;
@@ -1486,6 +1486,8 @@
if (chstr.isEmpty())
chstr = SpecialChars::ZWNBSPACE;
style.setLineSpacing (calculateLineSpacing (style, this));
+ FlopBaseline = (current.startOfCol && firstLineOffset() == FLOPBaselineGrid);
+
// find out about par gap and dropcap
if (a == firstInFrame())
{
@@ -1807,7 +1809,18 @@
if (current.startOfCol)
{
lastLineY = qMax(lastLineY, extra.Top + lineCorr);
- if (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing)
+ if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing || FlopBaseline)
+ {
+ if (current.yPos <= lastLineY)
+ current.yPos = lastLineY +1;
+ double by = Ypos;
+ if (OwnPage != -1)
+ by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
+ int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
+ int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
+ current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
+ }
+ else if (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing)
{
if (firstLineOffset() == FLOPRealGlyphHeight)
{
@@ -1820,17 +1833,6 @@
current.yPos += style.lineSpacing();
else
current.yPos += asce;
- }
- else if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
- {
- if (current.yPos <= lastLineY)
- current.yPos = lastLineY +1;
- double by = Ypos;
- if (OwnPage != -1)
- by = Ypos - m_Doc->Pages->at(OwnPage)->yOffset();
- int ol1 = qRound((by + current.yPos - m_Doc->guidesPrefs().offsetBaselineGrid) * 10000.0);
- int ol2 = static_cast<int>(ol1 / m_Doc->guidesPrefs().valueBaselineGrid);
- current.yPos = ceil( ol2 / 10000.0 ) * m_Doc->guidesPrefs().valueBaselineGrid + m_Doc->guidesPrefs().offsetBaselineGrid - by;
}
}
else
@@ -1939,7 +1941,7 @@
{
// new line
current.xPos = qMax(current.colLeft, maxDX);
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
+ if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing || FlopBaseline)
{
current.yPos++;
double by = Ypos;
@@ -2038,7 +2040,7 @@
maxDX = 0;
}
int linesDrop = 0;
- if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
+ if (style.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing || FlopBaseline)
{
linesDrop = ceil(diff / m_Doc->guidesPrefs().valueBaselineGrid);
current.yPos += m_Doc->guidesPrefs().valueBaselineGrid * linesDrop;
@@ -2750,7 +2752,8 @@
if (DropCmode)
addAsce = qMax(realAsce, asce + offset);
else
- addAsce = asce + offset; if (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing)
+ addAsce = asce + offset;
+ if (style.lineSpacingMode() != ParagraphStyle::BaselineGridLineSpacing)
{
if (firstLineOffset() == FLOPRealGlyphHeight)
addAsce = realAsce;
Modified: trunk/Scribus/scribus/sctextstruct.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17760&path=/trunk/Scribus/scribus/sctextstruct.h
==============================================================================
--- trunk/Scribus/scribus/sctextstruct.h (original)
+++ trunk/Scribus/scribus/sctextstruct.h Wed Aug 22 13:01:51 2012
@@ -150,8 +150,9 @@
enum FirstLineOffsetPolicy
{
FLOPRealGlyphHeight = 0, // Historical
- FLOPFontAscent = 1,
- FLOPLineSpacing = 2
+ FLOPFontAscent = 1,
+ FLOPLineSpacing = 2,
+ FLOPBaselineGrid = 3
};
Modified: trunk/Scribus/scribus/ui/propertiespalette_text.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17760&path=/trunk/Scribus/scribus/ui/propertiespalette_text.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_text.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_text.cpp Wed Aug 22 13:01:51 2012
@@ -444,8 +444,10 @@
flopBox->flopFontAscent->setChecked(true);
else if(f == FLOPLineSpacing)
flopBox->flopLineSpacing->setChecked(true);
- else
+ else if (f == FLOPRealGlyphHeight)
flopBox->flopRealHeight->setChecked(true); //Itâs historical behaviour.
+ else // if (f == FLOPBaseline)
+ flopBox->flopBaselineGrid->setChecked(true);
}
void PropertiesPalette_Text::setupLineSpacingSpinbox(int mode, double value)
@@ -725,6 +727,8 @@
i2->setFirstLineOffset(FLOPFontAscent);
else if( radioFlop == PropertyWidget_Flop::LineSpacingID)
i2->setFirstLineOffset(FLOPLineSpacing);
+ else if( radioFlop == PropertyWidget_Flop::BaselineGridID)
+ i2->setFirstLineOffset(FLOPBaselineGrid);
i2->update();
if (m_doc->appMode == modeEditTable)
m_item->asTable()->update();
Modified: trunk/Scribus/scribus/ui/propertywidget_flop.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17760&path=/trunk/Scribus/scribus/ui/propertywidget_flop.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_flop.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_flop.cpp Wed Aug 22 13:01:51 2012
@@ -24,6 +24,7 @@
flopGroup->setId(flopRealHeight, RealHeightID);
flopGroup->setId(flopFontAscent, FontAscentID);
flopGroup->setId(flopLineSpacing, LineSpacingID);
+ flopGroup->setId(flopBaselineGrid, BaselineGridID);
languageChange();
}
@@ -54,8 +55,10 @@
flopRealHeight->setText( tr("Maximum Ascent") );
flopFontAscent->setText( tr("Font Ascent") );
flopLineSpacing->setText( tr("Line Spacing") );
+ flopBaselineGrid->setText( tr("Baseline Grid") );
flopRealHeight->setToolTip( "<qt>" + tr("Set the height of the first line of the text frame to use the tallest height of the included characters") + "</qt>" );
flopFontAscent->setToolTip( "<qt>" + tr("Set the height of the first line of text frame to use the full ascent of the font(s) in use") + "</qt>" );
flopLineSpacing->setToolTip( "<qt>" + tr("Set the height of the first line of the text frame to the specified line height") + "</qt>" );
+ flopBaselineGrid->setToolTip( "<qt>" + tr("Set the base line of the first line of the text frame to the base line grid") + "</qt>" );
}
Modified: trunk/Scribus/scribus/ui/propertywidget_flop.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17760&path=/trunk/Scribus/scribus/ui/propertywidget_flop.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_flop.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_flop.h Wed Aug 22 13:01:51 2012
@@ -21,9 +21,10 @@
enum FlopButtonID
{
- RealHeightID = 0,
- FontAscentID = 1,
- LineSpacingID = 2
+ RealHeightID = 0,
+ FontAscentID = 1,
+ LineSpacingID = 2,
+ BaselineGridID = 3
};
PropertyWidget_Flop(QWidget* parent);
Modified: trunk/Scribus/scribus/ui/propertywidget_flopbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17760&path=/trunk/Scribus/scribus/ui/propertywidget_flopbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_flopbase.ui (original)
+++ trunk/Scribus/scribus/ui/propertywidget_flopbase.ui Wed Aug 22 13:01:51 2012
@@ -50,6 +50,16 @@
</attribute>
</widget>
</item>
+ <item>
+ <widget class="QRadioButton" name="flopBaselineGrid">
+ <property name="text">
+ <string>Baseline Grid</string>
+ </property>
+ <attribute name="buttonGroup">
+ <string>flopGroup</string>
+ </attribute>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
More information about the scribus-commit
mailing list