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

Public Member Functions

 RatioLabelPanel (wxWindow *parent)
void SetLabel (const wxString &text) override
wxString GetLabel () const override

Private Member Functions

void update_best_size ()
void on_paint (wxPaintEvent &)

Private Attributes

wxString m_text
bool m_hovered {false}

Detailed Description

Constructor & Destructor Documentation

◆ RatioLabelPanel()

Slic3r::GUI::RatioLabelPanel::RatioLabelPanel ( wxWindow * parent)
inline
68 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
69 {
70 SetBackgroundStyle(wxBG_STYLE_PAINT);
71 SetCursor(wxCursor(wxCURSOR_HAND));
72 SetToolTip(_L("Click to edit ratio"));
73 SetFont(::Label::Body_10);
74
75 Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& e) { m_hovered = true; Refresh(); e.Skip(); });
76 Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) { m_hovered = false; Refresh(); e.Skip(); });
77 Bind(wxEVT_PAINT, &RatioLabelPanel::on_paint, this);
78 }
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_10
Definition Label.hpp:56
void on_paint(wxPaintEvent &)
Definition MixedFilamentDialog.cpp:100
bool m_hovered
Definition MixedFilamentDialog.cpp:127
wxMouseEvent
Definition CameraPopup.cpp:47

References _L, Label::Body_10, m_hovered, on_paint(), and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

Member Function Documentation

◆ GetLabel()

wxString Slic3r::GUI::RatioLabelPanel::GetLabel ( ) const
inlineoverride
87{ return m_text; }
wxString m_text
Definition MixedFilamentDialog.cpp:126

References m_text.

◆ on_paint()

void Slic3r::GUI::RatioLabelPanel::on_paint ( wxPaintEvent & )
inlineprivate
101 {
102 wxBufferedPaintDC dc(this);
103 wxSize sz = GetClientSize();
104
105 wxColour parent_bg = GetParent() ? GetParent()->GetBackgroundColour()
107 dc.SetBrush(wxBrush(parent_bg));
108 dc.SetPen(*wxTRANSPARENT_PEN);
109 dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
110
111 if (m_hovered) {
112 dc.SetBrush(wxBrush(StateColor::darkModeColorFor(wxColour("#F8F8F8"))));
113 dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#CECECE")), 1));
114 dc.DrawRoundedRectangle(0, 0, sz.GetWidth(), sz.GetHeight(), FromDIP(3));
115 }
116
117 dc.SetFont(GetFont());
118 dc.SetTextForeground(m_hovered ? StateColor::darkModeColorFor(wxColour("#009688"))
119 : StateColor::darkModeColorFor(wxColour("#262E30")));
120 wxSize ts = dc.GetTextExtent(m_text);
121 int x = (sz.GetWidth() - ts.GetWidth()) / 2;
122 int y = (sz.GetHeight() - ts.GetHeight()) / 2;
123 dc.DrawText(m_text, x, y);
124 }
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor(), m_hovered, and m_text.

Referenced by RatioLabelPanel().

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

◆ SetLabel()

void Slic3r::GUI::RatioLabelPanel::SetLabel ( const wxString & text)
inlineoverride
81 {
82 if (m_text == text) return;
83 m_text = text;
85 Refresh();
86 }
void update_best_size()
Definition MixedFilamentDialog.cpp:90

References m_text, and update_best_size().

Here is the call graph for this function:

◆ update_best_size()

void Slic3r::GUI::RatioLabelPanel::update_best_size ( )
inlineprivate
91 {
92 wxClientDC dc(this);
93 dc.SetFont(GetFont());
94 wxSize ts = dc.GetTextExtent(m_text);
95 int pad_x = FromDIP(4), pad_y = FromDIP(3);
96 SetMinSize(wxSize(ts.GetWidth() + pad_x * 2, ts.GetHeight() + pad_y * 2));
97 InvalidateBestSize();
98 }

References m_text.

Referenced by SetLabel().

Here is the caller graph for this function:

Member Data Documentation

◆ m_hovered

bool Slic3r::GUI::RatioLabelPanel::m_hovered {false}
private
127{false};

Referenced by RatioLabelPanel(), and on_paint().

◆ m_text

wxString Slic3r::GUI::RatioLabelPanel::m_text
private

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