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

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

Inheritance diagram for Slic3r::GUI::FilamentItemPanel:
Collaboration diagram for Slic3r::GUI::FilamentItemPanel:

Public Member Functions

 FilamentItemPanel (wxWindow *parent, const wxString &text, const std::string &icon_name="", wxWindowID id=wxID_ANY)
void SetText (const wxString &text)
void SetIcon (const std::string &icon_name)
void msw_rescale ()

Private Member Functions

void OnPaint (wxPaintEvent &event)
void OnSize (wxSizeEvent &event)

Private Attributes

Label * m_text_label
wxStaticBitmap * m_icon_bitmap
std::string m_icon_name
ScalableBitmap m_icon

Detailed Description

Constructor & Destructor Documentation

◆ FilamentItemPanel()

Slic3r::GUI::FilamentItemPanel::FilamentItemPanel ( wxWindow * parent,
const wxString & text,
const std::string & icon_name = "",
wxWindowID id = wxID_ANY )
118 : wxPanel(parent, id)
119 , m_icon_name(icon_name)
120{
121 SetBackgroundColour(wxColour("#F0F0F1")); // Orca: light-gray panel scheme (#F0F0F1 replaces REF #F7F7F7)
122 SetMinSize(wxSize(FromDIP(64), FromDIP(106))); // Width: 64, Height: 106
123 SetSize(wxSize(FromDIP(64), FromDIP(106))); // Fixed size
124
125 // Create sizer for vertical layout
126 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
127
128 // Top section with text - moved to be closer to center
129 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
130 top_sizer->AddStretchSpacer(5);
131
132 m_text_label = new Label(this, text);
133 m_text_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour(*wxBLACK)));
134 m_text_label->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#F0F0F1")));
136 m_text_label->Wrap(FromDIP(40));
137 top_sizer->Add(m_text_label, 0, wxALIGN_CENTER_HORIZONTAL);
138
139 top_sizer->AddStretchSpacer(1); // Increased bottom spacer to push text down
140 sizer->Add(top_sizer, 1, wxEXPAND);
141
142 // Bottom section with icon - vertically centered in bottom half
143 wxBoxSizer* bottom_sizer = new wxBoxSizer(wxVERTICAL);
144 bottom_sizer->AddStretchSpacer(1);
145
146 m_icon_bitmap = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap);
147 m_icon_bitmap->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#F0F0F1")));
148 m_icon_bitmap->SetMinSize(wxSize(FromDIP(24), FromDIP(24)));
149 m_icon_bitmap->SetMaxSize(wxSize(FromDIP(24), FromDIP(24)));
150 bottom_sizer->Add(m_icon_bitmap, 0, wxALIGN_CENTER_HORIZONTAL);
151
152 bottom_sizer->AddStretchSpacer(1);
153 sizer->Add(bottom_sizer, 1, wxEXPAND);
154
155 SetSizer(sizer);
156
157 // Bind events
158 Bind(wxEVT_PAINT, &FilamentItemPanel::OnPaint, this);
159 Bind(wxEVT_SIZE, &FilamentItemPanel::OnSize, this);
160
161 SetIcon(icon_name);
162 wxGetApp().UpdateDarkUI(this);
163}
static wxFont Body_12
Definition Label.hpp:55
void OnSize(wxSizeEvent &event)
Definition AMSDryControl.cpp:226
wxStaticBitmap * m_icon_bitmap
Definition AMSDryControl.hpp:76
std::string m_icon_name
Definition AMSDryControl.hpp:77
void SetIcon(const std::string &icon_name)
Definition AMSDryControl.cpp:171
void OnPaint(wxPaintEvent &event)
Definition AMSDryControl.cpp:199
Label * m_text_label
Definition AMSDryControl.hpp:75
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References Label::Body_12, StateColor::darkModeColorFor(), m_icon_bitmap, m_icon_name, m_text_label, OnPaint(), OnSize(), and SetIcon().

Here is the call graph for this function:

Member Function Documentation

◆ msw_rescale()

void Slic3r::GUI::FilamentItemPanel::msw_rescale ( )
190{
191 if (m_icon_bitmap && !m_icon_name.empty()) {
192 m_icon.msw_rescale();
193 m_icon_bitmap->SetBitmap(m_icon.bmp());
194 m_icon_bitmap->Refresh();
195 }
196 Layout();
197}
ScalableBitmap m_icon
Definition AMSDryControl.hpp:78

