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

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

Inheritance diagram for Slic3r::GUI::PurgeModeBtnPanel:
Collaboration diagram for Slic3r::GUI::PurgeModeBtnPanel:

Public Member Functions

 PurgeModeBtnPanel (wxWindow *parent, const wxString &label, const wxString &detail, const std::string &icon_path)
void Select (bool selected)

Protected Member Functions

void OnPaint (wxPaintEvent &event)

Private Member Functions

void OnEnterWindow (wxMouseEvent &event)
void OnLeaveWindow (wxMouseEvent &event)
void UpdateStatus ()

Private Attributes

wxBitmap icon
wxBitmap check_icon
wxStaticBitmap * m_btn
wxStaticBitmap * m_check_btn
wxStaticText * m_label
Label * m_detail
bool m_hover {false}
bool m_selected {false}

Detailed Description

Constructor & Destructor Documentation

◆ PurgeModeBtnPanel()

Slic3r::GUI::PurgeModeBtnPanel::PurgeModeBtnPanel ( wxWindow * parent,
const wxString & label,
const wxString & detail,
const std::string & icon_path )
131 : wxPanel(parent)
132{
133 SetBackgroundColour(*wxWHITE);
134 SetBackgroundStyle(wxBG_STYLE_PAINT);
135
136 const int horizontal_margin = FromDIP(12);
137
138 auto sizer = new wxBoxSizer(wxVERTICAL);
139
140 icon = create_scaled_bitmap(icon_path, nullptr, 20);
141 m_btn = new wxStaticBitmap(this, wxID_ANY, icon, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
142
143 check_icon = create_scaled_bitmap("completed_2", nullptr, 20);
144 m_check_btn = new wxStaticBitmap(this, wxID_ANY, check_icon, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
145 m_check_btn->Hide();
146
147 auto icon_sizer = new wxBoxSizer(wxHORIZONTAL);
148 icon_sizer->Add(m_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, horizontal_margin);
149 icon_sizer->AddStretchSpacer();
150 icon_sizer->Add(m_check_btn, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, horizontal_margin);
151
152 m_label = new wxStaticText(this, wxID_ANY, label);
153 m_label->SetFont(Label::Head_14);
154 m_label->SetForegroundColour(TextNormalBlackColor);
155
156 auto label_sizer = new wxBoxSizer(wxHORIZONTAL);
157 label_sizer->Add(m_label, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, horizontal_margin);
158
159 auto detail_sizer = new wxBoxSizer(wxHORIZONTAL);
160 m_detail = new Label(this, detail);
161 m_detail->SetFont(Label::Body_12);
162 m_detail->SetForegroundColour(TextNormalGreyColor);
163 m_detail->Wrap(FromDIP(200));
164 detail_sizer->Add(m_detail, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, horizontal_margin);
165
166 sizer->AddSpacer(FromDIP(15));
167 sizer->Add(icon_sizer, 0, wxEXPAND);
168 sizer->AddSpacer(FromDIP(10));
169 sizer->Add(label_sizer, 0, wxEXPAND);
170 sizer->AddSpacer(FromDIP(6));
171 sizer->Add(detail_sizer, 0, wxEXPAND);
172 sizer->AddSpacer(FromDIP(10));
173
174 SetSizer(sizer);
175 Layout();
176 Fit();
177
178 wxGetApp().UpdateDarkUIWin(this);
179
180 // Clicks on child widgets must select the whole card, so re-dispatch them on the panel.
181 auto forward_click_to_parent = [this](wxMouseEvent &) {
182 wxCommandEvent click_event(wxEVT_LEFT_DOWN, GetId());
183 click_event.SetEventObject(this);
184 this->ProcessEvent(click_event);
185 };
186
187 m_btn->Bind(wxEVT_LEFT_DOWN, forward_click_to_parent);
188 m_label->Bind(wxEVT_LEFT_DOWN, forward_click_to_parent);
189 m_detail->Bind(wxEVT_LEFT_DOWN, forward_click_to_parent);
190
191 Bind(wxEVT_PAINT, &PurgeModeBtnPanel::OnPaint, this);
192 Bind(wxEVT_ENTER_WINDOW, &PurgeModeBtnPanel::OnEnterWindow, this);
193 Bind(wxEVT_LEAVE_WINDOW, &PurgeModeBtnPanel::OnLeaveWindow, this);
194}
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Head_14
Definition Label.hpp:45
static wxFont Body_12
Definition Label.hpp:55
void OnEnterWindow(wxMouseEvent &event)
Definition PurgeModeDialog.cpp:243
void OnLeaveWindow(wxMouseEvent &event)
Definition PurgeModeDialog.cpp:253
Label * m_detail
Definition PurgeModeDialog.hpp:41
wxStaticBitmap * m_check_btn
Definition PurgeModeDialog.hpp:39
void OnPaint(wxPaintEvent &event)
Definition PurgeModeDialog.cpp:196
wxStaticText * m_label
Definition PurgeModeDialog.hpp:40
wxBitmap check_icon
Definition PurgeModeDialog.hpp:36
wxStaticBitmap * m_btn
Definition PurgeModeDialog.hpp:38
wxBitmap icon
Definition PurgeModeDialog.hpp:35
wxMouseEvent
Definition CameraPopup.cpp:47
static const wxColour TextNormalGreyColor
Definition FilamentMapPanel.cpp:41
static const wxColour TextNormalBlackColor
Definition FilamentMapPanel.cpp:40
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 Label::Body_12, check_icon, create_scaled_bitmap(), Label::Head_14, icon, m_btn, m_check_btn, m_detail, m_label, OnEnterWindow(), OnLeaveWindow(), OnPaint(), Slic3r::GUI::TextNormalBlackColor, Slic3r::GUI::TextNormalGreyColor, Slic3r::GUI::wxMouseEvent, and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ OnEnterWindow()

void Slic3r::GUI::PurgeModeBtnPanel::OnEnterWindow ( wxMouseEvent & event)
private
244{
245 if (!m_hover) {
246 m_hover = true;
247 UpdateStatus();
248 Refresh();
249 event.Skip();
250 }
251}
void UpdateStatus()
Definition PurgeModeDialog.cpp:219
bool m_hover
Definition PurgeModeDialog.hpp:42

References m_hover, UpdateStatus(), and Slic3r::GUI::wxMouseEvent.

Referenced by PurgeModeBtnPanel().

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

◆ OnLeaveWindow()

void Slic3r::GUI::PurgeModeBtnPanel::OnLeaveWindow ( wxMouseEvent & event)
private
254{
255 if (m_hover) {
256 wxPoint pos = this->ScreenToClient(wxGetMousePosition());
257 if (this->GetClientRect().Contains(pos)) return;
258 m_hover = false;
259 UpdateStatus();
260 Refresh();
261 event.Skip();
262 }
263}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References m_hover, UpdateStatus(), and Slic3r::GUI::wxMouseEvent.

Referenced by PurgeModeBtnPanel().

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

◆ OnPaint()

void Slic3r::GUI::PurgeModeBtnPanel::OnPaint ( wxPaintEvent & event)
protected
197{
198 wxAutoBufferedPaintDC dc(this);
199 wxGraphicsContext *gc = wxGraphicsContext::Create(dc);
200
201 if (gc) {
202 dc.Clear();
203 wxRect rect = GetClientRect();
204 gc->SetBrush(wxTransparentColour);
205 gc->DrawRoundedRectangle(0, 0, rect.width, rect.height, 0);
207
208 wxColour border_color = m_hover || m_selected ? BorderSelectedColor : BorderNormalColor;
209
211 border_color = StateColor::darkModeColorFor(border_color);
212 gc->SetBrush(wxBrush(bg_color));
213 gc->SetPen(wxPen(border_color, 1));
214 gc->DrawRoundedRectangle(1, 1, rect.width - 2, rect.height - 2, 8);
215 delete gc;
216 }
217}
bool m_selected
Definition PurgeModeDialog.hpp:43
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxColour bg_color()
Definition SpeedDialDialog.cpp:69
static const wxColour BorderNormalColor
Definition CapsuleButton.cpp:24
static const wxColour BgNormalColor
Definition CapsuleButton.cpp:18
static const wxColour BgSelectColor
Definition CapsuleButton.cpp:19
static const wxColour BorderSelectedColor
Definition FilamentMapPanel.cpp:37

References Slic3r::GUI::BgNormalColor, Slic3r::GUI::BgSelectColor, Slic3r::GUI::BorderNormalColor, Slic3r::GUI::BorderSelectedColor, StateColor::darkModeColorFor(), m_hover, and m_selected.

Referenced by PurgeModeBtnPanel().

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

◆ Select()

void Slic3r::GUI::PurgeModeBtnPanel::Select ( bool selected)
266{
267 m_selected = selected;
268 UpdateStatus();
269 Refresh();
270}

References m_selected, and UpdateStatus().

Here is the call graph for this function:

◆ UpdateStatus()

void Slic3r::GUI::PurgeModeBtnPanel::UpdateStatus ( )
private
220{
221 if (m_selected) {
222 m_btn->SetBackgroundColour(BgSelectColor);
223 m_label->SetBackgroundColour(BgSelectColor);
224 m_detail->SetBackgroundColour(BgSelectColor);
225 if (m_check_btn) {
226 m_check_btn->SetBackgroundColour(BgSelectColor);
227 m_check_btn->Show();
228 }
229 } else {
230 m_btn->SetBackgroundColour(BgNormalColor);
231 m_label->SetBackgroundColour(BgNormalColor);
232 m_detail->SetBackgroundColour(BgNormalColor);
233 if (m_check_btn) {
234 m_check_btn->SetBackgroundColour(BgNormalColor);
235 m_check_btn->Hide();
236 }
237 }
238 Layout();
239 Refresh();
240 wxGetApp().UpdateDarkUIWin(this);
241}

References Slic3r::GUI::BgNormalColor, Slic3r::GUI::BgSelectColor, m_btn, m_check_btn, m_detail, m_label, and m_selected.

Referenced by OnEnterWindow(), OnLeaveWindow(), and Select().

Here is the caller graph for this function:

Member Data Documentation

◆ check_icon

wxBitmap Slic3r::GUI::PurgeModeBtnPanel::check_icon
private

Referenced by PurgeModeBtnPanel().

◆ icon

wxBitmap Slic3r::GUI::PurgeModeBtnPanel::icon
private

Referenced by PurgeModeBtnPanel().

◆ m_btn

wxStaticBitmap* Slic3r::GUI::PurgeModeBtnPanel::m_btn
private

Referenced by PurgeModeBtnPanel(), and UpdateStatus().

◆ m_check_btn

wxStaticBitmap* Slic3r::GUI::PurgeModeBtnPanel::m_check_btn
private

Referenced by PurgeModeBtnPanel(), and UpdateStatus().

◆ m_detail

Label* Slic3r::GUI::PurgeModeBtnPanel::m_detail
private

Referenced by PurgeModeBtnPanel(), and UpdateStatus().

◆ m_hover

bool Slic3r::GUI::PurgeModeBtnPanel::m_hover {false}
private
42{false};

Referenced by OnEnterWindow(), OnLeaveWindow(), and OnPaint().

◆ m_label

wxStaticText* Slic3r::GUI::PurgeModeBtnPanel::m_label
private

Referenced by PurgeModeBtnPanel(), and UpdateStatus().

◆ m_selected

bool Slic3r::GUI::PurgeModeBtnPanel::m_selected {false}
private
43{false};

Referenced by OnPaint(), Select(), and UpdateStatus().


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