Let's backport the first change, but not the option. It's getting really late to add new strings, I'd say. On Thursday 23 January 2014 Jan 09:47:35 Dmitry Kazakov wrote: > Hi, Juan! > > I checked IRC backlog for 22.01 where you were asking about backporting > your patches. Your patches are really good! I like the new ants' look! > > You can freely backport the first patch to 2.8 right now. About the second > one (with the option box), I would wait for Boud's/translators' approval, > because it adds a new string. I'm not sure I know the process of pinging > translators about new strings. > > If you like, I can do the backporting for you today. I have two calligra > checkouts for that :) > > > > On Wed, Jan 22, 2014 at 9:50 PM, Juan Palacios wrote: > > > Git commit 436b00539f7a5c94523af6e93bd98d3b72c00d1b by Juan Palacios. > > Committed on 22/01/2014 at 17:23. > > Pushed by jpalacios into branch 'master'. > > > > Change selection outline decoration > > > > The old selection outline draw method was implemented using the > > technique of Bill Atkinson. This method has the disadvantage of not > > looking like marching ants with selection borders that aren't parallel > > to the coordinate axes. > > > > The new method uses a QPen with a dash pattern to draw the ants, so they > > are always displayed as dashes, no matter the angle that borders has. > > It is draw in two passes. The first one uses a QPen configured > > to draw the selection outline in white. Then, the selection outline is > > draw again above the white outline, but this time using other QPen > > configured to draw the ants in black. > > > > Also, the outline is drawed without antialiasing. > > > > M +32 -26 krita/ui/kis_selection_decoration.cc > > M +3 -2 krita/ui/kis_selection_decoration.h > > > > http://commits.kde.org/calligra/436b00539f7a5c94523af6e93bd98d3b72c00d1b > > > > diff --git a/krita/ui/kis_selection_decoration.cc > > b/krita/ui/kis_selection_decoration.cc > > index 78a05d2..902c2a4 100644 > > --- a/krita/ui/kis_selection_decoration.cc > > +++ b/krita/ui/kis_selection_decoration.cc > > @@ -35,31 +35,30 @@ > > #include "kis_canvas_resource_provider.h" > > #include "kis_coordinates_converter.h" > > > > +static const unsigned int ANT_LENGTH = 4; > > +static const unsigned int ANT_SPACE = 4; > > +static const unsigned int ANT_ADVANCE_WIDTH = ANT_LENGTH + ANT_SPACE; > > + > > KisSelectionDecoration::KisSelectionDecoration(KisView2* view) > > : KisCanvasDecoration("selection", i18n("Selection decoration"), > > view), > > m_signalCompressor(500 /*ms*/, KisSignalCompressor::FIRST_INACTIVE), > > + m_outlinePath(), > > + m_offset(0), > > + m_antsPen(Qt::CustomDashLine), > > + m_outlinePen(Qt::SolidLine), > > m_mode(Ants) > > { > > - m_offset = 0; > > - > > - QRgb white = QColor(Qt::white).rgb(); > > - QRgb black = QColor(Qt::black).rgb(); > > - > > - for (int i = 0; i < 8; i++) { > > - QImage texture(8, 8, QImage::Format_RGB32); > > - for (int y = 0; y < 8; y++) { > > - QRgb *pixel = reinterpret_cast(texture.scanLine(y)); > > - for (int x = 0; x < 8; x++) { > > - pixel[x] = ((x + y + i) % 8 < 4) ? black : white; > > - } > > - } > > - QBrush brush; > > - brush.setTextureImage(texture); > > - m_brushes << brush; > > - } > > + QVector antDashPattern; > > + antDashPattern << ANT_LENGTH << ANT_SPACE; > > + m_antsPen.setDashPattern(antDashPattern); > > + m_antsPen.setCosmetic(true); > > + m_antsPen.setColor(Qt::black); > > + > > + m_outlinePen.setCosmetic(true); > > + m_outlinePen.setColor(Qt::white); > > > > m_antsTimer = new QTimer(this); > > - m_antsTimer->setInterval(300); > > + m_antsTimer->setInterval(150); > > m_antsTimer->setSingleShot(false); > > connect(m_antsTimer, SIGNAL(timeout()), SLOT(antsAttackEvent())); > > > > @@ -123,7 +122,8 @@ void KisSelectionDecoration::antsAttackEvent() > > if (!selection) return; > > > > if (selectionIsActive()) { > > - m_offset = (m_offset + 1) % 8; > > + m_offset = (m_offset + 1) % ANT_ADVANCE_WIDTH; > > + m_antsPen.setDashOffset(m_offset); > > view()->canvasBase()->updateCanvas(); > > } > > } > > @@ -135,20 +135,26 @@ void > > KisSelectionDecoration::drawDecoration(QPainter& gc, const QRectF& updateRe > > Q_ASSERT_X(m_mode == Ants, "KisSelectionDecoration.cc", "MASK MODE > > NOT SUPPORTED YET!"); > > > > if (!selectionIsActive()) return; > > - KisSelectionSP selection = view()->selection(); > > + if (m_outlinePath.isEmpty()) return; > > > > gc.save(); > > gc.setTransform(QTransform(), false); > > - gc.setRenderHints(0); > > > > - QPen pen(m_brushes[m_offset], 0); > > + // Disable antialiasing. This allow us to draw the selection outline > > with a consistent look in all zoom levels. > > + // Reason: The selection outline is 1 pixel width. Antialiasing will > > produce a fuzzy gray line of 2 pixels in most cases, > > + // but sometimes can produce a clear line of 1 pixel, while still > > producing other fuzzy lines at the same time! Thus, > > + // the overall look is not consistent if antialiasing is enabled for > > 1 pixel width lines. > > + gc.setRenderHints(QPainter::Antialiasing | > > QPainter::HighQualityAntialiasing, false); > > + > > QTransform transform = converter->imageToWidgetTransform(); > > > > - gc.setPen(pen); > > + // render selection outline in white > > + gc.setPen(m_outlinePen); > > + gc.drawPath(transform.map(m_outlinePath)); > > > > - if (!m_outlinePath.isEmpty()) { > > - gc.drawPath(transform.map(m_outlinePath)); > > - } > > + // render marching ants in black (above the white outline) > > + gc.setPen(m_antsPen); > > + gc.drawPath(transform.map(m_outlinePath)); > > > > gc.restore(); > > } > > diff --git a/krita/ui/kis_selection_decoration.h > > b/krita/ui/kis_selection_decoration.h > > index 3e3deca..a65f15a 100644 > > --- a/krita/ui/kis_selection_decoration.h > > +++ b/krita/ui/kis_selection_decoration.h > > @@ -20,7 +20,7 @@ > > > > #include > > #include > > -#include > > +#include > > > > #include > > #include "canvas/kis_canvas_decoration.h" > > @@ -58,7 +58,8 @@ private: > > QTimer* m_antsTimer; > > int m_offset; > > > > - QList m_brushes; > > + QPen m_antsPen; > > + QPen m_outlinePen; > > Mode m_mode; > > }; > > > > > > > > > -- Boudewijn Rempt http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl _______________________________________________ Krita mailing list kimageshop@kde.org https://mail.kde.org/mailman/listinfo/kimageshop