Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Improve/partially rework selection actions panel
Luna Lovecraft802cded9f60d
diff --git a/krita/pics/misc-dark/dark_drag-handle.svg b/krita/pics/misc-dark/dark_drag-handle.svgnew file mode 100644index 0000000000..671fbb64a7--- /dev/null+++ b/krita/pics/misc-dark/dark_drag-handle.svg@@ -0,0 +1,138 @@+<?xml version="1.0" encoding="UTF-8" standalone="no"?>+<!--Created with Inkscape (http://www.inkscape.org/)-->++<svg+ width="22"+ height="22"+ viewBox="0 0 22 22"+ id="svg2"+ version="1.1"+ inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"+ sodipodi:docname="dark_drag-handle.svg"+ inkscape:export-filename="krita_quickbrush.png"+ inkscape:export-xdpi="90"+ inkscape:export-ydpi="90"+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"+ xmlns="http://www.w3.org/2000/svg"+ xmlns:svg="http://www.w3.org/2000/svg"+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"+ xmlns:cc="http://creativecommons.org/ns#"+ xmlns:dc="http://purl.org/dc/elements/1.1/">+ <defs+ id="defs1" />+ <sodipodi:namedview+ id="base"+ pagecolor="#ffffff"+ bordercolor="#666666"+ borderopacity="1.0"+ inkscape:pageopacity="0"+ inkscape:pageshadow="2"+ inkscape:zoom="30.72379"+ inkscape:cx="12.286896"+ inkscape:cy="11.326728"+ inkscape:document-units="px"+ inkscape:current-layer="g4152"+ showgrid="true"+ units="px"+ inkscape:showpageshadow="false"+ showborder="true"+ inkscape:window-width="1078"+ inkscape:window-height="521"+ inkscape:window-x="0"+ inkscape:window-y="0"+ inkscape:window-maximized="0"+ objecttolerance="10"+ guidetolerance="10"+ inkscape:snap-perpendicular="true"+ inkscape:snap-tangential="true"+ inkscape:snap-path-clip="true"+ inkscape:snap-path-mask="true"+ gridtolerance="10"+ showguides="false"+ inkscape:pagecheckerboard="0"+ inkscape:deskcolor="#d1d1d1">+ <inkscape:grid+ type="xygrid"+ id="grid3336"+ dotted="false"+ empspacing="1"+ snapvisiblegridlinesonly="false"+ enabled="true"+ visible="true"+ empcolor="#aaaaff"+ empopacity="0.25098039"+ color="#7878ff"+ opacity="0.1254902"+ spacingx="1"+ spacingy="1"+ originx="0"+ originy="0"+ units="px" />+ </sodipodi:namedview>+ <metadata+ id="metadata7">+ <rdf:RDF>+ <cc:Work>+ <dc:format>image/svg+xml</dc:format>+ <dc:type+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />+ <dc:title />+ <dc:creator>+ <cc:Agent>+ <dc:title>Timothée Giet</dc:title>+ </cc:Agent>+ </dc:creator>+ <dc:date>2018</dc:date>+ <cc:license+ rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />+ </cc:Work>+ <cc:License+ rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">+ <cc:permits+ rdf:resource="http://creativecommons.org/ns#Reproduction" />+ <cc:permits+ rdf:resource="http://creativecommons.org/ns#Distribution" />+ <cc:requires+ rdf:resource="http://creativecommons.org/ns#Notice" />+ <cc:requires+ rdf:resource="http://creativecommons.org/ns#Attribution" />+ <cc:permits+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />+ <cc:requires+ rdf:resource="http://creativecommons.org/ns#ShareAlike" />+ </cc:License>+ </rdf:RDF>+ </metadata>+ <g+ style="display:inline"+ inkscape:label="Layer 3 copy"+ id="g4152"+ inkscape:groupmode="layer"+ transform="translate(0 -10)">+ <circle+ style="opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823"+ cx="8"+ cy="18.5"+ r="1.5" />+ <circle+ style="display:inline;opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823-1-8"+ cx="13.5"+ cy="18.5"+ r="1.5" />+ <circle+ style="display:inline;opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823-7-0"+ cx="8"+ cy="23.5"+ r="1.5" />+ <circle+ style="display:inline;opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823-1-8-2-3"+ cx="13.5"+ cy="23.5"+ r="1.5" />+ </g>+</svg>diff --git a/krita/pics/misc-dark/misc-dark-icons.qrc b/krita/pics/misc-dark/misc-dark-icons.qrcindex ba4aefb43c..cf74da06d7 100644--- a/krita/pics/misc-dark/misc-dark-icons.qrc+++ b/krita/pics/misc-dark/misc-dark-icons.qrc@@ -78,5 +78,6 @@<file>dark_view-choose-22.svg</file><file alias="dark_object-align-horizontal-right-calligra.svg">dark_ox16-action-object-align-horizontal-right-calligra.svg</file><file alias="dark_object-align-horizontal-left-calligra.svg">dark_ox16-action-object-align-horizontal-left-calligra.svg</file>+ <file>dark_drag-handle.svg</file></qresource></RCC>diff --git a/krita/pics/misc-light/light_drag-handle.svg b/krita/pics/misc-light/light_drag-handle.svgnew file mode 100644index 0000000000..f20eb6d855--- /dev/null+++ b/krita/pics/misc-light/light_drag-handle.svg@@ -0,0 +1,138 @@+<?xml version="1.0" encoding="UTF-8" standalone="no"?>+<!--Created with Inkscape (http://www.inkscape.org/)-->++<svg+ width="22"+ height="22"+ viewBox="0 0 22 22"+ id="svg2"+ version="1.1"+ inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"+ sodipodi:docname="light_drag-handle.svg"+ inkscape:export-filename="krita_quickbrush.png"+ inkscape:export-xdpi="90"+ inkscape:export-ydpi="90"+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"+ xmlns="http://www.w3.org/2000/svg"+ xmlns:svg="http://www.w3.org/2000/svg"+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"+ xmlns:cc="http://creativecommons.org/ns#"+ xmlns:dc="http://purl.org/dc/elements/1.1/">+ <defs+ id="defs1" />+ <sodipodi:namedview+ id="base"+ pagecolor="#ffffff"+ bordercolor="#666666"+ borderopacity="1.0"+ inkscape:pageopacity="0"+ inkscape:pageshadow="2"+ inkscape:zoom="30.72379"+ inkscape:cx="11.61966"+ inkscape:cy="12.937857"+ inkscape:document-units="px"+ inkscape:current-layer="g4152"+ showgrid="true"+ units="px"+ inkscape:showpageshadow="false"+ showborder="true"+ inkscape:window-width="1078"+ inkscape:window-height="1056"+ inkscape:window-x="0"+ inkscape:window-y="0"+ inkscape:window-maximized="0"+ objecttolerance="10"+ guidetolerance="10"+ inkscape:snap-perpendicular="true"+ inkscape:snap-tangential="true"+ inkscape:snap-path-clip="true"+ inkscape:snap-path-mask="true"+ gridtolerance="10"+ showguides="false"+ inkscape:pagecheckerboard="0"+ inkscape:deskcolor="#d1d1d1">+ <inkscape:grid+ type="xygrid"+ id="grid3336"+ dotted="false"+ empspacing="1"+ snapvisiblegridlinesonly="false"+ enabled="true"+ visible="true"+ empcolor="#aaaaff"+ empopacity="0.25098039"+ color="#7878ff"+ opacity="0.1254902"+ spacingx="1"+ spacingy="1"+ originx="0"+ originy="0"+ units="px" />+ </sodipodi:namedview>+ <metadata+ id="metadata7">+ <rdf:RDF>+ <cc:Work>+ <dc:format>image/svg+xml</dc:format>+ <dc:type+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />+ <dc:title />+ <dc:creator>+ <cc:Agent>+ <dc:title>Timothée Giet</dc:title>+ </cc:Agent>+ </dc:creator>+ <dc:date>2018</dc:date>+ <cc:license+ rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />+ </cc:Work>+ <cc:License+ rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">+ <cc:permits+ rdf:resource="http://creativecommons.org/ns#Reproduction" />+ <cc:permits+ rdf:resource="http://creativecommons.org/ns#Distribution" />+ <cc:requires+ rdf:resource="http://creativecommons.org/ns#Notice" />+ <cc:requires+ rdf:resource="http://creativecommons.org/ns#Attribution" />+ <cc:permits+ rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />+ <cc:requires+ rdf:resource="http://creativecommons.org/ns#ShareAlike" />+ </cc:License>+ </rdf:RDF>+ </metadata>+ <g+ style="display:inline"+ inkscape:label="Layer 3 copy"+ id="g4152"+ inkscape:groupmode="layer"+ transform="translate(0 -10)">+ <circle+ style="opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823"+ cx="8"+ cy="18.5"+ r="1.5" />+ <circle+ style="display:inline;opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823-1-8"+ cx="13.5"+ cy="18.5"+ r="1.5" />+ <circle+ style="display:inline;opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823-7-0"+ cx="8"+ cy="23.5"+ r="1.5" />+ <circle+ style="display:inline;opacity:1;fill:#1a1a1a;fill-opacity:1;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ id="path823-1-8-2-3"+ cx="13.5"+ cy="23.5"+ r="1.5" />+ </g>+</svg>diff --git a/krita/pics/misc-light/misc-light-icons.qrc b/krita/pics/misc-light/misc-light-icons.qrcindex b58774a1f8..40477ce1a1 100644--- a/krita/pics/misc-light/misc-light-icons.qrc+++ b/krita/pics/misc-light/misc-light-icons.qrc@@ -78,5 +78,6 @@<file>light_view-choose-22.svg</file><file alias="light_object-align-horizontal-left-calligra.svg">light_ox16-action-object-align-horizontal-left-calligra.svg</file><file alias="light_object-align-horizontal-right-calligra.svg">light_ox16-action-object-align-horizontal-right-calligra.svg</file>+ <file>light_drag-handle.svg</file></qresource></RCC>diff --git a/libs/ui/CMakeLists.txt b/libs/ui/CMakeLists.txtindex 2c4bf40cd8..efee1f07b6 100644--- a/libs/ui/CMakeLists.txt+++ b/libs/ui/CMakeLists.txt@@ -143,6 +143,8 @@ set(kritaui_LIB_SRCSkis_painting_assistant.cckis_painting_assistants_decoration.cppkis_selection_actions_panel.cpp+ kis_selection_actions_panel_handle.cpp+ kis_selection_actions_panel_button.cppKisDecorationsManager.cppkis_paintop_box.cckis_paintop_option.cppdiff --git a/libs/ui/canvas/kis_canvas_decoration.h b/libs/ui/canvas/kis_canvas_decoration.hindex f566edce23..2a4e2d9fd1 100644--- a/libs/ui/canvas/kis_canvas_decoration.h+++ b/libs/ui/canvas/kis_canvas_decoration.h@@ -15,6 +15,7 @@#include "KisView.h"#include <kis_shared.h>+class KisCanvasWidgetBase;class KisCanvas2;class QRectF;class QPainter;@@ -63,6 +64,7 @@ public:static bool comparePriority(KisCanvasDecorationSP decoration1, KisCanvasDecorationSP decoration2);virtual void notifyWindowMinimized(bool minimized);+ virtual void setCanvasWidget(KisCanvasWidgetBase* canvas) {};public Q_SLOTS:/**@@ -76,6 +78,7 @@ public Q_SLOTS:protected:virtual void drawDecoration(QPainter& gc, const QRectF& updateArea, const KisCoordinatesConverter *converter,KisCanvas2* canvas) = 0;+/*** @return the parent KisView*/diff --git a/libs/ui/canvas/kis_canvas_widget_base.cpp b/libs/ui/canvas/kis_canvas_widget_base.cppindex 5106af6eac..8e1b2f4e3f 100644--- a/libs/ui/canvas/kis_canvas_widget_base.cpp+++ b/libs/ui/canvas/kis_canvas_widget_base.cpp@@ -149,6 +149,11 @@ void KisCanvasWidgetBase::setDecorations(const QList<KisCanvasDecorationSP > &de{m_d->decorations=decorations;std::stable_sort(m_d->decorations.begin(), m_d->decorations.end(), KisCanvasDecoration::comparePriority);++ Q_FOREACH(auto d, m_d->decorations)+ {+ d->setCanvasWidget(this);+ }}QList<KisCanvasDecorationSP > KisCanvasWidgetBase::decorations() constdiff --git a/libs/ui/kis_selection_actions_panel.cpp b/libs/ui/kis_selection_actions_panel.cppindex 9046cd3a5c..bef5175cd7 100644--- a/libs/ui/kis_selection_actions_panel.cpp+++ b/libs/ui/kis_selection_actions_panel.cpp@@ -13,6 +13,8 @@#include "kis_canvas_resource_provider.h"#include "kis_icon_utils.h"#include "kis_selection.h"+#include "kis_selection_actions_panel_button.h"+#include "kis_selection_actions_panel_handle.h"#include "kis_selection_manager.h"#include <KoCompositeOpRegistry.h>#include <QList>@@ -31,7 +33,7 @@#include <QPainter>#include <QPainterPath>-static constexpr int BUTTON_SIZE = 25;+static constexpr int BUTTON_SIZE = 30;static constexpr int BUFFER_SPACE = 5;class KisSelectionManager;@@ -48,7 +50,6 @@ struct KisSelectionActionsPanel::Private {Private(){}-KisSelectionManager *m_selectionManager = nullptr;KisViewManager *m_viewManager = nullptr;@@ -64,7 +65,8 @@ struct KisSelectionActionsPanel::Private {QScopedPointer<DragHandle> m_dragHandle;- QVector<QPushButton *> m_buttons;+ KisSelectionActionsPanelHandle * m_handleWidget;+ QList<KisSelectionActionsPanelButton *> m_buttons;static const QVector<ActionButtonData> &buttonData(){static const QVector<ActionButtonData> data = {@@ -82,22 +84,20 @@ struct KisSelectionActionsPanel::Private {int m_actionBarWidth = m_buttonCount * BUTTON_SIZE;};-KisSelectionActionsPanel::KisSelectionActionsPanel(KisViewManager *viewManager, QWidget *parent)- : QWidget(parent)- , d(new Private)+KisSelectionActionsPanel::KisSelectionActionsPanel(KisViewManager *viewManager)+ : d(new Private){d->m_viewManager = viewManager;d->m_selectionManager = viewManager->selectionManager();- QWidget *canvasWidget = dynamic_cast<QWidget *>(viewManager->canvas());-// Setup buttons...for (const ActionButtonData &buttonData : Private::buttonData()) {- QPushButton *button = createButton(buttonData.iconName, buttonData.tooltip);- connect(button, &QPushButton::clicked, d->m_selectionManager, buttonData.slot);- button->setParent(canvasWidget);+ KisSelectionActionsPanelButton *button = new KisSelectionActionsPanelButton(buttonData.iconName, buttonData.tooltip, BUTTON_SIZE, viewManager->canvas());+ connect(button, &QAbstractButton::clicked, d->m_selectionManager, buttonData.slot);d->m_buttons.append(button);}++ d->m_handleWidget = new KisSelectionActionsPanelHandle(BUTTON_SIZE, viewManager->canvas());}KisSelectionActionsPanel::~KisSelectionActionsPanel()@@ -113,13 +113,11 @@ void KisSelectionActionsPanel::draw(QPainter &painter)}drawActionBarBackground(painter);-- for (int i = 0; i < d->m_buttons.size(); i++) {- QPushButton *button = d->m_buttons[i];- int buttonPosition = i * BUTTON_SIZE;- button->move(d->m_dragHandle->position.x() + buttonPosition, d->m_dragHandle->position.y());- button->show();+ Q_FOREACH(KisSelectionActionsPanelButton* button, d->m_buttons){+ button->draw(painter);}++ d->m_handleWidget->draw(painter);}void KisSelectionActionsPanel::setVisible(bool p_visible)@@ -137,18 +135,20 @@ void KisSelectionActionsPanel::setVisible(bool p_visible)}if (d->m_viewManager->selection() && p_visible) { // Now visible!- canvasWidget->installEventFilter(this);+ d->m_handleWidget->installEventFilter(this);if (!d->m_dragHandle) {d->m_dragHandle.reset(new Private::DragHandle());d->m_dragHandle->position = initialDragHandlePosition();+ movePanelWidgets();}} else { // Now hidden!- canvasWidget->removeEventFilter(this);+ d->m_handleWidget->removeEventFilter(this);- for (QPushButton *button : d->m_buttons) {+ for (KisSelectionActionsPanelButton *button : d->m_buttons) {button->hide();}+ d->m_handleWidget->hide();d->m_pressed = false;d->m_dragHandle.reset();@@ -170,10 +170,6 @@ void KisSelectionActionsPanel::setEnabled(bool enabled)bool KisSelectionActionsPanel::eventFilter(QObject *obj, QEvent *event){switch (event->type()) {- case QEvent::FocusIn:- event->accept();- return true;-case QEvent::MouseButtonPress: {const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);return handlePress(event, mouseEventPos(mouseEvent), mouseEvent->button());@@ -194,13 +190,13 @@ bool KisSelectionActionsPanel::eventFilter(QObject *obj, QEvent *event)case QEvent::MouseMove:if (d->m_pressed) {const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);- return handleMove(event, mouseEventPos(mouseEvent), obj);+ return handleMove(event, mouseEventPos(mouseEvent));}break;case QEvent::TabletMove:if (d->m_pressed) {const QTabletEvent *tabletEvent = static_cast<QTabletEvent *>(event);- return handleMove(event, tabletEventPos(tabletEvent), obj);+ return handleMove(event, tabletEventPos(tabletEvent));}break;case QEvent::TouchUpdate:@@ -208,7 +204,7 @@ bool KisSelectionActionsPanel::eventFilter(QObject *obj, QEvent *event)const QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);QPoint pos;if (touchEventPos(touchEvent, pos)) {- return handleMove(event, pos, obj);+ return handleMove(event, pos);}}break;@@ -218,12 +214,8 @@ bool KisSelectionActionsPanel::eventFilter(QObject *obj, QEvent *event)case QEvent::TouchEnd:case QEvent::TouchCancel:if (d->m_pressed) {- if (d->m_pressedIndex >= 0 && d->m_pressedIndex < d->m_buttons.size()) {- // A button was pressed, trigger it on the next event loop.- QTimer::singleShot(0, d->m_buttons[d->m_pressedIndex], &QPushButton::click);- }+ d->m_handleWidget->set_held(false);d->m_pressed = false;- d->m_pressedIndex = -1;event->accept();return true;}@@ -235,6 +227,19 @@ bool KisSelectionActionsPanel::eventFilter(QObject *obj, QEvent *event)return false;}++void KisSelectionActionsPanel::canvasWidgetChanged(KisCanvasWidgetBase* canvas)+{++ Q_FOREACH(QWidget* btn, d->m_buttons) {+ btn->setParent(canvas->widget());+ btn->show();+ }++ d->m_handleWidget->setParent(canvas->widget());+ d->m_handleWidget->show();+}+QPoint KisSelectionActionsPanel::updateCanvasBoundaries(QPoint position, QWidget *canvasWidget) const{QRect canvasBounds = canvasWidget->rect();@@ -285,60 +290,31 @@ QPoint KisSelectionActionsPanel::initialDragHandlePosition() constreturn updateCanvasBoundaries(widgetBottomCenter.toPoint(), d->m_viewManager->canvas());}-QPushButton *KisSelectionActionsPanel::createButton(const QString &iconName, const QString &tooltip)-{- QPushButton *button = new QPushButton();- button->setIcon(KisIconUtils::loadIcon(iconName));- button->setFixedSize(BUTTON_SIZE, BUTTON_SIZE);- button->setToolTip(tooltip);- return button;-}-void KisSelectionActionsPanel::drawActionBarBackground(QPainter &painter) const{- const int CORNER_RADIUS = 4;- const int PEN_WIDTH = 5;- const QColor BACKGROUND_COLOR = Qt::darkGray;- const QColor OUTLINE_COLOR(60, 60, 60, 80);- const QColor DOT_COLOR = Qt::lightGray;- const int DOT_SIZE = 4;- const int DOT_SPACING = 5;- const QPoint DRAG_HANDLE_RECT_DOTS_OFFSET(10, 10);-- QRectF actionBarRect(d->m_dragHandle->position, QSize(d->m_actionBarWidth, BUTTON_SIZE));+ const int cornerRadius = 4;+ QColor outlineColor = Qt::darkGray;+ const QColor bgColor = qApp->palette().window().color();+ QColor bgColorTrans = bgColor;+ bgColorTrans.setAlpha(80);+ const int outline_width = 4;++ //an outer 1px wide outline for contrast against the background+ QRectF contrastOutline(d->m_dragHandle->position - QPoint(outline_width + 1,outline_width + 1), QSize(d->m_actionBarWidth, BUTTON_SIZE) +QSize(outline_width + 1,outline_width + 1) * 2);+ QRectF midOutline(d->m_dragHandle->position - QPoint(outline_width,outline_width), QSize(d->m_actionBarWidth, BUTTON_SIZE) +QSize(outline_width,outline_width) * 2);+ //Add a bit of padding here for the icons+ QRectF centerBackground(d->m_dragHandle->position - QPoint(outline_width,outline_width) / 2, QSize(d->m_actionBarWidth - BUTTON_SIZE, BUTTON_SIZE) +QSize(outline_width,outline_width));QPainterPath bgPath;- bgPath.addRoundedRect(actionBarRect, CORNER_RADIUS, CORNER_RADIUS);- painter.fillPath(bgPath, BACKGROUND_COLOR);-- QPen pen(OUTLINE_COLOR);- pen.setWidth(PEN_WIDTH);- painter.setPen(pen);- painter.drawPath(bgPath);-- QRectF dragHandleRect(- QPoint(d->m_dragHandle->position.x() + d->m_actionBarWidth - BUTTON_SIZE, d->m_dragHandle->position.y()),- QSize(BUTTON_SIZE, BUTTON_SIZE));- QPainterPath dragHandlePath;- dragHandlePath.addRect(dragHandleRect);- painter.fillPath(dragHandlePath, BACKGROUND_COLOR);-- const std::list<std::pair<int, int>> DOT_OFFSETS = {{0, 0},- {DOT_SPACING, 0},- {-DOT_SPACING, 0},- {0, DOT_SPACING},- {0, -DOT_SPACING},- {DOT_SPACING, DOT_SPACING},- {DOT_SPACING, -DOT_SPACING},- {-DOT_SPACING, DOT_SPACING},- {-DOT_SPACING, -DOT_SPACING}};-- QPainterPath dragHandleRectDots;- for (const std::pair<int, int> &offset : DOT_OFFSETS) {- dragHandleRectDots.addEllipse(offset.first, offset.second, DOT_SIZE, DOT_SIZE);- };+ QPainterPath outlinePath;+ QPainterPath contrastOutlinePath;- dragHandleRectDots.translate(dragHandleRect.topLeft() + DRAG_HANDLE_RECT_DOTS_OFFSET);- painter.fillPath(dragHandleRectDots, DOT_COLOR);+ bgPath.addRoundedRect(centerBackground, cornerRadius, cornerRadius);+ outlinePath.addRoundedRect(midOutline, cornerRadius, cornerRadius);+ contrastOutlinePath.addRoundedRect(contrastOutline, cornerRadius, cornerRadius);++ painter.fillPath(contrastOutlinePath, bgColorTrans);+ painter.fillPath(outlinePath, outlineColor);+ painter.fillPath(bgPath, bgColor);}bool KisSelectionActionsPanel::handlePress(QEvent *event, const QPoint &pos, Qt::MouseButton button)@@ -349,63 +325,57 @@ bool KisSelectionActionsPanel::handlePress(QEvent *event, const QPoint &pos, Qt:}if (button == Qt::LeftButton) {- QRect targetRect(d->m_dragHandle->position, QSize(BUTTON_SIZE * d->m_buttonCount, BUTTON_SIZE));- if (targetRect.contains(pos)) {- d->m_pressed = true;-- d->m_pressedIndex = (pos.x() - targetRect.left()) / BUTTON_SIZE;- if (d->m_pressedIndex < 0 || d->m_pressedIndex >= d->m_buttons.size()) {- d->m_dragHandle->dragOrigin = pos - d->m_dragHandle->position;- }+ d->m_pressed = true;+ d->m_dragHandle->dragOrigin = pos - d->m_dragHandle->position;+ d->m_handleWidget->set_held(true);- event->accept();- return true;- }+ event->accept();+ return true;}return false;}-bool KisSelectionActionsPanel::handleMove(QEvent *event, const QPoint &pos, QObject *obj)+bool KisSelectionActionsPanel::handleMove(QEvent *event, const QPoint &pos){- // Are we dragging the bar or was a button pressed?- if (d->m_pressedIndex < 0 || d->m_pressedIndex >= d->m_buttons.size()) {- // bound actionBar to stay within canvas space- QWidget *canvasWidget = d->m_viewManager->canvas();-- // Explicitly casting just in case inheritance adjusts the pointer weirdly- // (MSVC does spicy things like that sometimes to keep you on your toes.)- if (obj == static_cast<QObject *>(canvasWidget)) {- QPoint newPos = pos - d->m_dragHandle->dragOrigin;- d->m_dragHandle->position = updateCanvasBoundaries(newPos, canvasWidget);- canvasWidget->update();- event->accept();- return true;- } else {- return false;- }- } else {- // Button was pressed, we're just waiting for a release.- event->accept();- return true;+ QWidget *canvasWidget = d->m_viewManager->canvas();+ QPoint newPos = pos - d->m_dragHandle->dragOrigin;+ d->m_dragHandle->position = updateCanvasBoundaries(newPos, canvasWidget);+ movePanelWidgets();+ canvasWidget->update();+ event->accept();+ return true;+}++void KisSelectionActionsPanel::movePanelWidgets()+{+ d->m_handleWidget->move(d->m_dragHandle->position.x() + d->m_buttons.size() * BUTTON_SIZE, d->m_dragHandle->position.y());+ d->m_handleWidget->show();++ int i = 0;+ Q_FOREACH(KisSelectionActionsPanelButton *button, d->m_buttons) {+ int buttonPosition = i * BUTTON_SIZE;+ button->move(d->m_dragHandle->position.x() + buttonPosition, d->m_dragHandle->position.y());+ button->show();+ i++;}}QPoint KisSelectionActionsPanel::mouseEventPos(const QMouseEvent *mouseEvent){#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)- return mouseEvent->position().toPoint();+ return transformHandleCoords(mouseEvent->position().toPoint());#else- return mouseEvent->pos();+ return transformHandleCoords(mouseEvent->pos());#endif}QPoint KisSelectionActionsPanel::tabletEventPos(const QTabletEvent *tabletEvent){#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)- return tabletEvent->position().toPoint();+ return transformHandleCoords(tabletEvent->position().toPoint());#else- return tabletEvent->pos();+ return transformHandleCoords(tabletEvent->pos());#endif}@@ -415,7 +385,7 @@ bool KisSelectionActionsPanel::touchEventPos(const QTouchEvent *touchEvent, QPoiif (touchEvent->pointCount() < 1) {return false;} else {- outPos = touchEvent->points().first().position().toPoint();+ outPos = transformHandleCoords(touchEvent->points().first().position().toPoint());return true;}#else@@ -423,8 +393,12 @@ bool KisSelectionActionsPanel::touchEventPos(const QTouchEvent *touchEvent, QPoiif (touchPoints.isEmpty()) {return false;} else {- outPos = touchPoints.first().pos().toPoint();+ outPos = transformHandleCoords(touchPoints.first().pos().toPoint());return true;}#endif}++constexpr QPoint KisSelectionActionsPanel::transformHandleCoords(QPoint pos) {+ return d->m_dragHandle->position + pos;+}diff --git a/libs/ui/kis_selection_actions_panel.h b/libs/ui/kis_selection_actions_panel.hindex e404663b62..49264865c5 100644--- a/libs/ui/kis_selection_actions_panel.h+++ b/libs/ui/kis_selection_actions_panel.h@@ -27,12 +27,12 @@ class KisViewManager;class KisSelectionActionsPanel;typedef KisSharedPtr<KisSelectionActionsPanel> KisSelectionActionsPanelSP;-class KRITAUI_EXPORT KisSelectionActionsPanel : public QWidget+class KRITAUI_EXPORT KisSelectionActionsPanel : public QObject{Q_OBJECTpublic:KisSelectionActionsPanel() = delete;- KisSelectionActionsPanel(KisViewManager *viewManager, QWidget *parent);+ KisSelectionActionsPanel(KisViewManager *viewManager);~KisSelectionActionsPanel();void draw(QPainter &painter);@@ -40,27 +40,29 @@ public:void setEnabled(bool enabled);bool eventFilter(QObject *obj, QEvent *event) override;+ void canvasWidgetChanged(KisCanvasWidgetBase* canvas);private:- void setupButtons();- QPushButton *createButton(const QString &iconName, const QString &tooltip);QPoint updateCanvasBoundaries(QPoint position, QWidget *canvasWidget) const;QPoint initialDragHandlePosition() const;void drawActionBarBackground(QPainter &gc) const;bool handlePress(QEvent *event, const QPoint &pos, Qt::MouseButton button = Qt::LeftButton);- bool handleMove(QEvent *event, const QPoint &pos, QObject *obj);- bool handleRelease(QEvent *event, const QPoint &pos, QObject *obj);+ bool handleMove(QEvent *event, const QPoint &pos);+ bool handleRelease(QEvent *event, const QPoint &pos);- static QPoint mouseEventPos(const QMouseEvent *mouseEvent);- static QPoint tabletEventPos(const QTabletEvent *tabletEvent);+ ///Moves all the widgets that are a part of the panel+ void movePanelWidgets();++ QPoint mouseEventPos(const QMouseEvent *mouseEvent);+ QPoint tabletEventPos(const QTabletEvent *tabletEvent);// Touch events can have zero touch points when pressing an entire palm on// the screen on Android, so this returns false if this is a non-touch.- static bool touchEventPos(const QTouchEvent *touchEvent, QPoint &outPos);+ bool touchEventPos(const QTouchEvent *touchEvent, QPoint &outPos);++ constexpr QPoint transformHandleCoords(QPoint pos);struct Private;QScopedPointer<Private> d;--Q_SIGNALS:};#endifdiff --git a/libs/ui/kis_selection_actions_panel_button.cpp b/libs/ui/kis_selection_actions_panel_button.cppnew file mode 100644index 0000000000..b0f44430a0--- /dev/null+++ b/libs/ui/kis_selection_actions_panel_button.cpp@@ -0,0 +1,61 @@+/*+ * SPDX-FileCopyrightText: 2026 Luna Lovecraft <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */++#include "kis_selection_actions_panel_button.h"++#include "kis_icon_utils.h"+#include <qapplication.h>+#include <qpainter.h>+#include <qpainterpath.h>++static constexpr int ICON_SIZE_OFFSET = 6;++KisSelectionActionsPanelButton::KisSelectionActionsPanelButton(const QString& iconName, const QString &tooltip, int size, QWidget *parent)+ : QAbstractButton(parent)+{+ setIcon(KisIconUtils::loadIcon(iconName));+ setFixedSize(size, size);+ setToolTip(tooltip);+ setCursor(Qt::PointingHandCursor);+ setIconSize(QSize(size - ICON_SIZE_OFFSET, size - ICON_SIZE_OFFSET));+}++KisSelectionActionsPanelButton::~KisSelectionActionsPanelButton()+{++}++void KisSelectionActionsPanelButton::draw(QPainter &painter)+{+ QRect rect = geometry();+ //Draw an outline when the button is pressed+ if(this->isDown()) {+ QColor bgColor = qApp->palette().window().color();+ //Invert the background color+ bgColor.setRed(255 - bgColor.red());+ bgColor.setGreen(255 - bgColor.green());+ bgColor.setBlue(255 - bgColor.blue());++ QPainterPath path;+ path.addRoundedRect(rect, 3, 3);+ QPen pen = bgColor;+ pen.setWidth(2);++ painter.setPen(pen);+ painter.drawPath(path) ;+ }++ QPixmap map = this->icon().pixmap(iconSize());+ painter.drawPixmap(rect.x() + ICON_SIZE_OFFSET / 2.0 , rect.y() + ICON_SIZE_OFFSET / 2.0, map);+}+++//Dummy paint event, so that this class isn't treated like an abstract class+void KisSelectionActionsPanelButton::paintEvent(QPaintEvent *e)+{+ Q_UNUSED(e);+}+diff --git a/libs/ui/kis_selection_actions_panel_button.h b/libs/ui/kis_selection_actions_panel_button.hnew file mode 100644index 0000000000..604d2c92fa--- /dev/null+++ b/libs/ui/kis_selection_actions_panel_button.h@@ -0,0 +1,23 @@+/*+ * SPDX-FileCopyrightText: 2026 Luna Lovecraft <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */++#ifndef _KIS_SELECTION_ACTIONS_PANEL_BUTTON+#define _KIS_SELECTION_ACTIONS_PANEL_BUTTON++#include <qabstractbutton.h>++///Custom widget for selection actions panel buttons, to prevent them being drawn over the pop-up palette+class KisSelectionActionsPanelButton : public QAbstractButton {+ public:+ KisSelectionActionsPanelButton(const QString& iconName, const QString &tooltip, int size, QWidget *parent);+ ~KisSelectionActionsPanelButton();+ void draw(QPainter &painter);+protected:+ void paintEvent(QPaintEvent *e) override;+};+++#endifdiff --git a/libs/ui/kis_selection_actions_panel_handle.cpp b/libs/ui/kis_selection_actions_panel_handle.cppnew file mode 100644index 0000000000..33b013459d--- /dev/null+++ b/libs/ui/kis_selection_actions_panel_handle.cpp@@ -0,0 +1,63 @@+/*+ * SPDX-FileCopyrightText: 2026 Luna Lovecraft <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */++#include "kis_selection_actions_panel_handle.h"+#include "kis_icon_utils.h"++struct KisSelectionActionsPanelHandle::Private+{+ Private(int size) { this->size = size;};+ QCursor default_cursor;+ QCursor held_cursor;+ QIcon handle_icon;+ int size;+};++KisSelectionActionsPanelHandle::KisSelectionActionsPanelHandle(int size, QWidget * parent) :+ QWidget(parent),+ d(new Private(size))+{+ d->default_cursor = Qt::OpenHandCursor;+ d->held_cursor = Qt::ClosedHandCursor;+ d->handle_icon = KisIconUtils::loadIcon("drag-handle");+ this->setCursor(d->default_cursor);+ setFixedSize(size, size);+}++KisSelectionActionsPanelHandle::~KisSelectionActionsPanelHandle()+{+}++void KisSelectionActionsPanelHandle::set_held(bool held)+{+ if(held)+ {+ this->setCursor(d->held_cursor);+ }+ else+ {+ this->setCursor(d->default_cursor);+ }+}++void KisSelectionActionsPanelHandle::draw(QPainter& painter)+{+ QPixmap map = d->handle_icon.pixmap(d->size);++ QRect rect = geometry();+ //Adjust the rct a bit to fill the right side of the bar properly+ rect.setY(rect.y() - 4);+ rect.setHeight(rect.height() + 4);+ rect.setX(rect.x() + 3);+ rect.setWidth(rect.width() + 1);++ QColor bgColor = Qt::darkGray;+ painter.fillRect(rect, bgColor);++ painter.fillRect(rect, bgColor);+ // Adjusting the icon location a bit to be properly centered+ painter.drawPixmap(geometry().x() + 3, geometry().y(), map);+}diff --git a/libs/ui/kis_selection_actions_panel_handle.h b/libs/ui/kis_selection_actions_panel_handle.hnew file mode 100644index 0000000000..0e35714429--- /dev/null+++ b/libs/ui/kis_selection_actions_panel_handle.h@@ -0,0 +1,23 @@+/*+ * SPDX-FileCopyrightText: 2026 Luna Lovecraft <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */++#ifndef _KIS_SELECTION_ACTIONS_PANNEL_HANDLE+#define _KIS_SELECTION_ACTIONS_PANNEL_HANDLE+#include <qpainter.h>+#include <qwidget.h>++class KisSelectionActionsPanelHandle : public QWidget+{+public:+ KisSelectionActionsPanelHandle(int size, QWidget *parent);+ ~KisSelectionActionsPanelHandle();+ void draw(QPainter& painter);+ void set_held(bool held);+private:+ struct Private;+ QScopedPointer<Private> d;+};+#endifdiff --git a/libs/ui/kis_selection_decoration.cc b/libs/ui/kis_selection_decoration.ccindex 6dbe5a8ada..9b9e932b74 100644--- a/libs/ui/kis_selection_decoration.cc+++ b/libs/ui/kis_selection_decoration.cc@@ -65,7 +65,7 @@ KisSelectionDecoration::KisSelectionDecoration(QPointer<KisView>_view)// selections should be at the top of the stacksetPriority(100);- m_selectionActionsPanel = new KisSelectionActionsPanel(this->view()->viewManager(), this->view());+ m_selectionActionsPanel = new KisSelectionActionsPanel(this->view()->viewManager());slotConfigChanged();}@@ -200,13 +200,19 @@ void KisSelectionDecoration::drawDecoration(QPainter& gc, const QRectF& updateReQ_UNUSED(canvas);// render Selection Action Bar first, so that it doesn't blink when making a new selection- m_selectionActionsPanel->draw(gc);if ((m_mode == Ants && m_outlinePath.isEmpty()) ||- (m_mode == Mask && m_thumbnailImage.isNull())) return;+ (m_mode == Mask && m_thumbnailImage.isNull())) {++ //The SAP needs to be drawn on top of the decoration, but to avoid the panel flashing when making a new selection, we also need to call draw here+ m_selectionActionsPanel->draw(gc);++ return;+ }QTransform transform = converter->imageToWidgetTransform();+ gc.save();gc.setTransform(transform, false);if (m_mode == Mask) {@@ -242,6 +248,14 @@ void KisSelectionDecoration::drawDecoration(QPainter& gc, const QRectF& updateRegc.setPen(m_antsPen);gc.drawPath(m_outlinePath);}++ gc.restore();+ m_selectionActionsPanel->draw(gc);+}++void KisSelectionDecoration::setCanvasWidget(KisCanvasWidgetBase* canvas)+{+ m_selectionActionsPanel->canvasWidgetChanged(canvas);}void KisSelectionDecoration::setVisible(bool v)diff --git a/libs/ui/kis_selection_decoration.h b/libs/ui/kis_selection_decoration.hindex 70b1c95ac8..52199226e2 100644--- a/libs/ui/kis_selection_decoration.h+++ b/libs/ui/kis_selection_decoration.h@@ -37,6 +37,7 @@ public:void setVisible(bool v) override;void notifyWindowMinimized(bool minimized) override;+ void setCanvasWidget(KisCanvasWidgetBase* canvas) override;protected:void drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter,KisCanvas2* canvas) override;