Browse Source

[Viewer] Color & thickness saving

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

Fixes #6
master
Bogdan Cordier 2 years 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):
locked = BooleanProperty(False)

def on_thickness(self, instance, value):
self.thickness = value
self.tools[self.current_tool]['thickness'] = value

def on_color(self, instance, value):
self.color = value
self.tools[self.current_tool]['color'] = value

def on_current_tool(self, instance, value):
self.color = self.tools[value]['color']
self.thickness = self.tools[value]['thickness']

def on_touch_down(self, touch):
if not self.locked and self.collide_point(*touch.pos):

+ 2
- 1
hadaly/viewer.py View File

@@ -199,7 +199,7 @@ class SlideViewer(ScatterLayout):
paint_color=self.painter.tools[self.painter.current_tool]['color'],
thickness=self.painter.thickness)
self.painter.bind(thickness=toolbar.on_thickness)
toolbar.bind(paint_color=self.painter.on_color)
self.painter.bind(color=toolbar.on_paint_color)
self.slidebox.toolbar.add_widget(toolbar)
self.app.root.get_screen('viewer').carousel.scroll_timeout = 50
elif self.locked:
@@ -233,6 +233,7 @@ class PainterToolBar(BoxLayout):

def on_paint_color(self, instance, value):
self.paint_color = value
self.painter.color = value

def on_thickness(self, instance, value):
self.thickness = value

Loading…
Cancel
Save