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

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

Inheritance diagram for Slic3r::GUI::FilamentPickerDialog:
Collaboration diagram for Slic3r::GUI::FilamentPickerDialog:

Public Member Functions

 FilamentPickerDialog (wxWindow *parent, const wxString &fila_id, const FilamentColor &fila_color, const std::string &fila_type, std::optional< FilamentColorPickerValue > ordered_color=std::nullopt)
virtual ~FilamentPickerDialog ()
bool HasSelectionChanged () const
const std::optional< ColorSelection > & GetCustomColorSelection () const
bool IsDataLoaded () const
wxColour GetSelectedColour () const
const FilamentColor & GetSelectedFilamentColor () const
void EndModal (int retCode) override
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

void on_dpi_changed (const wxRect &suggested_rect) override
void OnMouseLeftDown (wxMouseEvent &event)
void OnMouseMove (wxMouseEvent &event)
void OnMouseLeftUp (wxMouseEvent &event)
void OnButtonPaint (wxPaintEvent &event)
void OnTimerCheck (wxTimerEvent &event)
void OnFlashTimer (wxTimerEvent &event)
bool IsClickOnTopMostWindow (const wxPoint &mouse_pos)
void StartClickDetection ()
void StopClickDetection ()
void CleanupTimers ()
virtual void on_sys_color_changed ()

Private Member Functions

wxBoxSizer * CreatePreviewPanel (const FilamentColor &fila_color, const std::string &fila_type)
wxScrolledWindow * CreateColorGrid ()
wxBoxSizer * CreateSeparatorLine ()
void CreateMoreInfoButton ()
void BindEvents ()
void CreateColorBitmap (const FilamentColor &fila_color)
wxBoxSizer * CreateInfoSection ()
void SetupLabelsContent (const FilamentColor &fila_color, const std::string &fila_type)
void UpdatePreview (const FilamentColorCode &filament)
void UpdateCustomColorPreview (const std::vector< wxColour > &colors, bool gradient)
void UpdateButtonStates (wxBitmapButton *selected_btn)
void SetWindowShape ()
void CreateShapedBitmap ()
bool LoadFilamentData (const wxString &fila_id)
void StartFlashing ()
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

