mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 10:02:12 +00:00
FIX: Support dark mode in filament picker
- Applied dark theme styling to filament picker dialog - Fixed color picker background not updating on theme switch jira: STUDIO-12935 Change-Id: I9c7dcc518e7b0bd2c330f477ee42f4c61ea9fd4b (cherry picked from commit 66ae7a02b945ff603b2dc699c93e55589481379e)
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include "EncodedFilament.hpp"
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StateColor.hpp"
|
||||
#include <wx/wx.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
@@ -70,9 +72,7 @@ FilamentPickerDialog::FilamentPickerDialog(wxWindow *parent, const wxString& fil
|
||||
}
|
||||
|
||||
// "More colours" button (always present)
|
||||
m_more_btn = new wxButton(this, wxID_ANY, "+ " + _L("More Colors"),
|
||||
wxDefaultPosition, wxSize(-1, FromDIP(36)), 0);
|
||||
m_more_btn->SetBackgroundColour(wxColour(248, 248, 248)); // Light gray background
|
||||
CreateMoreInfoButton();
|
||||
main_sizer->Add(m_more_btn, 0, wxEXPAND | wxTOP | wxBOTTOM, FromDIP(8));
|
||||
main_sizer->AddSpacer(FromDIP(8));
|
||||
|
||||
@@ -112,6 +112,7 @@ FilamentPickerDialog::FilamentPickerDialog(wxWindow *parent, const wxString& fil
|
||||
Bind(wxEVT_CREATE, &FilamentPickerDialog::OnWindowCreate, this);
|
||||
#endif
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Layout();
|
||||
// Set window transparency
|
||||
SetTransparent(255);
|
||||
@@ -317,7 +318,7 @@ wxScrolledWindow* FilamentPickerDialog::CreateColorGrid()
|
||||
|
||||
if (btn) {
|
||||
// Remove any default background and borders
|
||||
btn->SetBackgroundColour(*wxWHITE);
|
||||
btn->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||
|
||||
// Set tooltip with filament information
|
||||
wxString tooltip = wxString::Format("%s", color_code->GetFilaColorName());
|
||||
@@ -412,7 +413,7 @@ void FilamentPickerDialog::UpdateButtonStates(wxBitmapButton* selected_btn)
|
||||
{
|
||||
// Reset selected button appearance
|
||||
if (m_currently_selected_btn) {
|
||||
m_currently_selected_btn->SetBackgroundColour(*wxWHITE); // Restore white background
|
||||
m_currently_selected_btn->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||
m_currently_selected_btn->Unbind(wxEVT_PAINT, &FilamentPickerDialog::OnButtonPaint, this);
|
||||
m_currently_selected_btn->Refresh();
|
||||
}
|
||||
@@ -426,6 +427,22 @@ void FilamentPickerDialog::UpdateButtonStates(wxBitmapButton* selected_btn)
|
||||
m_currently_selected_btn = selected_btn;
|
||||
}
|
||||
|
||||
void FilamentPickerDialog::CreateMoreInfoButton()
|
||||
{
|
||||
m_more_btn = new Button(this, "+ " + _L("More Colors"));
|
||||
m_more_btn->SetMinSize(wxSize(-1, FromDIP(36)));
|
||||
|
||||
StateColor btn_bg(
|
||||
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(248, 248, 248), StateColor::Normal)
|
||||
);
|
||||
|
||||
|
||||
m_more_btn->SetBackgroundColor(btn_bg);
|
||||
m_more_btn->SetBorderStyle(wxPENSTYLE_SHORT_DASH);
|
||||
m_more_btn->SetCornerRadius(FromDIP(0));
|
||||
}
|
||||
|
||||
wxBoxSizer* FilamentPickerDialog::CreateButtonPanel()
|
||||
{
|
||||
wxBoxSizer* btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -460,7 +477,7 @@ wxBoxSizer* FilamentPickerDialog::CreateButtonPanel()
|
||||
|
||||
// Create Cancel button using project's Button class
|
||||
m_cancel_btn = new Button(this, _L("Cancel"), "", 0, 0, wxID_CANCEL);
|
||||
m_cancel_btn->SetMinSize(wxSize(FromDIP(72), FromDIP(24)));
|
||||
m_cancel_btn->SetMinSize(wxSize(FromDIP(55), FromDIP(24)));
|
||||
m_cancel_btn->SetCornerRadius(FromDIP(12));
|
||||
m_cancel_btn->SetBackgroundColor(btn_bg_white);
|
||||
m_cancel_btn->SetBorderColor(btn_bd_white);
|
||||
@@ -470,7 +487,7 @@ wxBoxSizer* FilamentPickerDialog::CreateButtonPanel()
|
||||
|
||||
// Create OK button using project's Button class
|
||||
m_ok_btn = new Button(this, _L("OK"), "", 0, 0, wxID_OK);
|
||||
m_ok_btn->SetMinSize(wxSize(FromDIP(72), FromDIP(24)));
|
||||
m_ok_btn->SetMinSize(wxSize(FromDIP(55), FromDIP(24)));
|
||||
m_ok_btn->SetCornerRadius(FromDIP(12));
|
||||
m_ok_btn->SetBackgroundColor(btn_bg_green);
|
||||
m_ok_btn->SetBorderColor(btn_bd_green);
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
wxBoxSizer* CreatePreviewPanel(const FilamentColor& fila_color, const std::string& fila_type);
|
||||
wxScrolledWindow* CreateColorGrid();
|
||||
wxBoxSizer* CreateSeparatorLine();
|
||||
void CreateMoreInfoButton();
|
||||
wxBoxSizer* CreateButtonPanel();
|
||||
void BindEvents();
|
||||
|
||||
@@ -64,7 +65,7 @@ private:
|
||||
wxStaticText* m_label_preview_color{nullptr};
|
||||
wxStaticText* m_label_preview_idx{nullptr};
|
||||
wxStaticText* m_label_preview_type{nullptr};
|
||||
wxButton* m_more_btn{nullptr};
|
||||
Button* m_more_btn{nullptr};
|
||||
Button* m_ok_btn{nullptr};
|
||||
Button* m_cancel_btn{nullptr};
|
||||
wxString* m_cur_color_name{nullptr};
|
||||
|
||||
@@ -823,6 +823,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
int em = wxGetApp().em_unit();
|
||||
clr_picker = new wxBitmapButton(parent, wxID_ANY, {}, wxDefaultPosition, wxSize(FromDIP(20), FromDIP(20)), wxBU_EXACTFIT | wxBU_AUTODRAW | wxBORDER_NONE);
|
||||
clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||
clr_picker->SetToolTip(_L("Click to select filament color"));
|
||||
clr_picker->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {
|
||||
m_clrData.SetColour(clr_picker->GetBackgroundColour());
|
||||
@@ -1744,8 +1745,7 @@ void TabPresetComboBox::update_dirty()
|
||||
GUI::CalibrateFilamentComboBox::CalibrateFilamentComboBox(wxWindow *parent)
|
||||
: PlaterPresetComboBox(parent, Preset::TYPE_FILAMENT)
|
||||
{
|
||||
clr_picker->SetBackgroundColour(*wxWHITE);
|
||||
clr_picker->SetBitmap(*get_extruder_color_icon("#FFFFFFFF", "", FromDIP(20), FromDIP(20)));
|
||||
clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||
clr_picker->SetToolTip("");
|
||||
clr_picker->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {});
|
||||
}
|
||||
@@ -1936,4 +1936,11 @@ void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt)
|
||||
wxPostEvent(m_parent, e);
|
||||
}
|
||||
|
||||
void PlaterPresetComboBox::sys_color_changed()
|
||||
{
|
||||
PresetComboBox::sys_color_changed();
|
||||
if (clr_picker) {
|
||||
clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||
}
|
||||
}
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -209,6 +209,7 @@ public:
|
||||
FilamentColor get_cur_color_info();
|
||||
void show_default_color_picker();
|
||||
void sync_colour_config(const std::vector<std::string> &clrs, bool is_gradient);
|
||||
void sys_color_changed() override;
|
||||
|
||||
private:
|
||||
// BBS
|
||||
|
||||
@@ -52,6 +52,12 @@ void StaticBox::SetCornerRadius(double radius)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void StaticBox::SetBorderStyle(wxPenStyle style)
|
||||
{
|
||||
border_style = style;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void StaticBox::SetBorderWidth(int width)
|
||||
{
|
||||
border_width = width;
|
||||
@@ -197,7 +203,7 @@ void StaticBox::doRender(wxDC& dc)
|
||||
rc.y += d;
|
||||
rc.height -= d;
|
||||
}
|
||||
dc.SetPen(wxPen(border_color.colorForStates(states), border_width));
|
||||
dc.SetPen(wxPen(border_color.colorForStates(states), border_width, border_style));
|
||||
} else {
|
||||
dc.SetPen(wxPen(background_color.colorForStates(states)));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
void SetBorderColorNormal(wxColor const &color);
|
||||
|
||||
void SetBorderStyle(wxPenStyle style);
|
||||
|
||||
void SetBackgroundColor(StateColor const &color);
|
||||
|
||||
void SetBackgroundColorNormal(wxColor const &color);
|
||||
@@ -53,6 +55,7 @@ protected:
|
||||
protected:
|
||||
double radius;
|
||||
int border_width = 1;
|
||||
wxPenStyle border_style = wxPENSTYLE_SOLID;
|
||||
StateHandler state_handler;
|
||||
StateColor border_color;
|
||||
StateColor background_color;
|
||||
|
||||
Reference in New Issue
Block a user