Allow to change colors in the gui.

This commit is contained in:
remi durand 2021-03-21 18:22:39 +01:00
parent 2c8e531731
commit 9d3602fb6f
19 changed files with 239 additions and 67 deletions

View File

@ -63,6 +63,20 @@ void AppConfig::set_defaults()
if (get("freecad_path").empty())
set("freecad_path", ".");
if (get("color_very_dark").empty())
set("color_very_dark", "0047c7");
if (get("color_dark").empty())
set("color_dark", "2172eb");
if (get("color").empty())
set("color", "428dfd");
if (get("color_light").empty())
set("color_light", "8bb9fe");
if (get("color_very_light").empty())
set("color_very_light", "428cff");
if (get("version_check").empty())
set("version_check", "1");

View File

@ -230,12 +230,12 @@ wxBitmap* BitmapCache::insert_raw_rgba(const std::string &bitmap_key, unsigned w
}
wxBitmap* BitmapCache::load_png(const std::string &bitmap_name, unsigned width, unsigned height,
const bool grayscale/* = false*/)
uint32_t color/* = false*/)
{
std::string bitmap_key = bitmap_name + ( height !=0 ?
"-h" + std::to_string(height) :
"-w" + std::to_string(width))
+ (grayscale ? "-gs" : "");
+ ((color == 9079434) ? "-gs" : "");
auto it = m_map.find(bitmap_key);
if (it != m_map.end())
@ -254,20 +254,22 @@ wxBitmap* BitmapCache::load_png(const std::string &bitmap_name, unsigned width,
if (height != 0 && width != 0)
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
if (grayscale)
if (color == 9079434)
image = image.ConvertToGreyscale(m_gs, m_gs, m_gs);
else if( color < 0xFFFFFFFF)
image.Replace(33, 114, 235, color & 0xFF, (color & 0xFF00) >> 8, (color & 0xFF0000) >> 16);
return this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
}
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
const bool grayscale/* = false*/, const bool dark_mode/* = false*/)
uint32_t color /* = 2172eb*/, const bool dark_mode/* = false*/)
{
std::string bitmap_key = bitmap_name + ( target_height !=0 ?
"-h" + std::to_string(target_height) :
"-w" + std::to_string(target_width))
+ (m_scale != 1.0f ? "-s" + std::to_string(m_scale) : "")
+ (grayscale ? "-gs" : "");
+ (m_scale != 1.0f ? "-s" + std::to_string(m_scale) : "");
//+ (grayscale ? "-gs" : "");
/* For the Dark mode of any platform, we should draw icons in respect to OS background
* Note: All standard(regular) icons are collected in "icons" folder,
@ -309,6 +311,18 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
if (image == nullptr)
return nullptr;
//recolor
if (color < 0xFFFFFFFF) {
NSVGshape* shape = image->shapes;
while (shape != nullptr) {
if ((shape->fill.color & 0xFFFFFF) == 15430177 || (shape->fill.color & 0xFFFFFF) == 2223467)
shape->fill.color = color | 0xFF000000;
if ((shape->stroke.color & 0xFFFFFF) == 15430177 || (shape->stroke.color & 0xFFFFFF) == 2223467)
shape->stroke.color = color | 0xFF000000;
shape = shape->next;
}
}
target_height != 0 ? target_height *= m_scale : target_width *= m_scale;
float svg_scale = target_height != 0 ?
@ -334,7 +348,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
::nsvgDeleteRasterizer(rast);
::nsvgDelete(image);
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), grayscale);
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), 9079434 == color);
}
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap

View File

@ -31,9 +31,9 @@ public:
wxBitmap* insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
// Load png from resources/icons. bitmap_key is given without the .png suffix. Bitmap will be rescaled to provided height/width if nonzero.
wxBitmap* load_png(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false);
wxBitmap* load_png(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, uint32_t color = 0xFFFFFFFF);
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false);
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, uint32_t color = 0xFFFFFFFF, const bool dark_mode = false);
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false);
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling); }

View File

@ -25,6 +25,7 @@
#include "Field.hpp"
#include "format.hpp"
#include "NotificationManager.hpp"
#include "wxExtensions.hpp"
namespace Slic3r {
@ -118,16 +119,24 @@ Control::Control( wxWindow *parent,
//ORANGE_PEN = wxPen(wxColour(253, 126, 66));
//LIGHT_ORANGE_PEN = wxPen(wxColour(254, 177, 139));
DARK_BLUE_PEN = wxPen(wxColour(32, 113, 234));
BLUE_PEN = wxPen(wxColour(66, 141, 253));
LIGHT_BLUE_PEN = wxPen(wxColour(139, 185, 254));
//DARK_BLUE_PEN = wxPen(wxColour(32, 113, 234));
//BLUE_PEN = wxPen(wxColour(66, 141, 253));
//LIGHT_BLUE_PEN = wxPen(wxColour(139, 185, 254));
uint32_t dark_color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_dark"));
uint32_t main_color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color"));
uint32_t light_color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_light"));
DARK_COLOR_PEN = wxPen(wxColour(dark_color & 0xFF, (dark_color & 0xFF00) >> 8, (dark_color & 0xFF0000) >> 16));
COLOR_PEN = wxPen(wxColour(main_color & 0xFF, (main_color & 0xFF00) >> 8, (main_color & 0xFF0000) >> 16));
LIGHT_COLOR_PEN = wxPen(wxColour(light_color & 0xFF, (light_color & 0xFF00) >> 8, (light_color & 0xFF0000) >> 16));
DARK_GREY_PEN = wxPen(wxColour(128, 128, 128));
GREY_PEN = wxPen(wxColour(164, 164, 164));
LIGHT_GREY_PEN = wxPen(wxColour(204, 204, 204));
m_line_pens = { &DARK_GREY_PEN, &GREY_PEN, &LIGHT_GREY_PEN };
m_segm_pens = { &DARK_BLUE_PEN, &BLUE_PEN, &LIGHT_BLUE_PEN };
m_segm_pens = { &DARK_COLOR_PEN, &COLOR_PEN, &LIGHT_COLOR_PEN };
m_font = GetFont();
this->SetMinSize(get_min_size());
@ -503,7 +512,7 @@ void Control::draw_info_line_with_icon(wxDC& dc, const wxPoint& pos, const Selec
{
if (m_selection == selection) {
//draw info line
dc.SetPen(DARK_BLUE_PEN);
dc.SetPen(DARK_COLOR_PEN);
const wxPoint pt_beg = is_horizontal() ? wxPoint(pos.x, pos.y - m_thumb_size.y) : wxPoint(pos.x - m_thumb_size.x, pos.y/* - 1*/);
const wxPoint pt_end = is_horizontal() ? wxPoint(pos.x, pos.y + m_thumb_size.y) : wxPoint(pos.x + m_thumb_size.x, pos.y/* - 1*/);
dc.DrawLine(pt_beg, pt_end);
@ -551,7 +560,7 @@ void Control::draw_tick_on_mouse_position(wxDC& dc)
wxCoord new_pos = get_position_from_value(tick);
const wxPoint pos = is_horizontal() ? wxPoint(new_pos, height * 0.5) : wxPoint(0.5 * width, new_pos);
dc.SetPen(DARK_BLUE_PEN);
dc.SetPen(DARK_COLOR_PEN);
draw_ticks(dc, pos, -2);
draw_ticks(dc, pos, 2 );