wxStaticBitmap * m_color_demo {nullptr}
wxStaticText * m_label_preview_color {nullptr}
wxStaticText * m_label_preview_idx {nullptr}
wxStaticText * m_label_preview_type {nullptr}
Button * m_more_btn {nullptr}
Button * m_ok_btn {nullptr}
Button * m_cancel_btn {nullptr}
bool m_is_data_loaded {false}
wxString * m_cur_color_name {nullptr}
FilamentColorCodeQuery * m_color_query {nullptr}
FilamentColorCodes * m_cur_color_codes {nullptr}
wxBitmapButton * m_cur_selected_btn {nullptr}
FilamentColor m_cur_filament_color
std::optional< FilamentColorPickerValue > m_ordered_color
std::optional< ColorSelection > m_custom_selection
bool m_selection_changed = false
wxBitmap m_shape_bmp
int m_corner_radius {8}
wxPoint m_drag_delta
wxTimer * m_click_timer {nullptr}
bool m_last_mouse_down {false}
wxTimer * m_flash_timer {nullptr}
int m_flash_step {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

◆ FilamentPickerDialog()

Slic3r::GUI::FilamentPickerDialog::FilamentPickerDialog ( wxWindow * parent,
const wxString & fila_id,
const FilamentColor & fila_color,
const std::string & fila_type,
std::optional< FilamentColorPickerValue > ordered_color = std::nullopt )
88 : DPIDialog(parent ? parent : wxGetApp().mainframe,
89 wxID_ANY,
90 _L("Select Filament"),
91 wxDefaultPosition,
92 wxDefaultSize,
93 wxBORDER_NONE | wxFRAME_NO_TASKBAR | wxFRAME_SHAPED)
94{
95 SetBackgroundColour(wxColour(255, 255, 255));
96
97 m_color_query = new FilamentColorCodeQuery();
99 m_cur_filament_color = fila_color;
100 m_ordered_color = std::move(ordered_color);
101 wxString color_name = m_color_query->GetFilaColorName(fila_id, fila_color);
102 m_cur_color_name = new wxString(color_name);
103
104 wxBoxSizer *container_sizer = new wxBoxSizer(wxVERTICAL);
105 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
106
107 // Preview panel (always present)
108 wxBoxSizer *preview_sizer = CreatePreviewPanel(fila_color, fila_type);
109 main_sizer->AddSpacer(FromDIP(4));
110 main_sizer->Add(preview_sizer, 0, wxEXPAND, 0);
111 main_sizer->AddSpacer(FromDIP(12));
112
113 wxBoxSizer *line_sizer = CreateSeparatorLine();
114 main_sizer->Add(line_sizer, 0, wxEXPAND, 0);
115
116 // If caller passed an initial colour, reflect it in preview box.
117 if (m_is_data_loaded) {
118 // Colour grid with all filaments
119 wxScrolledWindow* color_grid = CreateColorGrid();
120 main_sizer->Add(color_grid, 0, wxEXPAND | wxTOP | wxBOTTOM, FromDIP(8));
121 }
122
123 // "More colours" button (always present)
125 main_sizer->Add(m_more_btn, 0, wxEXPAND | wxTOP, FromDIP(8));
126 //main_sizer->AddSpacer(FromDIP(8));
127
128 // OK / Cancel buttons
129 auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"});
130 m_ok_btn = dlg_btns->GetOK();
131 m_cancel_btn = dlg_btns->GetCANCEL();
132
133 container_sizer->Add(main_sizer, 1, wxEXPAND | wxALL, FromDIP(10));
134 container_sizer->Add(dlg_btns, 0, wxEXPAND);
135
136 SetSizerAndFit(container_sizer);
137 Layout();
138
139 // Position the dialog relative to the parent window
140 if (GetParent()) {
141 // Align the dialog with the sidebar
142 auto& sidebar = wxGetApp().sidebar();
143 wxPoint sidebar_pos = sidebar.GetScreenPosition();
144 wxSize sidebar_size = sidebar.GetSize();
145
146 wxPoint new_pos(
147 sidebar_pos.x + sidebar_size.GetWidth() + FromDIP(10),
148 sidebar_pos.y + FromDIP(80)
149 );
150 SetPosition(new_pos);
151 } else {
152 Centre(wxBOTH); // If no parent window, center the dialog
153 }
154
155 // Create shaped window after sizing
157#ifndef __WXGTK__
158 // Windows and macOS can set shape immediately
160#endif
161#ifdef __WXGTK__
162 // GTK platform needs to wait for window creation
163 Bind(wxEVT_CREATE, &FilamentPickerDialog::OnWindowCreate, this);
164#endif
165
166 wxGetApp().UpdateDlgDarkUI(this);
167 Layout();
168 // Set window transparency
169 SetTransparent(255);
170 BindEvents();
171
172 // Start click detection timer for outside click detection
174}
#define _L(s)
Definition OBJ.cpp:34
Button * m_ok_btn
Definition FilamentPickerDialog.hpp:94
std::optional< FilamentColorPickerValue > m_ordered_color
Definition FilamentPickerDialog.hpp:104
void SetWindowShape()
Definition FilamentPickerDialog.cpp:215
wxBoxSizer * CreatePreviewPanel(const FilamentColor &fila_color, const std::string &fila_type)
Definition FilamentPickerDialog.cpp:248
wxString * m_cur_color_name
Definition FilamentPickerDialog.hpp:99
wxScrolledWindow * CreateColorGrid()
Definition FilamentPickerDialog.cpp:378
Button * m_more_btn
Definition FilamentPickerDialog.hpp:93
void StartClickDetection()
Definition FilamentPickerDialog.cpp:767
FilamentColor m_cur_filament_color
Definition FilamentPickerDialog.hpp:103
bool LoadFilamentData(const wxString &fila_id)
Definition FilamentPickerDialog.cpp:229
Button * m_cancel_btn
Definition FilamentPickerDialog.hpp:95
FilamentColorCodeQuery * m_color_query
Definition FilamentPickerDialog.hpp:100
void CreateMoreInfoButton()
Definition FilamentPickerDialog.cpp:566
wxBoxSizer * CreateSeparatorLine()
Definition FilamentPickerDialog.cpp:365
void BindEvents()
Definition FilamentPickerDialog.cpp:572
bool m_is_data_loaded
Definition FilamentPickerDialog.hpp:98
void CreateShapedBitmap()
Definition FilamentPickerDialog.cpp:188

References _L, BindEvents(), CreateColorGrid(), CreateMoreInfoButton(), CreatePreviewPanel(), CreateSeparatorLine(), CreateShapedBitmap(), LoadFilamentData(), m_cancel_btn, m_color_query, m_cur_color_name, m_cur_filament_color, m_is_data_loaded, m_more_btn, m_ok_btn, m_ordered_color, SetWindowShape(), and StartClickDetection().

Here is the call graph for this function:

◆ ~FilamentPickerDialog()

Slic3r::GUI::FilamentPickerDialog::~FilamentPickerDialog ( )
virtual
177{
178 // Clean up all timers
180
181 delete m_color_query;
182 m_color_query = nullptr;
183
184 delete m_cur_color_name;
185 m_cur_color_name = nullptr;
186}
void CleanupTimers()
Definition FilamentPickerDialog.cpp:787

References CleanupTimers(), m_color_query, and m_cur_color_name.

Here is the call graph for this function:

Member Function Documentation

◆ BindEvents()

void Slic3r::GUI::FilamentPickerDialog::BindEvents ( )
private
573{
574 // Bind mouse events for window dragging
575 Bind(wxEVT_LEFT_DOWN, &FilamentPickerDialog::OnMouseLeftDown, this);
576 Bind(wxEVT_MOTION, &FilamentPickerDialog::OnMouseMove, this);
577 Bind(wxEVT_LEFT_UP, &FilamentPickerDialog::OnMouseLeftUp, this);
578
579 // Essential window events
580 Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) {
581 if (HasCapture()) {
582 ReleaseMouse();
583 }
584 event.Skip();
585 });
586
587 // Bind more colors button event
588 if (m_more_btn) {
589 m_more_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
590 // Pause click detection while color picker is open
592
593 FilamentColorPickerValue current;
594 if (m_ordered_color) {
595 current = *m_ordered_color;
596 } else {
597 for (const auto& color : m_cur_filament_color.m_colors)
598 current.colors.push_back(color.GetAsString(wxC2S_HTML_SYNTAX).ToStdString());
599 current.gradient = m_cur_filament_color.m_color_type == FilamentColor::ColorType::GRADIENT_CLR;
600 }
601 const auto initial = filament_color_picker_initial(current);
602 std::optional<ColorSelection> selected;
603 {
604 ColorPickerDialog dialog(this, initial, {true, true}, !filament_color_picker_selection(current), m_more_btn);
605 if (dialog.ShowModal() == wxID_OK)
606 selected = dialog.selection();
607 }
609 if (!filament_color_picker_changed(initial, selected))
610 return;
611
612 m_custom_selection = selected;
614 m_selection_changed = true;
615 std::vector<wxColour> colors;
616 m_cur_filament_color.m_colors.clear();
617 for (const auto& color : m_ordered_color->colors) {
618 colors.emplace_back(wxString::FromUTF8(color));
619 m_cur_filament_color.m_colors.insert(colors.back());
620 }
622 UpdateCustomColorPreview(colors, m_ordered_color->gradient);
623 UpdateButtonStates(nullptr);
624 });
625 }
626
627 // Bind OK button event
628 if (m_ok_btn) {
629 m_ok_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
630 EndModal(wxID_OK);
631 });
632 }
633
634 // Bind Cancel button event
635 if (m_cancel_btn) {
636 m_cancel_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
637 EndModal(wxID_CANCEL);
638 });
639 }
640}
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305
void OnMouseLeftDown(wxMouseEvent &event)
Definition FilamentPickerDialog.cpp:650
bool m_selection_changed
Definition FilamentPickerDialog.hpp:106
std::optional< ColorSelection > m_custom_selection
Definition FilamentPickerDialog.hpp:105
void OnMouseMove(wxMouseEvent &event)
Definition FilamentPickerDialog.cpp:675
void StopClickDetection()
Definition FilamentPickerDialog.cpp:778
void UpdateButtonStates(wxBitmapButton *selected_btn)
Definition FilamentPickerDialog.cpp:548
void UpdateCustomColorPreview(const std::vector< wxColour > &colors, bool gradient)
Definition FilamentPickerDialog.cpp:523
void OnMouseLeftUp(wxMouseEvent &event)
Definition FilamentPickerDialog.cpp:687
FilamentColorPickerValue filament_color_picker_result(const ColorSelection &selection)
Definition ColorPickerDialog.cpp:259
bool filament_color_picker_changed(const ColorSelection &initial, const std::optional< ColorSelection > &result)
Definition ColorPickerDialog.cpp:273
std::optional< ColorSelection > filament_color_picker_selection(const FilamentColorPickerValue &value)
Definition ColorPickerDialog.cpp:241
ColorSelection filament_color_picker_initial(const FilamentColorPickerValue &value)
Definition ColorPickerDialog.cpp:246
@ GRADIENT_CLR
Definition EncodedFilament.hpp:82
@ SINGLE_CLR
Definition EncodedFilament.hpp:80

