From 90ef703403d1da3e94f1970eaefb5fc13f4ca341 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Fri, 13 Oct 2023 23:58:04 -0700 Subject: [PATCH] Ensure hand pointer appears when hovering over tool controls ...e.g. size controls in Magic, flip/mirror, size, and rotate controls in Stamps, text style controls in Text and Label, etc. --- docs/CHANGES.txt | 5 ++++ src/tuxpaint.c | 75 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index b7a031645..19848ede9 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -19,6 +19,11 @@ https://tuxpaint.org/ when stamp controls were disabled. Bill Kendrick + * Ensuring mouse pointer shape changes to hand when hovering over + control buttons below the scroll-down arrow in the selector area + (e.g., stamp controls, text styles, etc.) + Bill Kendrick + * Localization Updates: --------------------- * Bulgarian diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 715d05992..5aaa7d43c 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -596,6 +596,7 @@ static void reposition_onscreen_keyboard(int y); int calc_magic_control_rows(void); +int calc_stamp_control_rows(void); void maybe_redraw_eraser_xor(void); static void reset_stamps(int *stamp_xored_rt, int *stamp_place_x, int *stamp_place_y, int *stamp_tool_mode); @@ -6381,15 +6382,6 @@ static void mainloop(void) { } - /* This if/if/if block is awful -bjk 2022.01.19 */ - if (cur_tool == TOOL_STAMP && !disable_stamp_controls) - { - if (!no_stamp_rotation) - control_rows = 4; - else - control_rows = 3; - } - if (cur_tool == TOOL_LABEL) { control_rows = 1; @@ -6401,6 +6393,8 @@ static void mainloop(void) control_rows = 2; if (cur_tool == TOOL_MAGIC) control_rows = calc_magic_control_rows(); + if (cur_tool == TOOL_STAMP) + control_rows = calc_stamp_control_rows(); if (cur_tool == TOOL_SHAPES && !disable_shape_controls) control_rows = 1; if ((cur_tool == TOOL_BRUSH || cur_tool == TOOL_LINES) && !disable_brushspacing) @@ -6436,34 +6430,52 @@ static void mainloop(void) } else { - /* One of the selectors: */ - - /* FIXME: Also show "cursor_hand" when touching controls (stamp size, brush spacing, etc.!) (See below) -bjk 2022.01.19 */ + /* One of the selectors or controls: */ which = ((event.button.y - r_ttoolopt.h - img_scroll_up->h) / button_h) * 2 + (event.button.x - (WINDOW_WIDTH - r_ttoolopt.w)) / button_w; - if (which < num_things) + if (which + *thing_scroll < num_things) + { + /* A selectable item */ do_setcursor(cursor_hand); + } + else if (which >= (buttons_tall - control_rows) * 2 - 2 /* account for scroll button */) + { + /* Controls at the bottom (below scroll-down button, if any) */ + do_setcursor(cursor_hand); + } else + { + /* Within the visible items, but nothing selectable */ do_setcursor(cursor_arrow); + } } } else { - /* No scroll buttons - must be a selector: */ - - /* FIXME: Also show "cursor_hand" when touching controls (stamp size, brush spacing, etc.!) (See above) -bjk 2022.01.19 */ + /* No scroll buttons - must be a selector or control: */ which = ((event.button.y - r_ttoolopt.h) / button_h) * 2 + (event.button.x - (WINDOW_WIDTH - r_ttoolopt.w)) / button_w; - if (which < num_things) + if (which + *thing_scroll < num_things) + { + /* A selectable item */ do_setcursor(cursor_hand); + } + else if (which >= (buttons_tall - control_rows) * 2) + { + /* Controls at the bottom (below scroll-down button, if any) */ + do_setcursor(cursor_hand); + } else + { + /* Within the visible items, but nothing selectable */ do_setcursor(cursor_arrow); + } } } else if (HIT(r_canvas) && keyglobal == 0) @@ -32213,6 +32225,35 @@ int calc_magic_control_rows(void) return r; } + +/** + * How many rows of controls (not actual Stamp items) + * are to be displayed at the bottom of the selector? + * (Based on whether stamp controls and/or stamp rotation are + * disabled) + * + * @return int + */ +int calc_stamp_control_rows(void) +{ + int r; + + /* Start with group changing (left/right) buttons */ + r = 1; + + /* Add Stamp controls (one row flip/mirror, another size) */ + if (!disable_stamp_controls) + { + r += 2; + + /* Add Stamp rotation controls */ + if (!no_stamp_rotation) + r++; + } + + return r; +} + /** * Redraw the Eraser XOR shape around the cursor if it's within * the canvas and the current tool is the Eraser.