OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
StateColor Class Reference

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

Collaboration diagram for StateColor:

Public Types

enum  State {
  Normal = 0 , Enabled = 1 , Checked = 2 , Focused = 4 ,
  Hovered = 8 , Pressed = 16 , Disabled = 1 << 16 , NotChecked = 2 << 16 ,
  NotFocused = 4 << 16 , NotHovered = 8 << 16 , NotPressed = 16 << 16
}

Public Member Functions

template<typename ... Colors>
 StateColor (std::pair< Colors, int >... colors)
 StateColor (wxColour const &color)
 StateColor (wxString const &color)
 StateColor (unsigned long color)
bool operator== (StateColor const &other) const
bool operator!= (StateColor const &other) const
void append (wxColour const &color, int states)
void append (wxString const &color, int states)
void append (unsigned long color, int states)
void clear ()
int count () const
int states () const
wxColour defaultColor ()
wxColour colorForStates (int states)
wxColour colorForStatesNoDark (int states)
int colorIndexForStates (int states)
bool setColorForStates (wxColour const &color, int states)
void setTakeFocusedAsHovered (bool set)

Static Public Member Functions

static std::tuple< double, double, double > GetLAB (const wxColour &color)
static double GetLightness (const wxColour &color)
static wxColour SetLightness (const wxColour &color, double lightness)
static wxColour LightenDarkenColor (const wxColour &color, int amount)
static double GetColorDifference (const wxColour &c1, const wxColour &c2)
static double LAB_Delta_E (const wxColour &c1, const wxColour &c2)
static void SetDarkMode (bool dark)
static std::map< wxColour, wxColour > const & GetDarkMap ()
static wxColour darkModeColorFor (wxColour const &color)
static wxColour lightModeColorFor (wxColour const &color)

Private Member Functions

template<typename Color, typename ... Colors>
void fill (std::pair< Color, int > color, std::pair< Colors, int >... colors)
template<typename Color>
void fillOne (std::pair< Color, int > color)
void fill ()

Private Attributes

std::vector< int > statesList_
std::vector< wxColour > colors_
bool takeFocusedAsHovered_ = true

Detailed Description

Member Enumeration Documentation

◆ State

Enumerator
Normal 
Enabled 
Checked 
Focused 
Hovered 
Pressed 
Disabled 
NotChecked 
NotFocused 
NotHovered 
NotPressed 
15 {
16 Normal = 0,
17 Enabled = 1,
18 Checked = 2,
19 Focused = 4,
20 Hovered = 8,
21 Pressed = 16,
22 Disabled = 1 << 16,
23 NotChecked = 2 << 16,
24 NotFocused = 4 << 16,
25 NotHovered = 8 << 16,
26 NotPressed = 16 << 16,
27 };
@ NotFocused
Definition StateColor.hpp:24
@ NotChecked
Definition StateColor.hpp:23
@ Hovered
Definition StateColor.hpp:20
@ Normal
Definition StateColor.hpp:16
@ NotHovered
Definition StateColor.hpp:25
@ Disabled
Definition StateColor.hpp:22
@ Pressed
Definition StateColor.hpp:21
@ NotPressed
Definition StateColor.hpp:26
@ Enabled
Definition StateColor.hpp:17
@ Checked
Definition StateColor.hpp:18
@ Focused
Definition StateColor.hpp:19

Constructor & Destructor Documentation

◆ StateColor() [1/4]

template<typename ... Colors>
StateColor::StateColor ( std::pair< Colors, int >... colors)
inline
45 {
46 fill(colors...);
47 }
void fill()
Definition StateColor.hpp:107

References fill().

Referenced by operator!=(), and operator==().

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

◆ StateColor() [2/4]

StateColor::StateColor ( wxColour const & color)
221{ append(color, 0); }
void append(wxColour const &color, int states)
Definition StateColor.cpp:227

References append().

Here is the call graph for this function:

◆ StateColor() [3/4]

StateColor::StateColor ( wxString const & color)
223{ append(color, 0); }