References Slic3r::GUI::FilamentColorPickerValue::colors, Slic3r::GUI::DPIDialog::EndModal(), Slic3r::GUI::filament_color_picker_changed(), Slic3r::GUI::filament_color_picker_initial(), Slic3r::GUI::filament_color_picker_result(), Slic3r::GUI::filament_color_picker_selection(), Slic3r::GUI::FilamentColorPickerValue::gradient, Slic3r::FilamentColor::GRADIENT_CLR, m_cancel_btn, m_cur_filament_color, m_custom_selection, m_more_btn, m_ok_btn, m_ordered_color, m_selection_changed, OnMouseLeftDown(), OnMouseLeftUp(), OnMouseMove(), Slic3r::GUI::ColorPickerDialog::selection(), Slic3r::FilamentColor::SINGLE_CLR, StartClickDetection(), StopClickDetection(), UpdateButtonStates(), and UpdateCustomColorPreview().

Referenced by FilamentPickerDialog().

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

◆ CleanupTimers()

void Slic3r::GUI::FilamentPickerDialog::CleanupTimers ( )
protected
788{
790
791 if (m_flash_timer) {
792 m_flash_timer->Stop();
793 delete m_flash_timer;
794 m_flash_timer = nullptr;
795 }
796}
wxTimer * m_flash_timer
Definition FilamentPickerDialog.hpp:120

References m_flash_timer, and StopClickDetection().

Referenced by ~FilamentPickerDialog().

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

◆ CreateColorBitmap()

void Slic3r::GUI::FilamentPickerDialog::CreateColorBitmap ( const FilamentColor & fila_color)
private
266{
267 m_color_demo = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap, wxDefaultPosition, COLOR_DEMO_SIZE, 0);
268
269 // Generate bitmap content
270 if (fila_color.ColorCount() > 0) {
271 std::vector<wxColour> wx_colors(fila_color.m_colors.begin(), fila_color.m_colors.end());
272 wxBitmap init_bmp = create_filament_bitmap(wx_colors, COLOR_DEMO_SIZE,
273 fila_color.m_color_type == FilamentColor::ColorType::GRADIENT_CLR);
274 m_color_demo->SetBitmap(init_bmp);
275 }
276 else{
277 std::vector<wxColour> wx_colors;
278 wx_colors.push_back(wxNullColour);
279 wxBitmap init_bmp = create_filament_bitmap(wx_colors, COLOR_DEMO_SIZE, false);
280 m_color_demo->SetBitmap(init_bmp);
281 }
282}
#define COLOR_DEMO_SIZE
Definition FilamentPickerDialog.cpp:47
wxStaticBitmap * m_color_demo
Definition FilamentPickerDialog.hpp:89
wxBitmap create_filament_bitmap(const std::vector< wxColour > &colors, const wxSize &size, bool force_gradient)
Definition FilamentBitmapUtils.cpp:415

References COLOR_DEMO_SIZE, Slic3r::FilamentColor::ColorCount(), Slic3r::GUI::create_filament_bitmap(), Slic3r::FilamentColor::GRADIENT_CLR, m_color_demo, Slic3r::FilamentColor::m_color_type, and Slic3r::FilamentColor::m_colors.

Referenced by CreatePreviewPanel().

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

◆ CreateColorGrid()

wxScrolledWindow * Slic3r::GUI::FilamentPickerDialog::CreateColorGrid ( )
private
379{
380 if (!m_cur_color_codes) return nullptr;
381
382 FilamentColor2CodeMap* color_map = m_cur_color_codes->GetFilamentColor2CodeMap();
383 if (!color_map) return nullptr;
384
385 // Calculate required row count
386 int total_colors = color_map->size();
387 int needed_rows = (total_colors + COLS - 1) / COLS; // round-up division
388 bool need_scroll = needed_rows > MAX_VISIBLE_ROWS;
389
390 // Create a vertical-only scrolled window
391 wxScrolledWindow* scroll_win = new wxScrolledWindow(
392 this,
393 wxID_ANY,
394 wxDefaultPosition,
395 wxDefaultSize,
396 wxVSCROLL | wxNO_BORDER
397 );
398
399 wxGridSizer* grid_sizer = new wxGridSizer(needed_rows, COLS, GRID_GAP, GRID_GAP);
400
401 if (!color_map->empty()) {
402 for (const auto& color_pair : *color_map) {
403 const FilamentColor& fila_color = color_pair.first; // color info
404 FilamentColorCode* color_code = color_pair.second; // color code
405
406 if (!color_code) continue;
407 std::vector<wxColour> wx_colors(fila_color.m_colors.begin(), fila_color.m_colors.end());
408 wxBitmap btn_bmp = create_filament_bitmap(
409 wx_colors,
411 fila_color.m_color_type == FilamentColor::ColorType::GRADIENT_CLR
412 );
413
414 if (!btn_bmp.IsOk()) {
415 BOOST_LOG_TRIVIAL(error) << "Failed to create bitmap for filament " << color_code->GetFilaColorCode().ToStdString();
416 continue;
417 }
418
419 wxBitmapButton* btn = new wxBitmapButton(
420 scroll_win,
421 wxID_ANY,
422 btn_bmp,
423 wxDefaultPosition,
425 wxBU_EXACTFIT | wxNO_BORDER
426 );
427
428 if (btn) {
429 // Remove any default background and borders
430 btn->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
431
432 // Set tooltip with filament information
433 wxString tooltip = wxString::Format("%s", color_code->GetFilaColorName());
434 btn->SetToolTip(tooltip);
435
436 // Check if this color matches the current color name and set as selected
437 bool is_matching_color = (m_cur_color_name &&
438 !m_cur_color_name->IsEmpty() &&
439 *m_cur_color_name == color_code->GetFilaColorName());
440
441 if (is_matching_color) {
442 m_cur_filament_color = color_code->GetFilaColor();
443 m_cur_selected_btn = btn;
444 UpdatePreview(*color_code);
445 btn->Bind(wxEVT_PAINT, &FilamentPickerDialog::OnButtonPaint, this);
446 }
447
448 // Bind click
449 btn->Bind(wxEVT_LEFT_DOWN, [this, btn, color_code](wxMouseEvent& evt) {
450 m_selection_changed = true;
451 m_ordered_color.reset();
452 m_custom_selection.reset();
453 m_cur_filament_color = color_code->GetFilaColor();
454 UpdatePreview(*color_code);
456 evt.Skip();
457 });
458
459 // Hover highlight
460 btn->Bind(wxEVT_ENTER_WINDOW, [](wxMouseEvent& evt) {
461 evt.Skip();
462 });
463
464 btn->Bind(wxEVT_LEAVE_WINDOW, [](wxMouseEvent& evt) {
465 evt.Skip();
466 });
467
468 grid_sizer->Add(btn, 0, wxALL | wxALIGN_CENTER, FromDIP(1));
469 }
470 }
471 }
472
473 scroll_win->SetSizer(grid_sizer);
474
475 if (need_scroll) {
476 int row_height = COLOR_BTN_SIZE.GetHeight() + FromDIP(2);
477 int col_width = COLOR_BTN_SIZE.GetWidth() + FromDIP(4);
478
479 // Reserve space for vertical scrollbar so it doesn't overlay content
480 int scrollbar_width = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
481
482 // Set minimum visible area (including scrollbar width)
483 scroll_win->SetMinSize(wxSize(col_width * COLS + scrollbar_width, row_height * MAX_VISIBLE_ROWS));
484
485 // Let wxScrolledWindow calculate appropriate virtual size
486 scroll_win->FitInside();
487 scroll_win->SetScrollRate(0, row_height);
488 } else {
489 scroll_win->FitInside();
490 scroll_win->SetScrollRate(0, 0);
491 }
492
493 return scroll_win;
494}
#define COLOR_BTN_SIZE
Definition FilamentPickerDialog.cpp:49
#define COLOR_BTN_BITMAP_SIZE
Definition FilamentPickerDialog.cpp:48
#define GRID_GAP
Definition FilamentPickerDialog.cpp:50
#define COLS
Definition FilamentPickerDialog.cpp:51
#define MAX_VISIBLE_ROWS
Definition FilamentPickerDialog.cpp:52
void UpdatePreview(const FilamentColorCode &filament)
Definition FilamentPickerDialog.cpp:496
void OnButtonPaint(wxPaintEvent &event)
Definition FilamentPickerDialog.cpp:696
FilamentColorCodes * m_cur_color_codes
Definition FilamentPickerDialog.hpp:101
wxBitmapButton * m_cur_selected_btn
Definition FilamentPickerDialog.hpp:102
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxMouseEvent
Definition CameraPopup.cpp:47
std::map< FilamentColor, FilamentColorCode *, EncodedFilaColorEqual > FilamentColor2CodeMap
Definition EncodedFilament.hpp:155

