OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ImageDPIFrame Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/ImageDPIFrame.hpp>

Inheritance diagram for Slic3r::GUI::ImageDPIFrame:
Collaboration diagram for Slic3r::GUI::ImageDPIFrame:

Public Member Functions

 ImageDPIFrame ()
 ~ImageDPIFrame () override
void on_dpi_changed (const wxRect &suggested_rect) override
void sys_color_changed ()
void on_show ()
void on_hide ()
bool Show (bool show=true) override
void set_bitmap (const wxBitmap &bit_map)
int get_image_px ()
void set_title (const wxString &title)
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()
int ShowModal ()

Protected Member Functions

virtual void on_sys_color_changed ()

Private Member Functions

void init_timer ()
void on_timer (wxTimerEvent &event)
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

wxStaticBitmap * m_bitmap = nullptr
wxBoxSizer * m_sizer_main {nullptr}
int m_image_px
wxString m_title_str
wxStaticText * m_title
wxTimer * m_refresh_timer {nullptr}
float m_timer_count = 0
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description

Constructor & Destructor Documentation

◆ ImageDPIFrame()

Slic3r::GUI::ImageDPIFrame::ImageDPIFrame ( )
25 : DPIFrame(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, "", wxDefaultPosition, wxDefaultSize, !wxCAPTION | !wxCLOSE_BOX | wxBORDER_NONE)
26{
27 m_image_px = 240;
28 int width = 270;
29 //SetTransparent(0);
30 SetMinSize(wxSize(FromDIP(width), -1));
31 SetMaxSize(wxSize(FromDIP(width), -1));
32 SetBackgroundColour(wxColour(255, 255, 255, 255));
33#ifdef __APPLE__
34 SetWindowStyleFlag(GetWindowStyleFlag() | wxSTAY_ON_TOP);
35#endif
36
37 // ORCA add border
38 Bind(wxEVT_PAINT, [this](wxPaintEvent& evt) {
39 wxPaintDC dc(this);
40 dc.SetPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")));
41 dc.SetBrush(*wxTRANSPARENT_BRUSH);
42 dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
43 });
44
45 m_sizer_main = new wxBoxSizer(wxVERTICAL);
46
47 m_title = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
48 m_title->SetFont(Label::Head_14);
49 m_title->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#262E30")));
50 m_title->SetMaxSize(wxSize(FromDIP(width), -1));
51
52 auto image_sizer = new wxBoxSizer(wxVERTICAL);
53 auto imgsize = FromDIP(width);
54 m_bitmap = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("printer_preview_C13", this, m_image_px), wxDefaultPosition, FromDIP(wxSize(m_image_px, m_image_px)), 0);
55 image_sizer->Add(m_bitmap, 0, wxALIGN_CENTER | wxALL, FromDIP(10));
56 m_sizer_main->Add(m_title, 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, FromDIP(10));
57 m_sizer_main->Add(image_sizer, FromDIP(0), wxALIGN_CENTER, FromDIP(0));
58
59 wxGetApp().UpdateDarkUI(this); // ORCA fix white bg on dark mode
60
61 Bind(wxEVT_CLOSE_WINDOW, [this](auto &e) {
62 on_hide();
63 });
64 SetSizer(m_sizer_main);
65 Layout();
66 Fit();
67 init_timer();
68}
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Head_14
Definition Label.hpp:45
wxStaticText * m_title
Definition ImageDPIFrame.hpp:37
wxStaticBitmap * m_bitmap
Definition ImageDPIFrame.hpp:33
int m_image_px
Definition ImageDPIFrame.hpp:35
void init_timer()
Definition ImageDPIFrame.cpp:104
wxBoxSizer * m_sizer_main
Definition ImageDPIFrame.hpp:34
void on_hide()
Definition ImageDPIFrame.cpp:149
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
DPIAware< wxFrame > DPIFrame
Definition GUI_Utils.hpp:298
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References create_scaled_bitmap(), StateColor::darkModeColorFor(), Label::Head_14, init_timer(), m_bitmap, m_image_px, m_sizer_main, m_title, on_hide(), and wxStaticText.

Here is the call graph for this function:

