mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 13:20:28 +00:00
Close toolbar popup when the document is closed
This commit is contained in:
parent
0c8b5c6a4f
commit
315584d819
@ -352,6 +352,17 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||
}
|
||||
}
|
||||
|
||||
void ToolBar::onVisible(bool visible)
|
||||
{
|
||||
Widget::onVisible(visible);
|
||||
if (!visible) {
|
||||
if (m_popupWindow) {
|
||||
closePopupWindow();
|
||||
closeTipWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ToolBar::getToolGroupIndex(ToolGroup* group)
|
||||
{
|
||||
ToolBox* toolbox = App::instance()->toolBox();
|
||||
@ -377,11 +388,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
|
||||
m_closeConn.disconnect();
|
||||
|
||||
onClosePopup();
|
||||
|
||||
// Close the current popup window
|
||||
m_popupWindow->closeWindow(NULL);
|
||||
delete m_popupWindow;
|
||||
m_popupWindow = NULL;
|
||||
closePopupWindow();
|
||||
}
|
||||
|
||||
// Close tip window
|
||||
@ -435,6 +442,15 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
|
||||
toolstrip->setBounds(rc);
|
||||
}
|
||||
|
||||
void ToolBar::closePopupWindow()
|
||||
{
|
||||
if (m_popupWindow) {
|
||||
m_popupWindow->closeWindow(nullptr);
|
||||
delete m_popupWindow;
|
||||
m_popupWindow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Rect ToolBar::getToolGroupBounds(int group_index)
|
||||
{
|
||||
ToolBox* toolbox = App::instance()->toolBox();
|
||||
|
@ -51,10 +51,12 @@ namespace app {
|
||||
bool onProcessMessage(ui::Message* msg) override;
|
||||
void onSizeHint(ui::SizeHintEvent& ev) override;
|
||||
void onPaint(ui::PaintEvent& ev) override;
|
||||
void onVisible(bool visible) override;
|
||||
|
||||
private:
|
||||
int getToolGroupIndex(tools::ToolGroup* group);
|
||||
void openPopupWindow(int group_index, tools::ToolGroup* group);
|
||||
void closePopupWindow();
|
||||
gfx::Rect getToolGroupBounds(int group_index);
|
||||
gfx::Point getToolPositionInGroup(int group_index, tools::Tool* tool);
|
||||
void openTipWindow(int group_index, tools::Tool* tool);
|
||||
|
@ -192,12 +192,16 @@ void Widget::setVisible(bool state)
|
||||
if (hasFlags(HIDDEN)) {
|
||||
disableFlags(HIDDEN);
|
||||
invalidate();
|
||||
|
||||
onVisible(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!hasFlags(HIDDEN)) {
|
||||
manager()->freeWidget(this); // Free from manager
|
||||
enableFlags(HIDDEN);
|
||||
|
||||
onVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1443,6 +1447,11 @@ void Widget::onSetDecorativeWidgetBounds()
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::onVisible(bool visible)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void Widget::onEnable(bool enabled)
|
||||
{
|
||||
// Do nothing
|
||||
|
@ -372,6 +372,7 @@ namespace ui {
|
||||
virtual void onBroadcastMouseMessage(WidgetsList& targets);
|
||||
virtual void onInitTheme(InitThemeEvent& ev);
|
||||
virtual void onSetDecorativeWidgetBounds();
|
||||
virtual void onVisible(bool visible);
|
||||
virtual void onEnable(bool enabled);
|
||||
virtual void onSelect(bool selected);
|
||||
virtual void onSetText();
|
||||
|
Loading…
x
Reference in New Issue
Block a user