References COLOR_BTN_BITMAP_SIZE, COLOR_BTN_SIZE, COLS, Slic3r::GUI::create_filament_bitmap(), StateColor::darkModeColorFor(), Slic3r::FilamentColorCode::GetFilaColor(), Slic3r::FilamentColorCode::GetFilaColorCode(), Slic3r::FilamentColorCode::GetFilaColorName(), Slic3r::FilamentColor::GRADIENT_CLR, GRID_GAP, Slic3r::FilamentColor::m_color_type, Slic3r::FilamentColor::m_colors, m_cur_color_codes, m_cur_color_name, m_cur_filament_color, m_cur_selected_btn, m_custom_selection, m_ordered_color, m_selection_changed, MAX_VISIBLE_ROWS, OnButtonPaint(), UpdateButtonStates(), UpdatePreview(), and Slic3r::GUI::wxMouseEvent.

Referenced by FilamentPickerDialog().

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

◆ CreateInfoSection()

wxBoxSizer * Slic3r::GUI::FilamentPickerDialog::CreateInfoSection ( )
private
285{
286 wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
287
288 // Create the container box
289 wxStaticBox *info_box = new wxStaticBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition);
290 info_box->SetSize(wxSize(FromDIP(240), FromDIP(24)));
291 info_box->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
292 wxStaticBoxSizer *box_sizer = new wxStaticBoxSizer(info_box, wxHORIZONTAL);
293
294 // Create labels with ellipsize style for text overflow
295 m_label_preview_color = new wxStaticText(this, wxID_ANY, _L("Custom Color"),
296 wxDefaultPosition, wxDefaultSize,
297 wxST_ELLIPSIZE_END);
298 m_label_preview_idx = new wxStaticText(this, wxID_ANY, "",
299 wxDefaultPosition, wxDefaultSize); // No size limit, no ellipsis
300 m_label_preview_type = new wxStaticText(this, wxID_ANY, "",
301 wxDefaultPosition, wxSize(FromDIP(220), FromDIP(16)),
302 wxST_ELLIPSIZE_END);
303
304 // Set maximum width for color label to enable proper ellipsis behavior
305 m_label_preview_color->SetMaxSize(wxSize(FromDIP(160), -1));
306
307 // Setup fonts
308 wxFont bold_font = m_label_preview_color->GetFont();
309 bold_font.SetWeight(wxFONTWEIGHT_BOLD);
310#ifdef __WXMSW__
311 bold_font.SetPointSize(FromDIP(8));
312#endif
313 m_label_preview_color->SetFont(bold_font);
314 m_label_preview_idx->SetFont(bold_font);
315
316 m_label_preview_type->SetForegroundColour(wxColour(128, 128, 128));
317
318 // Layout with platform-specific spacing
319#ifdef __WXMSW__
320 int spacer = FromDIP(2), vPadding = FromDIP(0), gap1 = FromDIP(-6), gap2 = FromDIP(4);
321#else
322 int spacer = FromDIP(0), vPadding = FromDIP(-1), gap1 = FromDIP(0), gap2 = FromDIP(2);
323#endif
324
325 box_sizer->AddSpacer(spacer);
326 box_sizer->Add(m_label_preview_color, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, vPadding);
327 box_sizer->AddSpacer(FromDIP(2));
328 box_sizer->Add(m_label_preview_idx, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, vPadding);
329 box_sizer->AddSpacer(spacer);
330
331 main_sizer->Add(box_sizer, 0, wxALIGN_CENTER_VERTICAL | wxTOP, gap1);
332 main_sizer->AddSpacer(gap2);
333 main_sizer->Add(m_label_preview_type, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(6));
334
335 return main_sizer;
336}
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
wxStaticText * m_label_preview_idx
Definition FilamentPickerDialog.hpp:91
wxStaticText * m_label_preview_type
Definition FilamentPickerDialog.hpp:92
wxStaticText * m_label_preview_color
Definition FilamentPickerDialog.hpp:90

References _L, StateColor::darkModeColorFor(), m_label_preview_color, m_label_preview_idx, m_label_preview_type, and wxStaticText.

Referenced by CreatePreviewPanel().

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

◆ CreateMoreInfoButton()

void Slic3r::GUI::FilamentPickerDialog::CreateMoreInfoButton ( )
private
567{
568 m_more_btn = new Button(this, "+ " + _L("More Colors"));
570}
@ Regular
Definition Button.hpp:24
@ Expanded
Definition Button.hpp:38

References _L, Expanded, m_more_btn, and Regular.

Referenced by FilamentPickerDialog().

Here is the caller graph for this function:

◆ CreatePreviewPanel()

