diff --git a/src/slic3r/GUI/PluginProgressDialog.cpp b/src/slic3r/GUI/PluginProgressDialog.cpp index 509f147165..778cbcde57 100644 --- a/src/slic3r/GUI/PluginProgressDialog.cpp +++ b/src/slic3r/GUI/PluginProgressDialog.cpp @@ -10,11 +10,15 @@ PluginProgressDialog::PluginProgressDialog(wxWindow* parent, int maximum, int style, CloseHandler on_destroyed) - : wxProgressDialog(title, message, maximum, parent, style) + : ProgressDialog(title, message, maximum, parent, style) , m_pulse_message(message) , m_on_destroyed(std::move(on_destroyed)) { - Bind(wxEVT_CLOSE_WINDOW, &PluginProgressDialog::on_close_window, this); + // The base ProgressDialog already binds wxEVT_CLOSE_WINDOW (its OnClose vetoes + // a non-cancelable dialog and marks a cancelable one Canceled). We deliberately + // don't add a second handler: a user-initiated close surfaces to the plugin as + // update()/pulse() returning false, and programmatic close() calls Destroy() + // directly, so no extra wiring is needed here. } PluginProgressDialog::~PluginProgressDialog() @@ -120,11 +124,6 @@ void PluginProgressDialog::close() Destroy(); } -void PluginProgressDialog::on_close_window(wxCloseEvent& /*event*/) -{ - close(); -} - void PluginProgressDialog::on_timer(wxTimerEvent& /*event*/) { if (m_open) diff --git a/src/slic3r/GUI/PluginProgressDialog.hpp b/src/slic3r/GUI/PluginProgressDialog.hpp index e50cbb232d..81e3950441 100644 --- a/src/slic3r/GUI/PluginProgressDialog.hpp +++ b/src/slic3r/GUI/PluginProgressDialog.hpp @@ -5,17 +5,24 @@ #include #include -#include #include #include #include +#include "Widgets/ProgressDialog.hpp" + namespace Slic3r { namespace GUI { // A host-owned progress dialog for Python plugins. This class is deliberately // Python-agnostic; the plugin layer owns any pybind/GIL concerns and marshals // all calls to the UI thread. -class PluginProgressDialog : public wxProgressDialog +// +// It derives from OrcaSlicer's own Slic3r::GUI::ProgressDialog (a real wxDialog +// with themable wx children) rather than the native wxProgressDialog: on Windows +// wxProgressDialog is a comctl32 TaskDialog running on a worker thread with no +// recolorable wx surface, so it cannot follow OrcaSlicer's (OS-independent) dark +// theme. The base themes itself via UpdateDlgDarkUI(this) in its Create(). +class PluginProgressDialog : public ProgressDialog { public: using CloseHandler = std::function; @@ -52,7 +59,6 @@ public: bool is_open() const { return m_open; } private: - void on_close_window(wxCloseEvent& event); void on_timer(wxTimerEvent& event); bool m_open{true}; diff --git a/src/slic3r/GUI/Widgets/ProgressDialog.cpp b/src/slic3r/GUI/Widgets/ProgressDialog.cpp index 0ace737d8d..9bb5452d52 100644 --- a/src/slic3r/GUI/Widgets/ProgressDialog.cpp +++ b/src/slic3r/GUI/Widgets/ProgressDialog.cpp @@ -231,6 +231,17 @@ bool ProgressDialog::Create(const wxString &title, const wxString &message, int m_sizer_main->Add(m_gauge, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(28)); } + // Optional elapsed/estimated/remaining time labels, created only when the + // caller opts in via the wxPD_*_TIME style flags (so callers that don't set + // them are unaffected). Update()/Pulse() already refresh these once non-null. + if (HasPDFlag(wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME)) { + wxFlexGridSizer *sizer_times = new wxFlexGridSizer(2, FromDIP(2), FromDIP(8)); + if (HasPDFlag(wxPD_ELAPSED_TIME)) m_elapsed = CreateLabel(GetElapsedLabel(), sizer_times); + if (HasPDFlag(wxPD_ESTIMATED_TIME)) m_estimated = CreateLabel(GetEstimatedLabel(), sizer_times); + if (HasPDFlag(wxPD_REMAINING_TIME)) m_remaining = CreateLabel(GetRemainingLabel(), sizer_times); + m_sizer_main->Add(sizer_times, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP | wxLEFT | wxRIGHT, FromDIP(12)); + } + #ifdef __WXMSW__ //m_block_left = new wxWindow(m_gauge, wxID_ANY, wxPoint(0, 0), wxSize(FromDIP(2), PROGRESSDIALOG_GAUGE_SIZE.y * 2)); //m_block_left->SetBackgroundColour(PROGRESSDIALOG_DEF_BK); @@ -490,6 +501,14 @@ wxStaticText *ProgressDialog::CreateLabel(const wxString &text, wxSizer *sizer) wxStaticText *label = new wxStaticText(this, wxID_ANY, text); wxStaticText *value = new wxStaticText(this, wxID_ANY, wxGetTranslation("unknown")); + // Match the message label's look so the times theme with the rest of the + // dialog: PROGRESSDIALOG_GREY_700 is a key in the dark-mode colour map, so + // UpdateDlgDarkUI() (called at the end of Create()) remaps it in dark mode. + for (wxStaticText *st : {label, value}) { + st->SetFont(::Label::Body_13); + st->SetForegroundColour(PROGRESSDIALOG_GREY_700); + } + // select placement most native or nice on target GUI #if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__) // value and time centered in one row