Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 26796) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -367,6 +367,7 @@ + Index: scribus/margins.h --- scribus/margins.h (Revision 26800) +++ scribus/margins.h (Arbeitskopie) @@ -42,12 +42,40 @@ inline void setRight(double aright) { m_right = aright; } inline void setBottom(double abottom) { m_bottom = abottom; } + bool operator==(const MarginStruct &other) const + { + return ((m_left == other.m_left) && (m_top == other.m_top) && (m_right == other.m_right) && (m_bottom == other.m_bottom)); + } + bool operator!=(const MarginStruct& other) const + { + return !((m_left == other.m_left) && (m_top == other.m_top) && (m_right == other.m_right) && (m_bottom == other.m_bottom)); + } + void fromString(const QString &string) + { + resetToZero(); + QStringList s = string.split(" "); + if (s.size() == 4) // l t r b + set(convert(s.at(1)), convert(s.at(0)), convert(s.at(3)), convert(s.at(2))); + } + + QString toString() const + { + return QString("%0 %1 %2 %3").arg(QString::number(m_left)).arg(QString::number(m_top)).arg(QString::number(m_right)).arg(QString::number(m_bottom)); + } + protected: double m_top {0.0}; double m_left {0.0}; double m_bottom {0.0}; double m_right {0.0}; + + double convert(const QString& s) + { + bool ok(false); + double number = s.toDouble(&ok); + return ok ? number : 0.0; + } }; class ScMargins : public QMarginsF Index: scribus/pageitem.cpp =================================================================== --- scribus/pageitem.cpp (Revision 26796) +++ scribus/pageitem.cpp (Arbeitskopie) @@ -1954,6 +1954,7 @@ void PageItem::DrawObj_Decoration(ScPainter *p) { p->save(); + p->setPenOpacity(1.0); // p->setAntialiasing(false); if (!isEmbedded) p->translate(m_xPos, m_yPos); @@ -1997,12 +1998,10 @@ p->strokePath(); } } - if ((m_Doc->guidesPrefs().framesShown) && textFlowUsesContourLine() && (!ContourLine.empty())) - { - p->setPen(Qt::darkGray, 0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin); - p->setupSharpPolygon(&ContourLine); - p->strokePath(); - } + + drawContourLine(p); + drawTextFlowPath(p); + if (itemType() == ImageFrame) { double minres = m_Doc->checkerProfiles()[m_Doc->curCheckProfile()].minResolution; @@ -2388,6 +2387,29 @@ p->drawPolygon(pts.constData() + firstVal, pts.size() - firstVal); } +void PageItem::setShape(const FPointArray &val) +{ + PoLine = val; + + if (textFlowUsesFrameShape()) + { + m_textFlowMarginsNeedUpdate = true; + checkChanges(); + } + +} + +void PageItem::setContour(const FPointArray &val) +{ + ContourLine = val; + + if (textFlowUsesContourLine()) + { + m_textFlowMarginsNeedUpdate = true; + checkChanges(); + } +} + void PageItem::setItemName(const QString& newName) { if (m_itemName == newName || newName.isEmpty()) @@ -4443,31 +4465,39 @@ m_PrintEnabled=!m_PrintEnabled; } -void PageItem::setTextFlowMode(TextFlowMode mode) +void PageItem::setTextFlowMode(TextFlowMode mode, MarginStruct distances) { - if (m_textFlowMode == mode) - return; - if (UndoManager::undoEnabled()) + if (m_textFlowMargins != distances) { - QString stateMessage; - if (mode == TextFlowUsesFrameShape) - stateMessage = Um::ObjectFrame; - else if (mode == TextFlowUsesBoundingBox) - stateMessage = Um::BoundingBox; - else if (mode == TextFlowUsesContourLine) - stateMessage = Um::ContourLine; - else if (mode == TextFlowUsesImageClipping) - stateMessage = Um::ImageClip; - else - stateMessage = Um::NoTextFlow; - auto *ss = new SimpleState(stateMessage, QString(), Um::IFont); - ss->set("TEXTFLOW_OLDMODE", (int) m_textFlowMode); - ss->set("TEXTFLOW_NEWMODE", (int) mode); - undoManager->action(this, ss); + m_textFlowMargins = distances; + m_textFlowMarginsNeedUpdate = true; } - m_textFlowMode = mode; - - checkTextFlowInteractions(); + + if (m_textFlowMode != mode) + { + if (UndoManager::undoEnabled()) + { + QString stateMessage; + if (mode == TextFlowUsesFrameShape) + stateMessage = Um::ObjectFrame; + else if (mode == TextFlowUsesBoundingBox) + stateMessage = Um::BoundingBox; + else if (mode == TextFlowUsesContourLine) + stateMessage = Um::ContourLine; + else if (mode == TextFlowUsesImageClipping) + stateMessage = Um::ImageClip; + else + stateMessage = Um::NoTextFlow; + auto *ss = new SimpleState(stateMessage, QString(), Um::IFont); + ss->set("TEXTFLOW_OLDMODE", (int) m_textFlowMode); + ss->set("TEXTFLOW_NEWMODE", (int) mode); + undoManager->action(this, ss); + } + m_textFlowMode = mode; + m_textFlowMarginsNeedUpdate = true; + } + + checkChanges(); } void PageItem::checkTextFlowInteractions(bool allItems) @@ -4597,7 +4627,7 @@ { if ((oldXpos != m_xPos || oldYpos != m_yPos) || (oldWidth != m_width || oldHeight != m_height) || - (oldRot != m_rotation)) + (oldRot != m_rotation || m_textFlowMarginsNeedUpdate)) { textFlowCheckRect = getOldBoundingRect(); QRectF rect1 = textInteractionRegion(0.0, 0.0).boundingRect().adjusted(-1, -1, 1, 1); @@ -4605,6 +4635,8 @@ rect2.setWidth(qMax(1.0, rect1.width() + oldWidth - m_width)); rect2.setHeight(qMax(1.0, rect1.height() + oldHeight - m_height)); textFlowCheckRect = textFlowCheckRect.united(rect1.united(rect2)); + spreadChanges = true; + m_textFlowMarginsNeedUpdate = false; } } @@ -4615,7 +4647,7 @@ spreadChanges = (textFlowMode() != TextFlowDisabled); } // has the item been rotated - if (force || ((oldRot != m_rotation) && (shouldCheck()))) + if (force || ((oldRot != m_rotation) && shouldCheck())) { rotateUndoAction(); spreadChanges = (textFlowMode() != TextFlowDisabled); @@ -9089,6 +9121,9 @@ PoLine.addPoint(x1, y1); PoLine.addPoint(x2, y2); } + + setShape(PoLine); + Clip = flattenPath(PoLine, Segments); ClipEdited = true; } @@ -9149,6 +9184,9 @@ PoLine.addQuadPoint(0, Height_rr, 0, Height_rr, 0, rr, 0, rr); PoLine.addQuadPoint(0, rr, rrxBezierFactor, rr, rr, 0, rr, rr*bezierFactor); } + + setShape(PoLine); + Clip = flattenPath(PoLine, Segments); ClipEdited = false; FrameType = 2; @@ -9664,19 +9702,14 @@ return arrowRect; } -QRegion PageItem::textInteractionRegion(double xOffset, double yOffset) const +QPainterPath PageItem::createTextFlowPath(double xOffset, double yOffset) { - QRegion res; - if (m_textFlowMode == TextFlowDisabled) - return res; + QPainterPath pathOut; - QTransform pp; - if (this->isGroupChild()) - pp.translate(gXpos, gYpos); - else - pp.translate(m_xPos - xOffset, m_yPos - yOffset); - pp.rotate(m_rotation); + if (textFlowMode() == TextFlowDisabled) + return pathOut; + // Bounding Box if (textFlowUsesBoundingBox()) { QRectF bb = getVisualBoundingRect(); @@ -9685,19 +9718,37 @@ bb.translate(-m_xPos, -m_yPos); bb.translate(gXpos, gYpos); } - res = QRegion(bb.toRect()); + + pathOut.addRect(bb.adjusted(-m_textFlowMargins.left(), -m_textFlowMargins.top(), m_textFlowMargins.right(), m_textFlowMargins.bottom())); + setTextFlowPath(pathOut); + return pathOut; } - else if ((textFlowUsesImageClipping()) && (!imageClip.empty())) + + QPainterPath shape; + QPolygonF poly; + QTransform pp; + bool strokePath = false; + + if (this->isGroupChild()) + pp.translate(gXpos, gYpos); + else + pp.translate(m_xPos - xOffset, m_yPos - yOffset); + + pp.rotate(m_rotation); + + // Image Clipping Path + if ((textFlowUsesImageClipping()) && (!imageClip.empty())) { - QList Segs; - QPolygon Clip2 = flattenPath(imageClip, Segs); - res = QRegion(pp.map(Clip2)).intersected(QRegion(pp.map(Clip))); + shape = pp.map(imageClip.toQPainterPath(true)); + poly = shape.toFillPolygon(); + strokePath = true; } + //Contour Line else if ((textFlowUsesContourLine()) && (!ContourLine.empty())) { - QList Segs; - QPolygon Clip2 = flattenPath(ContourLine, Segs); - res = QRegion(pp.map(Clip2)); + shape = pp.map(ContourLine.toQPainterPath(true)); + poly = shape.toFillPolygon(); + strokePath = true; } else { @@ -9714,14 +9765,19 @@ pp.scale(1, -1); } } + + poly = pp.map(Clip); + + // Shape with Stroke if ((((m_lineColor != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0)) && (m_lineWidth > 1)) || (!NamedLStyle.isEmpty())) { QPainterPath ppa; - QPainterPath result; + // QPainterPath result; if (itemType() == PageItem::PolyLine) ppa = PoLine.toQPainterPath(false); else ppa = PoLine.toQPainterPath(true); + if (NamedLStyle.isEmpty()) { QPainterPathStroker stroke; @@ -9728,8 +9784,8 @@ stroke.setCapStyle(PLineEnd); stroke.setJoinStyle(PLineJoin); stroke.setDashPattern(Qt::SolidLine); - stroke.setWidth(m_lineWidth); - result = stroke.createStroke(ppa); + stroke.setWidth(m_lineWidth + m_textFlowMargins.left() * 2.0); + shape = pp.map(stroke.createStroke(ppa)); } else { @@ -9741,23 +9797,51 @@ stroke.setCapStyle(static_cast(ml[ind].LineEnd)); stroke.setJoinStyle(static_cast(ml[ind].LineJoin)); stroke.setDashPattern(Qt::SolidLine); - stroke.setWidth(ml[ind].Width); - result = stroke.createStroke(ppa); + stroke.setWidth(ml[ind].Width + m_textFlowMargins.left() * 2.0); + shape = pp.map(stroke.createStroke(ppa)); } - } - res = QRegion(pp.map(Clip)); - QList pl = result.toSubpathPolygons(); - for (int b = 0; b < pl.count(); b++) - { - res = res.united(QRegion(pp.map(pl[b].toPolygon()))); - } + } } + // Shape without Stroke else - res = QRegion(pp.map(Clip)); + { + shape.addPolygon(poly); + shape.closeSubpath(); + + strokePath = true; + } } - return res; + + // TODO: nitramr: Replace QPainterPathStroker with a more performant path offset method. + if (strokePath) + { + QPainterPathStroker stroke; + stroke.setWidth(m_textFlowMargins.left() * 2.0); + stroke.setJoinStyle(Qt::MiterJoin); + shape = stroke.createStroke(shape); + } + + shape = shape.simplified(); + + QList pl = shape.toSubpathPolygons(); + for (int b = 0; b < pl.count(); b++) + { + poly = poly.united(pl[b].toPolygon()); + } + + pathOut.addPolygon(poly); + pathOut = pathOut.simplified(); + + setTextFlowPath(pathOut); + + return pathOut; } +QRegion PageItem::textInteractionRegion(double xOffset, double yOffset) +{ + return QRegion(createTextFlowPath(xOffset, yOffset).toFillPolygon().toPolygon()); +} + bool PageItem::pointWithinItem(int x, const int y) const { const_cast(this)->setRedrawBounding(); @@ -10132,6 +10216,37 @@ p->drawLine(FPoint(bx1 + scp1 / 2, ofy + scp1), FPoint(bx1 + scp1 * 3.5, ofy + scp1)); } +void PageItem::drawTextFlowPath(ScPainter *p) const +{ + bool usesTextFlowBoundingBox = textFlowUsesBoundingBox() && (m_textFlowMargins.left() > 0 || m_textFlowMargins.top() > 0 || m_textFlowMargins.right() > 0 || m_textFlowMargins.bottom() > 0); + bool usesTextFlowAround = textFlowAroundObject() && m_textFlowMargins.left() > 0; + + // Draw Text Flow Margin Path + if (m_Doc->guidesPrefs().framesShown && (usesTextFlowBoundingBox || usesTextFlowAround)) + { + QTransform tf; + tf.rotate(-m_rotation); + tf.translate(-m_xPos, -m_yPos); + QPainterPath qpp = tf.map(textFlowPath()); + FPointArray tfMargin; + tfMargin.fromQPainterPath(qpp); + // Color: Scribus Blue 200, https://wiki.scribus.net/canvas/IndigoUI_Style_Guide#Colors + p->setPen(QColor(168, 220, 248), 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); + p->setupSharpPolygon(&tfMargin); + p->strokePath(); + } +} + +void PageItem::drawContourLine(ScPainter *p) const +{ + if (m_Doc->guidesPrefs().framesShown && textFlowUsesContourLine() && (!ContourLine.empty())) + { + p->setPen(Qt::darkGray, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); + p->setupSharpPolygon(&ContourLine); + p->strokePath(); + } +} + void PageItem::drawArrow(ScPainter *p, QTransform &arrowTrans, int arrowIndex) { FPointArray arrow = m_Doc->arrowStyles().at(arrowIndex - 1).points.copy(); Index: scribus/pageitem.h =================================================================== --- scribus/pageitem.h (Revision 26796) +++ scribus/pageitem.h (Arbeitskopie) @@ -338,7 +338,7 @@ virtual QRectF getEndArrowBoundingRect() const; virtual QRectF getEndArrowOldBoundingRect() const; - virtual QRegion textInteractionRegion(double xOffset, double yOffset) const; + virtual QRegion textInteractionRegion(double xOffset, double yOffset); //>> ********* Functions related to drawing the item ********* @@ -453,9 +453,9 @@ void SetQColor(QColor *tmp, const QString& farbe, double shad); void DrawPolyL(QPainter *p, const QPolygon& pts); FPointArray shape() const { return PoLine; } - void setShape(const FPointArray& val) { PoLine = val; } + void setShape(const FPointArray& val); FPointArray contour() const { return ContourLine; } - void setContour(const FPointArray& val) { ContourLine = val; } + void setContour(const FPointArray& val); bool flipPathText() const { return textPathFlipped; } void setFlipPathText(bool val) { textPathFlipped = val; } int pathTextType() const { return textPathType; } @@ -1117,8 +1117,14 @@ * @param mode true if text is wanted to flow around this object or false if not * @sa textFlowMode() */ - void setTextFlowMode(TextFlowMode mode); + void setTextFlowMode(TextFlowMode mode, MarginStruct distances = MarginStruct()); + MarginStruct textFlowMargins() { return m_textFlowMargins; } + QPainterPath createTextFlowPath(double xOffset, double yOffset); + + void setTextFlowPath(const QPainterPath path) { m_textFlowPath = path; } + QPainterPath textFlowPath() const { return m_textFlowPath; } + /** * @brief If text should flow around object frame * @sa PageItem::setTextFlowMode() @@ -1533,6 +1539,8 @@ void DrawObj_PolyLine(ScPainter *p); void DrawObj_PathText(ScPainter *p, double sc); void drawLockedMarker(ScPainter *p) const; + void drawTextFlowPath(ScPainter *p) const; + void drawContourLine(ScPainter *p) const; void drawArrow(ScPainter *p, QTransform &arrowTrans, int arrowIndex); /** @brief Manages undostack and is where all undo actions/states are sent. */ @@ -1848,6 +1856,9 @@ * @sa PageItem::textFlowMode(), PateItem::setTextFlowMode() */ TextFlowMode m_textFlowMode {TextFlowDisabled}; + MarginStruct m_textFlowMargins; + QPainterPath m_textFlowPath; + bool m_textFlowMarginsNeedUpdate {false}; /** * @brief Stores the attributes of the pageitem (NOT properties, the user defined ATTRIBUTES) Index: scribus/pageitem_textframe.cpp =================================================================== --- scribus/pageitem_textframe.cpp (Revision 26796) +++ scribus/pageitem_textframe.cpp (Arbeitskopie) @@ -3587,6 +3587,7 @@ //#12405 if (isAnnotation() && ((annotation().Type() > 1) && (annotation().Type() < 7)) && (annotation().borderWidth() > 0)) // return; p->save(); + p->setPenOpacity(1.0); // p->setAntialiasing(false); if (!isEmbedded) p->translate(m_xPos, m_yPos); @@ -3608,13 +3609,10 @@ p->setupSharpPolygon(&PoLine); p->strokePath(); } - if ((m_Doc->guidesPrefs().framesShown) && textFlowUsesContourLine() && (!ContourLine.empty())) - { - p->setPen(Qt::darkGray, 0, Qt::DotLine, Qt::FlatCap, Qt::MiterJoin); - p->setupSharpPolygon(&ContourLine); - p->strokePath(); - } + drawContourLine(p); + drawTextFlowPath(p); + //Draw the overflow icon if (frameOverflows()) { Index: scribus/plugins/fileloader/scribus170format/scribus170format.cpp =================================================================== --- scribus/plugins/fileloader/scribus170format/scribus170format.cpp (Revision 26796) +++ scribus/plugins/fileloader/scribus170format/scribus170format.cpp (Arbeitskopie) @@ -5842,8 +5842,12 @@ currItem->BaseOffs = attrs.valueAsDouble("BASEOF", 0.0); currItem->textPathType = attrs.valueAsInt("textPathType", 0); currItem->textPathFlipped = attrs.valueAsBool("textPathFlipped", false); + + MarginStruct textFlowMargins; + textFlowMargins.fromString(attrs.valueAsString("TextFlowMargins", "0 0 0 0")); + if ( attrs.hasAttribute("TEXTFLOWMODE") ) - currItem->setTextFlowMode((PageItem::TextFlowMode) attrs.valueAsInt("TEXTFLOWMODE", 0)); + currItem->setTextFlowMode((PageItem::TextFlowMode) attrs.valueAsInt("TEXTFLOWMODE", 0), textFlowMargins); else if ( attrs.valueAsInt("TEXTFLOW", 0) != 0) { if (attrs.valueAsInt("TEXTFLOW2", 0)) @@ -5851,7 +5855,7 @@ else if (attrs.valueAsInt("TEXTFLOW3", 0)) currItem->setTextFlowMode(PageItem::TextFlowUsesContourLine); else - currItem->setTextFlowMode(PageItem::TextFlowUsesFrameShape); + currItem->setTextFlowMode(PageItem::TextFlowUsesFrameShape); } else currItem->setTextFlowMode(PageItem::TextFlowDisabled); Index: scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp =================================================================== --- scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp (Revision 26796) +++ scribus/plugins/fileloader/scribus170format/scribus170format_save.cpp (Arbeitskopie) @@ -2868,7 +2868,10 @@ docu.writeAttribute("ANNAME", item->itemName()); // "TEXTFLOWMODE" succeed to "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes if (item->textFlowMode() != 0) + { docu.writeAttribute("TEXTFLOWMODE", (int) item->textFlowMode() ); + docu.writeAttribute("TextFlowMargins", item->textFlowMargins().toString()); + } // Set "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes for compatibility // with versions prior to 1.3.4 // docu.writeAttribute("TEXTFLOW" , item->textFlowAroundObject() ? 1 : 0); Index: scribus/scribus.cpp =================================================================== --- scribus/scribus.cpp (Revision 26796) +++ scribus/scribus.cpp (Arbeitskopie) @@ -2723,7 +2723,7 @@ actionManager->setPDFActions(view); updateItemLayerList(); rebuildScrapbookMenu(); - propertiesPalette->setTextFlowMode(currItem->textFlowMode()); + propertiesPalette->setTextFlowMode(currItem->textFlowMode(), currItem->textFlowMargins()); } if (selectedType != -1) Index: scribus/ui/newmarginwidget.cpp =================================================================== --- scribus/ui/newmarginwidget.cpp (Revision 26796) +++ scribus/ui/newmarginwidget.cpp (Arbeitskopie) @@ -74,57 +74,71 @@ { topMarginSpinBox->setToolTip( "" + tr( "Distance between the top margin guide and the edge of the page" ) + ""); bottomMarginSpinBox->setToolTip( "" + tr( "Distance between the bottom margin guide and the edge of the page" ) + ""); - leftMarginSpinBox->setToolTip( "" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + ""); - rightMarginSpinBox->setToolTip( "" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + ""); + leftMarginSpinBox->setToolTip( "" + tr( "Distance between the left margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + ""); + rightMarginSpinBox->setToolTip( "" + tr( "Distance between the right margin guide and the edge of the page. If a double-sided layout is selected, this margin space can be used to achieve the correct margins for binding.") + ""); marginLinkButton->setToolTip( "" + tr( "Ensure all margins have the same value" ) + ""); } - else if (m_flags & BleedWidgetFlags) + else if (m_flags & BleedWidgetFlags) { topMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the top of the physical page" ) + "" ); bottomMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the bottom of the physical page" ) + "" ); - leftMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the left of the physical page" ) + "" ); + if (isSingleMode()) + leftMarginSpinBox->setToolTip( "" + tr( "Distance for bleed around the physical page" ) + "" ); + else + leftMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the left of the physical page" ) + "" ); rightMarginSpinBox->setToolTip( "" + tr( "Distance for bleed from the right of the physical page" ) + ""); marginLinkButton->setToolTip( "" + tr( "Ensure all bleeds have the same value" ) + ""); } - else - { - topMarginSpinBox->setToolTip( "" + tr( "Distance from the top" ) + "" ); - bottomMarginSpinBox->setToolTip( "" + tr( "Distance from the bottom" ) + "" ); - leftMarginSpinBox->setToolTip( "" + tr( "Distance from the left" ) + "" ); - rightMarginSpinBox->setToolTip( "" + tr( "Distance from the right" ) + ""); - marginLinkButton->setToolTip( "" + tr( "Ensure all distances have the same value" ) + ""); - } + else + { + topMarginSpinBox->setToolTip( "" + tr( "Distance from the top" ) + "" ); + bottomMarginSpinBox->setToolTip( "" + tr( "Distance from the bottom" ) + "" ); + if (isSingleMode()) + leftMarginSpinBox->setToolTip( "" + tr( "Distance around the object" ) + "" ); + else + leftMarginSpinBox->setToolTip( "" + tr( "Distance from the left" ) + "" ); + rightMarginSpinBox->setToolTip( "" + tr( "Distance from the right" ) + ""); + marginLinkButton->setToolTip( "" + tr( "Ensure all distances have the same value" ) + ""); + } printerMarginsPushButton->setToolTip( "" + tr( "Import the margins for the selected page size from the available printers" ) + ""); - - leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); - rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); + + if (isSingleMode()) + leftMarginLabel->setText( tr("Around")); + else + leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); + + rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); } -void NewMarginWidget::iconSetChange() -{ - IconManager &im = IconManager::instance(); - - leftMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-inside" : "border-left")); - rightMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-outside" : "border-right")); - topMarginLabel->setPixmap(im.loadPixmap("border-top")); - bottomMarginLabel->setPixmap(im.loadPixmap("border-bottom")); -} - -void NewMarginWidget::toggleLabelVisibility(bool v) -{ - formWidget->setLabelVisibility(v); - leftMarginLabel->setLabelVisibility(v); - rightMarginLabel->setLabelVisibility(v); - topMarginLabel->setLabelVisibility(v); - bottomMarginLabel->setLabelVisibility(v); - - leftMarginLabel->setIconVisibility(!v); - rightMarginLabel->setIconVisibility(!v); - topMarginLabel->setIconVisibility(!v); - bottomMarginLabel->setIconVisibility(!v); - -} - +void NewMarginWidget::iconSetChange() +{ + IconManager &im = IconManager::instance(); + + if (isSingleMode()) + leftMarginLabel->setPixmap(im.loadPixmap("border-all")); + else + leftMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-inside" : "border-left")); + + rightMarginLabel->setPixmap(im.loadPixmap(m_facingPages ? "border-outside" : "border-right")); + topMarginLabel->setPixmap(im.loadPixmap("border-top")); + bottomMarginLabel->setPixmap(im.loadPixmap("border-bottom")); +} + +void NewMarginWidget::toggleLabelVisibility(bool v) +{ + formWidget->setLabelVisibility(v); + leftMarginLabel->setLabelVisibility(v); + rightMarginLabel->setLabelVisibility(v); + topMarginLabel->setLabelVisibility(v); + bottomMarginLabel->setLabelVisibility(v); + + leftMarginLabel->setIconVisibility(!v); + rightMarginLabel->setIconVisibility(!v); + topMarginLabel->setIconVisibility(!v); + bottomMarginLabel->setIconVisibility(!v); + +} + void NewMarginWidget::setNewValues(const MarginStruct& margs) { m_marginData = m_savedMarginData = margs; @@ -308,10 +322,10 @@ void NewMarginWidget::updateMarginSpinValues() { - bool leftBlocked = leftMarginSpinBox->blockSignals(true); - bool rightBlocked = rightMarginSpinBox->blockSignals(true); - bool topBlocked = topMarginSpinBox->blockSignals(true); - bool bottomBlocked = bottomMarginSpinBox->blockSignals(true); + QSignalBlocker leftBlocked(leftMarginSpinBox); + QSignalBlocker rightBlocked(rightMarginSpinBox); + QSignalBlocker topBlocked(topMarginSpinBox); + QSignalBlocker bottomBlocked(bottomMarginSpinBox); topMarginSpinBox->setValue(m_marginData.top() * m_unitRatio); rightMarginSpinBox->setValue(m_marginData.right() * m_unitRatio); @@ -318,34 +332,26 @@ bottomMarginSpinBox->setValue(m_marginData.bottom() * m_unitRatio); leftMarginSpinBox->setValue(m_marginData.left() * m_unitRatio); - leftMarginSpinBox->blockSignals(leftBlocked); - rightMarginSpinBox->blockSignals(rightBlocked); - topMarginSpinBox->blockSignals(topBlocked); - bottomMarginSpinBox->blockSignals(bottomBlocked); } void NewMarginWidget::slotLinkMargins() { - bool leftBlocked = leftMarginSpinBox->blockSignals(true); - bool rightBlocked = rightMarginSpinBox->blockSignals(true); - bool topBlocked = topMarginSpinBox->blockSignals(true); - bool bottomBlocked = bottomMarginSpinBox->blockSignals(true); + if (!marginLinkButton->isChecked()) + return; - if (marginLinkButton->isChecked()) - { - bottomMarginSpinBox->setValue(leftMarginSpinBox->value()); - topMarginSpinBox->setValue(leftMarginSpinBox->value()); - rightMarginSpinBox->setValue(leftMarginSpinBox->value()); - double newVal = leftMarginSpinBox->value() / m_unitRatio; - m_marginData.set(newVal, newVal, newVal, newVal); - - emit marginChanged(m_marginData); - } + QSignalBlocker leftBlocked(leftMarginSpinBox); + QSignalBlocker rightBlocked(rightMarginSpinBox); + QSignalBlocker topBlocked(topMarginSpinBox); + QSignalBlocker bottomBlocked(bottomMarginSpinBox); - leftMarginSpinBox->blockSignals(leftBlocked); - rightMarginSpinBox->blockSignals(rightBlocked); - topMarginSpinBox->blockSignals(topBlocked); - bottomMarginSpinBox->blockSignals(bottomBlocked); + bottomMarginSpinBox->setValue(leftMarginSpinBox->value()); + topMarginSpinBox->setValue(leftMarginSpinBox->value()); + rightMarginSpinBox->setValue(leftMarginSpinBox->value()); + double newVal = leftMarginSpinBox->value() / m_unitRatio; + m_marginData.set(newVal, newVal, newVal, newVal); + + emit marginChanged(m_marginData); + emit valuesChanged(m_marginData); } void NewMarginWidget::setMarginPreset(int p) @@ -386,15 +392,32 @@ presetLayoutComboBox->blockSignals(false); } +void NewMarginWidget::setSingleMode(bool isSingle) +{ + m_isSingle = isSingle; + + QSignalBlocker blocker(this); + + topMarginLabel->setVisible(!isSingle); + rightMarginLabel->setVisible(!isSingle); + bottomMarginLabel->setVisible(!isSingle); + formWidget->setVisible(!isSingle); + + // we have to avoid that the single mode changes all other values if link button is checked + if (isSingle) + marginLinkButton->setChecked(false); + + iconSetChange(); + languageChange(); // update tooltips +} + void NewMarginWidget::setFacingPages(bool facing, int pageType) { m_facingPages = facing; m_pageType = pageType; - - leftMarginLabel->setText( m_facingPages ? tr("Inside") : tr("Left")); - rightMarginLabel->setText( m_facingPages ? tr("Outside") : tr("Right")); - - iconSetChange(); + + languageChange(); + iconSetChange(); setPreset(); } Index: scribus/ui/newmarginwidget.h =================================================================== --- scribus/ui/newmarginwidget.h (Revision 26796) +++ scribus/ui/newmarginwidget.h (Arbeitskopie) @@ -44,6 +44,9 @@ void setMarginPreset(int p); int marginPreset() { return m_savedPresetItem; }; const MarginStruct & margins() const { return m_marginData; }; + /*! \brief Switch 4 inputs to 1*/ + void setSingleMode(bool isSingle); + bool isSingleMode() { return m_isSingle; }; public slots: void languageChange(); @@ -66,6 +69,7 @@ MarginStruct m_savedMarginData; QString m_pageSize; bool m_facingPages {false}; + bool m_isSingle {false}; double m_pageHeight {0.0}; double m_pageWidth {0.0}; double m_unitRatio {1.0}; Index: scribus/ui/newmarginwidgetbase.ui =================================================================== --- scribus/ui/newmarginwidgetbase.ui (Revision 26796) +++ scribus/ui/newmarginwidgetbase.ui (Arbeitskopie) @@ -6,7 +6,7 @@ 0 0 - 164 + 168 182 @@ -35,40 +35,6 @@ 8 - - - - - - Preset: - - - - - - - - 0 - 0 - - - - - - - - Qt::Orientation::Horizontal - - - - 0 - 0 - - - - - - @@ -120,8 +86,8 @@ - - + + 0 @@ -129,7 +95,7 @@ - Left + Right @@ -136,7 +102,7 @@ 8 - + 0 @@ -150,7 +116,7 @@ 0 - + 0 @@ -162,8 +128,8 @@ - - + + 0 @@ -171,7 +137,7 @@ - Top + Bottom @@ -178,7 +144,7 @@ 8 - + 0 @@ -192,7 +158,7 @@ 0 - + 0 @@ -204,32 +170,8 @@ - - - - - - Printer Margins... - - - - - - - Qt::Orientation::Horizontal - - - - 0 - 0 - - - - - - - - + + 0 @@ -237,7 +179,7 @@ - Bottom + Left @@ -244,7 +186,7 @@ 8 - + 0 @@ -258,7 +200,7 @@ 0 - + 0 @@ -270,8 +212,66 @@ - - + + + + + + Preset: + + + + + + + + 0 + 0 + + + + + + + + Qt::Orientation::Horizontal + + + + 0 + 0 + + + + + + + + + + + + Printer Margins... + + + + + + + Qt::Orientation::Horizontal + + + + 0 + 0 + + + + + + + + 0 @@ -279,7 +279,7 @@ - Right + Top @@ -286,7 +286,7 @@ 8 - + 0 @@ -300,7 +300,7 @@ 0 - + 0 @@ -312,6 +312,19 @@ + + + + Qt::Orientation::Horizontal + + + + 0 + 0 + + + + Index: scribus/ui/nodeeditpalette.cpp =================================================================== --- scribus/ui/nodeeditpalette.cpp (Revision 26796) +++ scribus/ui/nodeeditpalette.cpp (Arbeitskopie) @@ -370,7 +370,7 @@ UndoManager::instance()->action(currItem, is); } //FIXME make an internal item copy poline to contourline member - currItem->ContourLine = currItem->PoLine.copy(); + currItem->setContour(currItem->PoLine.copy()); currItem->ClipEdited = true; m_doc->regionsChanged()->update(QRectF()); emit DocChanged(); @@ -382,7 +382,7 @@ return; PageItem *currItem = m_doc->m_Selection->itemAt(0); - currItem->ContourLine = currItem->imageClip.copy(); + currItem->setContour(currItem->imageClip.copy()); currItem->ClipEdited = true; m_doc->regionsChanged()->update(QRectF()); emit DocChanged(); @@ -394,7 +394,7 @@ return; PageItem *currItem = m_doc->m_Selection->itemAt(0); - currItem->PoLine = currItem->imageClip.copy(); + currItem->setShape(currItem->imageClip.copy()); currItem->ClipEdited = true; currItem->FrameType = 3; m_doc->adjustItemSize(currItem); @@ -796,9 +796,9 @@ // relative to the current position (in the item's coordinate space). // adjustItemSize will then take care of moving the position and changing // image offsets, etc. - currItem->PoLine = m_itemPath.copy(); + currItem->setShape(m_itemPath.copy()); currItem->PoLine.translate(delta.x(), delta.y()); - currItem->ContourLine = m_itemContourPath.copy(); + currItem->setContour(m_itemContourPath.copy()); m_doc->adjustItemSize(currItem); if (currItem->itemType() == PageItem::PathText) currItem->updatePolyClip(); @@ -828,15 +828,15 @@ QPointF delta = m.map(QPointF(m_xPos, m_yPos)) - m.map(QPointF(currItem->xPos(), currItem->yPos())); if (EditCont->isChecked()) { - currItem->ContourLine = m_itemContourPath.copy(); + currItem->setContour(m_itemContourPath.copy()); currItem->ContourLine.translate(delta.x(), delta.y()); } else { // See comment in NodePalette::CancelEdit - currItem->PoLine = m_itemPath; + currItem->setShape(m_itemPath); currItem->PoLine.translate(delta.x(), delta.y()); - currItem->ContourLine = m_itemContourPath; + currItem->setContour(m_itemContourPath); m_doc->adjustItemSize(currItem); } if (currItem->itemType() == PageItem::PathText) Index: scribus/ui/propertiespalette.cpp =================================================================== --- scribus/ui/propertiespalette.cpp (Revision 26796) +++ scribus/ui/propertiespalette.cpp (Arbeitskopie) @@ -243,11 +243,11 @@ handleSelectionChanged(); } -void PropertiesPalette::setTextFlowMode(PageItem::TextFlowMode mode) +void PropertiesPalette::setTextFlowMode(PageItem::TextFlowMode mode, MarginStruct distances) { if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveItem) return; - shapePal->showTextFlowMode(mode); + shapePal->showTextFlowMode(mode, distances); } PageItem* PropertiesPalette::currentItemFromSelection() @@ -307,7 +307,7 @@ m_haveItem = false; m_item = item; - setTextFlowMode(m_item->textFlowMode()); + setTextFlowMode(m_item->textFlowMode(), m_item->textFlowMargins()); //CB replaces old emits from PageItem::emitAllToGUI() setLocked(item->locked()); Index: scribus/ui/propertiespalette.h =================================================================== --- scribus/ui/propertiespalette.h (Revision 26796) +++ scribus/ui/propertiespalette.h (Arbeitskopie) @@ -62,7 +62,7 @@ // void updateColorSpecialGradient(); void updateColorList(); void setGradientEditMode(bool); - void setTextFlowMode(PageItem::TextFlowMode mode); + void setTextFlowMode(PageItem::TextFlowMode mode, MarginStruct distances); /** @brief Returns true if there is a user action going on at the moment of call. */ bool userActionOn(); // not yet implemented!!! This is needed badly. Index: scribus/ui/propertiespalette_line.cpp =================================================================== --- scribus/ui/propertiespalette_line.cpp (Revision 26796) +++ scribus/ui/propertiespalette_line.cpp (Arbeitskopie) @@ -674,8 +674,11 @@ return; bool setter = (c == 0); m_doc->itemSelection_SetNamedLineStyle(setter ? QString("") : comboLineStyle->currentText()); + m_doc->invalidateAll(); + m_doc->regionsChanged()->update(QRect()); buttonLineStyleEdit->setEnabled(comboLineStyle->currentIndex() != 0); + } void PropertiesPalette_Line::handleLineStyleNew() @@ -757,7 +760,6 @@ m_item->setStrokeGradientExtend(buttonLineColor->gradientData().repeatMethod); m_item->update(); - m_doc->regionsChanged()->update(QRect()); break; case Mode::Hatch: @@ -782,9 +784,9 @@ } m_doc->itemSelection_SetOverprint(buttonLineColor->generalData().overprint); + m_doc->invalidateAll(); + m_doc->regionsChanged()->update(QRect()); - // m_item->update(); - // m_doc->regionsChanged()->update(QRect()); blockUpdates(false); } Index: scribus/ui/propertiespalette_shape.cpp =================================================================== --- scribus/ui/propertiespalette_shape.cpp (Revision 26796) +++ scribus/ui/propertiespalette_shape.cpp (Arbeitskopie) @@ -38,11 +38,18 @@ iconSetChange(); languageChange(); + MarginStruct distances; + distances.resetToZero(); + + textFlowMargins->setup(distances, 0, m_unitIndex, NewMarginWidget::DistanceWidgetFlags); + textFlowMargins->toggleLabelVisibility(false); + connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange())); connect(ScQApp, SIGNAL(labelVisibilityChanged(bool)), this, SLOT(toggleLabelVisibility(bool))); connect(textFlowBtnGroup, SIGNAL(idClicked(int)), this, SLOT(handleTextFlow())); + connect(textFlowMargins, SIGNAL(valuesChanged(MarginStruct)), this, SLOT(handleTextFlow())); connect(editShape, SIGNAL(clicked()) , this, SLOT(handleShapeEdit())); connect(roundRect, SIGNAL(valueChanged(double)) , this, SLOT(handleCornerRadius())); connect(customShape, SIGNAL(FormSel(int,int,qreal*)), this, SLOT(handleNewShape(int,int,qreal*))); @@ -325,13 +332,12 @@ customShape->setIcon(customShape->getIconPixmap(m_item->FrameType-2)); roundRect->setValue(m_item->cornerRadius()*m_unitRatio); - showTextFlowMode(m_item->textFlowMode()); setLocked(m_item->locked()); setSizeLocked(m_item->sizeLocked()); // Frame type 3 is obsolete: CR 2005-02-06 //if (((i->itemType() == PageItem::TextFrame) || (i->itemType() == PageItem::ImageFrame) || (i->itemType() == 3)) && (!i->ClipEdited)) - if (((m_item->isTextFrame()) || (m_item->isImageFrame())) && (!m_item->ClipEdited) && ((m_item->FrameType == 0) || (m_item->FrameType == 2))) + if ((m_item->isTextFrame() || m_item->isImageFrame()) && (!m_item->ClipEdited) && ((m_item->FrameType == 0) || (m_item->FrameType == 2))) roundRect->setEnabled(true); else { @@ -356,7 +362,8 @@ customShape->setEnabled(false); } m_haveItem = true; - showTextFlowMode(m_item->textFlowMode()); + + showTextFlowMode(m_item->textFlowMode(), m_item->textFlowMargins()); } void PropertiesPalette_Shape::handleTextFlow() @@ -364,17 +371,38 @@ PageItem::TextFlowMode mode = PageItem::TextFlowDisabled; if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; + if (textFlowDisabled->isChecked()) + { mode = PageItem::TextFlowDisabled; - if (textFlowUsesFrameShape->isChecked()) + textFlowMargins->setVisible(false); + } + else if (textFlowUsesFrameShape->isChecked()) + { mode = PageItem::TextFlowUsesFrameShape; - if (textFlowUsesBoundingBox->isChecked()) + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(true); + } + else if (textFlowUsesBoundingBox->isChecked()) + { mode = PageItem::TextFlowUsesBoundingBox; - if (textFlowUsesContourLine->isChecked()) + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(false); + } + else if (textFlowUsesContourLine->isChecked()) + { mode = PageItem::TextFlowUsesContourLine; - if (textFlowUsesImageClipping->isChecked()) + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(true); + } + else if (textFlowUsesImageClipping->isChecked()) + { mode = PageItem::TextFlowUsesImageClipping; - m_item->setTextFlowMode(mode); + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(true); + } + + m_item->setTextFlowMode(mode, textFlowMargins->margins()); m_doc->changed(); m_doc->changedPagePreview(); m_doc->invalidateAll(); @@ -447,30 +475,57 @@ roundRect->blockSignals(b); if (f == 0) m_doc->setFrameRounded(); - if ((m_item->itemType() == PageItem::ImageFrame) || (m_item->itemType() == PageItem::TextFrame)) - return; + // if ((m_item->itemType() == PageItem::ImageFrame) || (m_item->itemType() == PageItem::TextFrame)) + // return; m_doc->invalidateAll(); m_doc->regionsChanged()->update(QRect()); } -void PropertiesPalette_Shape::showTextFlowMode(PageItem::TextFlowMode mode) +void PropertiesPalette_Shape::showTextFlowMode(PageItem::TextFlowMode mode, MarginStruct distances) { if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveItem) return; + + QSignalBlocker textFlowMarginsBlocker(textFlowMargins); + textFlowMargins->setPageHeight(2000); + textFlowMargins->setPageWidth(2000); + textFlowMargins->setNewValues(distances); + if (mode == PageItem::TextFlowDisabled) + { textFlowDisabled->setChecked(true); + textFlowMargins->setVisible(false); + } else if (mode == PageItem::TextFlowUsesFrameShape) + { textFlowUsesFrameShape->setChecked(true); + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(true); + } else if (mode == PageItem::TextFlowUsesBoundingBox) + { textFlowUsesBoundingBox->setChecked(true); + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(false); + } else if (mode == PageItem::TextFlowUsesContourLine) + { textFlowUsesContourLine->setChecked(true); + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(true); + } else if (mode == PageItem::TextFlowUsesImageClipping) + { textFlowUsesImageClipping->setChecked(true); + textFlowMargins->setVisible(true); + textFlowMargins->setSingleMode(true); + } + if ((m_item->isImageFrame()) && (!m_item->imageClip.empty())) textFlowUsesImageClipping->setEnabled(true); else textFlowUsesImageClipping->setEnabled(false); + } void PropertiesPalette_Shape::iconSetChange() @@ -501,9 +556,12 @@ m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); - roundRect->blockSignals(true); + QSignalBlocker roundRectBlocker(roundRect); + QSignalBlocker textFlowMarginBlocker(textFlowMargins); + roundRect->setNewUnit( m_unitIndex ); - roundRect->blockSignals(false); + textFlowMargins->setNewUnit(m_unitIndex); + } void PropertiesPalette_Shape::localeChange() @@ -510,6 +568,7 @@ { const QLocale& l(LocaleManager::instance().userPreferredLocale()); roundRect->setLocale(l); + textFlowMargins->setLocale(l); } void PropertiesPalette_Shape::toggleLabelVisibility(bool v) Index: scribus/ui/propertiespalette_shape.h =================================================================== --- scribus/ui/propertiespalette_shape.h (Revision 26796) +++ scribus/ui/propertiespalette_shape.h (Arbeitskopie) @@ -35,7 +35,7 @@ void setLocked(bool isLocked); void setSizeLocked(bool isLocked); void setRoundRectEnabled(bool enabled); - void showTextFlowMode(PageItem::TextFlowMode mode); + void showTextFlowMode(PageItem::TextFlowMode mode, MarginStruct distances); protected: bool m_haveDoc {false}; Index: scribus/ui/propertiespalette_shapebase.ui =================================================================== --- scribus/ui/propertiespalette_shapebase.ui (Revision 26796) +++ scribus/ui/propertiespalette_shapebase.ui (Arbeitskopie) @@ -7,7 +7,7 @@ 0 0 238 - 107 + 117 @@ -54,10 +54,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -93,7 +93,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -148,7 +148,7 @@ true - Qt::ToolButtonIconOnly + Qt::ToolButtonStyle::ToolButtonIconOnly textFlowBtnGroup @@ -156,9 +156,9 @@ - + - Text flow around frame shape + Text flow around bounding box true @@ -167,7 +167,7 @@ true - Qt::ToolButtonIconOnly + Qt::ToolButtonStyle::ToolButtonIconOnly textFlowBtnGroup @@ -175,9 +175,9 @@ - + - Text flow around bounding box + Text flow around frame shape true @@ -186,7 +186,7 @@ true - Qt::ToolButtonIconOnly + Qt::ToolButtonStyle::ToolButtonIconOnly textFlowBtnGroup @@ -205,7 +205,7 @@ true - Qt::ToolButtonIconOnly + Qt::ToolButtonStyle::ToolButtonIconOnly textFlowBtnGroup @@ -224,7 +224,7 @@ true - Qt::ToolButtonIconOnly + Qt::ToolButtonStyle::ToolButtonIconOnly textFlowBtnGroup @@ -237,7 +237,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -250,9 +250,29 @@ + + + + + + + + Qt::Orientation::Horizontal + + + + 0 + 0 + + + + + + + - Qt::Vertical + Qt::Orientation::Vertical @@ -274,7 +294,7 @@ ScrSpinBox QDoubleSpinBox -
ui/scrspinbox.h
+
ui/scrspinbox.h
Autoforms @@ -281,6 +301,12 @@ QToolButton
ui/autoform.h
+ + NewMarginWidget + QWidget +
ui/newmarginwidget.h
+ 1 +