wxBoxSizer * Slic3r::GUI::FilamentPickerDialog::CreatePreviewPanel ( const FilamentColor & fila_color,
const std::string & fila_type )
private
249{
250 wxBoxSizer *preview_sizer = new wxBoxSizer(wxHORIZONTAL);
251
252 // Create color preview bitmap
253 CreateColorBitmap(fila_color);
254 preview_sizer->Add(m_color_demo, 0, wxALIGN_CENTER_VERTICAL, 0);
255 preview_sizer->AddSpacer(FromDIP(12));
256
257 // Create info labels section
258 wxBoxSizer *label_sizer = CreateInfoSection();
259 SetupLabelsContent(fila_color, fila_type);
260 preview_sizer->Add(label_sizer, 1, wxALIGN_CENTER_VERTICAL, 0);
261
262 return preview_sizer;
263}
void SetupLabelsContent(const FilamentColor &fila_color, const std::string &fila_type)
Definition FilamentPickerDialog.cpp:338
void CreateColorBitmap(const FilamentColor &fila_color)
Definition FilamentPickerDialog.cpp:265
wxBoxSizer * CreateInfoSection()
Definition FilamentPickerDialog.cpp:284

References CreateColorBitmap(), CreateInfoSection(), m_color_demo, and SetupLabelsContent().

Referenced by FilamentPickerDialog().

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

◆ CreateSeparatorLine()

