From 989fcc2c4f0d4055837959655d4ac2c204d70aa7 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 31 Jul 2024 20:57:19 +0200 Subject: [PATCH] UI: Mouse Event Icon Alignment We have a number of event icons, used on the Status Bar, to indicate mouse actions. It is currently difficult to align these nicely because they vary in width and design. This PR makes them all the same design width and aligned to the left edge. This removes a need to add negative spacing before any of them and only requires space after some of them. This also adds a new one to indicate "double left click" as my current use of this looks a bit sus. This also adds a "mouse wheel scroll" Pull Request: https://projects.blender.org/blender/blender/pulls/125731 --- release/datafiles/icons_svg/mouse_lmb.svg | 2 +- release/datafiles/icons_svg/mouse_lmb_2x.svg | 1 + release/datafiles/icons_svg/mouse_lmb_drag.svg | 2 +- release/datafiles/icons_svg/mouse_mmb.svg | 2 +- release/datafiles/icons_svg/mouse_mmb_drag.svg | 2 +- release/datafiles/icons_svg/mouse_mmb_scroll.svg | 1 + release/datafiles/icons_svg/mouse_move.svg | 2 +- release/datafiles/icons_svg/mouse_rmb.svg | 2 +- release/datafiles/icons_svg/mouse_rmb_drag.svg | 2 +- source/blender/editors/datafiles/CMakeLists.txt | 2 ++ source/blender/editors/include/UI_icons.hh | 2 ++ .../blender/editors/interface/interface_icons.cc | 3 +++ .../interface/templates/interface_templates.cc | 10 +++------- source/blender/editors/screen/area.cc | 14 +++----------- 14 files changed, 22 insertions(+), 25 deletions(-) create mode 100644 release/datafiles/icons_svg/mouse_lmb_2x.svg create mode 100644 release/datafiles/icons_svg/mouse_mmb_scroll.svg diff --git a/release/datafiles/icons_svg/mouse_lmb.svg b/release/datafiles/icons_svg/mouse_lmb.svg index f138663571f..429880e83ac 100644 --- a/release/datafiles/icons_svg/mouse_lmb.svg +++ b/release/datafiles/icons_svg/mouse_lmb.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_lmb_2x.svg b/release/datafiles/icons_svg/mouse_lmb_2x.svg new file mode 100644 index 00000000000..bb28507f0dc --- /dev/null +++ b/release/datafiles/icons_svg/mouse_lmb_2x.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_lmb_drag.svg b/release/datafiles/icons_svg/mouse_lmb_drag.svg index 245afd80f53..466d4933239 100644 --- a/release/datafiles/icons_svg/mouse_lmb_drag.svg +++ b/release/datafiles/icons_svg/mouse_lmb_drag.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_mmb.svg b/release/datafiles/icons_svg/mouse_mmb.svg index d5dec68eb9a..388637f565e 100644 --- a/release/datafiles/icons_svg/mouse_mmb.svg +++ b/release/datafiles/icons_svg/mouse_mmb.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_mmb_drag.svg b/release/datafiles/icons_svg/mouse_mmb_drag.svg index 0b1d20f652b..4312852bd9a 100644 --- a/release/datafiles/icons_svg/mouse_mmb_drag.svg +++ b/release/datafiles/icons_svg/mouse_mmb_drag.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_mmb_scroll.svg b/release/datafiles/icons_svg/mouse_mmb_scroll.svg new file mode 100644 index 00000000000..1e6da51c97f --- /dev/null +++ b/release/datafiles/icons_svg/mouse_mmb_scroll.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_move.svg b/release/datafiles/icons_svg/mouse_move.svg index 958b5e1f1c3..af40467fce7 100644 --- a/release/datafiles/icons_svg/mouse_move.svg +++ b/release/datafiles/icons_svg/mouse_move.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_rmb.svg b/release/datafiles/icons_svg/mouse_rmb.svg index 7dd8201bc33..e6bc096e8ce 100644 --- a/release/datafiles/icons_svg/mouse_rmb.svg +++ b/release/datafiles/icons_svg/mouse_rmb.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/release/datafiles/icons_svg/mouse_rmb_drag.svg b/release/datafiles/icons_svg/mouse_rmb_drag.svg index 802257d334f..6bbbf9045c1 100644 --- a/release/datafiles/icons_svg/mouse_rmb_drag.svg +++ b/release/datafiles/icons_svg/mouse_rmb_drag.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index ee14c8b50fd..52f976af2c3 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -548,9 +548,11 @@ if(WITH_BLENDER) mod_wireframe monkey mouse_lmb + mouse_lmb_2x mouse_lmb_drag mouse_mmb mouse_mmb_drag + mouse_mmb_scroll mouse_move mouse_rmb mouse_rmb_drag diff --git a/source/blender/editors/include/UI_icons.hh b/source/blender/editors/include/UI_icons.hh index 8af6211e305..18f19946858 100644 --- a/source/blender/editors/include/UI_icons.hh +++ b/source/blender/editors/include/UI_icons.hh @@ -246,6 +246,8 @@ DEF_ICON(RNA_ADD) DEF_ICON(MOUSE_LMB) DEF_ICON(MOUSE_MMB) DEF_ICON(MOUSE_RMB) +DEF_ICON(MOUSE_MMB_SCROLL) +DEF_ICON(MOUSE_LMB_2X) DEF_ICON(MOUSE_MOVE) DEF_ICON(MOUSE_LMB_DRAG) DEF_ICON(MOUSE_MMB_DRAG) diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 53be48a440d..654b1c31bef 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -559,6 +559,9 @@ int UI_icon_from_event_type(short event_type, short event_value) } while ((di = di->data.input.next)); if (event_type == LEFTMOUSE) { + if (event_value == KM_DBL_CLICK) { + return ICON_MOUSE_LMB_2X; + } return (event_value == KM_CLICK_DRAG) ? ICON_MOUSE_LMB_DRAG : ICON_MOUSE_LMB; } if (event_type == MIDDLEMOUSE) { diff --git a/source/blender/editors/interface/templates/interface_templates.cc b/source/blender/editors/interface/templates/interface_templates.cc index 1312b020730..9dd7343389b 100644 --- a/source/blender/editors/interface/templates/interface_templates.cc +++ b/source/blender/editors/interface/templates/interface_templates.cc @@ -6800,14 +6800,10 @@ bool uiTemplateEventFromKeymapItem(uiLayout *layout, /* Icon and text separately is closer together with aligned layout. */ - if (icon >= ICON_MOUSE_LMB && icon <= ICON_MOUSE_RMB_DRAG) { - /* Negative space before all narrow mice icons. */ - uiItemS_ex(layout, -0.5f); - } uiItemL(layout, "", icon); - if (icon >= ICON_MOUSE_LMB && icon <= ICON_MOUSE_RMB) { - /* Negative space after non-drag mice icons. */ - uiItemS_ex(layout, -0.5f); + if (icon >= ICON_MOUSE_LMB && icon <= ICON_MOUSE_MMB_SCROLL) { + /* Negative space after narrow mice icons. */ + uiItemS_ex(layout, -0.9f); } uiItemS_ex(layout, 0.3f); diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index d40ccd8ebd5..f8ed80c06f7 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -876,7 +876,7 @@ WorkspaceStatus::WorkspaceStatus(bContext *C) static constexpr float STATUS_AFTER_TEXT = 0.7f; static constexpr float STATUS_BEFORE_TEXT = 0.3f; -static constexpr float STATUS_MOUSE_ICON_PAD = -0.5f; +static constexpr float STATUS_MOUSE_ICON_PAD = -0.9f; static void ed_workspace_status_text_item(WorkSpace *workspace, std::string text) { @@ -892,13 +892,9 @@ static void ed_workspace_status_mouse_item(WorkSpace *workspace, const bool inverted = false) { if (icon) { - if (icon >= ICON_MOUSE_LMB && icon <= ICON_MOUSE_RMB_DRAG) { - /* Negative space before all narrow mice icons. */ - ed_workspace_status_space(workspace, STATUS_MOUSE_ICON_PAD); - } ed_workspace_status_item(workspace, {}, icon, 0.0f, inverted); - if (icon >= ICON_MOUSE_LMB && icon <= ICON_MOUSE_RMB) { - /* Negative space after non-drag mice icons. */ + if (icon >= ICON_MOUSE_LMB && icon <= ICON_MOUSE_MMB_SCROLL) { + /* Negative space after narrow mice icons. */ ed_workspace_status_space(workspace, STATUS_MOUSE_ICON_PAD); } } @@ -962,10 +958,6 @@ void WorkspaceStatus::opmodal(std::string text, if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) { ed_workspace_status_item(workspace_, {}, ICON_EVENT_OS, 0.0f, inverted); } - if (kmi->val == KM_DBL_CLICK) { - ed_workspace_status_item(workspace_, "2" BLI_STR_UTF8_MULTIPLICATION_SIGN, ICON_NONE); - ed_workspace_status_space(workspace_, -0.7f); - } ed_workspace_status_mouse_item(workspace_, icon, inverted); ed_workspace_status_text_item(workspace_, std::move(text)); }