◆ ~ImageDPIFrame()

Slic3r::GUI::ImageDPIFrame::~ImageDPIFrame ( )
override
70 {
71
72}

Member Function Documentation

◆ em_unit()

int Slic3r::GUI::DPIAware< wxFrame >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

References m_em_unit.

Referenced by Slic3r::GUI::MainFrame::create_side_tools(), and Slic3r::GUI::MainFrame::update_side_button_style().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxFrame >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

References m_force_rescale.

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxFrame >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

References m_force_rescale.

◆ get_image_px()

int Slic3r::GUI::ImageDPIFrame::get_image_px ( )
inline
25{ return m_image_px; }

References m_image_px.

◆ init_timer()

void Slic3r::GUI::ImageDPIFrame::init_timer ( )
private
105{
106 m_refresh_timer = new wxTimer();
107 m_refresh_timer->SetOwner(this);
108 Bind(wxEVT_TIMER, &ImageDPIFrame::on_timer, this);
109}
void on_timer(wxTimerEvent &event)
Definition ImageDPIFrame.cpp:111
wxTimer * m_refresh_timer
Definition ImageDPIFrame.hpp:38

References m_refresh_timer, and on_timer().

Referenced by ImageDPIFrame().

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

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxFrame >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

References m_prev_scale_factor, and m_scale_factor.

◆ normal_font()

const wxFont & Slic3r::GUI::DPIAware< wxFrame >::normal_font ( ) const
inlineinherited
205{ return m_normal_font; }

References m_normal_font.

Referenced by Slic3r::GUI::MainFrame::init_tabpanel(), and Slic3r::GUI::MainFrame::on_dpi_changed().

Here is the caller graph for this function:

◆ on_dpi_changed()

void Slic3r::GUI::ImageDPIFrame::on_dpi_changed ( const wxRect & suggested_rect)
overridevirtual

Implements Slic3r::GUI::DPIAware< wxFrame >.

94{
95 // m_image->Rescale();
96 //m_bitmap->Rescale();
97}

◆ on_hide()

void Slic3r::GUI::ImageDPIFrame::on_hide ( )
150{
151 if (m_refresh_timer) {
152 m_refresh_timer->Stop();
153 }
154 if (IsShown()) {
155 Hide();
156 if (wxGetApp().mainframe != nullptr) {
157 wxGetApp().mainframe->Show();
158 wxGetApp().mainframe->Raise();
159 }
160 }
161}

References m_refresh_timer.

Referenced by ImageDPIFrame(), on_show(), and on_timer().

Here is the caller graph for this function:

◆ on_show()

void Slic3r::GUI::ImageDPIFrame::on_show ( )
139 {
140 if (IsShown()) {
141 on_hide();
142 }
143 if (m_refresh_timer) {
144 m_timer_count = 0;
146 }
147}
#define ANIMATION_REFRESH_INTERVAL
Definition BaseTransparentDPIFrame.cpp:26
float m_timer_count
Definition ImageDPIFrame.hpp:39

References ANIMATION_REFRESH_INTERVAL, m_refresh_timer, m_timer_count, and on_hide().

Here is the call graph for this function:

◆ on_sys_color_changed()

virtual void Slic3r::GUI::DPIAware< wxFrame >::on_sys_color_changed ( )
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::MainFrame.

226{};

◆ on_timer()

void Slic3r::GUI::ImageDPIFrame::on_timer ( wxTimerEvent & event)
private
112{
113 if (!IsShown()) {//after 1s to show Frame
114 if (m_timer_count >= 20) { // ORCA show frame faster to maatch time with tooltips
115 Show();
116 Raise();
117 }
119 }else{
120 wxPoint mouse_pos = wxGetMousePosition();
121 wxRect window_rect = GetScreenRect();
122
123 wxPoint center(window_rect.x + window_rect.width / 2, window_rect.y + window_rect.height / 2);
124 int half_width = window_rect.width / 2;
125 int half_height = window_rect.height / 2;
126 wxRect expanded_rect(
127 center.x - half_width * 2,
128 center.y - half_height * 2,
129 window_rect.width * 2,
130 window_rect.height * 2
131 );
132
133 if (!expanded_rect.Contains(mouse_pos)) {
134 on_hide();
135 }
136 }
137}
bool Show(bool show=true) override
Definition ImageDPIFrame.cpp:74
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382

