Update Plater.cpp

This commit is contained in:
yw4z
2025-11-19 23:36:14 +03:00
parent 770e1f9e8b
commit 68ae97e111

View File

@@ -1670,13 +1670,19 @@ Sidebar::Sidebar(Plater *parent)
p->m_panel_printer_content = new wxPanel(p->scrolled, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
p->m_panel_printer_content->SetBackgroundColour(wxColour(255, 255, 255));
StateColor panel_bd_col(std::pair<wxColour, int>(wxColour("#009688"), StateColor::Pressed),
std::pair<wxColour, int>(wxColour("#009688"), StateColor::Hovered),
std::pair<wxColour, int>(wxColour("#DBDBDB"), StateColor::Normal));
struct PanelColors {
wxColour bg_normal = "#FFFFFF";
wxColour bg_focus = "#E5F0EE";
wxColour bd_normal = "#DBDBDB";
wxColour bd_hover = "#009688";
wxColour bd_focus = "#009688";
};
PanelColors panel_color;
p->panel_printer_preset = new StaticBox(p->m_panel_printer_content);
p->panel_printer_preset->SetCornerRadius(FromDIP(8));
p->panel_printer_preset->SetBorderColor(panel_bd_col);
p->panel_printer_preset->SetBorderColor(panel_color.bd_normal);
p->panel_printer_preset->SetMinSize(FromDIP(PRINTER_PANEL_SIZE));
p->panel_printer_preset->Bind(wxEVT_LEFT_DOWN, [this](auto & evt) {
p->combo_printer->wxEvtHandler::ProcessEvent(evt);
@@ -1694,12 +1700,14 @@ Sidebar::Sidebar(Plater *parent)
ScalableButton *edit_btn = new ScalableButton(p->panel_printer_preset, wxID_ANY, "edit");
edit_btn->SetToolTip(_L("Click to edit preset"));
edit_btn->Hide(); // hide for first launch
edit_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent)
{
p->editing_filament = -1;
if (p->combo_printer->switch_to_tab())
p->editing_filament = 0;
});
edit_btn->Bind(wxEVT_BUTTON, [this, panel_color](wxCommandEvent){
p->editing_filament = -1;
if (p->combo_printer->switch_to_tab())
p->editing_filament = 0;
p->panel_printer_preset->SetBorderColor(panel_color.bd_normal);
p->btn_edit_printer->Hide();
p->panel_printer_preset->Layout();
});
p->btn_edit_printer = edit_btn;
ScalableBitmap bitmap_printer(p->panel_printer_preset, "printer_placeholder", PRINTER_THUMBNAIL_SIZE.GetHeight());
p->image_printer = new wxStaticBitmap(p->panel_printer_preset, wxID_ANY, bitmap_printer.bmp(), wxDefaultPosition, FromDIP(PRINTER_THUMBNAIL_SIZE), 0);
@@ -1708,18 +1716,13 @@ Sidebar::Sidebar(Plater *parent)
});
PlaterPresetComboBox *combo_printer = new PlaterPresetComboBox(p->panel_printer_preset, Preset::TYPE_PRINTER);
//combo_printer->SetWindowStyle(combo_printer->GetWindowStyle() & ~wxALIGN_MASK | wxALIGN_CENTER_HORIZONTAL);
combo_printer->SetBorderWidth(0);
p->combo_printer = combo_printer;
// ORCA paint whole combobox on focus
auto printer_focus_bg = [this, panel_bd_col](bool focused){
auto bg_color = StateColor::darkModeColorFor(wxColour(focused ? "#E5F0EE" : "#FFFFFF"));
auto panel = p->panel_printer_preset;
panel->SetBackgroundColor(bg_color);
if(focused)
panel->SetBorderColor(wxColour("#009688"));
else
panel->SetBorderColor(panel_bd_col);
auto printer_focus_bg = [this, panel_color](bool focused){
auto bg_color = StateColor::darkModeColorFor(focused ? panel_color.bg_focus : panel_color.bg_normal);
p->panel_printer_preset->SetBackgroundColor(bg_color);
p->panel_printer_preset->SetBorderColor(focused ? panel_color.bd_focus : panel_color.bd_normal);
p->btn_edit_printer->SetBackgroundColour(bg_color);
p->image_printer->SetBackgroundColour(bg_color);
p->combo_printer->SetBackgroundColour(bg_color); // paints margins instead combo background
@@ -1739,20 +1742,20 @@ Sidebar::Sidebar(Plater *parent)
*/
// ORCA use Show/Hide to gain text area instead using blank icon. also manages hover effect for border
for (wxWindow *w : std::initializer_list<wxWindow *>{p->panel_printer_preset, p->btn_edit_printer, p->image_printer, p->combo_printer}) {
w->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent &e) {
w->Bind(wxEVT_ENTER_WINDOW, [this, panel_color](wxMouseEvent &e) {
if(!p->combo_printer->HasFocus())
p->panel_printer_preset->SetBorderColor(wxColour("#009688"));
p->panel_printer_preset->SetBorderColor(panel_color.bd_hover);
if(!p->btn_edit_printer->IsShown()){
p->btn_edit_printer->Show();
p->panel_printer_preset->Layout();
}
e.Skip();
});
w->Bind(wxEVT_LEAVE_WINDOW, [this, panel_bd_col](wxMouseEvent &e) {
w->Bind(wxEVT_LEAVE_WINDOW, [this, panel_color](wxMouseEvent &e) {
wxWindow* next_w = wxFindWindowAtPoint(wxGetMousePosition());
if (!next_w || !p->panel_printer_preset->IsDescendant(next_w)){
if(!p->combo_printer->HasFocus())
p->panel_printer_preset->SetBorderColor(panel_bd_col);
p->panel_printer_preset->SetBorderColor(panel_color.bd_normal);
p->btn_edit_printer->Hide();
p->panel_printer_preset->Layout();
}
@@ -1763,7 +1766,7 @@ Sidebar::Sidebar(Plater *parent)
// ORCA unified Nozzle diameter selection
p->panel_nozzle_dia = new StaticBox(p->m_panel_printer_content);
p->panel_nozzle_dia->SetCornerRadius(FromDIP(8));
p->panel_nozzle_dia->SetBorderColor(panel_bd_col);
p->panel_nozzle_dia->SetBorderColor(panel_color.bd_normal);
p->panel_nozzle_dia->SetMinSize(FromDIP(PRINTER_PANEL_SIZE));
p->panel_nozzle_dia->Bind(wxEVT_LEFT_DOWN, [this](auto & evt) {
p->combo_nozzle_dia->wxEvtHandler::ProcessEvent(evt);
@@ -1790,14 +1793,10 @@ Sidebar::Sidebar(Plater *parent)
e.Skip();
});
// ORCA paint whole combobox on focus
auto nozzle_focus_bg = [this, panel_bd_col](bool focused){
auto bg_color = StateColor::darkModeColorFor(wxColour(focused ? "#E5F0EE" : "#FFFFFF"));
auto panel = p->panel_nozzle_dia;
panel->SetBackgroundColor(bg_color);
if(focused)
panel->SetBorderColor(wxColour("#009688"));
else
panel->SetBorderColor(panel_bd_col);
auto nozzle_focus_bg = [this, panel_color](bool focused){
auto bg_color = StateColor::darkModeColorFor(focused ? panel_color.bg_focus : panel_color.bg_normal);
p->panel_nozzle_dia->SetBackgroundColor(bg_color);
p->panel_nozzle_dia->SetBorderColor(focused ? panel_color.bd_focus : panel_color.bd_normal);
p->label_nozzle_title->SetBackgroundColour(bg_color);
p->label_nozzle_type->SetBackgroundColour(bg_color);
p->combo_nozzle_dia->SetBackgroundColour(bg_color); // paints margins instead combo background
@@ -1815,16 +1814,15 @@ Sidebar::Sidebar(Plater *parent)
// highlight border on hover
for (wxWindow *w : std::initializer_list<wxWindow *>{p->panel_nozzle_dia, p->label_nozzle_title, p->label_nozzle_type, p->combo_nozzle_dia}) {
w->Bind(wxEVT_ENTER_WINDOW, [this](wxMouseEvent &e) {
w->Bind(wxEVT_ENTER_WINDOW, [this, panel_color](wxMouseEvent &e) {
if(!p->combo_nozzle_dia->HasFocus())
p->panel_nozzle_dia->SetBorderColor(wxColour("#009688"));
p->panel_nozzle_dia->SetBorderColor(panel_color.bd_hover);
e.Skip();
});
w->Bind(wxEVT_LEAVE_WINDOW, [this, panel_bd_col](wxMouseEvent &e) {
w->Bind(wxEVT_LEAVE_WINDOW, [this, panel_color](wxMouseEvent &e) {
wxWindow* next_w = wxFindWindowAtPoint(wxGetMousePosition());
if (!p->combo_nozzle_dia->HasFocus() && (!next_w || !p->panel_nozzle_dia->IsDescendant(next_w)))
p->panel_nozzle_dia->SetBorderColor(panel_bd_col);
p->panel_nozzle_dia->SetBorderColor(panel_color.bd_normal);
e.Skip();
});
}
@@ -1839,7 +1837,7 @@ Sidebar::Sidebar(Plater *parent)
// Bed type selection
p->panel_printer_bed = new StaticBox(p->m_panel_printer_content);
p->panel_printer_bed->SetCornerRadius(FromDIP(8));
p->panel_printer_bed->SetBorderColor(panel_bd_col);
p->panel_printer_bed->SetBorderColor(panel_color.bd_normal);
p->panel_printer_bed->SetMinSize(FromDIP(PRINTER_PANEL_SIZE));
p->panel_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
@@ -1853,10 +1851,8 @@ Sidebar::Sidebar(Plater *parent)
ScalableBitmap bitmap_bed(p->panel_printer_bed, "printer_placeholder", PRINTER_THUMBNAIL_SIZE.GetHeight());
p->image_printer_bed = new wxStaticBitmap(p->panel_printer_bed, wxID_ANY, bitmap_bed.bmp(), wxDefaultPosition, wxDefaultSize, 0);
p->image_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
if (p->big_bed_image_popup) {
if (p->big_bed_image_popup)
p->big_bed_image_popup->on_hide();
}
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
});
@@ -1878,14 +1874,10 @@ Sidebar::Sidebar(Plater *parent)
});
// ORCA paint whole combobox on focus
auto bed_focus_bg = [this, panel_bd_col](bool focused){
auto bg_color = StateColor::darkModeColorFor(wxColour(focused ? "#E5F0EE" : "#FFFFFF"));
auto panel = p->panel_printer_bed;
panel->SetBackgroundColor(bg_color);
if(focused)
panel->SetBorderColor(wxColour("#009688"));
else
panel->SetBorderColor(panel_bd_col);
auto bed_focus_bg = [this, panel_color](bool focused){
auto bg_color = StateColor::darkModeColorFor(focused ? panel_color.bg_focus : panel_color.bg_normal);
p->panel_printer_bed->SetBackgroundColor(bg_color);
p->panel_printer_bed->SetBorderColor(focused ? panel_color.bd_focus : panel_color.bd_normal);
p->image_printer_bed->SetBackgroundColour(bg_color);
p->combo_printer_bed->SetBackgroundColour(bg_color); // paints margins instead combo background
};
@@ -1894,17 +1886,17 @@ Sidebar::Sidebar(Plater *parent)
// highlight border on hover
for (wxWindow *w : std::initializer_list<wxWindow *>{p->panel_printer_bed, p->image_printer_bed, p->combo_printer_bed}) {
w->Bind(wxEVT_ENTER_WINDOW, [this, w](wxMouseEvent &e) {
w->Bind(wxEVT_ENTER_WINDOW, [this, w, panel_color](wxMouseEvent &e) {
if(!p->combo_printer_bed->HasFocus())
p->panel_printer_bed->SetBorderColor(wxColour("#009688"));
p->panel_printer_bed->SetBorderColor(panel_color.bd_hover);
if(w == p->image_printer_bed && !p->combo_printer_bed->is_drop_down()) // dont trigger while combo open
on_enter_image_printer_bed(e);
e.Skip();
});
w->Bind(wxEVT_LEAVE_WINDOW, [this, w, panel_bd_col](wxMouseEvent &e) {
w->Bind(wxEVT_LEAVE_WINDOW, [this, w, panel_color](wxMouseEvent &e) {
wxWindow* next_w = wxFindWindowAtPoint(wxGetMousePosition());
if (!p->combo_printer_bed->HasFocus() && (!next_w || !p->panel_printer_bed->IsDescendant(next_w)))
p->panel_printer_bed->SetBorderColor(panel_bd_col);
p->panel_printer_bed->SetBorderColor(panel_color.bd_normal);
if(w == p->image_printer_bed)
on_leave_image_printer_bed(e);
e.Skip();