wxBoxSizer * Slic3r::GUI::FilamentPickerDialog::CreateSeparatorLine ( )
private
366{
367 wxBoxSizer *line_sizer = new wxBoxSizer(wxHORIZONTAL);
368 wxPanel* separator_line = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, FromDIP(1)));
369 separator_line->SetBackgroundColour(wxColour(238,238,238));
370 wxStaticText* line_text = new wxStaticText(this, wxID_ANY, _L("Official Filament"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
371 line_text->SetForegroundColour(wxColour(128, 128, 128));
372 line_sizer->Add(line_text, 0, wxEXPAND, 0);
373 line_sizer->AddSpacer(FromDIP(8));
374 line_sizer->Add(separator_line, 1, wxALIGN_CENTER_VERTICAL, 0);
375 return line_sizer;
376}

References _L, and wxStaticText.

Referenced by FilamentPickerDialog().

Here is the caller graph for this function:

◆ CreateShapedBitmap()

void Slic3r::GUI::FilamentPickerDialog::CreateShapedBitmap ( )
private
189{
190 wxSize size = GetSize();
191 if (size.GetWidth() <= 0 || size.GetHeight() <= 0) {
192 return;
193 }
194
195 // Create a bitmap with alpha channel
196 m_shape_bmp.Create(size.GetWidth(), size.GetHeight(), 32);
197
198 wxMemoryDC dc;
199 dc.SelectObject(m_shape_bmp);
200
201 dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
202 dc.Clear();
203
204 // Draw main white shape on top, positioned to let shadow show through
205 dc.SetBrush(wxBrush(wxColour(255, 255, 255, 255)));
206 dc.SetPen(*wxTRANSPARENT_PEN);
207 dc.DrawRoundedRectangle(0, 0,
208 size.GetWidth(),
209 size.GetHeight(),
210 FromDIP(m_corner_radius));
211
212 dc.SelectObject(wxNullBitmap);
213}
int m_corner_radius
Definition FilamentPickerDialog.hpp:110
wxBitmap m_shape_bmp
Definition FilamentPickerDialog.hpp:109

References m_corner_radius, and m_shape_bmp.

Referenced by FilamentPickerDialog(), and on_dpi_changed().

Here is the caller graph for this function:

◆ em_unit()

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

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

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

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

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

◆ GetCustomColorSelection()

const std::optional< ColorSelection > & Slic3r::GUI::FilamentPickerDialog::GetCustomColorSelection ( ) const
inline
35{ return m_custom_selection; }

References m_custom_selection.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox().

Here is the caller graph for this function:

◆ GetSelectedColour()

wxColour Slic3r::GUI::FilamentPickerDialog::GetSelectedColour ( ) const
57{
58 if (!m_color_demo) return wxNullColour;
59 return m_color_demo->GetBackgroundColour();
60}

References m_color_demo.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox().

Here is the caller graph for this function:

◆ GetSelectedFilamentColor()

const FilamentColor & Slic3r::GUI::FilamentPickerDialog::GetSelectedFilamentColor ( ) const
inline
38{ return m_cur_filament_color; }

References m_cur_filament_color.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox().

Here is the caller graph for this function:

◆ HasSelectionChanged()

bool Slic3r::GUI::FilamentPickerDialog::HasSelectionChanged ( ) const
inline
34{ return m_selection_changed; }

References m_selection_changed.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox().

Here is the caller graph for this function:

◆ is_new_scale_factor()

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

◆ IsClickOnTopMostWindow()

bool Slic3r::GUI::FilamentPickerDialog::IsClickOnTopMostWindow ( const wxPoint & mouse_pos)
protected
728{
729 wxWindow* main_window = wxGetApp().mainframe;
730 if (!main_window) {
731 return false;
732 }
733
734 wxRect main_rect = main_window->GetScreenRect();
735 bool in_main_app = main_rect.Contains(mouse_pos);
736
737 if (!in_main_app) {
738 return false;
739 }
740
741#ifdef _WIN32
742 // Windows: Use WindowFromPoint to check actual topmost window
743 POINT pt = {mouse_pos.x, mouse_pos.y};
744 HWND hwnd_at_point = WindowFromPoint(pt);
745 HWND main_hwnd = (HWND)main_window->GetHandle();
746
747 // Check if clicked window belongs to our main window hierarchy
748 HWND parent_hwnd = hwnd_at_point;
749 while (parent_hwnd != NULL) {
750 if (parent_hwnd == main_hwnd) {
751 return true;
752 }
753 parent_hwnd = ::GetParent(parent_hwnd);
754 }
755 return false;
756
757#elif defined(__WXOSX__)
758 // macOS: Use focus and active window check
759 return (wxGetActiveWindow() == main_window) || main_window->HasFocus();
760
761#else
762 // Linux: Use focus check (similar to macOS)
763 return (wxGetActiveWindow() == main_window) || main_window->HasFocus();
764#endif
765}

Referenced by OnTimerCheck().

Here is the caller graph for this function:

◆ IsDataLoaded()

bool Slic3r::GUI::FilamentPickerDialog::IsDataLoaded ( ) const
inline
36{ return m_is_data_loaded; }

References m_is_data_loaded.

Referenced by Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox().

Here is the caller graph for this function:

◆ LoadFilamentData()

bool Slic3r::GUI::FilamentPickerDialog::LoadFilamentData ( const wxString & fila_id)
private
230{
231 m_cur_color_codes = m_color_query->GetFilaInfoMap(fila_id);
232
233 if (!m_cur_color_codes) {
234 BOOST_LOG_TRIVIAL(warning) << "No color codes found for filament ID: " << fila_id.ToStdString();
235 return false;
236 }
237
238 FilamentColor2CodeMap* color_map = m_cur_color_codes->GetFilamentColor2CodeMap();
239 if (!color_map) {
240 BOOST_LOG_TRIVIAL(warning) << "No color map found for filament ID: " << fila_id.ToStdString();
241 return false;
242 }
243
244 BOOST_LOG_TRIVIAL(info) << "Successfully loaded " << color_map->size() << " color variants for filament " << fila_id.ToStdString();
245 return !color_map->empty();
246}

References m_color_query, and m_cur_color_codes.

Referenced by FilamentPickerDialog().

Here is the caller graph for this function:

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::FilamentPickerDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprotectedvirtual

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

63{
64 // Handle DPI change
67 Refresh();
68 Layout();
69}

References CreateShapedBitmap(), and SetWindowShape().

Here is the call graph for this function:

◆ on_sys_color_changed()

◆ OnButtonPaint()

void Slic3r::GUI::FilamentPickerDialog::OnButtonPaint ( wxPaintEvent & event)
protected
697{
698 wxWindow* button = dynamic_cast<wxWindow*>(event.GetEventObject());
699 if (!button) {
700 event.Skip();
701 return;
702 }
703
704 // Create paint DC and let default painting happen first
705 wxPaintDC dc(button);
706
707 //Clear the button with white background
708 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
709 dc.SetPen(*wxTRANSPARENT_PEN);
710 dc.DrawRectangle(0, 0, COLOR_BTN_SIZE.GetWidth(), COLOR_BTN_SIZE.GetHeight());
711
712 // Draw the bitmap in the center
713 wxBitmapButton* bmpBtn = dynamic_cast<wxBitmapButton*>(button);
714 if (bmpBtn && bmpBtn->GetBitmap().IsOk()) {
715 wxBitmap bmp = bmpBtn->GetBitmap();
716 int x = (COLOR_BTN_SIZE.GetWidth() - COLOR_BTN_BITMAP_SIZE.GetWidth()) / 2;
717 int y = (COLOR_BTN_SIZE.GetHeight() - COLOR_BTN_BITMAP_SIZE.GetHeight()) / 2;
718 dc.DrawBitmap(bmp, x, y, true);
719 }
720
721 // Draw the green border
722 dc.SetPen(wxPen(wxColour("#009688"), 2)); // Green pen, 2px thick
723 dc.SetBrush(*wxTRANSPARENT_BRUSH);
724 dc.DrawRectangle(1, 1, COLOR_BTN_SIZE.GetWidth() - 1, COLOR_BTN_SIZE.GetHeight() - 1);
725}
bool button(const IconManager::Icon &activ, const IconManager::Icon &hover, const IconManager::Icon &disable, bool disabled)
Use icon as button with 3 states activ hover and disabled.
Definition IconManager.cpp:418

References Slic3r::GUI::button(), COLOR_BTN_BITMAP_SIZE, and COLOR_BTN_SIZE.

Referenced by CreateColorGrid(), and UpdateButtonStates().

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

◆ OnFlashTimer()

void Slic3r::GUI::FilamentPickerDialog::OnFlashTimer ( wxTimerEvent & event)
protected
833{
834 // 5 flashes = 10 steps (semi-transparent -> opaque for each flash)
835 if (m_flash_step < 10) {
836 if (m_flash_step % 2 == 0) {
837 // Even steps: semi-transparent
838 SetTransparent(120);
839 } else {
840 // Odd steps: opaque
841 SetTransparent(255);
842 }
843
844 m_flash_step++;
845 } else {
846 // Complete flash sequence
847 SetTransparent(255);
848 m_flash_timer->Stop();
849 delete m_flash_timer;
850 m_flash_timer = nullptr;
851 }
852}
int m_flash_step
Definition FilamentPickerDialog.hpp:121

References m_flash_step, and m_flash_timer.

Referenced by StartFlashing().

Here is the caller graph for this function:

◆ OnMouseLeftDown()

void Slic3r::GUI::FilamentPickerDialog::OnMouseLeftDown ( wxMouseEvent & event)
protected
651{
652 // Only allow dragging from empty areas (not from buttons or other controls)
653 wxWindow* hit_window = wxFindWindowAtPoint(ClientToScreen(event.GetPosition()));
654 if (hit_window && hit_window != this) {
655 // Click was on a child control, don't drag
656 event.Skip();
657 return;
658 }
659
660 // Release any existing capture first
661 if (HasCapture()) {
662 ReleaseMouse();
663 }
664
665 CaptureMouse();
666 wxPoint pt = ClientToScreen(event.GetPosition());
667 wxPoint origin = GetPosition();
668 int dx = pt.x - origin.x;
669 int dy = pt.y - origin.y;
670 m_drag_delta = wxPoint(dx, dy);
671
672 // Don't skip the event for dragging to work properly
673}
wxPoint m_drag_delta
Definition FilamentPickerDialog.hpp:113

References m_drag_delta, and Slic3r::GUI::wxMouseEvent.

Referenced by BindEvents().

Here is the caller graph for this function:

◆ OnMouseLeftUp()

void Slic3r::GUI::FilamentPickerDialog::OnMouseLeftUp ( wxMouseEvent & event)
protected
688{
689 if (HasCapture()) {
690 ReleaseMouse();
691 }
692
693 event.Skip();
694}

References Slic3r::GUI::wxMouseEvent.

Referenced by BindEvents().

Here is the caller graph for this function:

◆ OnMouseMove()

void Slic3r::GUI::FilamentPickerDialog::OnMouseMove ( wxMouseEvent & event)
protected
676{
677 wxPoint pt = event.GetPosition();
678
679 if (event.Dragging() && event.LeftIsDown() && HasCapture()) {
680 wxPoint pos = ClientToScreen(pt);
681 Move(wxPoint(pos.x - m_drag_delta.x, pos.y - m_drag_delta.y));
682 }
683
684 event.Skip();
685}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References m_drag_delta, and Slic3r::GUI::wxMouseEvent.

Referenced by BindEvents().

Here is the caller graph for this function:

◆ OnTimerCheck()

void Slic3r::GUI::FilamentPickerDialog::OnTimerCheck ( wxTimerEvent & event)
protected
800{
801 static wxPoint last_mouse_pos(-1, -1);
802 wxPoint current_pos = wxGetMousePosition();
803
804 // If the mouse position and button state haven't changed, skip the detection
805 if (current_pos == last_mouse_pos &&
806 wxGetMouseState().LeftIsDown() == m_last_mouse_down) {
807 return;
808 }
809
810 last_mouse_pos = current_pos;
811
812 wxPoint mouse_pos = wxGetMousePosition();
813 wxRect window_rect = GetScreenRect();
814
815 // Check if mouse button state changed
816 bool mouse_down = wxGetMouseState().LeftIsDown();
817
818 if (mouse_down != m_last_mouse_down) {
819 if (mouse_down) {
820 bool in_dialog = window_rect.Contains(mouse_pos);
821 bool is_valid_click = IsClickOnTopMostWindow(mouse_pos);
822
823 if (is_valid_click && !in_dialog) {
825 }
826 }
827
828 m_last_mouse_down = mouse_down;
829 }
830}
bool m_last_mouse_down
Definition FilamentPickerDialog.hpp:117
void StartFlashing()
Definition FilamentPickerDialog.cpp:72
bool IsClickOnTopMostWindow(const wxPoint &mouse_pos)
Definition FilamentPickerDialog.cpp:727

References IsClickOnTopMostWindow(), m_last_mouse_down, and StartFlashing().

Referenced by StartClickDetection().

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

◆ prev_scale_factor()

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

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::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

◆ scale_factor()

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

◆ set_em_unit()

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

◆ set_prev_scale_factor()

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

◆ set_scale_factor()

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

◆ SetupLabelsContent()

void Slic3r::GUI::FilamentPickerDialog::SetupLabelsContent ( const FilamentColor & fila_color,
const std::string & fila_type )
private
339{
340 m_label_preview_type->SetLabel(from_u8(fila_type));
341 if (m_cur_color_name && !m_cur_color_name->IsEmpty()) {
343
344 // Try to get additional color code information
345 if (m_cur_color_codes) {
346 FilamentColorCode *color_code = m_cur_color_codes->GetColorCode(fila_color);
347 if (color_code) {
348 m_label_preview_idx->SetLabel(wxString::Format("(%s)", color_code->GetFilaColorCode()));
349 }
350 }
351 }
352 else{
353 if (fila_color.ColorCount() == 0){
354 m_label_preview_color->SetLabel(_L("Null Color"));
355 }
356 else if (fila_color.ColorCount() == 1) {
357 m_label_preview_color->SetLabel(fila_color.m_colors.begin()->GetAsString(wxC2S_HTML_SYNTAX));
358 }
359 else{
360 m_label_preview_color->SetLabel(_L("Multiple Color"));
361 }
362 }
363}
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References _L, Slic3r::FilamentColor::ColorCount(), Slic3r::GUI::from_u8(), Slic3r::FilamentColorCode::GetFilaColorCode(), Slic3r::FilamentColor::m_colors, m_cur_color_codes, m_cur_color_name, m_label_preview_color, m_label_preview_idx, and m_label_preview_type.

Referenced by CreatePreviewPanel().

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

◆ SetWindowShape()

void Slic3r::GUI::FilamentPickerDialog::SetWindowShape ( )
private
216{
217 if (!m_shape_bmp.IsOk()) {
218 return;
219 }
220
221 // Create a region from the bitmap using magenta as transparent mask color
222 wxRegion region(m_shape_bmp, wxColour(0, 0, 0));
223
224 if (region.IsOk()) {
225 SetShape(region);
226 }
227}

References m_shape_bmp.

Referenced by FilamentPickerDialog(), and on_dpi_changed().

Here is the caller graph for this function:

◆ ShowModal()

◆ StartClickDetection()

void Slic3r::GUI::FilamentPickerDialog::StartClickDetection ( )
protected
768{
769 if (m_click_timer) {
771 }
772
773 m_click_timer = new wxTimer(this, wxID_ANY);
774 Bind(wxEVT_TIMER, &FilamentPickerDialog::OnTimerCheck, this, m_click_timer->GetId());
775 m_click_timer->Start(50);
776}
void OnTimerCheck(wxTimerEvent &event)
Definition FilamentPickerDialog.cpp:799
wxTimer * m_click_timer
Definition FilamentPickerDialog.hpp:116

References m_click_timer, OnTimerCheck(), and StopClickDetection().

Referenced by FilamentPickerDialog(), and BindEvents().

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

◆ StartFlashing()

void Slic3r::GUI::FilamentPickerDialog::StartFlashing ( )
private
73{
74 // Stop any existing flash timer
75 if (m_flash_timer) {
76 m_flash_timer->Stop();
77 delete m_flash_timer;
78 }
79
80 m_flash_timer = new wxTimer(this, wxID_ANY + 1);
81 Bind(wxEVT_TIMER, &FilamentPickerDialog::OnFlashTimer, this, m_flash_timer->GetId());
82 m_flash_step = 0;
83 m_flash_timer->Start(50);
84}
void OnFlashTimer(wxTimerEvent &event)
Definition FilamentPickerDialog.cpp:832

References m_flash_step, m_flash_timer, and OnFlashTimer().

Referenced by OnTimerCheck().

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

◆ StopClickDetection()

void Slic3r::GUI::FilamentPickerDialog::StopClickDetection ( )
protected
779{
780 if (m_click_timer) {
781 m_click_timer->Stop();
782 delete m_click_timer;
783 m_click_timer = nullptr;
784 }
785}

References m_click_timer.

Referenced by BindEvents(), CleanupTimers(), and StartClickDetection().

Here is the caller graph for this function:

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::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 }