View File

@ -397,9 +397,9 @@ private:
//wxPen ORANGE_PEN;
//wxPen LIGHT_ORANGE_PEN;
wxPen DARK_BLUE_PEN;
wxPen BLUE_PEN;
wxPen LIGHT_BLUE_PEN;
wxPen DARK_COLOR_PEN;
wxPen COLOR_PEN;
wxPen LIGHT_COLOR_PEN;
wxPen DARK_GREY_PEN;
wxPen GREY_PEN;

View File

@ -260,7 +260,7 @@ void GCodeViewer::SequentialView::Marker::render() const
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::SetNextWindowBgAlpha(0.25f);
imgui.begin(std::string("ToolPosition"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _u8L("Tool position") + ":");
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), _u8L("Tool position") + ":");
ImGui::SameLine();
char buf[1024];
sprintf(buf, "X: %.2f, Y: %.2f, Z: %.2f", m_world_position(0), m_world_position(1), m_world_position(2));
@ -2315,7 +2315,7 @@ void GCodeViewer::render_legend() const
pos = ImGui::GetCursorScreenPos();
float width = std::max(1.0f, percent_bar_size * percent / max_percent);
draw_list->AddRectFilled({ pos.x, pos.y + 2.0f }, { pos.x + width, pos.y + icon_size - 2.0f },
ImGui::GetColorU32(ImGuiWrapper::COL_BLUE_LIGHT));
ImGui::GetColorU32(ImGuiWrapper::get_COL_LIGHT()));
ImGui::Dummy({ percent_bar_size, icon_size });
ImGui::SameLine();
char buf[64];
@ -2945,7 +2945,7 @@ void GCodeViewer::render_statistics() const
auto add_time = [this, &imgui](const std::string& label, int64_t time) {
char buf[1024];
sprintf(buf, "%lld ms (%s)", time, get_time_dhms(static_cast<float>(time) * 0.001f).c_str());
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, label);
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), label);
ImGui::SameLine(offset);
imgui.text(buf);
};
@ -2963,7 +2963,7 @@ void GCodeViewer::render_statistics() const
static const float inv_mb = 1.0f / mb;
static const float gb = 1024.0f * mb;
static const float inv_gb = 1.0f / gb;
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, label);
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), label);
ImGui::SameLine(offset);
if (static_cast<float>(memory) < mb)
imgui.text(format_string("KB", inv_kb));
@ -2976,7 +2976,7 @@ void GCodeViewer::render_statistics() const
auto add_counter = [this, &imgui](const std::string& label, int64_t counter) {
char buf[1024];
sprintf(buf, "%lld", counter);
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, label);
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), label);
ImGui::SameLine(offset);
imgui.text(buf);
};

