From 67451c03b5bd7e1314ad5c5bc6ec90ed74ef9c80 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Thu, 3 May 2018 07:55:41 -0500 Subject: [PATCH] Moved statusbar up to public (allow children to manipulate the statusbar) --- src/GUI/MainFrame.hpp | 4 ++-- src/GUI/Plater.cpp | 11 ++++++++--- src/GUI/Plater.hpp | 4 ++++ src/GUI/ProgressStatusBar.cpp | 5 ----- src/GUI/ProgressStatusBar.hpp | 22 +--------------------- 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/GUI/MainFrame.hpp b/src/GUI/MainFrame.hpp index b073d0c48..1838114bb 100644 --- a/src/GUI/MainFrame.hpp +++ b/src/GUI/MainFrame.hpp @@ -21,7 +21,7 @@ namespace Slic3r { namespace GUI { - +class Plater; constexpr unsigned int TOOLTIP_TIMER = 32767; @@ -30,6 +30,7 @@ class MainFrame: public wxFrame public: MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size); MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr _gui_config); + ProgressStatusBar* statusbar {new ProgressStatusBar(this, -1)}; private: wxDECLARE_EVENT_TABLE(); @@ -48,7 +49,6 @@ private: std::shared_ptr gui_config; std::map preset_editor_tabs; - ProgressStatusBar* statusbar {new ProgressStatusBar(this, -1)}; }; diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index 51f684df9..623299215 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -1,10 +1,12 @@ #include #include +#include #include "Plater.hpp" #include "ProgressStatusBar.hpp" #include "Log.hpp" +#include "MainFrame.hpp" namespace Slic3r { namespace GUI { @@ -182,13 +184,13 @@ std::vector Plater::load_file(const wxString& file, const int obj_idx_to_lo this->objects[j].input_file = file; this->objects[j].input_file_obj_idx = i++; } - ProgressStatusBar::SendStatusText(this, this->GetId(), _("Loaded ") + input_file.GetName()); + GetFrame()->statusbar->SetStatusText(_("Loaded ") + input_file.GetName()); if (this->scaled_down) { - ProgressStatusBar::SendStatusText(this, this->GetId(), _("Your object appears to be too large, so it was automatically scaled down to fit your print bed.")); + GetFrame()->statusbar->SetStatusText(_("Your object appears to be too large, so it was automatically scaled down to fit your print bed.")); } if (this->outside_bounds) { - ProgressStatusBar::SendStatusText(this, this->GetId(), _("Some of your object(s) appear to be outside the print bed. Use the arrange button to correct this.")); + GetFrame()->statusbar->SetStatusText(_("Some of your object(s) appear to be outside the print bed. Use the arrange button to correct this.")); } } @@ -207,5 +209,8 @@ std::vector Plater::load_model_objects(ModelObjectPtrs model_objects) { return std::vector(); } +MainFrame* Plater::GetFrame() { return dynamic_cast(wxGetTopLevelParent(this)); } + + }} // Namespace Slic3r::GUI diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index 9bc5165db..5068e788e 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -18,6 +18,8 @@ #include "Plater/Plate2D.hpp" #include "Settings.hpp" +#include "MainFrame.hpp" + namespace Slic3r { namespace GUI { using UndoOperation = int; @@ -25,6 +27,7 @@ using obj_index = unsigned int; class PlaterObject; class Plate2D; +class MainFrame; class Plater : public wxPanel { @@ -65,6 +68,7 @@ private: bool scaled_down {false}; bool outside_bounds {false}; + MainFrame* GetFrame(); }; diff --git a/src/GUI/ProgressStatusBar.cpp b/src/GUI/ProgressStatusBar.cpp index 8684c2e35..24822748b 100644 --- a/src/GUI/ProgressStatusBar.cpp +++ b/src/GUI/ProgressStatusBar.cpp @@ -2,9 +2,4 @@ namespace Slic3r { namespace GUI { -void ProgressStatusBar::SendStatusText(wxEvtHandler* dest, wxWindowID origin, const wxString& msg) { - wxQueueEvent(dest, new StatusTextEvent(EVT_STATUS_TEXT_POST, origin, msg)); - -} - }} // Namespace Slic3r::GUI diff --git a/src/GUI/ProgressStatusBar.hpp b/src/GUI/ProgressStatusBar.hpp index 1b690f589..f2984691b 100644 --- a/src/GUI/ProgressStatusBar.hpp +++ b/src/GUI/ProgressStatusBar.hpp @@ -5,29 +5,9 @@ namespace Slic3r { namespace GUI { -class StatusTextEvent : public wxEvent { -public: - StatusTextEvent(wxEventType eventType, int winid, const wxString& msg) - : wxEvent(winid, eventType), - message(msg) { } - - bool ShouldPropagate() const { return true; } // propagate this event - - /// One accessor - const wxString& GetMessage() const {return message;} - /// implement the base class pure virtual - virtual wxEvent *Clone() const { return new StatusTextEvent(*this); } - -private: - const wxString message; -}; - -wxDEFINE_EVENT(EVT_STATUS_TEXT_POST, StatusTextEvent); - class ProgressStatusBar : public wxStatusBar { public: - //< Post an event to owning box and let it percolate up to a window that sets the appropriate status text. - static void SendStatusText(wxEvtHandler* dest, wxWindowID origin, const wxString& msg); + /// Constructor stub from parent ProgressStatusBar(wxWindow* parent, int id) : wxStatusBar(parent, id) { } };