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)
|
||||
, m_tipTimer(300, this)
|
||||
, m_closeSlot(NULL)
|
||||
, m_openedRecently(false)
|
||||
{
|
||||
m_instance = this;
|
||||
|
||||
@ -199,9 +200,9 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
new_hot_tool = tool;
|
||||
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);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -264,6 +265,12 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
if (!hasCapture())
|
||||
break;
|
||||
|
||||
if (!m_openedRecently) {
|
||||
if (m_popupWindow && m_popupWindow->isVisible())
|
||||
m_popupWindow->closeWindow(this);
|
||||
}
|
||||
m_openedRecently = false;
|
||||
|
||||
releaseMouse();
|
||||
// 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
|
||||
m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickOutsideHotRegion);
|
||||
m_closeSlot = m_popupWindow->Close.connect(Bind<void, ToolBar, ToolBar>(&ToolBar::onClosePopup, this));
|
||||
m_openedRecently = true;
|
||||
|
||||
ToolStrip* toolstrip = new ToolStrip(tool_group, this);
|
||||
m_currentStrip = toolstrip;
|
||||
@ -586,10 +594,6 @@ void ToolBar::closeTipWindow()
|
||||
m_tipWindow->closeWindow(NULL);
|
||||
delete m_tipWindow;
|
||||
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
|
||||
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
|
||||
ui::PopupWindow* m_popupWindow;
|
||||
class ToolStrip;
|
||||
|
Loading…
x
Reference in New Issue
Block a user