View File

@ -235,23 +235,23 @@ void GLCanvas3D::LayersEditing::render_overlay(const GLCanvas3D& canvas) const
imgui.begin(_L("Variable layer height"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse);
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Left mouse button:"));
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), _L("Left mouse button:"));
ImGui::SameLine();
imgui.text(_L("Add detail"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Right mouse button:"));
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), _L("Right mouse button:"));
ImGui::SameLine();
imgui.text(_L("Remove detail"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Shift + Left mouse button:"));
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), _L("Shift + Left mouse button:"));
ImGui::SameLine();
imgui.text(_L("Reset to base"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Shift + Right mouse button:"));
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), _L("Shift + Right mouse button:"));
ImGui::SameLine();
imgui.text(_L("Smoothing"));
imgui.text_colored(ImGuiWrapper::COL_BLUE_LIGHT, _L("Mouse wheel:"));
imgui.text_colored(ImGuiWrapper::get_COL_LIGHT(), _L("Mouse wheel:"));
ImGui::SameLine();
imgui.text(_L("Increase/decrease edit area"));

View File

@ -159,7 +159,7 @@ bool GLTexture::load_from_svg_file(const std::string& filename, bool use_mipmaps
return false;
}
bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress)
bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress, uint32_t color)
{
reset();
@ -208,6 +208,18 @@ bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::stri
if (image == nullptr)
continue;
//recolor
if (color < 0xFFFFFFFF) {
NSVGshape* shape = image->shapes;
while (shape != nullptr) {
if ((shape->fill.color & 0xFFFFFF) == 15430177 || (shape->fill.color & 0xFFFFFF) == 2223467)
shape->fill.color = color | 0xFF000000;
if ((shape->stroke.color & 0xFFFFFF) == 15430177 || (shape->stroke.color & 0xFFFFFF) == 2223467)
shape->stroke.color = color | 0xFF000000;
shape = shape->next;
}
}
float scale = (float)sprite_size_px / std::max(image->width, image->height);
// offset by 1 to leave the first pixel empty (both in x and y)

View File

@ -99,7 +99,7 @@ namespace GUI {
// second field (bool):
// false -> no changes
// true -> add background color
bool load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress);
bool load_from_svg_files_as_sprites_array(const std::vector<std::string>& filenames, const std::vector<std::pair<int, bool>>& states, unsigned int sprite_size_px, bool compress, uint32_t color);
void reset();
unsigned int get_id() const { return m_id; }

View File

@ -1,5 +1,6 @@
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/Point.hpp"
#include "GLToolbar.hpp"
@ -1251,7 +1252,8 @@ bool GLToolbar::generate_icons_texture() const
// if (sprite_size_px % 2 != 0)
// sprite_size_px += 1;
bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false);
uint32_t color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_dark"));
bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false, color);
if (res)
m_icons_texture_dirty = false;

