adding feedback for each of the tools

This commit is contained in:
Amy Bowersox 2019-12-11 14:52:32 -07:00
parent 35a12760d7
commit b620f55420
1 changed files with 17 additions and 12 deletions

View File

@ -50,8 +50,6 @@ def select_next_color():
current_color = 0
draw_current_color()
# --- Graphic feedback --
origin_x = 0
@ -59,9 +57,17 @@ origin_y = 0
current_x = 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):
global current_x, current_y
hdc.text_color = YELLOW
hdc.text_color = LTGRAY
hdc.rop2 = upiwin.R2_XORPEN
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))
@ -72,7 +78,7 @@ def rubberband_rectangle(x, y, down, up):
def rubberband_line(x, y, down, up):
global current_x, current_y
hdc.text_color = YELLOW
hdc.text_color = LTGRAY
hdc.rop2 = upiwin.R2_XORPEN
if not down:
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.line_to(current_x, current_y)
# --- Tool definitions ---
tool_list = [
{ 'icon': bmp_freehand },
{ 'icon': bmp_line },
{ 'icon': bmp_rect },
{ 'icon': bmp_fillrect }
{ 'icon': bmp_freehand, 'feedback': freehand_draw },
{ 'icon': bmp_line, 'feedback': rubberband_line },
{ 'icon': bmp_rect, 'feedback': rubberband_rect },
{ 'icon': bmp_fillrect, 'feedback': rubberband_rect }
]
current_tool = 0
@ -113,15 +118,15 @@ def on_touchdown(x, y):
if point_in_rect(drawing_rect, x, y):
origin_x = x
origin_y = y
rubberband_line(x, y, True, False)
tool_list[current_tool]['feedback'](x, y, True, False)
def on_touchmove(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):
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):
if point_in_rect(cmd1_rect, x, y):