From 06352f79e8569aead3320dd277eab4621a6d3929 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 13 Dec 2018 10:48:12 -0300 Subject: [PATCH] Add ui::IGNORE_MOUSE flag for static widgets This avoids some MouseEnter/Leave messages between widgets that don't need them. --- src/app/ui/button_set.cpp | 2 ++ src/app/ui/workspace.cpp | 2 ++ src/app/ui/workspace_panel.cpp | 2 ++ src/ui/base.h | 6 ++++-- src/ui/box.cpp | 2 ++ src/ui/grid.cpp | 3 +++ src/ui/label.cpp | 2 ++ src/ui/link_label.cpp | 3 +++ src/ui/manager.cpp | 7 ++++++- src/ui/menu.cpp | 1 + src/ui/separator.cpp | 2 ++ src/ui/view.cpp | 2 ++ src/ui/viewport.cpp | 4 +++- 13 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/app/ui/button_set.cpp b/src/app/ui/button_set.cpp index d38721d93..cb617b266 100644 --- a/src/app/ui/button_set.cpp +++ b/src/app/ui/button_set.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -300,6 +301,7 @@ ButtonSet::ButtonSet(int columns) , m_triggerOnMouseUp(false) , m_multipleSelection(false) { + enableFlags(IGNORE_MOUSE); InitTheme.connect( [this]{ noBorderNoChildSpacing(); diff --git a/src/app/ui/workspace.cpp b/src/app/ui/workspace.cpp index 3f4a03587..c75fc0daa 100644 --- a/src/app/ui/workspace.cpp +++ b/src/app/ui/workspace.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -41,6 +42,7 @@ Workspace::Workspace() , m_dropPreviewPanel(nullptr) , m_dropPreviewTabs(nullptr) { + enableFlags(IGNORE_MOUSE); addChild(&m_mainPanel); InitTheme.connect( diff --git a/src/app/ui/workspace_panel.cpp b/src/app/ui/workspace_panel.cpp index 4f5720bb4..e375d6b7d 100644 --- a/src/app/ui/workspace_panel.cpp +++ b/src/app/ui/workspace_panel.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -47,6 +48,7 @@ WorkspacePanel::WorkspacePanel(PanelType panelType) , m_topTime(0) , m_bottomTime(0) { + enableFlags(IGNORE_MOUSE); InitTheme.connect( [this]{ SkinTheme* theme = static_cast(this->theme()); diff --git a/src/ui/base.h b/src/ui/base.h index 6f9788e88..947252815 100644 --- a/src/ui/base.h +++ b/src/ui/base.h @@ -1,4 +1,5 @@ // Aseprite UI Library +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2016 David Capello // // This file is released under the terms of the MIT license. @@ -50,7 +51,8 @@ namespace ui { DOUBLE_BUFFERED = 0x00002000, // The widget is painted in a back-buffer and then flipped to the main display TRANSPARENT = 0x00004000, // The widget has transparent parts that needs the background painted before CTRL_RIGHT_CLICK = 0x00008000, // The widget should transform Ctrl+click to right-click on OS X. - PROPERTIES_MASK = 0x0000ffff, + IGNORE_MOUSE = 0x80000000, // Don't process mouse messages for this widget (useful for labels, boxes, grids, etc.) + PROPERTIES_MASK = 0x8000ffff, HORIZONTAL = 0x00010000, VERTICAL = 0x00020000, @@ -62,7 +64,7 @@ namespace ui { BOTTOM = 0x00800000, HOMOGENEOUS = 0x01000000, WORDWRAP = 0x02000000, - ALIGN_MASK = 0xffff0000, + ALIGN_MASK = 0x7fff0000, }; } // namespace ui diff --git a/src/ui/box.cpp b/src/ui/box.cpp index b48ed274f..6ba3d0002 100644 --- a/src/ui/box.cpp +++ b/src/ui/box.cpp @@ -1,4 +1,5 @@ // Aseprite UI Library +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -22,6 +23,7 @@ using namespace gfx; Box::Box(int align) : Widget(kBoxWidget) { + enableFlags(IGNORE_MOUSE); setAlign(align); initTheme(); } diff --git a/src/ui/grid.cpp b/src/ui/grid.cpp index 8e937e721..3c4dbf009 100644 --- a/src/ui/grid.cpp +++ b/src/ui/grid.cpp @@ -1,4 +1,5 @@ // Aseprite UI Library +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -42,6 +43,8 @@ Grid::Grid(int columns, bool same_width_columns) { ASSERT(columns > 0); + enableFlags(IGNORE_MOUSE); + m_same_width_columns = same_width_columns; for (std::size_t col=0; colpick(mousePos); - if (widget) + if (widget) { + // Get the first ancestor of the picked widget that doesn't + // ignore mouse events. + while (widget && widget->hasFlags(IGNORE_MOUSE)) + widget = widget->parent(); break; + } } // Fixup "mouse" flag diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index 3fcfe6e83..2327ad361 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -104,6 +104,7 @@ Menu::Menu() : Widget(kMenuWidget) , m_menuitem(NULL) { + enableFlags(IGNORE_MOUSE); initTheme(); } diff --git a/src/ui/separator.cpp b/src/ui/separator.cpp index 0fd239e99..8044ed886 100644 --- a/src/ui/separator.cpp +++ b/src/ui/separator.cpp @@ -1,4 +1,5 @@ // Aseprite UI Library +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -22,6 +23,7 @@ using namespace gfx; Separator::Separator(const std::string& text, int align) : Widget(kSeparatorWidget) { + enableFlags(IGNORE_MOUSE); setAlign(align); if (!text.empty()) setText(text); diff --git a/src/ui/view.cpp b/src/ui/view.cpp index d7fe46cd6..f375c1e83 100644 --- a/src/ui/view.cpp +++ b/src/ui/view.cpp @@ -1,4 +1,5 @@ // Aseprite UI Library +// Copyright (C) 2018 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -46,6 +47,7 @@ View::View() { m_hasBars = true; + enableFlags(IGNORE_MOUSE); setFocusStop(true); addChild(&m_viewport); setScrollableSize(Size(0, 0)); diff --git a/src/ui/viewport.cpp b/src/ui/viewport.cpp index 70592370c..fe98cf8b6 100644 --- a/src/ui/viewport.cpp +++ b/src/ui/viewport.cpp @@ -1,5 +1,6 @@ // Aseprite UI Library -// Copyright (C) 2001-2013, 2015 David Capello +// Copyright (C) 2018 Igara Studio S.A. +// Copyright (C) 2001-2015 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -24,6 +25,7 @@ using namespace gfx; Viewport::Viewport() : Widget(kViewViewportWidget) { + enableFlags(IGNORE_MOUSE); initTheme(); }