mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Fix ToolBar behavior to avoid changing tools unintentionally
- Avoid opening other groups if the user is not with the mouse down - A second MouseUp closes the group
This commit is contained in:
parent
6414e37f9a
commit
ddf894867a
@ -94,6 +94,7 @@ ToolBar::ToolBar()
|
|||||||
: Widget(kGenericWidget)
|
: Widget(kGenericWidget)
|
||||||
, m_tipTimer(300, this)
|
, m_tipTimer(300, this)
|
||||||
, m_closeSlot(NULL)
|
, m_closeSlot(NULL)
|
||||||
|
, m_openedRecently(false)
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
|
|
||||||
@ -199,9 +200,9 @@ bool ToolBar::onProcessMessage(Message* msg)
|
|||||||
new_hot_tool = tool;
|
new_hot_tool = tool;
|
||||||
new_hot_index = c;
|
new_hot_index = c;
|
||||||
|
|
||||||
if ((m_openOnHot) && (m_hotTool != new_hot_tool))
|
if ((m_openOnHot) && (m_hotTool != new_hot_tool) && hasCapture()) {
|
||||||
openPopupWindow(c, tool_group);
|
openPopupWindow(c, tool_group);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,6 +265,12 @@ bool ToolBar::onProcessMessage(Message* msg)
|
|||||||
if (!hasCapture())
|
if (!hasCapture())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (!m_openedRecently) {
|
||||||
|
if (m_popupWindow && m_popupWindow->isVisible())
|
||||||
|
m_popupWindow->closeWindow(this);
|
||||||
|
}
|
||||||
|
m_openedRecently = false;
|
||||||
|
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
||||||
@ -440,6 +447,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
|
|||||||
// In case this tool contains more than just one tool, show the popup window
|
// In case this tool contains more than just one tool, show the popup window
|
||||||
m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickOutsideHotRegion);
|
m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickOutsideHotRegion);
|
||||||
m_closeSlot = m_popupWindow->Close.connect(Bind<void, ToolBar, ToolBar>(&ToolBar::onClosePopup, this));
|
m_closeSlot = m_popupWindow->Close.connect(Bind<void, ToolBar, ToolBar>(&ToolBar::onClosePopup, this));
|
||||||
|
m_openedRecently = true;
|
||||||
|
|
||||||
ToolStrip* toolstrip = new ToolStrip(tool_group, this);
|
ToolStrip* toolstrip = new ToolStrip(tool_group, this);
|
||||||
m_currentStrip = toolstrip;
|
m_currentStrip = toolstrip;
|
||||||
@ -586,10 +594,6 @@ void ToolBar::closeTipWindow()
|
|||||||
m_tipWindow->closeWindow(NULL);
|
m_tipWindow->closeWindow(NULL);
|
||||||
delete m_tipWindow;
|
delete m_tipWindow;
|
||||||
m_tipWindow = NULL;
|
m_tipWindow = NULL;
|
||||||
|
|
||||||
// Flush kPaintMessage messages and send them
|
|
||||||
getManager()->flushRedraw();
|
|
||||||
getManager()->dispatchMessages();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,10 @@ namespace app {
|
|||||||
// True if the popup-window must be opened when a tool-button is hot
|
// True if the popup-window must be opened when a tool-button is hot
|
||||||
bool m_openOnHot;
|
bool m_openOnHot;
|
||||||
|
|
||||||
|
// True if the last MouseDown opened the popup. This is used to
|
||||||
|
// close the popup with a second MouseUp event.
|
||||||
|
bool m_openedRecently;
|
||||||
|
|
||||||
// Window displayed to show a tool-group
|
// Window displayed to show a tool-group
|
||||||
ui::PopupWindow* m_popupWindow;
|
ui::PopupWindow* m_popupWindow;
|
||||||
class ToolStrip;
|
class ToolStrip;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user