mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-30 21:36:57 +00:00
Add startup progress bar to loading screen (#14155)
* Add startup progress bar to splash screen * Move progress bar down and remove percentages * Cleaned up changes * Update GUI_App.cpp --------- Co-authored-by: yw4z <ywsyildiz@gmail.com>
This commit is contained in:
@@ -304,6 +304,9 @@ public:
|
|||||||
|
|
||||||
m_bg_color = StateColor::darkModeColorFor(wxColour("#FFFFFF"));
|
m_bg_color = StateColor::darkModeColorFor(wxColour("#FFFFFF"));
|
||||||
m_fg_color = StateColor::darkModeColorFor(wxColour("#6B6A6A"));
|
m_fg_color = StateColor::darkModeColorFor(wxColour("#6B6A6A"));
|
||||||
|
m_progress_bg_color = StateColor::darkModeColorFor(wxColour("#DFDFDF"));
|
||||||
|
m_progress_fg_color = StateColor::darkModeColorFor(wxColour("#009688"));
|
||||||
|
m_progress_h = FromDIP(6);
|
||||||
bool dark_mode = m_fg_color != wxColour("#6B6A6A");
|
bool dark_mode = m_fg_color != wxColour("#6B6A6A");
|
||||||
wxSize sz = m_window->GetClientSize();
|
wxSize sz = m_window->GetClientSize();
|
||||||
BitmapCache bmp_cache;
|
BitmapCache bmp_cache;
|
||||||
@@ -333,20 +336,34 @@ public:
|
|||||||
dc.DrawLabel(m_text_version, rc, wxALIGN_CENTER);
|
dc.DrawLabel(m_text_version, rc, wxALIGN_CENTER);
|
||||||
|
|
||||||
dc.SetFont(m_font_action);
|
dc.SetFont(m_font_action);
|
||||||
rc.y = c_sz.GetHeight() * 0.88;
|
rc.y = c_sz.GetHeight() * 0.85;
|
||||||
rc.height = dc.GetTextExtent(m_text_action).GetHeight();
|
rc.height = dc.GetTextExtent(m_text_action).GetHeight();
|
||||||
dc.DrawLabel(m_text_action, rc, wxALIGN_CENTER);
|
dc.DrawLabel(m_text_action, rc, wxALIGN_CENTER);
|
||||||
|
|
||||||
|
const wxRect progress_rc(0, c_sz.GetHeight() - m_progress_h, c_sz.GetWidth(), m_progress_h);
|
||||||
|
|
||||||
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
dc.SetBrush(wxBrush(m_progress_bg_color));
|
||||||
|
dc.DrawRectangle(progress_rc);
|
||||||
|
|
||||||
|
const int fill_width = progress_rc.GetWidth() * m_progress * 0.01;
|
||||||
|
if (fill_width > 0) {
|
||||||
|
dc.SetBrush(wxBrush(m_progress_fg_color));
|
||||||
|
dc.DrawRectangle(0, progress_rc.GetTop(), fill_width, m_progress_h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetText(const wxString& text)
|
void SetText(const wxString& text, int progress)
|
||||||
{
|
{
|
||||||
if (!text.empty()) {
|
int calc_progress = std::max(m_progress, std::clamp(progress, 0, 100));
|
||||||
|
if (m_text_action != text || m_progress != calc_progress){
|
||||||
m_text_action = text;
|
m_text_action = text;
|
||||||
|
m_progress = calc_progress;
|
||||||
m_window->Refresh();
|
m_window->Refresh();
|
||||||
m_window->Update();
|
m_window->Update();
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
// without this code splash screen wouldn't be updated under OSX
|
// without this code splash screen wouldn't be updated under OSX
|
||||||
wxYield();
|
wxYield();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,9 +400,13 @@ private:
|
|||||||
wxBitmap m_logo_bmp;
|
wxBitmap m_logo_bmp;
|
||||||
wxColour m_fg_color;
|
wxColour m_fg_color;
|
||||||
wxColour m_bg_color;
|
wxColour m_bg_color;
|
||||||
|
wxColour m_progress_bg_color;
|
||||||
|
wxColour m_progress_fg_color;
|
||||||
|
|
||||||
wxString m_text_version = GUI_App::format_display_version();
|
wxString m_text_version = GUI_App::format_display_version();
|
||||||
wxString m_text_action = _L("Loading configuration") + dots;
|
wxString m_text_action = _L("Loading configuration") + dots;
|
||||||
|
int m_progress = 0;
|
||||||
|
int m_progress_h = 6;
|
||||||
|
|
||||||
wxFont m_font_version = Label::Body_16;
|
wxFont m_font_version = Label::Body_16;
|
||||||
wxFont m_font_action = Label::Body_16;
|
wxFont m_font_action = Label::Body_16;
|
||||||
@@ -2856,7 +2877,7 @@ bool GUI_App::on_init_inner()
|
|||||||
//BBS use BBL splashScreen
|
//BBS use BBL splashScreen
|
||||||
scrn = new SplashScreen(splashscreen_pos);
|
scrn = new SplashScreen(splashscreen_pos);
|
||||||
wxYield();
|
wxYield();
|
||||||
scrn->SetText(_L("Loading configuration") + dots);
|
scrn->SetText(_L("Loading configuration") + dots, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "loading systen presets...";
|
BOOST_LOG_TRIVIAL(info) << "loading systen presets...";
|
||||||
@@ -3035,7 +3056,7 @@ bool GUI_App::on_init_inner()
|
|||||||
// Enable all substitutions (in both user and system profiles), but log the substitutions in user profiles only.
|
// Enable all substitutions (in both user and system profiles), but log the substitutions in user profiles only.
|
||||||
// If there are substitutions in system profiles, then a "reconfigure" event shall be triggered, which will force
|
// If there are substitutions in system profiles, then a "reconfigure" event shall be triggered, which will force
|
||||||
// installation of a compatible system preset, thus nullifying the system preset substitutions.
|
// installation of a compatible system preset, thus nullifying the system preset substitutions.
|
||||||
if (scrn) { scrn->SetText(_L("Loading printer & filament profiles") + dots); wxYield(); }
|
if (scrn) { scrn->SetText(_L("Loading printer & filament profiles") + dots, 30); wxYield(); }
|
||||||
init_params->preset_substitutions = preset_bundle->load_presets(*app_config, ForwardCompatibilitySubstitutionRule::EnableSystemSilent);
|
init_params->preset_substitutions = preset_bundle->load_presets(*app_config, ForwardCompatibilitySubstitutionRule::EnableSystemSilent);
|
||||||
}
|
}
|
||||||
catch (const std::exception& ex) {
|
catch (const std::exception& ex) {
|
||||||
@@ -3066,7 +3087,7 @@ bool GUI_App::on_init_inner()
|
|||||||
|
|
||||||
if (scrn) {
|
if (scrn) {
|
||||||
const auto scrn_txt = _L("Creating main window") + dots;
|
const auto scrn_txt = _L("Creating main window") + dots;
|
||||||
scrn->SetText(scrn_txt);
|
scrn->SetText(scrn_txt, 70);
|
||||||
wxYield();
|
wxYield();
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << "create the main window";
|
BOOST_LOG_TRIVIAL(info) << "create the main window";
|
||||||
@@ -3094,7 +3115,7 @@ bool GUI_App::on_init_inner()
|
|||||||
plater_->set_printer_technology(ptFFF);
|
plater_->set_printer_technology(ptFFF);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (scrn) { scrn->SetText(_L("Loading current preset") + dots); wxYield(); }
|
if (scrn) { scrn->SetText(_L("Loading current preset") + dots, 85); wxYield(); }
|
||||||
load_current_presets();
|
load_current_presets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3108,10 +3129,10 @@ bool GUI_App::on_init_inner()
|
|||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
mainframe->topbar()->SaveNormalRect();
|
mainframe->topbar()->SaveNormalRect();
|
||||||
#endif
|
#endif
|
||||||
if (scrn) { scrn->SetText(_L("Showing main window") + dots); wxYield(); }
|
if (scrn) { scrn->SetText(_L("Showing main window") + dots, 95); wxYield(); }
|
||||||
mainframe->Show(true);
|
mainframe->Show(true);
|
||||||
// Close the splash now that the main UI is visible.
|
// Close the splash now that the main UI is visible.
|
||||||
if (scrn) { scrn->Destroy(); scrn = nullptr; }
|
if (scrn) { scrn->SetText(_L("Showing main window") + dots, 100); scrn->Destroy(); scrn = nullptr; }
|
||||||
BOOST_LOG_TRIVIAL(info) << "main frame firstly shown";
|
BOOST_LOG_TRIVIAL(info) << "main frame firstly shown";
|
||||||
|
|
||||||
//#if BBL_HAS_FIRST_PAGE
|
//#if BBL_HAS_FIRST_PAGE
|
||||||
|
|||||||
Reference in New Issue
Block a user