References append().

Here is the call graph for this function:

◆ StateColor() [4/4]

StateColor::StateColor ( unsigned long color)
225{ append(color, 0); }

References append().

Here is the call graph for this function:

Member Function Documentation

◆ append() [1/3]

void StateColor::append ( unsigned long color,
int states )
240{
241 if ((color & 0xff000000) == 0)
242 color |= 0xff000000;
243 wxColour cl; cl.SetRGBA((color & 0xff00ff00) | ((color & 0xff) << 16) | ((color >> 16) & 0xff));
244 append(cl, states);
245}
int states() const
Definition StateColor.cpp:253

References append(), and states().

Here is the call graph for this function:

◆ append() [2/3]

void StateColor::append ( wxColour const & color,
int states )
228{
229 statesList_.push_back(states);
230 colors_.push_back(color);
231}
std::vector< wxColour > colors_
Definition StateColor.hpp:112
std::vector< int > statesList_
Definition StateColor.hpp:111

References colors_, states(), and statesList_.

Referenced by StateColor(), StateColor(), StateColor(), append(), append(), and fillOne().

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

◆ append() [3/3]

void StateColor::append ( wxString const & color,
int states )
234{
235 wxColour c1(color);
236 append(c1, states);
237}

References append(), and states().

Here is the call graph for this function:

◆ clear()

void StateColor::clear ( )
248{
249 statesList_.clear();
250 colors_.clear();
251}

References colors_, and statesList_.

◆ colorForStates()

wxColour StateColor::colorForStates ( int states)
268{
269 bool focused = takeFocusedAsHovered_ && (states & Focused);
270 for (int i = 0; i < statesList_.size(); ++i) {
271 int s = statesList_[i];
272 int on = s & 0xffff;
273 int off = s >> 16;
274 if ((on & states) == on && (off & ~states) == off) {
275 return darkModeColorFor2(colors_[i]);
276 }
277 if (focused && (on & Hovered)) {
278 on |= Focused;
279 on &= ~Hovered;
280 if ((on & states) == on && (off & ~states) == off) {
281 return darkModeColorFor2(colors_[i]);
282 }
283 }
284 }
285 return wxColour(0, 0, 0, 0);
286}
wxColour darkModeColorFor2(wxColour const &color)
Definition StateColor.cpp:195
bool takeFocusedAsHovered_
Definition StateColor.hpp:113

References colors_, darkModeColorFor2(), Focused, Hovered, states(), statesList_, and takeFocusedAsHovered_.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps(), and defaultColor().

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

◆ colorForStatesNoDark()

wxColour StateColor::colorForStatesNoDark ( int states)
289{
290 bool focused = takeFocusedAsHovered_ && (states & Focused);
291 for (int i = 0; i < statesList_.size(); ++i) {
292 int s = statesList_[i];
293 int on = s & 0xffff;
294 int off = s >> 16;
295 if ((on & states) == on && (off & ~states) == off) {
296 return colors_[i];
297 }
298 if (focused && (on & Hovered)) {
299 on |= Focused;
300 on &= ~Hovered;
301 if ((on & states) == on && (off & ~states) == off) {
302 return colors_[i];
303 }
304 }
305 }
306 return wxColour(0, 0, 0, 0);
307}

References colors_, Focused, Hovered, states(), statesList_, and takeFocusedAsHovered_.

Here is the call graph for this function:

◆ colorIndexForStates()

int StateColor::colorIndexForStates ( int states)
310{
311 for (int i = 0; i < statesList_.size(); ++i) {
312 int s = statesList_[i];
313 int on = s & 0xffff;
314 int off = s >> 16;
315 if ((on & states) == on && (off & ~states) == off) { return i; }
316 }
317 return -1;
318}

References states(), and statesList_.

Here is the call graph for this function:

◆ count()

int StateColor::count ( ) const
inline
78{ return statesList_.size(); }

References statesList_.

◆ darkModeColorFor()

wxColour StateColor::darkModeColorFor ( wxColour const & color)
static
219{ return darkModeColorFor2(color); }

