OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::SplashScreen Class Reference
Inheritance diagram for Slic3r::GUI::SplashScreen:
Collaboration diagram for Slic3r::GUI::SplashScreen:

Public Member Functions

 SplashScreen (wxPoint pos=wxDefaultPosition)
void OnPaint (wxPaintEvent &evt)
void SetText (const wxString &text, int progress)
int FilterEvent (wxEvent &) override
void scale_font (wxFont &font, float scale)

Private Attributes

wxBitmap m_logo_bmp
wxColour m_fg_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_action = _L("Loading configuration") + dots
int m_progress = 0
int m_progress_h = 6
wxFont m_font_version = Label::Body_16
wxFont m_font_action = Label::Body_16

Detailed Description

Constructor & Destructor Documentation

◆ SplashScreen()

Slic3r::GUI::SplashScreen::SplashScreen ( wxPoint pos = wxDefaultPosition)
inline
453 : wxSplashScreen(wxBitmap(FromDIP(wxSize(480,480),nullptr)), wxSPLASH_CENTRE_ON_SCREEN, 0, nullptr, wxID_ANY, wxDefaultPosition, wxDefaultSize,
454#ifdef __APPLE__
455 wxBORDER_NONE | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP
456#else
457 wxBORDER_NONE | wxFRAME_NO_TASKBAR
458#endif // !__APPLE__
459 )
460 {
461 // Some desktop environments ignore splash screen typed window properties
462 // when running the app through Wayland,resulting in the titlebar being shown
463 // on the splash screen. The code below creates a client-side window decoration
464 // when running on Wayland and then removes that decoration. This ensures every
465 // environment correctly targets and removes the titlebar for this screen.
466 #if defined(__WXGTK__)
467 if (Slic3r::GUI::is_running_on_wayland()) {
468 GtkWidget *empty = gtk_fixed_new();
469 gtk_widget_set_size_request(empty, 0, 0);
470 gtk_window_set_titlebar(GTK_WINDOW(GetHandle()), empty);
471 gtk_window_set_decorated(GTK_WINDOW(GetHandle()), false);
472 }
473 #endif
474
475 this->SetPosition(pos);
476 this->CenterOnScreen();
477
478 scale_font(m_font_version, 1.65f); // only scale this one since it hasnt a preloaded font like Label::Body_24;
479
480 m_bg_color = StateColor::darkModeColorFor(wxColour("#FFFFFF"));
481 m_fg_color = StateColor::darkModeColorFor(wxColour("#6B6A6A"));
484 m_progress_h = FromDIP(6);
485 bool dark_mode = m_fg_color != wxColour("#6B6A6A");
486 wxSize sz = m_window->GetClientSize();
487 BitmapCache bmp_cache;
488 m_logo_bmp = *bmp_cache.load_svg(dark_mode ? "splash_logo_dark" : "splash_logo", sz.GetWidth(), sz.GetHeight());
489
490 m_window->Bind(wxEVT_PAINT, &SplashScreen::OnPaint, this);
491 m_window->Refresh();
492 m_window->Update();
493 }
wxColour m_fg_color
Definition GUI_App.cpp:576
wxColour m_progress_fg_color
Definition GUI_App.cpp:579
int m_progress_h
Definition GUI_App.cpp:584
void OnPaint(wxPaintEvent &evt)
Definition GUI_App.cpp:495
wxFont m_font_version
Definition GUI_App.cpp:586
wxColour m_bg_color
Definition GUI_App.cpp:577
void scale_font(wxFont &font, float scale)
Definition GUI_App.cpp:557
wxColour m_progress_bg_color
Definition GUI_App.cpp:578
wxBitmap m_logo_bmp
Definition GUI_App.cpp:575
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
bool empty(const BoundingBoxBase< PointType, PointsType > &bb)
Definition BoundingBox.hpp:273

References StateColor::darkModeColorFor(), Slic3r::empty(), Slic3r::GUI::BitmapCache::load_svg(), m_bg_color, m_fg_color, m_font_version, m_logo_bmp, m_progress_bg_color, m_progress_fg_color, m_progress_h, OnPaint(), and scale_font().

Here is the call graph for this function:

Member Function Documentation

◆ FilterEvent()

int Slic3r::GUI::SplashScreen::FilterEvent ( wxEvent & )
inlineoverride
555{ return wxEventFilter::Event_Skip; }

◆ OnPaint()