View File

@ -138,7 +138,8 @@ public:
memDC.SelectObject(bitmap);
memDC.SetFont(m_action_font);
memDC.SetTextForeground(wxColour(0, 102, 255));
uint32_t color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_very_dark"));
memDC.SetTextForeground(wxColour(color & 0xFF, (color & 0xFF00) >> 8, (color & 0xFF0000) >> 16));
memDC.DrawText(text, int(m_scale * 60), m_action_line_y_position);
memDC.SelectObject(wxNullBitmap);
@ -189,7 +190,8 @@ public:
// load bitmap for logo
BitmapCache bmp_cache;
int logo_size = lround(width * 0.25);
wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().is_editor() ? "super_slicer_logo" : "add_gcode", logo_size, logo_size);
//uint32_t color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_dark")); //uncomment if you also want to modify the icon color
wxBitmap logo_bmp = *bmp_cache.load_svg(wxGetApp().is_editor() ? "super_slicer_logo" : "add_gcode", logo_size, logo_size/*, color*/);
wxCoord margin = int(m_scale * 20);
@ -652,13 +654,15 @@ GUI_App::GUI_App(EAppMode mode)
: wxApp()
, m_app_mode(mode)
, m_em_unit(10)
, m_imgui(new ImGuiWrapper())
, m_imgui()
, m_wizard(nullptr)
, m_removable_drive_manager(std::make_unique<RemovableDriveManager>())
, m_other_instance_message_handler(std::make_unique<OtherInstanceMessageHandler>())
{
//app config initializes early becasuse it is used in instance checking in PrusaSlicer.cpp
this->init_app_config();
//ImGuiWrapper need the app config to get the colors
m_imgui.reset(new ImGuiWrapper{});
}
GUI_App::~GUI_App()

View File

@ -116,7 +116,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
window_width = std::max(window_width, cursor_type_radio_left + cursor_type_radio_width1 + cursor_type_radio_width2);
auto draw_text_with_caption = [this, &caption_max](const wxString& caption, const wxString& text) {
m_imgui->text_colored(ImGuiWrapper::COL_BLUE_LIGHT, caption);
m_imgui->text_colored(ImGuiWrapper::get_COL_LIGHT(), caption);
ImGui::SameLine(caption_max);
m_imgui->text(text);
};

View File

@ -1,12 +1,14 @@
#include "GLGizmoSeam.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/AppConfig.hpp"
//#include "slic3r/GUI/3DScene.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/ImGuiWrapper.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
#include <GL/glew.h>
@ -102,10 +104,13 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
window_width = std::max(window_width, button_width);
window_width = std::max(window_width, cursor_type_radio_left + cursor_type_radio_width1 + cursor_type_radio_width2);
auto draw_text_with_caption = [this, &caption_max](const wxString& caption, const wxString& text) {
uint32_t very_light_color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_very_light"));
const ImVec4 text_color = { (very_light_color & 0xFF) / 255.f, ((very_light_color & 0xFF00) >> 8) / 255.f, ((very_light_color & 0xFF0000) >> 16) / 255.f, 1.0f };
auto draw_text_with_caption = [this, &caption_max, &text_color](const wxString& caption, const wxString& text) {
// static const ImVec4 ORANGE(1.0f, 0.49f, 0.22f, 1.0f);
static const ImVec4 BLUE(0.26f, 0.55f, 1.0f, 1.0f);
m_imgui->text_colored(BLUE, caption);
//static const ImVec4 BLUE(0.26f, 0.55f, 1.0f, 1.0f);
m_imgui->text_colored(text_color, caption);
ImGui::SameLine(caption_max);
m_imgui->text(text);
};

View File

@ -1065,7 +1065,8 @@ bool GLGizmosManager::generate_icons_texture() const
// if (sprite_size_px % 2 != 0)
// sprite_size_px += 1;
bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false);
uint32_t color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_dark"));
bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false, color);
if (res)
m_icons_texture_dirty = false;

View File

