Add ui::IGNORE_MOUSE flag for static widgets

This avoids some MouseEnter/Leave messages between widgets that don't
need them.
master
David Capello 2018-12-13 10:48:12 -03:00
parent 105d389fdc
commit 06352f79e8
13 changed files with 34 additions and 4 deletions

View File

@ -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();

View File

@ -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(

View File

@ -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<SkinTheme*>(this->theme());

View File

@ -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

View File

@ -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();
}

View File

@ -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; col<m_colstrip.size(); ++col) {

View File

@ -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.
@ -19,6 +20,7 @@ namespace ui {
Label::Label(const std::string& text)
: Widget(kLabelWidget)
{
enableFlags(IGNORE_MOUSE);
setAlign(LEFT | MIDDLE);
setText(text);
initTheme();

View File

@ -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 @@ LinkLabel::LinkLabel(const std::string& urlOrText)
: Label(urlOrText)
, m_url(urlOrText)
{
disableFlags(IGNORE_MOUSE);
setType(kLinkLabelWidget);
initTheme();
}
@ -30,6 +32,7 @@ LinkLabel::LinkLabel(const std::string& url, const std::string& text)
: Label(text)
, m_url(url)
{
disableFlags(IGNORE_MOUSE);
setType(kLinkLabelWidget);
initTheme();
}

View File

@ -504,8 +504,13 @@ void Manager::handleMouseMove(const gfx::Point& mousePos,
Widget* widget = nullptr;
for (auto mouseWidget : mouse_widgets_list) {
widget = mouseWidget->pick(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

View File

@ -104,6 +104,7 @@ Menu::Menu()
: Widget(kMenuWidget)
, m_menuitem(NULL)
{
enableFlags(IGNORE_MOUSE);
initTheme();
}

View File

@ -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);

View File

@ -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));

View File

@ -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();
}