Browse Source

[Viewer] Color & thickness saving

- For each tool color & thickness is saved in memory.

Fixes #6
master
Bogdan Cordier 1 year ago
parent
commit
b782807721
2 changed files with 8 additions and 3 deletions
  1. 6
    2
      hadaly/painter.py
  2. 2
    1
      hadaly/viewer.py

+ 6
- 2
hadaly/painter.py View File

@@ -19,10 +19,14 @@ class Painter(Widget):
19 19
     locked = BooleanProperty(False)
20 20
 
21 21
     def on_thickness(self, instance, value):
22
-        self.thickness = value
22
+        self.tools[self.current_tool]['thickness'] = value
23 23
 
24 24
     def on_color(self, instance, value):
25
-        self.color = value
25
+        self.tools[self.current_tool]['color'] = value
26
+
27
+    def on_current_tool(self, instance, value):
28
+        self.color = self.tools[value]['color']
29
+        self.thickness = self.tools[value]['thickness']
26 30
 
27 31
     def on_touch_down(self, touch):
28 32
         if not self.locked and self.collide_point(*touch.pos):

+ 2
- 1
hadaly/viewer.py View File

@@ -199,7 +199,7 @@ class SlideViewer(ScatterLayout):
199 199
                                      paint_color=self.painter.tools[self.painter.current_tool]['color'],
200 200
                                      thickness=self.painter.thickness)
201 201
             self.painter.bind(thickness=toolbar.on_thickness)
202
-            toolbar.bind(paint_color=self.painter.on_color)
202
+            self.painter.bind(color=toolbar.on_paint_color)
203 203
             self.slidebox.toolbar.add_widget(toolbar)
204 204
             self.app.root.get_screen('viewer').carousel.scroll_timeout = 50
205 205
         elif self.locked:
@@ -233,6 +233,7 @@ class PainterToolBar(BoxLayout):
233 233
 
234 234
     def on_paint_color(self, instance, value):
235 235
         self.paint_color = value
236
+        self.painter.color = value
236 237
 
237 238
     def on_thickness(self, instance, value):
238 239
         self.thickness = value

Loading…
Cancel
Save