void Slic3r::GUI::SplashScreen::OnPaint ( wxPaintEvent & evt)
inline
496 {
497 wxPaintDC dc(m_window);
498 wxSize c_sz = m_window->GetClientSize();
499
500 dc.SetBackground(wxBrush(m_bg_color));
501 dc.Clear();
502 if (m_logo_bmp.IsOk())
503 dc.DrawBitmap(m_logo_bmp, 0, 0, true);
504
505 wxRect rc = wxRect(0, 0, c_sz.GetWidth(), 0);
506 dc.SetTextForeground(m_fg_color);
507
508 dc.SetFont(m_font_version);
509 rc.y = c_sz.GetHeight() * 0.72;
510 rc.height = dc.GetTextExtent(m_text_version).GetHeight();
511 dc.DrawLabel(m_text_version, rc, wxALIGN_CENTER);
512
513 dc.SetFont(m_font_action);
514 rc.y = c_sz.GetHeight() * 0.85;
515 rc.height = dc.GetTextExtent(m_text_action).GetHeight();
516 dc.DrawLabel(m_text_action, rc, wxALIGN_CENTER);
517
518 const wxRect progress_rc(0, c_sz.GetHeight() - m_progress_h, c_sz.GetWidth(), m_progress_h);
519
520 dc.SetPen(*wxTRANSPARENT_PEN);
521 dc.SetBrush(wxBrush(m_progress_bg_color));
522 dc.DrawRectangle(progress_rc);
523
524 const int fill_width = progress_rc.GetWidth() * m_progress * 0.01;
525 if (fill_width > 0) {
526 dc.SetBrush(wxBrush(m_progress_fg_color));
527 dc.DrawRectangle(0, progress_rc.GetTop(), fill_width, m_progress_h);
528 }
529 }
int m_progress
Definition GUI_App.cpp:583
wxString m_text_action
Definition GUI_App.cpp:582
wxFont m_font_action
Definition GUI_App.cpp:587
wxString m_text_version
Definition GUI_App.cpp:581

References m_bg_color, m_fg_color, m_font_action, m_font_version, m_logo_bmp, m_progress, m_progress_bg_color, m_progress_fg_color, m_progress_h, m_text_action, and m_text_version.

Referenced by SplashScreen().

Here is the caller graph for this function:

◆ scale_font()

void Slic3r::GUI::SplashScreen::scale_font ( wxFont & font,
float scale )
inline
558 {
559#ifdef __WXMSW__
560 // Workaround for the font scaling in respect to the current active display,
561 // not for the primary display, as it's implemented in Font.cpp
562 // See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
563 // void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
564 wxNativeFontInfo nfi= *font.GetNativeFontInfo();
565 float pointSizeNew = scale * font.GetPointSize();
566 nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
567 nfi.pointSize = pointSizeNew;
568 font = wxFont(nfi);
569#else
570 font.Scale(scale);
571#endif //__WXMSW__
572 }
int scale(const int val)
Definition WipeTowerDialog.cpp:58
int get_dpi_for_window(const wxWindow *window)
Definition GUI_Utils.cpp:234

References Slic3r::GUI::get_dpi_for_window(), and scale().

Referenced by SplashScreen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetText()

void Slic3r::GUI::SplashScreen::SetText ( const wxString & text,
int progress )
inline
532 {
533 int calc_progress = std::max(m_progress, std::clamp(progress, 0, 100));
534 if (m_text_action != text || m_progress != calc_progress){
535 m_text_action = text;
536 m_progress = calc_progress;
537 m_window->Refresh();
538 m_window->Update();
539#ifdef __WXOSX__
540 // without this code splash screen wouldn't be updated under OSX
541 wxYield();
542#endif
543 }
544 }

References m_progress, and m_text_action.

Member Data Documentation

◆ m_bg_color

wxColour Slic3r::GUI::SplashScreen::m_bg_color
private

Referenced by SplashScreen(), and OnPaint().

◆ m_fg_color

wxColour Slic3r::GUI::SplashScreen::m_fg_color
private

Referenced by SplashScreen(), and OnPaint().

◆ m_font_action

wxFont Slic3r::GUI::SplashScreen::m_font_action = Label::Body_16
private

Referenced by OnPaint().

◆ m_font_version

wxFont Slic3r::GUI::SplashScreen::m_font_version = Label::Body_16
private

Referenced by SplashScreen(), and OnPaint().

◆ m_logo_bmp

wxBitmap Slic3r::GUI::SplashScreen::m_logo_bmp
private

Referenced by SplashScreen(), and OnPaint().

◆ m_progress

int Slic3r::GUI::SplashScreen::m_progress = 0
private

Referenced by OnPaint(), and SetText().

◆ m_progress_bg_color

wxColour Slic3r::GUI::SplashScreen::m_progress_bg_color
private

Referenced by SplashScreen(), and OnPaint().

◆ m_progress_fg_color

wxColour Slic3r::GUI::SplashScreen::m_progress_fg_color
private

Referenced by SplashScreen(), and OnPaint().

◆ m_progress_h

int Slic3r::GUI::SplashScreen::m_progress_h = 6
private

Referenced by SplashScreen(), and OnPaint().

◆ m_text_action

wxString Slic3r::GUI::SplashScreen::m_text_action = _L("Loading configuration") + dots
private

Referenced by OnPaint(), and SetText().

◆ m_text_version

wxString Slic3r::GUI::SplashScreen::m_text_version = GUI_App::format_display_version()
private

Referenced by OnPaint().


The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GUI_App.cpp