[krita/kazakov/lazy-brush-remastered] /: Bind Primary and Secondary alternate modes to show key strokes and coloring

Dmitry Kazakov null at kde.org
Fri Nov 17 17:19:23 UTC 2017


Git commit 57720072703d7463d4d18fd22beac4d341e38f2a by Dmitry Kazakov.
Committed on 17/11/2017 at 17:19.
Pushed by dkazakov into branch 'kazakov/lazy-brush-remastered'.

Bind Primary and Secondary alternate modes to show key strokes and coloring

Ctrl+Shift -> Show Key Strokes (you can paint in this mode)
Alt+Shift -> Show Coloring (you can paint in this mode)
Enter -> Update the mask


CC:kimageshop at kde.org

M  +4    -0    libs/ui/input/kis_alternate_invocation_action.cpp
M  +1    -0    libs/ui/input/kis_alternate_invocation_action.h
M  +93   -0    plugins/tools/tool_lazybrush/kis_tool_lazy_brush.cpp
M  +7    -0    plugins/tools/tool_lazybrush/kis_tool_lazy_brush.h

https://commits.kde.org/krita/57720072703d7463d4d18fd22beac4d341e38f2a

diff --git a/libs/ui/input/kis_alternate_invocation_action.cpp b/libs/ui/input/kis_alternate_invocation_action.cpp
index 4f83c349b4a..0cb11249c35 100644
--- a/libs/ui/input/kis_alternate_invocation_action.cpp
+++ b/libs/ui/input/kis_alternate_invocation_action.cpp
@@ -41,6 +41,7 @@ KisAlternateInvocationAction::KisAlternateInvocationAction()
     QHash<QString, int> shortcuts;
     shortcuts.insert(i18n("Primary Mode"), PrimaryAlternateModeShortcut);
     shortcuts.insert(i18n("Secondary Mode"), SecondaryAlternateModeShortcut);
+    shortcuts.insert(i18n("Tertiary Mode"), TertiaryAlternateModeShortcut);
 
 
     shortcuts.insert(i18n("Pick Foreground Color from Current Layer"), PickColorFgLayerModeShortcut);
@@ -79,6 +80,9 @@ KisTool::ToolAction KisAlternateInvocationAction::shortcutToToolAction(int short
     case SecondaryAlternateModeShortcut:
         action = KisTool::AlternateThird;
         break;
+    case TertiaryAlternateModeShortcut:
+        action = KisTool::AlternateFourth;
+        break;
     }
 
     return action;
diff --git a/libs/ui/input/kis_alternate_invocation_action.h b/libs/ui/input/kis_alternate_invocation_action.h
index dd8e5fdeb5b..35032fe91bc 100644
--- a/libs/ui/input/kis_alternate_invocation_action.h
+++ b/libs/ui/input/kis_alternate_invocation_action.h
@@ -39,6 +39,7 @@ public:
     enum Shortcut {
         PrimaryAlternateModeShortcut, ///< Toggle Primary mode.
         SecondaryAlternateModeShortcut, ///< Toggle Secondary mode.
+        TertiaryAlternateModeShortcut, ///< Toggle Tertiary mode.
         PickColorFgLayerModeShortcut,
         PickColorBgLayerModeShortcut,
         PickColorFgImageModeShortcut,
diff --git a/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.cpp b/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.cpp
index b5b4a0bfdc3..9daf9831ff8 100644
--- a/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.cpp
+++ b/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.cpp
@@ -41,6 +41,8 @@
 struct KisToolLazyBrush::Private
 {
     bool activateMaskMode = false;
+    bool oldShowKeyStrokesValue = false;
+    bool oldShowColoringValue = false;
 };
 
 
@@ -149,6 +151,97 @@ void KisToolLazyBrush::endPrimaryAction(KoPointerEvent *event)
     KisToolFreehand::endPrimaryAction(event);
 }
 