◆ UpdateButtonStates()

void Slic3r::GUI::FilamentPickerDialog::UpdateButtonStates ( wxBitmapButton * selected_btn)
private
549{
550 // Reset selected button appearance
551 if (m_cur_selected_btn) {
552 m_cur_selected_btn->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
553 m_cur_selected_btn->Unbind(wxEVT_PAINT, &FilamentPickerDialog::OnButtonPaint, this);
554 m_cur_selected_btn->Refresh();
555 }
556
557 if (selected_btn) {
558 // Bind paint event to draw custom green border
559 selected_btn->Bind(wxEVT_PAINT, &FilamentPickerDialog::OnButtonPaint, this);
560 selected_btn->Refresh();
561 }
562
563 m_cur_selected_btn = selected_btn;
564}

References StateColor::darkModeColorFor(), m_cur_selected_btn, and OnButtonPaint().

Referenced by BindEvents(), and CreateColorGrid().

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

◆ UpdateCustomColorPreview()

void Slic3r::GUI::FilamentPickerDialog::UpdateCustomColorPreview ( const std::vector< wxColour > & colors,
bool gradient )
private
524{
525 // Update preview bitmap
526 wxBitmap bmp = create_filament_bitmap(wx_colors, COLOR_DEMO_SIZE, gradient);
527
528 if (bmp.IsOk()) {
529 BOOST_LOG_TRIVIAL(debug) << "Custom color bitmap created successfully: " << bmp.GetWidth() << "x" << bmp.GetHeight();
530 m_color_demo->SetBitmap(bmp);
531 m_color_demo->SetBackgroundColour(wx_colors.front());
532 m_color_demo->Refresh();
533 } else {
534 BOOST_LOG_TRIVIAL(error) << "Failed to create custom color bitmap";
535 }
536
537 // Update preview labels for custom color
538 wxString label;
539 for (const auto& color : wx_colors) {
540 if (!label.empty()) label += " / ";
541 label += color.GetAsString(wxC2S_HTML_SYNTAX);
542 }
543 m_label_preview_color->SetLabel(label);
544 m_label_preview_idx->SetLabel("");
545 Layout();
546}