@ -22,11 +22,14 @@
#include <imgui/imgui_internal.h>
#include "libslic3r/libslic3r.h"
#include "libslic3r/AppConfig.hpp"
#include "libslic3r/Utils.hpp"
#include "3DScene.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "Search.hpp"
#include "wxExtensions.hpp"
#include "../Utils/MacDarkMode.hpp"
#include "nanosvg/nanosvg.h"
@ -58,12 +61,39 @@ const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
//const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
//const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
const ImVec4 ImGuiWrapper::COL_BLUE_DARK = { 0.0f, 0.28f, 0.78f, 1.0f }; //0047c7
const ImVec4 ImGuiWrapper::COL_BLUE_LIGHT = { 0.13f, 0.45f, 0.92f, 1.0f }; //2172eb
//const ImVec4 ImGuiWrapper::COL_BLUE_DARK = { 0.0f, 0.28f, 0.78f, 1.0f }; //0047c7
//const ImVec4 ImGuiWrapper::COL_BLUE_LIGHT = { 0.13f, 0.45f, 0.92f, 1.0f }; //2172eb
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.133f, 0.133f, 0.133f, 0.8f };
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_BLUE_DARK;
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_BLUE_LIGHT;
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
//const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_BLUE_DARK;
//const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_BLUE_LIGHT;
//const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
bool ImGuiWrapper::COL_LOADED = false;
ImVec4 ImGuiWrapper::COL_DARK = { 0.0f, 0.28f, 0.78f, 1.0f }; //0047c7
ImVec4 ImGuiWrapper::COL_LIGHT = { 0.13f, 0.45f, 0.92f, 1.0f }; //2172eb
void ImGuiWrapper::load_colors()
{
uint32_t dark_color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_very_dark"));
uint32_t light_color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_dark"));
ImGuiWrapper::COL_DARK = { (dark_color & 0xFF) / 255.f, ((dark_color & 0xFF00) >> 8) / 255.f, ((dark_color & 0xFF0000) >> 16) / 255.f, 1.0f };
ImGuiWrapper::COL_LIGHT = { (light_color & 0xFF) / 255.f, ((light_color & 0xFF00) >> 8) / 255.f, ((light_color & 0xFF0000) >> 16) / 255.f, 1.0f };
}
ImVec4 ImGuiWrapper::get_COL_DARK() {
if (!ImGuiWrapper::COL_LOADED) {
load_colors();
}
return ImGuiWrapper::COL_DARK;
}
ImVec4 ImGuiWrapper::get_COL_LIGHT() {
if (!ImGuiWrapper::COL_LOADED) {
load_colors();
}
return ImGuiWrapper::COL_LIGHT;
}
ImGuiWrapper::ImGuiWrapper()
: m_glyph_ranges(nullptr)
@ -1061,7 +1091,7 @@ void ImGuiWrapper::init_style()
// Window
style.WindowRounding = 4.0f;
set_color(ImGuiCol_WindowBg, COL_WINDOW_BACKGROUND);
set_color(ImGuiCol_TitleBgActive, COL_BLUE_DARK);
set_color(ImGuiCol_TitleBgActive, get_COL_DARK());
// Generics
set_color(ImGuiCol_FrameBg, COL_GREY_DARK);
@ -1069,32 +1099,32 @@ void ImGuiWrapper::init_style()
set_color(ImGuiCol_FrameBgActive, COL_GREY_LIGHT);
// Text selection
set_color(ImGuiCol_TextSelectedBg, COL_BLUE_DARK);
set_color(ImGuiCol_TextSelectedBg, get_COL_DARK());
// Buttons
set_color(ImGuiCol_Button, COL_BUTTON_BACKGROUND);
set_color(ImGuiCol_ButtonHovered, COL_BUTTON_HOVERED);
set_color(ImGuiCol_ButtonActive, COL_BUTTON_ACTIVE);
set_color(ImGuiCol_Button, get_COL_DARK()); //COL_BUTTON_BACKGROUND);
set_color(ImGuiCol_ButtonHovered, get_COL_LIGHT()); //COL_BUTTON_HOVERED);
set_color(ImGuiCol_ButtonActive, get_COL_LIGHT()); //COL_BUTTON_ACTIVE);
// Checkbox
set_color(ImGuiCol_CheckMark, COL_BLUE_LIGHT);
set_color(ImGuiCol_CheckMark, get_COL_LIGHT());
// ComboBox items
set_color(ImGuiCol_Header, COL_BLUE_DARK);
set_color(ImGuiCol_HeaderHovered, COL_BLUE_LIGHT);
set_color(ImGuiCol_HeaderActive, COL_BLUE_LIGHT);
set_color(ImGuiCol_Header, get_COL_DARK());
set_color(ImGuiCol_HeaderHovered, get_COL_LIGHT());
set_color(ImGuiCol_HeaderActive, get_COL_LIGHT());
// Slider
set_color(ImGuiCol_SliderGrab, COL_BLUE_DARK);
set_color(ImGuiCol_SliderGrabActive, COL_BLUE_LIGHT);
set_color(ImGuiCol_SliderGrab, get_COL_DARK());
set_color(ImGuiCol_SliderGrabActive, get_COL_LIGHT());
// Separator
set_color(ImGuiCol_Separator, COL_BLUE_LIGHT);
set_color(ImGuiCol_Separator, get_COL_LIGHT());
// Tabs
set_color(ImGuiCol_Tab, COL_BLUE_DARK);
set_color(ImGuiCol_TabHovered, COL_BLUE_LIGHT);
set_color(ImGuiCol_TabActive, COL_BLUE_LIGHT);
set_color(ImGuiCol_Tab, get_COL_DARK());
set_color(ImGuiCol_TabHovered, get_COL_LIGHT());
set_color(ImGuiCol_TabActive, get_COL_LIGHT());
set_color(ImGuiCol_TabUnfocused, COL_GREY_DARK);
set_color(ImGuiCol_TabUnfocusedActive, COL_GREY_LIGHT);
}