References darkModeColorFor2().

Referenced by Slic3r::GUI::AMSCountPopupWindow::AMSCountPopupWindow(), Slic3r::GUI::AMSExtImage::AMSExtImage(), Slic3r::GUI::AMSextruderImage::AMSextruderImage(), Slic3r::GUI::AMSExtText::AMSExtText(), Slic3r::GUI::AmsItem::AmsItem(), Slic3r::GUI::AMSLib::AMSLib(), Slic3r::GUI::AmsMapingPopup::AmsMapingPopup(), Slic3r::GUI::AMSRoadUpPart::AMSRoadUpPart(), Slic3r::GUI::AuFile::AuFile(), Slic3r::GUI::AutoMixSelectPopup::AutoMixSelectPopup(), Slic3r::GUI::BaseTransparentDPIFrame::BaseTransparentDPIFrame(), Slic3r::GUI::CalibrateFilamentComboBox::CalibrateFilamentComboBox(), CheckList::CheckList(), Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ColorPickerPopup::ColorPickerPopup(), Slic3r::GUI::DialogButtons::DialogButtons(), Slic3r::GUI::DragCanvas::DragCanvas(), Slic3r::GUI::DragDropPanel::DragDropPanel(), Slic3r::GUI::ExtruderGroup::ExtruderGroup(), Slic3r::GUI::FilamentItemPanel::FilamentItemPanel(), Slic3r::GUI::FilamentSelectPopup::FilamentSelectPopup(), Slic3r::GUI::HoverLabel::HoverLabel(), Slic3r::GUI::ImageDPIFrame::ImageDPIFrame(), Slic3r::GUI::MachineObjectPanel::MachineObjectPanel(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MappingContainer::MappingContainer(), Slic3r::GUI::MappingItem::MappingItem(), Slic3r::GUI::MObjectPanel::MObjectPanel(), Slic3r::GUI::MultiTaskItem::MultiTaskItem(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlaterPresetComboBox::PlaterPresetComboBox(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PrinterPartsDialog::PrinterPartsDialog(), Slic3r::GUI::PrintOption::PrintOption(), RammingPanel::RammingPanel(), Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::SceneBenchmarkDialog(), Slic3r::Search::SearchItem::SearchItem(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::Sidebar::Sidebar(), Slic3r::GUI::SplashScreen::SplashScreen(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SwitcherImage::SwitcherImage(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), Slic3r::GUI::ThermalPreconditioningDialog::ThermalPreconditioningDialog(), Slic3r::GUI::TroubleshootDialog::TroubleshootDialog(), Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::add_checkbox_label(), Slic3r::GUI::PublishSettingsDialog::add_mixed_visual(), Slic3r::GUI::add_msg_content(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::add_sentence_with_chips(), Slic3r::GUI::AmsItem::AddCan(), Slic3r::GUI::AmsItem::AddLiteCan(), Slic3r::GUI::wgtMsgPanel::AddMessage(), Slic3r::GUI::TextCtrl::BUILD(), Slic3r::GUI::UnsavedChangesDialog::build(), Slic3r::GUI::TextureImportDialog::build_bottom_buttons(), Slic3r::GUI::TextureImportDialog::build_mapping_panel(), Slic3r::GUI::TextureImportDialog::build_params_panel(), Slic3r::GUI::TextureImportDialog::build_preview_panel(), Slic3r::GUI::ColorDecomposeDialog::build_ui(), Slic3r::GUI::MixedFilamentDialog::build_ui(), Slic3r::GUI::TextureImportDialog::build_ui(), Slic3r::GUI::ProgressDialog::Create(), TempInput::Create(), Slic3r::GUI::AMSDryCtrWin::create(), Slic3r::GUI::AMSHumidity::create(), Slic3r::GUI::AMSrefresh::create(), Slic3r::GUI::AmsReplaceMaterialDialog::create(), Slic3r::GUI::create_h_divider(), Slic3r::GUI::TroubleshootDialog::create_item_loaded_profiles(), Slic3r::GUI::AutoMixSelectPopup::create_item_row(), Slic3r::GUI::FilamentSelectPopup::create_item_row(), Slic3r::GUI::MixedFilamentDialog::create_material_selection(), Slic3r::GUI::FilamentSelectPopup::create_mixed_item_row(), Slic3r::GUI::ColorDecomposeDialog::create_mode_card(), Slic3r::GUI::create_mode_group_label(), Slic3r::GUI::ColorDecomposeDialog::create_mode_selection_section(), Slic3r::GUI::AMSDryCtrWin::create_normal_state_panel(), Slic3r::GUI::ExtruderGroup::create_nozzle_row(), Slic3r::GUI::KBShortcutsDialog::create_page(), Slic3r::GUI::MixedFilamentDialog::create_preview_panel(), Slic3r::GUI::MixedFilamentDialog::create_ratio_slider(), Slic3r::GUI::MixedFilamentDialog::create_recommendation_grid(), Slic3r::GUI::MainFrame::create_side_tools(), Slic3r::GUI::SyncAmsInfoDialog::create_sizer_thumbnail(), Slic3r::GUI::ColorDecomposeDialog::create_target_color_section(), Slic3r::GUI::MixedFilamentDialog::create_triangle_picker(), Slic3r::GUI::ThermalPreconditioningDialog::create_ui(), Slic3r::GUI::AMSControl::createAmsPanel(), Slic3r::GUI::FilamentPickerDialog::CreateColorGrid(), Slic3r::GUI::wgtMsgPanel::CreateGui(), Slic3r::GUI::wgtMsgPanelItem::CreateGui(), Slic3r::GUI::FilamentPickerDialog::CreateInfoSection(), WebView::CreateWebView(), Slic3r::GUI::AMSExtText::doRender(), Slic3r::GUI::AMSHumidity::doRender(), Slic3r::GUI::AMSPreview::doRender(), Slic3r::GUI::FanOperate::doRender(), Slic3r::GUI::MachineObjectPanel::doRender(), Slic3r::GUI::MaterialItem::doRender(), Slic3r::GUI::MObjectPanel::doRender(), Slic3r::GUI::PinCodePanel::doRender(), Slic3r::GUI::PrintOptionItem::doRender(), Slic3r::GUI::SideToolsPanel::doRender(), SideButton::dorender(), Chart::draw(), Slic3r::GUI::ColourPicker::draw_bmp_btn(), Slic3r::GUI::draw_mixed_ratio_segments(), Slic3r::GUI::OG_CustomCtrl::CtrlLine::draw_text(), BBLTopbarArt::DrawButton(), Slic3r::GUI::wxRenderer::DrawFocusRect(), Slic3r::GUI::wxRenderer::DrawItemSelectionRect(), Slic3r::GUI::wxRenderer::DrawItemText(), Slic3r::Search::SearchItem::DrawTextString(), Slic3r::GUI::DevicePickItem::DrawTextWithEllipsis(), Slic3r::GUI::MultiMachineItem::DrawTextWithEllipsis(), Slic3r::GUI::MultiTaskItem::DrawTextWithEllipsis(), Slic3r::GUI::SendDeviceItem::DrawTextWithEllipsis(), Slic3r::GUI::wxRenderer::DrawTreeItemButton(), Slic3r::GUI::PrintOption::enable(), Slic3r::GUI::SelectMachineDialog::Enable_Auto_Refill(), Slic3r::GUI::extruder_group_chip_bg(), Slic3r::GUI::framed_input(), Slic3r::GUI::SyncAmsInfoDialog::generate_override_fix_ams_list(), Slic3r::GUI::IMSlider::horizontal_slider(), Slic3r::GUI::anonymous_namespace{WebViewHostDialog.cpp}::host_theme_vars_css(), Slic3r::GUI::CrealityPrintHostSendDialog::init(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::PartSkipDialog::InitDialogUI(), Slic3r::GUI::ObjectTablePanel::load_data(), Slic3r::GUI::anonymous_namespace{PublishSettingsDialog.cpp}::mixed_filament_tab_bitmap(), Slic3r::Search::SearchItem::on_mouse_enter(), Slic3r::Search::SearchItem::on_mouse_leave(), Slic3r::Search::SearchItem::on_mouse_left_down(), Slic3r::GUI::GradientCurveEditor::on_paint(), Slic3r::GUI::RatioLabelPanel::on_paint(), Slic3r::GUI::StatusPanel::on_switch_speed(), Slic3r::GUI::DesignRowList::OnDrawBackground(), Slic3r::GUI::DesignRowList::OnDrawItem(), AccentSlider::OnPaint(), Slic3r::GUI::CapsuleButton::OnPaint(), Slic3r::GUI::FilamentItemPanel::OnPaint(), Slic3r::GUI::FilamentMapBtnPanel::OnPaint(), Slic3r::GUI::OG_CustomCtrl::OnPaint(), Slic3r::GUI::PurgeModeBtnPanel::OnPaint(), Slic3r::GUI::WikiLabel::OnPaint(), TabButtonsListCtrl::OnPaint(), Slic3r::GUI::MixedFilamentDialog::paint_warning_panel(), Slic3r::GUI::AuFile::PaintBackground(), Slic3r::GUI::AmsMapingPopup::paintEvent(), Slic3r::GUI::AMSMaterialsSetting::paintEvent(), Slic3r::GUI::AMSrefresh::paintEvent(), Slic3r::GUI::AmsReplaceMaterialDialog::paintEvent(), Slic3r::GUI::TextureImportDialog::rebuild_mapping_rows(), AxisCtrlButton::render(), Button::render(), DropDown::render(), Slic3r::GUI::ImageGrid::render(), Slic3r::GUI::MaterialSyncItem::render(), Slic3r::GUI::OG_CustomCtrl::CtrlLine::render(), Slic3r::GUI::TexturePreviewCanvas::render(), StaticLine::render(), TempInput::render(), Slic3r::GUI::AMSLib::render_lite_lib(), Slic3r::GUI::ImageGrid::renderContent2(), Slic3r::GUI::Bed_2D::repaint(), Slic3r::GUI::SyncAmsInfoDialog::reset_and_sync_ams_list(), Slic3r::GUI::s_show_label(), Slic3r::GUI::ColorPickerPopup::set_ams_colours(), Slic3r::GUI::ColorPickerPopup::set_preset_colours(), Slic3r::GUI::wgtDeviceNozzleRackNozzleItem::SetDisable(), Slic3r::GUI::wgtDeviceNozzleRackNozzleItem::SetNozzleStatus(), Slic3r::GUI::wgtDeviceNozzleRackNozzleItem::SetSelected(), Button::SetStyle(), Slic3r::GUI::MsgDialog::show_dsa_button(), Slic3r::GUI::SelectMachineDialog::show_timelapse_folder_popup(), Slic3r::GUI::MixedFilamentDialog::start_ratio_editor(), Slic3r::GUI::PublishSettingsDialog::subcategory_index_for(), Slic3r::GUI::ExtruderGroup::sys_color_changed(), Slic3r::GUI::HoverLabel::sys_color_changed(), Slic3r::GUI::PlaterPresetComboBox::sys_color_changed(), texture_import_separator_colour(), texture_import_text_colour(), Slic3r::GUI::MixedFilamentDialog::update_gradient_direction_items(), Slic3r::Search::SearchDialog::update_list(), Slic3r::Search::SearchObjectDialog::update_list(), Slic3r::GUI::Sidebar::update_mixed_filament_list(), Slic3r::GUI::ColorDecomposeDialog::update_mode_card_content(), Slic3r::GUI::SelectMachinePopup::update_other_devices(), Slic3r::GUI::PrintOptionsDialog::update_purify_air_at_print_end(), Slic3r::GUI::MainFrame::update_side_button_style(), Slic3r::GUI::SendToPrinterDialog::update_storage_list(), Slic3r::GUI::UpdateVersionDialog::update_version_info(), Slic3r::GUI::DialogButtons::UpdateButtons(), Slic3r::GUI::FilamentPickerDialog::UpdateButtonStates(), Slic3r::GUI::ExtruderSwithingStatus::updateBy(), Slic3r::GUI::GUI_App::UpdateDarkUI(), Slic3r::GUI::wgtDeviceNozzleRackHotendUpdate::UpdateInfo(), Slic3r::GUI::ImageGrid::UpdateLayout(), Slic3r::GUI::SeparatedDragDropPanel::UpdateLayout(), and Slic3r::GUI::IMSlider::vertical_slider().

Here is the call graph for this function:

◆ defaultColor()

wxColour StateColor::defaultColor ( )
263 {
264 return colorForStates(0);
265}
wxColour colorForStates(int states)
Definition StateColor.cpp:267

References colorForStates().

Here is the call graph for this function:

◆ fill() [1/2]

void StateColor::fill ( )
inlineprivate
107 {
108 }

Referenced by StateColor(), and fill().

Here is the caller graph for this function:

◆ fill() [2/2]

template<typename Color, typename ... Colors>
void StateColor::fill ( std::pair< Color, int > color,
std::pair< Colors, int >... colors )
inlineprivate
97 {
98 fillOne(color);
99 fill(colors...);
100 }
void fillOne(std::pair< Color, int > color)
Definition StateColor.hpp:103

References fill(), and fillOne().

Here is the call graph for this function:

◆ fillOne()

template<typename Color>
void StateColor::fillOne ( std::pair< Color, int > color)
inlineprivate
103 {
104 append(color.first, color.second);
105 }

References append().

Referenced by fill().

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

◆ GetColorDifference()

double StateColor::GetColorDifference ( const wxColour & c1,
const wxColour & c2 )
static
95 {
96 return LAB_Delta_E(color1, color2);
97}
static double LAB_Delta_E(const wxColour &c1, const wxColour &c2)
Definition StateColor.cpp:89

References LAB_Delta_E().

Referenced by Slic3r::GUI::GUI_App::UpdateDarkUI().

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

◆ GetDarkMap()

std::map< wxColour, wxColour > const & StateColor::GetDarkMap ( )
static
189{
190 return gDarkColors;
191}
static std::map< wxColour, wxColour > gDarkColors
Definition StateColor.cpp:13

References gDarkColors.

◆ GetLAB()

std::tuple< double, double, double > StateColor::GetLAB ( const wxColour & color)
static
59 {
60 // Convert color to RGB color space
61 double r = color.Red() / 255.0;
62 double g = color.Green() / 255.0;
63 double b = color.Blue() / 255.0;
64
65 // Convert to XYZ color space
66 double x = 0.412453*r + 0.357580*g + 0.180423*b;
67 double y = 0.212671*r + 0.715160*g + 0.072169*b;
68 double z = 0.019334*r + 0.119193*g + 0.950227*b;
69
70 // Normalize XYZ values
71 double x_n = x / 0.950456;
72 double y_n = y / 1.0;
73 double z_n = z / 1.088754;
74
75 // Convert to LAB color space
76 double epsilon = 0.008856;
77 double kappa = 903.3;
78 double fx = (x_n > epsilon) ? cbrt(x_n) : (kappa*x_n + 16.0) / 116.0;
79 double fy = (y_n > epsilon) ? cbrt(y_n) : (kappa*y_n + 16.0) / 116.0;
80 double fz = (z_n > epsilon) ? cbrt(z_n) : (kappa*z_n + 16.0) / 116.0;
81
82 double l = 116.0 * fy - 16.0;
83 double a = 500.0 * (fx - fy);
84 double b_lab = 200.0 * (fy - fz);
85
86 return std::tuple<double, double, double>(l, a, b_lab);
87}
constexpr double epsilon()
Definition IMSlider.hpp:31

Referenced by GetLightness(), LAB_Delta_E(), LightenDarkenColor(), and SetLightness().

Here is the caller graph for this function:

◆ GetLightness()

double StateColor::GetLightness ( const wxColour & color)
static
99 {
100 auto [l, a, b_lab] = GetLAB(color);
101 return l;
102}
static std::tuple< double, double, double > GetLAB(const wxColour &color)
Definition StateColor.cpp:59

References GetLAB().

Referenced by Slic3r::GUI::GUI_App::UpdateDarkUI().

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

◆ LAB_Delta_E()

double StateColor::LAB_Delta_E ( const wxColour & c1,
const wxColour & c2 )
static
89 {
90 auto [l1, a1, b1] = GetLAB(color1);
91 auto [l2, a2, b2] = GetLAB(color2);
92 return sqrt((l1 - l2) * (l1 - l2) + (a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2));
93}
T l2(const boost::geometry::model::d2::point_xy< T > &v)
Definition ExtrusionSimulator.cpp:177

References GetLAB().

Referenced by GetColorDifference().

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

◆ LightenDarkenColor()

wxColour StateColor::LightenDarkenColor ( const wxColour & color,
int amount )
static
145 {
146 auto [l, a, b_lab] = GetLAB(color);
147
148 // Modify lightness
149 l += amount;
150
151 // Clamp lightness value
152 l = std::max(0.0, std::min(100.0, l));
153
154 // Convert back to XYZ color space
155 double fy_3 = (l + 16.0) / 116.0;
156 double fx_3 = a / 500.0 + fy_3;
157 double fz_3 = fy_3 - b_lab / 200.0;
158
159 double epsilon = 0.008856;
160 double kappa = 903.3;
161 double x_3 = (fx_3 > epsilon) ? fx_3 * fx_3 * fx_3 : (116.0 * fx_3 - 16.0) / kappa;
162 double y_3 = (l > kappa*epsilon) ? fy_3 * fy_3 * fy_3 : l / kappa;
163 double z_3 = (fz_3 > epsilon) ? fz_3 * fz_3 * fz_3 : (116.0 * fz_3 - 16.0) / kappa;
164
165 // Denormalize XYZ values
166 double x = x_3 * 0.950456;
167 double y = y_3 * 1.0;
168 double z = z_3 * 1.088754;
169
170 // Convert XYZ to RGB
171 double r_new = 3.240479*x - 1.537150*y - 0.498535*z;
172 double g_new = -0.969256*x + 1.875992*y + 0.041556*z;
173 double b_new = 0.055648*x - 0.204043*y + 1.057311*z;
174
175 // Clamp RGB values
176 r_new = std::max(0.0, std::min(1.0, r_new));
177 g_new = std::max(0.0, std::min(1.0, g_new));
178 b_new = std::max(0.0, std::min(1.0, b_new));
179
180 // Convert back to wxColour
181 int r_int = static_cast<int>(r_new * 255);
182 int g_int = static_cast<int>(g_new * 255);
183 int b_int = static_cast<int>(b_new * 255);
184
185 return wxColour(r_int, g_int, b_int);
186}

References GetLAB().

Here is the call graph for this function:

◆ lightModeColorFor()

wxColour StateColor::lightModeColorFor ( wxColour const & color)
static
212{
213 static std::map<wxColour, wxColour> gLightColors = revert(gDarkColors);
214 auto iter = gLightColors.find(color);
215 if (iter != gLightColors.end()) return iter->second;
216 return color;
217}
std::map< wxColour, wxColour > revert(std::map< wxColour, wxColour > const &map)
Definition StateColor.cpp:204

References gDarkColors, and revert().

Referenced by Slic3r::GUI::GUI_App::UpdateDarkUI().

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

◆ operator!=()

bool StateColor::operator!= ( StateColor const & other) const
inline
64 {
65 return !(*this == other);
66 };

References StateColor().

Here is the call graph for this function:

◆ operator==()

bool StateColor::operator== ( StateColor const & other) const
inline
59 {
60 return statesList_ == other.statesList_ && colors_ == other.colors_ && takeFocusedAsHovered_ == other.takeFocusedAsHovered_;
61 };

References StateColor(), colors_, statesList_, and takeFocusedAsHovered_.

Here is the call graph for this function:

◆ setColorForStates()

bool StateColor::setColorForStates ( wxColour const & color,
int states )
321{
322 for (int i = 0; i < statesList_.size(); ++i) {
323 if (statesList_[i] == states) {
324 colors_[i] = color;
325 return true;
326 }
327 }
328 return false;
329}

References colors_, states(), and statesList_.

Here is the call graph for this function:

◆ SetDarkMode()

void StateColor::SetDarkMode ( bool dark)
static
193{ gDarkMode = dark; }
static bool gDarkMode
Definition StateColor.cpp:9

References gDarkMode.

Referenced by Slic3r::GUI::GUI_App::init_label_colours().

Here is the caller graph for this function:

◆ SetLightness()

wxColour StateColor::SetLightness ( const wxColour & color,
double lightness )
static
105 {
106 auto [l, a, b_lab] = GetLAB(color);
107
108 // Clamp lightness value
109 l = std::max(0.0, std::min(100.0, lightness));
110
111 // Convert back to XYZ color space
112 double fy_3 = (l + 16.0) / 116.0;
113 double fx_3 = a / 500.0 + fy_3;
114 double fz_3 = fy_3 - b_lab / 200.0;
115
116 double epsilon = 0.008856;
117 double kappa = 903.3;
118 double x_3 = (fx_3 > epsilon) ? fx_3 * fx_3 * fx_3 : (116.0 * fx_3 - 16.0) / kappa;
119 double y_3 = (l > kappa*epsilon) ? fy_3 * fy_3 * fy_3 : l / kappa;
120 double z_3 = (fz_3 > epsilon) ? fz_3 * fz_3 * fz_3 : (116.0 * fz_3 - 16.0) / kappa;
121
122 // Denormalize XYZ values
123 double x = x_3 * 0.950456;
124 double y = y_3 * 1.0;
125 double z = z_3 * 1.088754;
126
127 // Convert XYZ to RGB
128 double r_new = 3.240479*x - 1.537150*y - 0.498535*z;
129 double g_new = -0.969256*x + 1.875992*y + 0.041556*z;
130 double b_new = 0.055648*x - 0.204043*y + 1.057311*z;
131
132 // Clamp RGB values
133 r_new = std::max(0.0, std::min(1.0, r_new));
134 g_new = std::max(0.0, std::min(1.0, g_new));
135 b_new = std::max(0.0, std::min(1.0, b_new));
136
137 // Convert back to wxColour
138 int r_int = static_cast<int>(r_new * 255);
139 int g_int = static_cast<int>(g_new * 255);
140 int b_int = static_cast<int>(b_new * 255);
141
142 return wxColour(r_int, g_int, b_int);
143}

References GetLAB().

Referenced by Slic3r::GUI::GUI_App::UpdateDarkUI().

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

◆ setTakeFocusedAsHovered()

void StateColor::setTakeFocusedAsHovered ( bool set)
void set(id object, const void *key, id value)
Definition MacIME.mm:24

References takeFocusedAsHovered_.

◆ states()

int StateColor::states ( ) const
254{
255 int states = 0;
256 for (auto s : statesList_) states |= s;
257 states = (states & 0xffff) | (states >> 16);
259 states |= Focused;
260 return states;
261}

References Focused, Hovered, states(), statesList_, and takeFocusedAsHovered_.

Referenced by append(), append(), append(), colorForStates(), colorForStatesNoDark(), colorIndexForStates(), setColorForStates(), and states().

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

Member Data Documentation

◆ colors_

std::vector<wxColour> StateColor::colors_
private

◆ statesList_

std::vector<int> StateColor::statesList_
private

◆ takeFocusedAsHovered_

bool StateColor::takeFocusedAsHovered_ = true
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/StateColor.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/StateColor.cpp