OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard Class Reference
Inheritance diagram for Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard:
Collaboration diagram for Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard:

Public Member Functions

 FlashforgeSlotCard (wxWindow *parent)
void set_slot (const Slic3r::FlashforgeMaterialSlot &slot, bool enabled)

Private Member Functions

void on_left_down (wxMouseEvent &e)
void on_paint (wxPaintEvent &)

Static Private Member Functions

static wxColour parse_color (const std::string &raw)

Private Attributes

int m_slot_id {0}
wxColour m_color {*wxWHITE}
wxString m_name
bool m_empty {true}
bool m_enabled {false}
bool m_hover {false}

Detailed Description

Constructor & Destructor Documentation

◆ FlashforgeSlotCard()

Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::FlashforgeSlotCard ( wxWindow * parent)
inline
113 : wxPanel(parent, wxID_ANY)
114 {
115 SetDoubleBuffered(true);
116 SetMinSize(wxSize(FromDIP(68), FromDIP(92)));
117 SetMaxSize(GetMinSize());
118 Bind(wxEVT_PAINT, &FlashforgeSlotCard::on_paint, this);
119 Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent& e) {
120 m_hover = true;
121 SetCursor(wxCursor(m_enabled ? wxCURSOR_HAND : wxCURSOR_NO_ENTRY));
122 Refresh();
123 e.Skip();
124 });
125 Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) {
126 m_hover = false;
127 SetCursor(wxCursor(wxCURSOR_ARROW));
128 Refresh();
129 e.Skip();
130 });
131 Bind(wxEVT_LEFT_DOWN, &FlashforgeSlotCard::on_left_down, this);
132 }
void on_left_down(wxMouseEvent &e)
Definition PrintHostDialogs.cpp:159
void on_paint(wxPaintEvent &)
Definition PrintHostDialogs.cpp:171
wxMouseEvent
Definition CameraPopup.cpp:47

References m_enabled, m_hover, on_left_down(), on_paint(), and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

Member Function Documentation

◆ on_left_down()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::on_left_down ( wxMouseEvent & e)
inlineprivate
160 {
161 if (!m_enabled)
162 return;
163
164 wxCommandEvent evt(wxEVT_BUTTON, GetId());
165 evt.SetInt(m_slot_id);
166 evt.SetString(m_color.GetAsString(wxC2S_HTML_SYNTAX));
167 wxPostEvent(this, evt);
168 e.Skip();
169 }

References m_color, m_enabled, m_slot_id, and Slic3r::GUI::wxMouseEvent.

Referenced by FlashforgeSlotCard().

Here is the caller graph for this function:

◆ on_paint()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::on_paint ( wxPaintEvent & )
inlineprivate
172 {
173 wxPaintDC dc(this);
174 std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::Create(dc));
175 if (gc == nullptr)
176 return;
177
178 const wxSize size = GetSize();
179 const int circle_size = FromDIP(24);
180 const int outline_width = (m_hover && m_enabled) ? FromDIP(2) : FromDIP(1);
181 const wxRect body_rect(FromDIP(7), FromDIP(26), size.x - FromDIP(14), size.y - FromDIP(32));
182 const wxColour badge_color = m_enabled ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)
183 : wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
184 const wxColour body_border = m_enabled ? wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)
185 : wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
186
187 gc->SetPen(*wxTRANSPARENT_PEN);
188 gc->SetBrush(wxBrush((m_hover && m_enabled) ? badge_color.ChangeLightness(130) : badge_color));
189 gc->DrawEllipse((size.x - circle_size) / 2.0, 0, circle_size, circle_size);
190
191 dc.SetFont(::Label::Body_13);
192 dc.SetTextForeground(*wxWHITE);
193 const wxString slot_txt = wxString::Format("%d", m_slot_id);
194 const wxSize slot_size = dc.GetTextExtent(slot_txt);
195 dc.DrawText(slot_txt, (size.x - slot_size.x) / 2, (circle_size - slot_size.y) / 2);
196
197 const wxColour bg_color = m_empty ? wxColour("#F6F6F6") : m_color;
198 gc->SetPen(wxPen(body_border, outline_width));
199 gc->SetBrush(wxBrush(bg_color));
200 gc->DrawRoundedRectangle(body_rect.x, body_rect.y, body_rect.width, body_rect.height, FromDIP(8));
201
202 dc.SetFont(::Label::Body_12);
203 dc.SetTextForeground(contrasting_text_color(bg_color));
204
205 wxString label = m_empty ? _L("Empty") : m_name;
206 if (dc.GetTextExtent(label).x > body_rect.width - FromDIP(8))
207 dc.SetFont(::Label::Body_10);
208 if (dc.GetTextExtent(label).x > body_rect.width - FromDIP(8)) {
209 while (!label.empty() && dc.GetTextExtent(label + "...").x > body_rect.width - FromDIP(8))
210 label.RemoveLast();
211 label += "...";
212 }
213 const wxSize label_size = dc.GetTextExtent(label);
214 dc.DrawText(label, body_rect.x + (body_rect.width - label_size.x) / 2, body_rect.y + (body_rect.height - label_size.y) / 2);
215 }
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_13
Definition Label.hpp:54
static wxFont Body_12
Definition Label.hpp:55
static wxFont Body_10
Definition Label.hpp:56
wxColour contrasting_text_color(const wxColour &background)
Definition PrintHostDialogs.cpp:96

