Moved statusbar up to public (allow children to manipulate the statusbar)

This commit is contained in:
Joseph Lenox 2018-05-03 07:55:41 -05:00
parent 33d2232f09
commit 2bab9f27e1
5 changed files with 15 additions and 31 deletions

View File

@ -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<Settings> _gui_config);
ProgressStatusBar* statusbar {new ProgressStatusBar(this, -1)};
private:
wxDECLARE_EVENT_TABLE();
@ -48,7 +49,6 @@ private:
std::shared_ptr<Settings> gui_config;
std::map<wxWindowID, PresetEditor*> preset_editor_tabs;
ProgressStatusBar* statusbar {new ProgressStatusBar(this, -1)};
};

View File

@ -1,10 +1,12 @@
#include <memory>
#include <wx/progdlg.h>
#include <wx/window.h>
#include "Plater.hpp"
#include "ProgressStatusBar.hpp"
#include "Log.hpp"
#include "MainFrame.hpp"
namespace Slic3r { namespace GUI {
@ -182,13 +184,13 @@ std::vector<int> 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<int> Plater::load_model_objects(ModelObjectPtrs model_objects) {
return std::vector<int>();
}
MainFrame* Plater::GetFrame() { return dynamic_cast<MainFrame*>(wxGetTopLevelParent(this)); }
}} // Namespace Slic3r::GUI

View File

@ -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();
};

View File

@ -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

View File

@ -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) { }
};