diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 57e64387f..a75af6a8b 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -29,7 +29,6 @@ add_library(gui-lib jmenu.cpp jmessage.cpp jpanel.cpp - jpopup_window.cpp jquickmenu.cpp jrect.cpp jregion.cpp @@ -40,6 +39,7 @@ add_library(gui-lib jtooltips.cpp jview.cpp label.cpp + popup_frame.cpp preferred_size_event.cpp property.cpp slider.cpp diff --git a/src/gui/jinete.h b/src/gui/jinete.h index 3db745402..51f81cff0 100644 --- a/src/gui/jinete.h +++ b/src/gui/jinete.h @@ -29,7 +29,6 @@ #include "gui/jmenu.h" #include "gui/jmessage.h" #include "gui/jpanel.h" -#include "gui/jpopup_window.h" #include "gui/jquickmenu.h" #include "gui/jrect.h" #include "gui/jregion.h" @@ -40,6 +39,7 @@ #include "gui/jtooltips.h" #include "gui/jview.h" #include "gui/label.h" +#include "gui/popup_frame.h" #include "gui/slider.h" #include "gui/theme.h" #include "gui/widget.h" diff --git a/src/gui/jpopup_window.cpp b/src/gui/popup_frame.cpp similarity index 94% rename from src/gui/jpopup_window.cpp rename to src/gui/popup_frame.cpp index af62806e7..b36e14142 100644 --- a/src/gui/jpopup_window.cpp +++ b/src/gui/popup_frame.cpp @@ -15,7 +15,7 @@ using namespace gfx; -PopupWindow::PopupWindow(const char* text, bool close_on_buttonpressed) +PopupFrame::PopupFrame(const char* text, bool close_on_buttonpressed) : Frame(false, text) { m_close_on_buttonpressed = close_on_buttonpressed; @@ -36,7 +36,7 @@ PopupWindow::PopupWindow(const char* text, bool close_on_buttonpressed) jwidget_noborders(this); } -PopupWindow::~PopupWindow() +PopupFrame::~PopupFrame() { if (m_filtering) { m_filtering = false; @@ -53,7 +53,7 @@ PopupWindow::~PopupWindow() * @param region The new hot-region. This pointer is holded by the @a widget. * So you cannot destroy it after calling this routine. */ -void PopupWindow::setHotRegion(JRegion region) +void PopupFrame::setHotRegion(JRegion region) { ASSERT(region != NULL); @@ -69,7 +69,7 @@ void PopupWindow::setHotRegion(JRegion region) m_hot_region = region; } -bool PopupWindow::onProcessMessage(JMessage msg) +bool PopupFrame::onProcessMessage(JMessage msg) { switch (msg->type) { @@ -164,7 +164,7 @@ bool PopupWindow::onProcessMessage(JMessage msg) return Frame::onProcessMessage(msg); } -void PopupWindow::onPreferredSize(PreferredSizeEvent& ev) +void PopupFrame::onPreferredSize(PreferredSizeEvent& ev) { Size resultSize(0, 0); diff --git a/src/gui/jpopup_window.h b/src/gui/popup_frame.h similarity index 69% rename from src/gui/jpopup_window.h rename to src/gui/popup_frame.h index 416597890..4badf3af0 100644 --- a/src/gui/jpopup_window.h +++ b/src/gui/popup_frame.h @@ -4,26 +4,27 @@ // This source file is ditributed under a BSD-like license, please // read LICENSE.txt for more information. -#ifndef GUI_JPOPUP_WINDOW_H_INCLUDED -#define GUI_JPOPUP_WINDOW_H_INCLUDED +#ifndef GUI_POPUP_FRAME_H_INCLUDED +#define GUI_POPUP_FRAME_H_INCLUDED #include "gui/frame.h" -class PopupWindow : public Frame +class PopupFrame : public Frame { - bool m_close_on_buttonpressed; - JRegion m_hot_region; - bool m_filtering; - public: - PopupWindow(const char* text, bool close_on_buttonpressed); - ~PopupWindow(); + PopupFrame(const char* text, bool close_on_buttonpressed); + ~PopupFrame(); void setHotRegion(JRegion region); protected: bool onProcessMessage(JMessage msg); void onPreferredSize(PreferredSizeEvent& ev); + +private: + bool m_close_on_buttonpressed; + JRegion m_hot_region; + bool m_filtering; }; #endif diff --git a/src/widgets/color_button.cpp b/src/widgets/color_button.cpp index 23c274dae..dd408bcf9 100644 --- a/src/widgets/color_button.cpp +++ b/src/widgets/color_button.cpp @@ -242,7 +242,7 @@ void ColorButton::openSelectorDialog() JRegion rgn = jregion_new(rc, 1); jrect_free(rc); - static_cast(window)->setHotRegion(rgn); + static_cast(window)->setHotRegion(rgn); } } diff --git a/src/widgets/color_selector.cpp b/src/widgets/color_selector.cpp index 47488baba..0a9e45dd8 100644 --- a/src/widgets/color_selector.cpp +++ b/src/widgets/color_selector.cpp @@ -83,7 +83,7 @@ static Model models[] = { Frame* colorselector_new() { - Frame* window = new PopupWindow(NULL, false); + Frame* window = new PopupFrame(NULL, false); Widget* grid1 = jgrid_new(2, false); Widget* grid2 = jgrid_new(5, false); Widget* models_box = jbox_new(JI_HORIZONTAL); diff --git a/src/widgets/toolbar.cpp b/src/widgets/toolbar.cpp index b261dbd9a..d0019a402 100644 --- a/src/widgets/toolbar.cpp +++ b/src/widgets/toolbar.cpp @@ -56,7 +56,7 @@ class ToolBar : public Widget bool m_open_on_hot; // Window displayed to show a tool-group - PopupWindow* m_popup_window; + PopupFrame* m_popupFrame; // Tool-tip window TipWindow* m_tipWindow; @@ -79,14 +79,14 @@ protected: private: int getToolGroupIndex(ToolGroup* group); - void openPopupWindow(int group_index, ToolGroup* group); + void openPopupFrame(int group_index, ToolGroup* group); Rect getToolGroupBounds(int group_index); void openTipWindow(int group_index, Tool* tool); void onClosePopup(); }; // Class to show a group of tools (horizontally) -// This widget is inside the ToolBar::m_popup_window +// This widget is inside the ToolBar::m_popupFrame class ToolStrip : public Widget { ToolGroup* m_group; @@ -148,7 +148,7 @@ ToolBar::ToolBar() m_hot_tool = NULL; m_hot_conf = false; m_open_on_hot = false; - m_popup_window = NULL; + m_popupFrame = NULL; m_tipWindow = NULL; m_tipTimerId = jmanager_add_timer(this, 300); m_tipOpened = false; @@ -164,7 +164,7 @@ ToolBar::ToolBar() ToolBar::~ToolBar() { jmanager_remove_timer(m_tipTimerId); - delete m_popup_window; + delete m_popupFrame; delete m_tipWindow; } @@ -270,7 +270,7 @@ bool ToolBar::onProcessMessage(JMessage msg) UIContext::instance()->getSettings()->setCurrentTool(tool); invalidate(); - openPopupWindow(c, tool_group); + openPopupFrame(c, tool_group); } } @@ -303,7 +303,7 @@ bool ToolBar::onProcessMessage(JMessage msg) hot_tool = tool; if ((m_open_on_hot) && (m_hot_tool != hot_tool)) - openPopupWindow(c, tool_group); + openPopupFrame(c, tool_group); tip_index = c; break; @@ -336,7 +336,7 @@ bool ToolBar::onProcessMessage(JMessage msg) case JM_MOUSELEAVE: closeTipWindow(); - if (!m_popup_window) + if (!m_popupFrame) m_tipOpened = false; m_hot_tool = NULL; @@ -375,13 +375,13 @@ int ToolBar::getToolGroupIndex(ToolGroup* group) return -1; } -void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group) +void ToolBar::openPopupFrame(int group_index, ToolGroup* tool_group) { // Close the current popup window - if (m_popup_window) { - m_popup_window->closeWindow(NULL); - delete m_popup_window; - m_popup_window = NULL; + if (m_popupFrame) { + m_popupFrame->closeWindow(NULL); + delete m_popupFrame; + m_popupFrame = NULL; } // Close tip window @@ -400,11 +400,11 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group) // In case this tool contains more than just one tool, show the popup window m_open_on_hot = true; - m_popup_window = new PopupWindow(NULL, false); - m_popup_window->Close.connect(Bind(&ToolBar::onClosePopup, this)); + m_popupFrame = new PopupFrame(NULL, false); + m_popupFrame->Close.connect(Bind(&ToolBar::onClosePopup, this)); ToolStrip* toolstrip = new ToolStrip(tool_group, this); - jwidget_add_child(m_popup_window, toolstrip); + jwidget_add_child(m_popupFrame, toolstrip); Rect rc = getToolGroupBounds(group_index); int w = 0; @@ -436,13 +436,13 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group) { jrect rc2 = { rc.x, rc.y, this->rc->x2, rc.y+rc.h }; JRegion hotregion = jregion_new(&rc2, 1); - m_popup_window->setHotRegion(hotregion); + m_popupFrame->setHotRegion(hotregion); } - m_popup_window->set_autoremap(false); - m_popup_window->setBounds(rc); + m_popupFrame->set_autoremap(false); + m_popupFrame->setBounds(rc); toolstrip->setBounds(rc); - m_popup_window->open_window(); + m_popupFrame->open_window(); toolstrip->setBounds(rc); }