References Slic3r::center(), m_timer_count, on_hide(), and Show().

Referenced by init_timer().

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

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxFrame >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

References m_prev_scale_factor.

◆ rescale()

void Slic3r::GUI::DPIAware< wxFrame >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

References m_force_rescale, m_normal_font, m_prev_scale_factor, m_scale_factor, Slic3r::GUI::DPIAware< P >::on_dpi_changed(), and Slic3r::GUI::DPIAware< P >::update_em_unit().

Here is the call graph for this function:

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxFrame >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

References m_scale_factor.

◆ set_bitmap()

void Slic3r::GUI::ImageDPIFrame::set_bitmap ( const wxBitmap & bit_map)
80 {
81 if (bit_map.IsOk()) {
82 m_bitmap->SetBitmap(bit_map);
83 }
84}

References m_bitmap.

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxFrame >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

References m_em_unit.

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxFrame >::set_prev_scale_factor ( float v)
inlineinherited

References m_prev_scale_factor.

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxFrame >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

References m_scale_factor.

◆ set_title()

void Slic3r::GUI::ImageDPIFrame::set_title ( const wxString & title)
86 {
87 m_title->Show(!title.empty());
88 if(!title.empty())
89 m_title->SetLabel(title);
90 Layout();
91}

References m_title.

◆ Show()

bool Slic3r::GUI::ImageDPIFrame::Show ( bool show = true)
override
75{
76 Layout();
77 return DPIFrame::Show(show);
78}

Referenced by on_timer().

Here is the caller graph for this function:

◆ ShowModal()

int Slic3r::GUI::DPIAware< wxFrame >::ShowModal ( )
inlineinherited
217 {
218 dialogStack.push_front(this);
219 int r = wxDialog::ShowModal();
220 dialogStack.pop_front();
221 return r;
222 }

References Slic3r::GUI::dialogStack.

◆ sys_color_changed()

void Slic3r::GUI::ImageDPIFrame::sys_color_changed ( )
100{
101 wxGetApp().UpdateDarkUI(this);
102}

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxFrame >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

References m_em_unit, and m_scale_factor.

Member Data Documentation

◆ m_bitmap

wxStaticBitmap* Slic3r::GUI::ImageDPIFrame::m_bitmap = nullptr
private

Referenced by ImageDPIFrame(), and set_bitmap().

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxFrame >::m_can_rescale
privateinherited
235{ true };

Referenced by DPIAware().

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxFrame >::m_em_unit
privateinherited

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxFrame >::m_force_rescale
privateinherited
236{ false };

Referenced by DPIAware(), enable_force_rescale(), force_rescale(), and rescale().

◆ m_image_px

int Slic3r::GUI::ImageDPIFrame::m_image_px
private

Referenced by ImageDPIFrame(), and get_image_px().

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxFrame >::m_new_font_point_size
privateinherited

Referenced by DPIAware().

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxFrame >::m_normal_font
privateinherited

Referenced by DPIAware(), normal_font(), and rescale().

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxFrame >::m_prev_scale_factor
privateinherited

◆ m_refresh_timer

wxTimer* Slic3r::GUI::ImageDPIFrame::m_refresh_timer {nullptr}
private
38{nullptr};

Referenced by init_timer(), on_hide(), and on_show().

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxFrame >::m_scale_factor
privateinherited

◆ m_sizer_main

wxBoxSizer* Slic3r::GUI::ImageDPIFrame::m_sizer_main {nullptr}
private
34{nullptr};

Referenced by ImageDPIFrame().

◆ m_timer_count

float Slic3r::GUI::ImageDPIFrame::m_timer_count = 0
private

Referenced by on_show(), and on_timer().

◆ m_title

wxStaticText* Slic3r::GUI::ImageDPIFrame::m_title
private

Referenced by ImageDPIFrame(), and set_title().

◆ m_title_str

wxString Slic3r::GUI::ImageDPIFrame::m_title_str
private

The documentation for this class was generated from the following files: