summarylogtreecommitdiffstats
path: root/radius_lock.patch
blob: b1e405916988c6ee88726762122273e9e308b759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
diff --git a/gui/brushmodifier.py b/gui/brushmodifier.py
index f2b46e95..6a5a609f 100644
--- a/gui/brushmodifier.py
+++ b/gui/brushmodifier.py
@@ -96,12 +96,20 @@ class BrushModifier (object):
         b = self.app.brush
         prev_lock_alpha = b.is_alpha_locked()
 
+        lock_radius = self.app.preferences['misc.context_lock_radius']
+        if lock_radius:
+            prev_radius = b.get_base_value('radius_logarithmic')
+
         # Changing the effective brush
         b.begin_atomic()
         color = b.get_color_hsv()
 
         mix_old = b.get_base_value('restore_color')
         b.load_from_brushinfo(brushinfo)
+
+        if lock_radius:
+            b.set_base_value('radius_logarithmic', prev_radius)
+
         self.unmodified_brushinfo = b.clone()
 
         # Preserve color
diff --git a/gui/document.py b/gui/document.py
index 047fca9e..ff911ba4 100644
--- a/gui/document.py
+++ b/gui/document.py
@@ -354,6 +354,11 @@ class Document (CanvasController):  # TODO: rename to "DocumentController"
             toggle_action.set_active(
                 self.app.preferences['misc.context_restores_color']
             )
+            
+            toggle_action = self.app.builder.get_object('ContextLockRadius')
+            toggle_action.set_active(
+                self.app.preferences['misc.context_lock_radius']
+            )
 
         #: Saved transformation to allow FitView to be toggled.
         self.saved_view = None
@@ -1686,6 +1691,11 @@ class Document (CanvasController):  # TODO: rename to "DocumentController"
         value = bool(action.get_active())
         self.app.preferences['misc.context_restores_color'] = value
 
+    def context_toggle_lock_radius_cb(self, action):
+        """GtkToggleAction callback for whether the radius is locked between brush changes"""
+        value = bool(action.get_active())
+        self.app.preferences['misc.context_lock_radius'] = value
+
     ## UI feedback for current layer/stroke
 
     def strokeblink_state_enter(self, strokeshape, bbox, center):
diff --git a/gui/menu.xml b/gui/menu.xml
index eab7a7d1..c20d6759 100644
--- a/gui/menu.xml
+++ b/gui/menu.xml
@@ -142,6 +142,7 @@
         <menuitem action='Context09s'/>
       </menu>
       <menuitem action='PickContext'/>
+      <menuitem action='ContextLockRadius'/>
       <!-- Brush pack import -->
       <separator/>
       <menuitem action='ImportBrushPack'/>
diff --git a/gui/resources.xml b/gui/resources.xml
index a0641e5e..1812dc35 100644
--- a/gui/resources.xml
+++ b/gui/resources.xml
@@ -385,6 +385,13 @@ Vocabulary
         </object>
         <accelerator key="grave"/>
       </child>
+      <child>
+        <object class="GtkToggleAction" id="ContextLockRadius">
+          <property name="label" translatable="yes" context="Menu→Brush">Lock Radius</property>
+          <property name="tooltip" translatable="yes" context="Accel Editor (descriptions)">Toggle whether changing the brush should keep current radius.</property>
+          <signal name="activate" handler="context_toggle_lock_radius_cb"/>
+        </object>
+      </child>
       <child>
         <object class="GtkAction" id="ContextStore">
           <property name="label" translatable="yes" context="Menu→Brush→Shortcut Keys (labels), Accel Editor (labels)">Save Brush to Most Recent Shortcut Key</property>
diff --git a/gui/userconfig.py b/gui/userconfig.py
index 582d7f13..9de0c696 100644
--- a/gui/userconfig.py
+++ b/gui/userconfig.py
@@ -91,6 +91,7 @@ def default_configuration():
         'brushmanager.selected_groups': [],
         'frame.color_rgba': (0.12, 0.12, 0.12, 0.92),
         'misc.context_restores_color': True,
+        'misc.context_lock_radius': False,
 
         'document.autosave_backups': True,
         'document.autosave_interval': 10,