Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Fix SAP disappearing when toggling selection visibility

Luna Lovecraftf6673f9a53d1
diff --git a/libs/ui/kis_selection_decoration.cc b/libs/ui/kis_selection_decoration.cc
index 9b9e932b74..5912115aec 100644
--- a/libs/ui/kis_selection_decoration.cc
+++ b/libs/ui/kis_selection_decoration.cc
@@ -194,6 +194,10 @@ void KisSelectionDecoration::antsAttackEvent()
}
}
+void KisSelectionDecoration::toggleSlectionVisibility() {
+ m_selectionVisibility = !m_selectionVisibility;
+}
+
void KisSelectionDecoration::drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter, KisCanvas2 *canvas)
{
Q_UNUSED(updateRect);
@@ -201,15 +205,18 @@ void KisSelectionDecoration::drawDecoration(QPainter& gc, const QRectF& updateRe
// render Selection Action Bar first, so that it doesn't blink when making a new selection
- if ((m_mode == Ants && m_outlinePath.isEmpty()) ||
- (m_mode == Mask && m_thumbnailImage.isNull())) {
-
+ if ((m_mode == Ants && m_outlinePath.isEmpty()) || (m_mode == Mask && m_thumbnailImage.isNull())
+ || !m_selectionVisibility) {
//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;
}
+ if (!m_selectionVisibility) {
+ return;
+ }
+
QTransform transform = converter->imageToWidgetTransform();
gc.save();
@@ -260,6 +267,7 @@ void KisSelectionDecoration::setCanvasWidget(KisCanvasWidgetBase* canvas)
void KisSelectionDecoration::setVisible(bool v)
{
+ m_selectionVisibility = v;
KisCanvasDecoration::setVisible(v);
selectionChanged();
m_selectionActionsPanel->setVisible(v);
diff --git a/libs/ui/kis_selection_decoration.h b/libs/ui/kis_selection_decoration.h
index 52199226e2..d8db1690b2 100644
--- a/libs/ui/kis_selection_decoration.h
+++ b/libs/ui/kis_selection_decoration.h
@@ -39,6 +39,8 @@ public:
void notifyWindowMinimized(bool minimized) override;
void setCanvasWidget(KisCanvasWidgetBase* canvas) override;
+ void toggleSlectionVisibility();
+
protected:
void drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter,KisCanvas2* canvas) override;
@@ -72,6 +74,8 @@ private:
QColor m_maskColor;
bool m_antialiasSelectionOutline;
KisSelectionActionsPanel *m_selectionActionsPanel;
+
+ bool m_selectionVisibility;
};
#endif
diff --git a/libs/ui/kis_selection_manager.cc b/libs/ui/kis_selection_manager.cc
index 88b959419c..eac200e35a 100644
--- a/libs/ui/kis_selection_manager.cc
+++ b/libs/ui/kis_selection_manager.cc
@@ -561,7 +561,7 @@ void KisSelectionManager::toggleDisplaySelection()
{
KIS_ASSERT_RECOVER_RETURN(m_selectionDecoration);
- m_selectionDecoration->toggleVisibility();
+ m_selectionDecoration->toggleSlectionVisibility();
m_toggleDisplaySelection->blockSignals(true);
m_toggleDisplaySelection->setChecked(m_selectionDecoration->visible());
m_toggleDisplaySelection->blockSignals(false);