References COLOR_DEMO_SIZE, Slic3r::GUI::create_filament_bitmap(), m_color_demo, m_label_preview_color, and m_label_preview_idx.

Referenced by BindEvents().

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

◆ UpdatePreview()

void Slic3r::GUI::FilamentPickerDialog::UpdatePreview ( const FilamentColorCode & filament)
private
497{
498 FilamentColor fila_color = color_code.GetFilaColor();
499
500 std::vector<wxColour> wx_colors(fila_color.m_colors.begin(), fila_color.m_colors.end());
501
502 // Update preview bitmap
503 wxBitmap bmp = create_filament_bitmap(wx_colors, COLOR_DEMO_SIZE,
504 fila_color.m_color_type == FilamentColor::ColorType::GRADIENT_CLR);
505
506 if (bmp.IsOk()) {
507 BOOST_LOG_TRIVIAL(debug) << "Bitmap created successfully: " << bmp.GetWidth() << "x" << bmp.GetHeight();
508 m_color_demo->SetBitmap(bmp);
509 if (!wx_colors.empty()) {
510 m_color_demo->SetBackgroundColour(wx_colors[0]);
511 }
512 m_color_demo->Refresh();
513 } else {
514 BOOST_LOG_TRIVIAL(error) << "Failed to create bitmap";
515 }
516
517 // Update preview labels
518 m_label_preview_color->SetLabel(color_code.GetFilaColorName());
519 m_label_preview_idx->SetLabel(wxString::Format("(%s)", color_code.GetFilaColorCode()));
520 Layout();
521}

References COLOR_DEMO_SIZE, Slic3r::GUI::create_filament_bitmap(), Slic3r::FilamentColorCode::GetFilaColor(), Slic3r::FilamentColorCode::GetFilaColorCode(), Slic3r::FilamentColorCode::GetFilaColorName(), Slic3r::FilamentColor::GRADIENT_CLR, m_color_demo, Slic3r::FilamentColor::m_color_type, Slic3r::FilamentColor::m_colors, m_label_preview_color, and m_label_preview_idx.

Referenced by CreateColorGrid().

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

Member Data Documentation

◆ m_can_rescale

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

◆ m_cancel_btn

Button* Slic3r::GUI::FilamentPickerDialog::m_cancel_btn {nullptr}
private
95{nullptr};

Referenced by FilamentPickerDialog(), and BindEvents().

◆ m_click_timer

wxTimer* Slic3r::GUI::FilamentPickerDialog::m_click_timer {nullptr}
private
116{nullptr};

Referenced by StartClickDetection(), and StopClickDetection().

◆ m_color_demo

wxStaticBitmap* Slic3r::GUI::FilamentPickerDialog::m_color_demo {nullptr}
private

◆ m_color_query

FilamentColorCodeQuery* Slic3r::GUI::FilamentPickerDialog::m_color_query {nullptr}
private

◆ m_corner_radius

int Slic3r::GUI::FilamentPickerDialog::m_corner_radius {8}
private
110{8};

Referenced by CreateShapedBitmap().

◆ m_cur_color_codes

FilamentColorCodes* Slic3r::GUI::FilamentPickerDialog::m_cur_color_codes {nullptr}
private
101{nullptr};

Referenced by CreateColorGrid(), LoadFilamentData(), and SetupLabelsContent().

◆ m_cur_color_name

wxString* Slic3r::GUI::FilamentPickerDialog::m_cur_color_name {nullptr}
private

◆ m_cur_filament_color

FilamentColor Slic3r::GUI::FilamentPickerDialog::m_cur_filament_color
private

◆ m_cur_selected_btn

wxBitmapButton* Slic3r::GUI::FilamentPickerDialog::m_cur_selected_btn {nullptr}
private
102{nullptr};

Referenced by CreateColorGrid(), and UpdateButtonStates().

◆ m_custom_selection

std::optional<ColorSelection> Slic3r::GUI::FilamentPickerDialog::m_custom_selection
private

◆ m_drag_delta

wxPoint Slic3r::GUI::FilamentPickerDialog::m_drag_delta
private

Referenced by OnMouseLeftDown(), and OnMouseMove().

◆ m_em_unit

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

◆ m_flash_step

int Slic3r::GUI::FilamentPickerDialog::m_flash_step {0}
private
121{0};

Referenced by OnFlashTimer(), and StartFlashing().

◆ m_flash_timer

wxTimer* Slic3r::GUI::FilamentPickerDialog::m_flash_timer {nullptr}
private
120{nullptr};

Referenced by CleanupTimers(), OnFlashTimer(), and StartFlashing().

◆ m_force_rescale

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

◆ m_is_data_loaded

bool Slic3r::GUI::FilamentPickerDialog::m_is_data_loaded {false}
private
98{false};

Referenced by FilamentPickerDialog(), and IsDataLoaded().

◆ m_label_preview_color

wxStaticText* Slic3r::GUI::FilamentPickerDialog::m_label_preview_color {nullptr}
private

◆ m_label_preview_idx

wxStaticText* Slic3r::GUI::FilamentPickerDialog::m_label_preview_idx {nullptr}
private

◆ m_label_preview_type

wxStaticText* Slic3r::GUI::FilamentPickerDialog::m_label_preview_type {nullptr}
private
92{nullptr};

Referenced by CreateInfoSection(), and SetupLabelsContent().

◆ m_last_mouse_down

bool Slic3r::GUI::FilamentPickerDialog::m_last_mouse_down {false}
private
117{false};

Referenced by OnTimerCheck().

◆ m_more_btn

Button* Slic3r::GUI::FilamentPickerDialog::m_more_btn {nullptr}
private
93{nullptr};

Referenced by FilamentPickerDialog(), BindEvents(), and CreateMoreInfoButton().

◆ m_new_font_point_size

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

◆ m_normal_font

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

◆ m_ok_btn

Button* Slic3r::GUI::FilamentPickerDialog::m_ok_btn {nullptr}
private
94{nullptr};

Referenced by FilamentPickerDialog(), and BindEvents().

◆ m_ordered_color

std::optional<FilamentColorPickerValue> Slic3r::GUI::FilamentPickerDialog::m_ordered_color
private

◆ m_prev_scale_factor

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

◆ m_scale_factor

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

◆ m_selection_changed

bool Slic3r::GUI::FilamentPickerDialog::m_selection_changed = false
private

◆ m_shape_bmp

wxBitmap Slic3r::GUI::FilamentPickerDialog::m_shape_bmp
private

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