Browse Source

[Viewer] Add free line drawing tool

Fixes #7
master
Bogdan Cordier 1 year ago
parent
commit
18a605d2f0
2 changed files with 10 additions and 3 deletions
  1. 3
    0
      hadaly/app.py
  2. 7
    3
      hadaly/painter.py

+ 3
- 0
hadaly/app.py View File

@@ -568,6 +568,9 @@ class Manager(ScreenManager):
568 568
         elif key == 258 and self.current == 'viewer':
569 569
             current_slide = self.get_screen('viewer').carousel.current_slide
570 570
             current_slide.viewer.painter.current_tool = 'line'
571
+        elif key == 259 and self.current == 'viewer':
572
+            current_slide = self.get_screen('viewer').carousel.current_slide
573
+            current_slide.viewer.painter.current_tool = 'freeline'
571 574
         elif key == 269 and self.current == 'viewer':
572 575
             current_slide = self.get_screen('viewer').carousel.current_slide
573 576
             painter = current_slide.viewer.painter

+ 7
- 3
hadaly/painter.py View File

@@ -8,8 +8,9 @@ from kivy.properties import StringProperty, DictProperty, BooleanProperty, Bound
8 8
 
9 9
 
10 10
 class Painter(Widget):
11
-    tools = DictProperty({'arrow': {'color': (1, 1, 1, 1), 'thickness': 0.4},
12
-                          'line': {'color': (1, 1, 1, 1), 'thickness': 0.4},
11
+    tools = DictProperty({'arrow': {'color': (1, 1, 1, 1), 'thickness': 0.5},
12
+                          'line': {'color': (1, 1, 1, 1), 'thickness': 0.5},
13
+                          'freeline': {'color': (1, 1, 1, 1), 'thickness': 0.5},
13 14
                           'eraser': {'thickness': 0.4}
14 15
                           })
15 16
     current_tool = StringProperty('arrow')
@@ -40,7 +41,10 @@ class Painter(Widget):
40 41
     def on_touch_move(self, touch):
41 42
         if not self.locked and self.collide_point(*touch.pos):
42 43
             try:
43
-                touch.ud['line'].points = [touch.ox, touch.oy, touch.x, touch.y]
44
+                if self.current_tool == 'freeline':
45
+                    touch.ud['line'].points += [touch.x, touch.y]
46
+                else:
47
+                    touch.ud['line'].points = [touch.ox, touch.oy, touch.x, touch.y]
44 48
             except KeyError:
45 49
                 pass
46 50
         else:

Loading…
Cancel
Save