References _L, Label::Body_10, Label::Body_12, Label::Body_13, Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::contrasting_text_color(), m_color, m_empty, m_enabled, m_hover, m_name, and m_slot_id.

Referenced by FlashforgeSlotCard().

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

◆ parse_color()

wxColour Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::parse_color ( const std::string & raw)
inlinestaticprivate
146 {
147 wxColour color(from_u8(raw));
148 if (color.IsOk())
149 return color;
150
151 std::string value = raw;
152 boost::trim(value);
153 if (!value.empty() && value.front() != '#')
154 value.insert(value.begin(), '#');
155 color = wxColour(from_u8(value));
156 return color.IsOk() ? color : wxColour("#D0D0D0");
157 }
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References Slic3r::GUI::from_u8().

Referenced by set_slot().

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

◆ set_slot()

void Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::set_slot ( const Slic3r::FlashforgeMaterialSlot & slot,
bool enabled )
inline
135 {
136 m_slot_id = slot.slot_id;
138 m_name = slot.material_name.empty() ? _L("Unknown") : from_u8(slot.material_name);
139 m_empty = !slot.has_filament;
140 m_enabled = enabled && !m_empty;
141 Refresh();
142 }
static wxColour parse_color(const std::string &raw)
Definition PrintHostDialogs.cpp:145
bool has_filament
Definition Flashforge.hpp:20
std::string material_name
Definition Flashforge.hpp:21
std::string material_color
Definition Flashforge.hpp:22
int slot_id
Definition Flashforge.hpp:19

References _L, Slic3r::GUI::from_u8(), Slic3r::FlashforgeMaterialSlot::has_filament, m_color, m_empty, m_enabled, m_name, m_slot_id, Slic3r::FlashforgeMaterialSlot::material_color, Slic3r::FlashforgeMaterialSlot::material_name, parse_color(), and Slic3r::FlashforgeMaterialSlot::slot_id.

Here is the call graph for this function:

Member Data Documentation

◆ m_color

wxColour Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::m_color {*wxWHITE}
private
219{*wxWHITE};

Referenced by on_left_down(), on_paint(), and set_slot().

◆ m_empty

bool Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::m_empty {true}
private
221{true};

Referenced by on_paint(), and set_slot().

◆ m_enabled

bool Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::m_enabled {false}
private
222{false};

Referenced by FlashforgeSlotCard(), on_left_down(), on_paint(), and set_slot().

◆ m_hover

bool Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::m_hover {false}
private
223{false};

Referenced by FlashforgeSlotCard(), and on_paint().

◆ m_name

wxString Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::m_name
private

Referenced by on_paint(), and set_slot().

◆ m_slot_id

int Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotCard::m_slot_id {0}
private
218{0};

Referenced by on_left_down(), on_paint(), and set_slot().


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