Tech ENABLE_COLOR_CLASSES - 1st installment -> Introduction of classes ColorRGB and ColorRGBA to unify color data definition and manipulation

This commit is contained in:
enricoturri1966 2021-12-22 10:45:35 +01:00
parent 48098fbaff
commit cd4094743e
53 changed files with 1810 additions and 60 deletions

View file

@ -11,6 +11,9 @@
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/PresetBundle.hpp"
#if ENABLE_COLOR_CLASSES
#include "libslic3r/Color.hpp"
#endif // ENABLE_COLOR_CLASSES
#include "format.hpp"
#include "GUI_App.hpp"
#include "Plater.hpp"
@ -58,8 +61,12 @@ static std::string get_icon_name(Preset::Type type, PrinterTechnology pt) {
static std::string def_text_color()
{
wxColour def_colour = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
#if ENABLE_COLOR_CLASSES
return encode_color(ColorRGB(def_colour.Red(), def_colour.Green(), def_colour.Blue()));
#else
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), def_colour.Red(), def_colour.Green(), def_colour.Blue());
return clr_str.ToStdString();
#endif // ENABLE_COLOR_CLASSES
}
static std::string grey = "#808080";
static std::string orange = "#ed6b21";
@ -124,8 +131,13 @@ wxBitmap ModelNode::get_bitmap(const wxString& color)
const int icon_height = lround(1.6 * em);
BitmapCache bmp_cache;
#if ENABLE_COLOR_CLASSES
ColorRGB rgb;
decode_color(into_u8(color), rgb);
#else
unsigned char rgb[3];
BitmapCache::parse_color(into_u8(color), rgb);
#endif // ENABLE_COLOR_CLASSES
// there is no need to scale created solid bitmap
#ifndef __linux__
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);