+void KisToolLazyBrush::activateAlternateAction(KisTool::AlternateAction action)
+{
+    if (action == KisTool::Secondary && !m_d->activateMaskMode) {
+        KisNodeSP node = currentNode();
+        if (!node) return;
+
+        m_d->oldShowKeyStrokesValue =
+            KisLayerPropertiesIcons::nodeProperty(node,
+                                                  KisLayerPropertiesIcons::colorizeEditKeyStrokes,
+                                                  true).toBool();
+
+        KisLayerPropertiesIcons::setNodeProperty(node,
+                                                 KisLayerPropertiesIcons::colorizeEditKeyStrokes,
+                                                 !m_d->oldShowKeyStrokesValue, image());
+
+        KisToolFreehand::activatePrimaryAction();
+
+    } else if (action == KisTool::Third && !m_d->activateMaskMode) {
+        KisNodeSP node = currentNode();
+        if (!node) return;
+
+        m_d->oldShowColoringValue =
+                KisLayerPropertiesIcons::nodeProperty(node,
+                                                      KisLayerPropertiesIcons::colorizeShowColoring,
+                                                      true).toBool();
+
+        KisLayerPropertiesIcons::setNodeProperty(node,
+                                                 KisLayerPropertiesIcons::colorizeShowColoring,
+                                                 !m_d->oldShowColoringValue, image());
+
+        KisToolFreehand::activatePrimaryAction();
+
+    } else {
+        KisToolFreehand::activateAlternateAction(action);
+    }
+}
+
+void KisToolLazyBrush::deactivateAlternateAction(KisTool::AlternateAction action)
+{
+    if (action == KisTool::Secondary && !m_d->activateMaskMode) {
+        KisNodeSP node = currentNode();
+        if (!node) return;
+
+        KisLayerPropertiesIcons::setNodeProperty(node,
+                                                 KisLayerPropertiesIcons::colorizeEditKeyStrokes,
+                                                 m_d->oldShowKeyStrokesValue, image());
+
+        KisToolFreehand::deactivatePrimaryAction();
+
+    } else if (action == KisTool::Third && !m_d->activateMaskMode) {
+        KisNodeSP node = currentNode();
+        if (!node) return;
+
+        KisLayerPropertiesIcons::setNodeProperty(node,
+                                                 KisLayerPropertiesIcons::colorizeShowColoring,
+                                                 m_d->oldShowColoringValue, image());
+
+        KisToolFreehand::deactivatePrimaryAction();
+
+    } else {
+        KisToolFreehand::deactivateAlternateAction(action);
+    }
+}
+
+void KisToolLazyBrush::beginAlternateAction(KoPointerEvent *event, KisTool::AlternateAction action)
+{
+    if (!m_d->activateMaskMode && (action == KisTool::Secondary || action == KisTool::Third)) {
+        beginPrimaryAction(event);
+    } else {
+        KisToolFreehand::beginAlternateAction(event, action);
+    }
+}
+
+void KisToolLazyBrush::continueAlternateAction(KoPointerEvent *event, KisTool::AlternateAction action)
+{
+    if (!m_d->activateMaskMode && (action == KisTool::Secondary || action == KisTool::Third)) {
+        continuePrimaryAction(event);
+    } else {
+        KisToolFreehand::continueAlternateAction(event, action);
+    }
+}
+
+void KisToolLazyBrush::endAlternateAction(KoPointerEvent *event, KisTool::AlternateAction action)
+{
+    if (!m_d->activateMaskMode && (action == KisTool::Secondary || action == KisTool::Third)) {
+        endPrimaryAction(event);
+    } else {
+        KisToolFreehand::endAlternateAction(event, action);
+    }
+}
+
 void KisToolLazyBrush::explicitUserStrokeEndRequest()
 {
     if (m_d->activateMaskMode) {
diff --git a/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.h b/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.h
index fe4c532d44b..a5368274835 100644
--- a/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.h
+++ b/plugins/tools/tool_lazybrush/kis_tool_lazy_brush.h
@@ -51,6 +51,13 @@ public:
     void continuePrimaryAction(KoPointerEvent *event) override;
     void endPrimaryAction(KoPointerEvent *event) override;
 
+    void activateAlternateAction(AlternateAction action) override;
+    void deactivateAlternateAction(AlternateAction action) override;
+
+    void beginAlternateAction(KoPointerEvent *event, AlternateAction action) override;
+    void continueAlternateAction(KoPointerEvent *event, AlternateAction action) override;
+    void endAlternateAction(KoPointerEvent *event, AlternateAction action) override;
+
     void explicitUserStrokeEndRequest() override;
 
 protected Q_SLOTS:


More information about the kimageshop mailing list