View File

@ -100,14 +100,20 @@ public:
static const ImVec4 COL_GREY_LIGHT;
//static const ImVec4 COL_ORANGE_DARK;
//static const ImVec4 COL_ORANGE_LIGHT;
static const ImVec4 COL_BLUE_DARK;
static const ImVec4 COL_BLUE_LIGHT;
//static const ImVec4 COL_BLUE_DARK;
//static const ImVec4 COL_BLUE_LIGHT
static ImVec4 get_COL_DARK();
static ImVec4 get_COL_LIGHT();
static const ImVec4 COL_WINDOW_BACKGROUND;
static const ImVec4 COL_BUTTON_BACKGROUND;
static const ImVec4 COL_BUTTON_HOVERED;
static const ImVec4 COL_BUTTON_ACTIVE;
//static const ImVec4 COL_BUTTON_BACKGROUND;
//static const ImVec4 COL_BUTTON_HOVERED;
//static const ImVec4 COL_BUTTON_ACTIVE;
private:
static bool COL_LOADED;
static ImVec4 COL_DARK;
static ImVec4 COL_LIGHT;
static void load_colors();
void init_font(bool compress);
void init_input();
void init_style();

View File

@ -302,6 +302,8 @@ void PreferencesDialog::build()
m_optgroup_gui->m_on_change = [this, tabs](t_config_option_key opt_key, boost::any value) {
if (opt_key == "suppress_hyperlinks")
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "";
else if (opt_key.find("color") != std::string::npos)
m_values[opt_key] = boost::any_cast<std::string>(value);
else
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
@ -345,6 +347,54 @@ void PreferencesDialog::build()
m_optgroup_gui->append_single_option_line(option);
}
// color prusa -> susie eb7221
//ICON 237, 107, 33 -> ed6b21 ; 2172eb
//DARK 237, 107, 33 -> ed6b21 ; 32, 113, 234 2071ea
//MAIN 253, 126, 66 -> fd7e42 ; 66, 141, 253 428dfd
//LIGHT 254, 177, 139 -> feac8b; 139, 185, 254 8bb9fe
//TEXT 1.0f, 0.49f, 0.22f, 1.0f ff7d38 ; 0.26f, 0.55f, 1.0f, 1.0f 428cff
def.label = L("Very dark gui color");
def.type = coString;
def.tooltip = std::string(L("Very dark color, in the RGB hex format.")) + std::string(L(" Mainly used as background or dark text color. Slic3r(yellow): , PrusaSlicer(orange): c46737, SuperSlicer(blue): 0047c7"));
def.set_default_value(new ConfigOptionString{ app_config->get("color_very_dark") });
option = Option(def, "color_very_dark");
option.opt.width = 6;
m_optgroup_gui->append_single_option_line(option);
def.label = L("Dark gui color");
def.type = coString;
def.tooltip = std::string(L("Dark color, in the RGB hex format.")) + std::string(L(" Mainly used as icon color. Slic3r(yellow): , PrusaSlicer(orange): ed6b21, SuperSlicer(blue): 2172eb"));
def.set_default_value(new ConfigOptionString{ app_config->get("color_dark") });
option = Option(def, "color_dark");
option.opt.width = 6;
m_optgroup_gui->append_single_option_line(option);
def.label = L("Gui color");
def.type = coString;
def.tooltip = std::string(L("Main color, in the RGB hex format.")) + std::string(L(" Slic3r(yellow): , PrusaSlicer(orange): fd7e42, SuperSlicer(blue): 428dfd"));
def.set_default_value(new ConfigOptionString{ app_config->get("color") });
option = Option(def, "color");
option.opt.width = 6;
m_optgroup_gui->append_single_option_line(option);
def.label = L("Light gui color");
def.type = coString;
def.tooltip = std::string(L("Light color, in the RGB hex format.")) + std::string(L(" Slic3r(yellow): , PrusaSlicer(orange): feac8b, SuperSlicer(blue): 8bb9fe"));
def.set_default_value(new ConfigOptionString{ app_config->get("color_light") });
option = Option(def, "color_light");
option.opt.width = 6;
m_optgroup_gui->append_single_option_line(option);
def.label = L("Very light gui color");
def.type = coString;
def.tooltip = std::string(L("Very light color, in the RGB hex format.")) + std::string(L(" Mainly used as light text color. Slic3r(yellow): , PrusaSlicer(orange): ff7d38, SuperSlicer(blue): 428cff"));
def.set_default_value(new ConfigOptionString{ app_config->get("color_very_light") });
option = Option(def, "color_very_light");
option.opt.width = 6;
m_optgroup_gui->append_single_option_line(option);
activate_options_tab(m_optgroup_gui);
if (is_editor) {

View File

@ -7,6 +7,9 @@
#include <boost/algorithm/string/replace.hpp>
#include "libslic3r/AppConfig.hpp"
#include "BitmapCache.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
@ -177,6 +180,19 @@ wxMenuItem* append_menu_check_item(wxMenu* menu, int id, const wxString& string,
return item;
}
uint32_t color_from_hex(std::string hex)
{
std::stringstream ss;
ss << std::hex << hex;
uint32_t color_bad_endian;
ss >> color_bad_endian;
uint32_t color = 0;
color |= (color_bad_endian & 0xFF) << 16;
color |= (color_bad_endian & 0xFF00);
color |= (color_bad_endian & 0xFF0000) >> 16;
return color;
}
const unsigned int wxCheckListBoxComboPopup::DefaultWidth = 200;
const unsigned int wxCheckListBoxComboPopup::DefaultHeight = 200;
@ -434,9 +450,16 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
boost::replace_last(bmp_name, ".png", "");
// Try loading an SVG first, then PNG if SVG is not found:
wxBitmap *bmp = cache.load_svg(bmp_name, width, height, grayscale, Slic3r::GUI::wxGetApp().dark_mode());
uint32_t color = -1;
if (grayscale) color = 9079434;
else if (Slic3r::GUI::wxGetApp().app_config->get("color_dark").length() == 6)
try {
color = color_from_hex(Slic3r::GUI::wxGetApp().app_config->get("color_dark"));
}
catch (std::exception /*e*/) {}
wxBitmap *bmp = cache.load_svg(bmp_name, width, height, color, Slic3r::GUI::wxGetApp().dark_mode());
if (bmp == nullptr) {
bmp = cache.load_png(bmp_name, width, height, grayscale);
bmp = cache.load_png(bmp_name, width, height, color);
}
if (bmp == nullptr) {

View File

@ -43,6 +43,8 @@ wxMenuItem* append_menu_check_item(wxMenu* menu, int id, const wxString& string,
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win);
uint32_t color_from_hex(std::string hex);
class wxDialog;
void edit_tooltip(wxString& tooltip);