adding feedback for each of the tools
This commit is contained in:
parent
35a12760d7
commit
b620f55420
|
@ -50,8 +50,6 @@ def select_next_color():
|
||||||
current_color = 0
|
current_color = 0
|
||||||
draw_current_color()
|
draw_current_color()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# --- Graphic feedback --
|
# --- Graphic feedback --
|
||||||
|
|
||||||
origin_x = 0
|
origin_x = 0
|
||||||
|
@ -59,9 +57,17 @@ origin_y = 0
|
||||||
current_x = 0
|
current_x = 0
|
||||||
current_y = 0
|
current_y = 0
|
||||||
|
|
||||||
|
def freehand_draw(x, y, down, up):
|
||||||
|
global current_x, current_y
|
||||||
|
hdc.text_color = color_list[current_color]
|
||||||
|
hdc.move_to(current_x, current_y)
|
||||||
|
hdc.line_to(x, y)
|
||||||
|
current_x = x
|
||||||
|
current_y = y
|
||||||
|
|
||||||
def rubberband_rectangle(x, y, down, up):
|
def rubberband_rectangle(x, y, down, up):
|
||||||
global current_x, current_y
|
global current_x, current_y
|
||||||
hdc.text_color = YELLOW
|
hdc.text_color = LTGRAY
|
||||||
hdc.rop2 = upiwin.R2_XORPEN
|
hdc.rop2 = upiwin.R2_XORPEN
|
||||||
if not down:
|
if not down:
|
||||||
hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y))
|
hdc.rectangle(min(origin_x, current_x), min(origin_y, current_y), max(origin_x, current_x), max(origin_y, current_y))
|
||||||
|
@ -72,7 +78,7 @@ def rubberband_rectangle(x, y, down, up):
|
||||||
|
|
||||||
def rubberband_line(x, y, down, up):
|
def rubberband_line(x, y, down, up):
|
||||||
global current_x, current_y
|
global current_x, current_y
|
||||||
hdc.text_color = YELLOW
|
hdc.text_color = LTGRAY
|
||||||
hdc.rop2 = upiwin.R2_XORPEN
|
hdc.rop2 = upiwin.R2_XORPEN
|
||||||
if not down:
|
if not down:
|
||||||
hdc.move_to(origin_x, origin_y)
|
hdc.move_to(origin_x, origin_y)
|
||||||
|
@ -83,14 +89,13 @@ def rubberband_line(x, y, down, up):
|
||||||
hdc.move_to(origin_x, origin_y)
|
hdc.move_to(origin_x, origin_y)
|
||||||
hdc.line_to(current_x, current_y)
|
hdc.line_to(current_x, current_y)
|
||||||
|
|
||||||
|
|
||||||
# --- Tool definitions ---
|
# --- Tool definitions ---
|
||||||
|
|
||||||
tool_list = [
|
tool_list = [
|
||||||
{ 'icon': bmp_freehand },
|
{ 'icon': bmp_freehand, 'feedback': freehand_draw },
|
||||||
{ 'icon': bmp_line },
|
{ 'icon': bmp_line, 'feedback': rubberband_line },
|
||||||
{ 'icon': bmp_rect },
|
{ 'icon': bmp_rect, 'feedback': rubberband_rect },
|
||||||
{ 'icon': bmp_fillrect }
|
{ 'icon': bmp_fillrect, 'feedback': rubberband_rect }
|
||||||
]
|
]
|
||||||
|
|
||||||
current_tool = 0
|
current_tool = 0
|
||||||
|
@ -113,15 +118,15 @@ def on_touchdown(x, y):
|
||||||
if point_in_rect(drawing_rect, x, y):
|
if point_in_rect(drawing_rect, x, y):
|
||||||
origin_x = x
|
origin_x = x
|
||||||
origin_y = y
|
origin_y = y
|
||||||
rubberband_line(x, y, True, False)
|
tool_list[current_tool]['feedback'](x, y, True, False)
|
||||||
|
|
||||||
def on_touchmove(x, y):
|
def on_touchmove(x, y):
|
||||||
if point_in_rect(drawing_rect, x, y):
|
if point_in_rect(drawing_rect, x, y):
|
||||||
rubberband_line(x, y, False, False)
|
tool_list[current_tool]['feedback'](x, y, False, False)
|
||||||
|
|
||||||
def on_touchup(x, y):
|
def on_touchup(x, y):
|
||||||
if point_in_rect(drawing_rect, x, y):
|
if point_in_rect(drawing_rect, x, y):
|
||||||
rubberband_line(x, y, False, True)
|
tool_list[current_tool]['feedback'](x, y, False, True)
|
||||||
|
|
||||||
def on_touchclick(x, y):
|
def on_touchclick(x, y):
|
||||||
if point_in_rect(cmd1_rect, x, y):
|
if point_in_rect(cmd1_rect, x, y):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user