References m_icon, m_icon_bitmap, and m_icon_name.

◆ OnPaint()

void Slic3r::GUI::FilamentItemPanel::OnPaint ( wxPaintEvent & event)
private
200{
201 wxPaintDC dc(this);
202 wxSize size = GetSize();
203
204 // bool is_dark_mode = wxGetApp().dark_mode();
205 wxColour backgroundColor = StateColor::darkModeColorFor(wxColour("#F0F0F1"));
206 wxColour borderColor = StateColor::darkModeColorFor(wxColour("#DBDBDB"));
207
208 // Draw white background rectangle with rounded corners inside the thick vertical lines
209 dc.SetBrush(wxBrush(backgroundColor));
210 dc.SetPen(wxPen(backgroundColor));
211 dc.DrawRectangle(FromDIP(6), FromDIP(12), size.GetWidth() - FromDIP(12), size.GetHeight() - 2 * FromDIP(12));
212
213 // Draw much thicker vertical rounded rectangles on left and right (3 times thicker)
214 dc.SetBrush(wxBrush(wxColour(borderColor)));
215 dc.SetPen(wxPen(wxColour(borderColor)));
216 dc.DrawRoundedRectangle(FromDIP(0), FromDIP(0), FromDIP(6), size.GetHeight(), FromDIP(6)); // Left rounded rectangle
217 dc.DrawRoundedRectangle(size.GetWidth() - FromDIP(6), FromDIP(0), FromDIP(6), size.GetHeight(), FromDIP(6)); // Right rounded rectangle
218
219 // Draw thin horizontal rounded rectangles on top and bottom (moved closer to center by half the distance)
220 dc.SetBrush(wxBrush(wxColour(borderColor)));
221 dc.SetPen(wxPen(wxColour(borderColor)));
222 dc.DrawRoundedRectangle(FromDIP(6), FromDIP(12), size.GetWidth() - FromDIP(12), FromDIP(3), FromDIP(1)); // Top rounded rectangle
223 dc.DrawRoundedRectangle(FromDIP(6), size.GetHeight() - FromDIP(13), size.GetWidth() - FromDIP(12), FromDIP(3), FromDIP(1)); // Bottom rounded rectangle
224}

References StateColor::darkModeColorFor().

Referenced by FilamentItemPanel().

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

◆ OnSize()

void Slic3r::GUI::FilamentItemPanel::OnSize ( wxSizeEvent & event)
private
227{
228 Refresh();
229 event.Skip();
230}

Referenced by FilamentItemPanel().

Here is the caller graph for this function:

◆ SetIcon()

void Slic3r::GUI::FilamentItemPanel::SetIcon ( const std::string & icon_name)
172{
173 m_icon_name = icon_name;
174 if (!icon_name.empty()) {
175 try {
176 m_icon = ScalableBitmap(this, icon_name, 20);
177 m_icon.msw_rescale();
178 m_icon_bitmap->SetBitmap(m_icon.bmp());
179 } catch (Exception&) {
180 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": failed to load filament icon";
181 m_icon_bitmap->SetBitmap(wxNullBitmap);
182 }
183 } else {
184 m_icon_bitmap->SetBitmap(wxNullBitmap);
185 }
186 m_icon_bitmap->Refresh();
187}

References m_icon, m_icon_bitmap, and m_icon_name.

Referenced by FilamentItemPanel().

Here is the caller graph for this function:

◆ SetText()

void Slic3r::GUI::FilamentItemPanel::SetText ( const wxString & text)
166{
167 m_text_label->SetLabel(text);
168 Layout();
169}

References m_text_label.

Member Data Documentation

◆ m_icon

ScalableBitmap Slic3r::GUI::FilamentItemPanel::m_icon
private

Referenced by msw_rescale(), and SetIcon().

◆ m_icon_bitmap

wxStaticBitmap* Slic3r::GUI::FilamentItemPanel::m_icon_bitmap
private

◆ m_icon_name

std::string Slic3r::GUI::FilamentItemPanel::m_icon_name
private

◆ m_text_label

Label* Slic3r::GUI::FilamentItemPanel::m_text_label
private

Referenced by FilamentItemPanel(), and SetText().


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