ENH:refine GLCanvas update dark mode logic

Change-Id: Id4c4f00a18fa0672eab528a6819b6665031a8915
This commit is contained in:
liz.li 2022-12-05 18:21:15 +08:00 committed by Lane.Wei
parent e59fe6511d
commit aab62b77bf
27 changed files with 234 additions and 148 deletions

View File

@ -314,6 +314,11 @@ Point Bed3D::point_projection(const Point& point) const
return m_polygon.point_projection(point);
}*/
void Bed3D::on_change_color_mode(bool is_dark)
{
m_is_dark = is_dark;
}
void Bed3D::render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes)
{
render_internal(canvas, bottom, scale_factor, show_axes);
@ -335,7 +340,7 @@ void Bed3D::render_internal(GLCanvas3D& canvas, bool bottom, float scale_factor,
glsafe(::glEnable(GL_DEPTH_TEST));
m_model.set_color(-1, wxGetApp().app_config->get("dark_color_mode") == "1" ? DEFAULT_MODEL_COLOR_DARK : DEFAULT_MODEL_COLOR);
m_model.set_color(-1, m_is_dark ? DEFAULT_MODEL_COLOR_DARK : DEFAULT_MODEL_COLOR);
switch (m_type)
{
@ -652,7 +657,7 @@ void Bed3D::render_model() const
GLModel* model = const_cast<GLModel*>(&m_model);
if (model->get_filename() != m_model_filename && model->init_from_file(m_model_filename)) {
model->set_color(-1, wxGetApp().app_config->get("dark_color_mode") == "1" ? DEFAULT_MODEL_COLOR_DARK : DEFAULT_MODEL_COLOR);
model->set_color(-1, m_is_dark ? DEFAULT_MODEL_COLOR_DARK : DEFAULT_MODEL_COLOR);
update_model_offset();
}

View File

@ -105,6 +105,7 @@ private:
//BBS: add part plate related logic
Vec2d m_position{ Vec2d::Zero() };
std::vector<Vec2d> m_bed_shape;
bool m_is_dark = false;
public:
Bed3D() = default;
@ -141,6 +142,8 @@ public:
void render(GLCanvas3D& canvas, bool bottom, float scale_factor, bool show_axes);
//void render_for_picking(GLCanvas3D& canvas, bool bottom, float scale_factor);
void on_change_color_mode(bool is_dark);
private:
//BBS: add partplate related logic
// Calculate an extended bounding box from axes and current model for visualization purposes.

View File

@ -330,8 +330,8 @@ void GCodeViewer::SequentialView::Marker::render(int canvas_width, int canvas_he
static float last_window_width = 0.0f;
static size_t last_text_length = 0;
const ImU32 text_name_clr = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(255, 255, 255, 0.88 * 255) : IM_COL32(38, 46, 48, 255);
const ImU32 text_value_clr = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(255, 255, 255, 0.4 * 255) : IM_COL32(144, 144, 144, 255);
const ImU32 text_name_clr = m_is_dark ? IM_COL32(255, 255, 255, 0.88 * 255) : IM_COL32(38, 46, 48, 255);
const ImU32 text_value_clr = m_is_dark ? IM_COL32(255, 255, 255, 0.4 * 255) : IM_COL32(144, 144, 144, 255);
auto it = std::find_if(moves.begin(), moves.end(), [&curr_line_id](auto move) {
return move.gcode_id == curr_line_id;
@ -863,6 +863,11 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": finished");
}
void GCodeViewer::on_change_color_mode(bool is_dark) {
m_is_dark = is_dark;
m_sequential_view.marker.on_change_color_mode(m_is_dark);
}
void GCodeViewer::set_scale(float scale)
{
if(m_scale != scale)m_scale = scale;

View File

@ -614,6 +614,7 @@ public:
Vec3f m_world_offset;
float m_z_offset{ 0.5f };
bool m_visible{ true };
bool m_is_dark = false;
public:
float m_scale = 1.0f;
@ -630,6 +631,7 @@ public:
//BBS: GUI refactor: add canvas size
void render(int canvas_width, int canvas_height, const EViewType& view_type, const std::vector<GCodeProcessorResult::MoveVertex>& moves, uint64_t curr_line_id) const;
void on_change_color_mode(bool is_dark) { m_is_dark = is_dark; }
};
class GCodeWindow
@ -771,11 +773,13 @@ private:
bool m_contained_in_bed{ true };
mutable bool m_no_render_path { false };
bool m_is_dark = false;
public:
GCodeViewer();
~GCodeViewer();
void on_change_color_mode(bool is_dark);
float m_scale = 1.0;
void set_scale(float scale = 1.0);
void init(ConfigOptionMode mode, Slic3r::PresetBundle* preset_bundle);

View File

@ -1161,6 +1161,9 @@ bool GLCanvas3D::init()
if (m_canvas == nullptr || m_context == nullptr)
return false;
// init dark mode status
on_change_color_mode(wxGetApp().app_config->get("dark_color_mode") == "1", false);
BOOST_LOG_TRIVIAL(info) <<__FUNCTION__<< " enter";
glsafe(::glClearColor(1.0f, 1.0f, 1.0f, 1.0f));
glsafe(::glClearDepth(1.0f));
@ -1235,7 +1238,6 @@ bool GLCanvas3D::init()
GLCanvas3D::load_render_colors();
Bed3D::load_render_colors();
#endif
//if (!wxGetApp().is_gl_version_greater_or_equal_to(3, 0))
// wxGetApp().plater()->enable_wireframe(false);
m_initialized = true;
@ -1243,23 +1245,40 @@ bool GLCanvas3D::init()
return true;
}
void GLCanvas3D::on_change_toolbar_color_mode() {
// reset svg
_init_toolbars();
m_gizmos.init();
// re-generate icon texture
m_separator_toolbar.set_icon_dirty();
_render_separator_toolbar_right();
m_separator_toolbar.set_icon_dirty();
_render_separator_toolbar_left();
m_main_toolbar.set_icon_dirty();
_render_main_toolbar();
wxGetApp().plater()->get_collapse_toolbar().set_icon_dirty();
_render_collapse_toolbar();
m_assemble_view_toolbar.set_icon_dirty();
_render_assemble_view_toolbar();
m_gizmos.set_icon_dirty();
m_gizmos.render_overlay();
void GLCanvas3D::on_change_color_mode(bool is_dark, bool reinit) {
m_is_dark = is_dark;
// Bed color
m_bed.on_change_color_mode(is_dark);
// GcodeViewer color
m_gcode_viewer.on_change_color_mode(is_dark);
// ImGui Style
wxGetApp().imgui()->on_change_color_mode(is_dark);
// Notification
wxGetApp().plater()->get_notification_manager()->on_change_color_mode(is_dark);
// Preview Slider
IMSlider* m_layers_slider = get_gcode_viewer().get_layers_slider();
IMSlider* m_moves_slider = get_gcode_viewer().get_moves_slider();
m_layers_slider->on_change_color_mode(is_dark);
m_moves_slider->on_change_color_mode(is_dark);
// Partplate
wxGetApp().plater()->get_partplate_list().on_change_color_mode(is_dark);
// Toolbar
if (m_canvas_type == CanvasView3D) {
m_gizmos.on_change_color_mode(is_dark);
if (reinit) {
// reset svg
_init_toolbars();
m_gizmos.init();
// set dirty to re-generate icon texture
m_separator_toolbar.set_icon_dirty();
m_separator_toolbar.set_icon_dirty();
m_main_toolbar.set_icon_dirty();
wxGetApp().plater()->get_collapse_toolbar().set_icon_dirty();
m_assemble_view_toolbar.set_icon_dirty();
m_gizmos.set_icon_dirty();
}
}
}
void GLCanvas3D::set_as_dirty()
@ -5692,10 +5711,8 @@ bool GLCanvas3D::_init_main_toolbar()
if (!m_main_toolbar.is_enabled())
return true;
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
BackgroundTexture::Metadata background_data;
background_data.filename = dark_mode ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.left = 16;
background_data.top = 16;
background_data.right = 16;
@ -5737,7 +5754,7 @@ bool GLCanvas3D::_init_main_toolbar()
GLToolbarItem::Data item;
item.name = "add";
item.icon_filename = dark_mode ? "toolbar_open_dark.svg" : "toolbar_open.svg";
item.icon_filename = m_is_dark ? "toolbar_open_dark.svg" : "toolbar_open.svg";
item.tooltip = _utf8(L("Add")) + " [" + GUI::shortkey_ctrl_prefix() + "I]";
item.sprite_id = 0;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); };
@ -5746,7 +5763,7 @@ bool GLCanvas3D::_init_main_toolbar()
return false;
item.name = "addplate";
item.icon_filename = dark_mode ? "toolbar_add_plate_dark.svg" : "toolbar_add_plate.svg";
item.icon_filename = m_is_dark ? "toolbar_add_plate_dark.svg" : "toolbar_add_plate.svg";
item.tooltip = _utf8(L("Add plate"));
item.sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD_PLATE)); };
@ -5755,7 +5772,7 @@ bool GLCanvas3D::_init_main_toolbar()
return false;
item.name = "orient";
item.icon_filename = dark_mode ? "toolbar_orient_dark.svg" : "toolbar_orient.svg";
item.icon_filename = m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg";
item.tooltip = _utf8(L("Auto orient"));
item.sprite_id++;
item.left.render_callback = nullptr;
@ -5775,7 +5792,7 @@ bool GLCanvas3D::_init_main_toolbar()
return false;
item.name = "arrange";
item.icon_filename = dark_mode ? "toolbar_arrange_dark.svg" : "toolbar_arrange.svg";
item.icon_filename = m_is_dark ? "toolbar_arrange_dark.svg" : "toolbar_arrange.svg";
item.tooltip = _utf8(L("Arrange all objects")) + " [A]\n" + _utf8(L("Arrange objects on selected plates")) + " [Shift+A]";
item.sprite_id++;
item.left.action_callback = []() {};
@ -5799,7 +5816,7 @@ bool GLCanvas3D::_init_main_toolbar()
return false;
item.name = "splitobjects";
item.icon_filename = dark_mode ? "split_objects_dark.svg" : "split_objects.svg";
item.icon_filename = m_is_dark ? "split_objects_dark.svg" : "split_objects.svg";
item.tooltip = _utf8(L("Split to objects"));
item.sprite_id++;
item.left.render_callback = nullptr;
@ -5810,7 +5827,7 @@ bool GLCanvas3D::_init_main_toolbar()
return false;
item.name = "splitvolumes";
item.icon_filename = dark_mode ? "split_parts_dark.svg" : "split_parts.svg";
item.icon_filename = m_is_dark ? "split_parts_dark.svg" : "split_parts.svg";
item.tooltip = _utf8(L("Split to parts"));
item.sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); };
@ -5820,7 +5837,7 @@ bool GLCanvas3D::_init_main_toolbar()
return false;
item.name = "layersediting";
item.icon_filename = dark_mode ? "toolbar_variable_layer_height_dark.svg" : "toolbar_variable_layer_height.svg";
item.icon_filename = m_is_dark ? "toolbar_variable_layer_height_dark.svg" : "toolbar_variable_layer_height.svg";
item.tooltip = _utf8(L("Variable layer height"));
item.sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
@ -5877,10 +5894,8 @@ bool GLCanvas3D::_init_assemble_view_toolbar()
if (!m_assemble_view_toolbar.is_enabled())
return true;
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
BackgroundTexture::Metadata background_data;
background_data.filename = dark_mode ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.left = 16;
background_data.top = 16;
background_data.right = 16;
@ -5936,10 +5951,8 @@ bool GLCanvas3D::_init_separator_toolbar()
if (!m_separator_toolbar.is_enabled())
return true;
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
BackgroundTexture::Metadata background_data;
background_data.filename = dark_mode ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.left = 0;
background_data.top = 0;
background_data.right = 0;
@ -6291,8 +6304,8 @@ void GLCanvas3D::_render_background() const
::glBegin(GL_QUADS);
float* background_color = wxGetApp().app_config->get("dark_color_mode") == "1" ? DEFAULT_BG_LIGHT_COLOR_DARK : DEFAULT_BG_LIGHT_COLOR;
float* error_background_color = wxGetApp().app_config->get("dark_color_mode") == "1" ? ERROR_BG_LIGHT_COLOR_DARK : ERROR_BG_LIGHT_COLOR;
float* background_color = m_is_dark ? DEFAULT_BG_LIGHT_COLOR_DARK : DEFAULT_BG_LIGHT_COLOR;
float* error_background_color = m_is_dark ? ERROR_BG_LIGHT_COLOR_DARK : ERROR_BG_LIGHT_COLOR;
if (use_error_color)
::glColor3fv(error_background_color);

View File

@ -200,8 +200,10 @@ class GLCanvas3D
static float DEFAULT_BG_LIGHT_COLOR[3];
static float DEFAULT_BG_LIGHT_COLOR_DARK[3];
static float ERROR_BG_LIGHT_COLOR[3];
static float DEFAULT_BG_LIGHT_COLOR_LIGHT[3];
static float ERROR_BG_LIGHT_COLOR_LIGHT[3];
static float DEFAULT_BG_LIGHT_COLOR_DARK[3];
static float ERROR_BG_LIGHT_COLOR_DARK[3];
static void update_render_colors();
@ -492,6 +494,7 @@ public:
};
private:
bool m_is_dark = false;
wxGLCanvas* m_canvas;
wxGLContext* m_context;
Bed3D &m_bed;
@ -701,7 +704,8 @@ public:
bool init();
void post_event(wxEvent &&event);
void on_change_toolbar_color_mode();
void on_change_color_mode(bool is_dark, bool reinit = true);
const bool get_dark_mode_status() { return m_is_dark; }
void set_as_dirty();
void requires_check_outside_state() { m_requires_check_outside_state = true; }

View File

@ -1186,7 +1186,6 @@ void GUI_App::post_init()
}
}
}
BOOST_LOG_TRIVIAL(info) << "finished post_init";
//BBS: remove the single instance currently
/*#ifdef _WIN32
@ -2127,7 +2126,6 @@ bool GUI_App::on_init_inner()
#endif // __WINDOWS__
#endif
// initialize label colors and fonts
init_label_colours();
init_fonts();

View File

@ -95,12 +95,6 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Model* model, DynamicPrintConfig
void View3D::set_as_dirty()
{
if (m_canvas != nullptr) {
static bool last_dark_mode_tatus = wxGetApp().app_config->get("dark_color_mode") == "1";
bool dark_mode_status = wxGetApp().app_config->get("dark_color_mode") == "1";
if (dark_mode_status != last_dark_mode_tatus) {
last_dark_mode_tatus = dark_mode_status;
m_canvas->on_change_toolbar_color_mode();
}
m_canvas->set_as_dirty();
}
}

View File

@ -126,6 +126,8 @@ protected:
GLModel m_cylinder;
GLModel m_sphere;
bool m_is_dark_mode = false;
public:
GLGizmoBase(GLCanvas3D& parent,
const std::string& icon_filename,
@ -181,6 +183,7 @@ public:
void render() { m_tooltip.clear(); on_render(); }
void render_for_picking() { on_render_for_picking(); }
void render_input_window(float x, float y, float bottom_limit);
void on_change_color_mode(bool is_dark) { m_is_dark_mode = is_dark; }
virtual std::string get_tooltip() const { return ""; }

View File

@ -249,9 +249,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("tool_type"));
std::array<wchar_t, 4> tool_ids = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon };
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
std::array<wchar_t, 4> icons;
if (dark_mode)
if (m_is_dark_mode)
icons = { ImGui::CircleButtonDarkIcon, ImGui::SphereButtonDarkIcon, ImGui::FillButtonDarkIcon, ImGui::GapFillDarkIcon };
else
icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon };
@ -265,9 +264,9 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
if (m_current_tool == tool_ids[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Button, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);

View File

@ -468,9 +468,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
std::array<wchar_t, 6> tool_ids;
tool_ids = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::HeightRangeIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon };
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
std::array<wchar_t, 6> icons;
if (dark_mode)
if (m_is_dark_mode)
icons = { ImGui::CircleButtonDarkIcon, ImGui::SphereButtonDarkIcon, ImGui::TriangleButtonDarkIcon, ImGui::HeightRangeDarkIcon, ImGui::FillButtonDarkIcon, ImGui::GapFillDarkIcon };
else
icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::HeightRangeIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon };
@ -482,9 +481,9 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.5f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
if (m_current_tool == tool_ids[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Button, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);

View File

@ -208,9 +208,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
ImGui::AlignTextToFramePadding();
m_imgui->text(m_desc.at("cursor_type"));
std::array<wchar_t, 2> tool_ids = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon };
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
std::array<wchar_t, 2> icons;
if (dark_mode)
if (m_is_dark_mode)
icons = { ImGui::CircleButtonDarkIcon, ImGui::SphereButtonDarkIcon};
else
icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon };
@ -222,9 +221,9 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
if (m_current_tool == tool_ids[i]) {
ImGui::PushStyleColor(ImGuiCol_Button, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Button, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f)); // r, g, b, a
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, m_is_dark_mode ? ImVec4(43 / 255.0f, 64 / 255.0f, 54 / 255.0f, 1.00f) : ImVec4(0.86f, 0.99f, 0.91f, 1.00f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.00f, 0.68f, 0.26f, 1.00f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);

View File

@ -69,7 +69,7 @@ void GLGizmoText::on_render_for_picking()
}
void GLGizmoText::push_button_style(bool pressed) {
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
if (pressed) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(43 / 255.f, 64 / 255.f, 54 / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(43 / 255.f, 64 / 255.f, 54 / 255.f, 1.f));
@ -105,7 +105,7 @@ void GLGizmoText::pop_button_style() {
}
void GLGizmoText::push_combo_style(const float scale) {
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * scale);
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BG_DARK);
@ -221,13 +221,12 @@ void GLGizmoText::on_render_input_window(float x, float y, float bottom_limit)
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {1.0f * currt_scale, 1.0f * currt_scale });
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 2.0f * currt_scale);
push_button_style(m_bold);
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
if (ImGui::ImageButton(dark_mode ? normal_B_dark : normal_B, { button_size - 2 * ImGui::GetStyle().FramePadding.x, button_size - 2 * ImGui::GetStyle().FramePadding.y }))
if (ImGui::ImageButton(m_is_dark_mode ? normal_B_dark : normal_B, { button_size - 2 * ImGui::GetStyle().FramePadding.x, button_size - 2 * ImGui::GetStyle().FramePadding.y }))
m_bold = !m_bold;
pop_button_style();
ImGui::SameLine();
push_button_style(m_italic);
if (ImGui::ImageButton(dark_mode ? normal_T_dark : normal_T, { button_size - 2 * ImGui::GetStyle().FramePadding.x, button_size - 2 * ImGui::GetStyle().FramePadding.y }))
if (ImGui::ImageButton(m_is_dark_mode ? normal_T_dark : normal_T, { button_size - 2 * ImGui::GetStyle().FramePadding.x, button_size - 2 * ImGui::GetStyle().FramePadding.y }))
m_italic = !m_italic;
pop_button_style();
ImGui::PopStyleVar(3);

View File

@ -125,8 +125,7 @@ bool GLGizmosManager::init()
bool result = init_icon_textures();
if (!result) return result;
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
m_background_texture.metadata.filename = dark_mode ? "toolbar_background_dark.png" : "toolbar_background.png";
m_background_texture.metadata.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png";
m_background_texture.metadata.left = 16;
m_background_texture.metadata.top = 16;
m_background_texture.metadata.right = 16;
@ -142,15 +141,15 @@ bool GLGizmosManager::init()
//BBS: GUI refactor: add obj manipulation
m_gizmos.clear();
unsigned int sprite_id = 0;
m_gizmos.emplace_back(new GLGizmoMove3D(m_parent, dark_mode ? "toolbar_move_dark.svg" : "toolbar_move.svg", EType::Move, &m_object_manipulation));
m_gizmos.emplace_back(new GLGizmoRotate3D(m_parent, dark_mode ? "toolbar_rotate_dark.svg" : "toolbar_rotate.svg", EType::Rotate, &m_object_manipulation));
m_gizmos.emplace_back(new GLGizmoScale3D(m_parent, dark_mode ? "toolbar_scale_dark.svg" : "toolbar_scale.svg", EType::Scale, &m_object_manipulation));
m_gizmos.emplace_back(new GLGizmoFlatten(m_parent, dark_mode ? "toolbar_flatten_dark.svg" : "toolbar_flatten.svg", EType::Flatten));
m_gizmos.emplace_back(new GLGizmoAdvancedCut(m_parent, dark_mode ? "toolbar_cut_dark.svg" : "toolbar_cut.svg", EType::Cut));
m_gizmos.emplace_back(new GLGizmoFdmSupports(m_parent, dark_mode ? "toolbar_support_dark.svg" : "toolbar_support.svg", EType::FdmSupports));
m_gizmos.emplace_back(new GLGizmoSeam(m_parent, dark_mode ? "toolbar_seam_dark.svg" : "toolbar_seam.svg", EType::Seam));
m_gizmos.emplace_back(new GLGizmoText(m_parent, dark_mode ? "toolbar_text_dark.svg" : "toolbar_text.svg", EType::Text));
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, dark_mode ? "mmu_segmentation_dark.svg" : "mmu_segmentation.svg", EType::MmuSegmentation));
m_gizmos.emplace_back(new GLGizmoMove3D(m_parent, m_is_dark ? "toolbar_move_dark.svg" : "toolbar_move.svg", EType::Move, &m_object_manipulation));
m_gizmos.emplace_back(new GLGizmoRotate3D(m_parent, m_is_dark ? "toolbar_rotate_dark.svg" : "toolbar_rotate.svg", EType::Rotate, &m_object_manipulation));
m_gizmos.emplace_back(new GLGizmoScale3D(m_parent, m_is_dark ? "toolbar_scale_dark.svg" : "toolbar_scale.svg", EType::Scale, &m_object_manipulation));
m_gizmos.emplace_back(new GLGizmoFlatten(m_parent, m_is_dark ? "toolbar_flatten_dark.svg" : "toolbar_flatten.svg", EType::Flatten));
m_gizmos.emplace_back(new GLGizmoAdvancedCut(m_parent, m_is_dark ? "toolbar_cut_dark.svg" : "toolbar_cut.svg", EType::Cut));
m_gizmos.emplace_back(new GLGizmoFdmSupports(m_parent, m_is_dark ? "toolbar_support_dark.svg" : "toolbar_support.svg", EType::FdmSupports));
m_gizmos.emplace_back(new GLGizmoSeam(m_parent, m_is_dark ? "toolbar_seam_dark.svg" : "toolbar_seam.svg", EType::Seam));
m_gizmos.emplace_back(new GLGizmoText(m_parent, m_is_dark ? "toolbar_text_dark.svg" : "toolbar_text.svg", EType::Text));
m_gizmos.emplace_back(new GLGizmoMmuSegmentation(m_parent, m_is_dark ? "mmu_segmentation_dark.svg" : "mmu_segmentation.svg", EType::MmuSegmentation));
m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify));
//m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++));
//m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++));
@ -166,6 +165,7 @@ bool GLGizmosManager::init()
return false;
}
gizmo->set_common_data_pool(m_common_gizmos_data.get());
gizmo->on_change_color_mode(m_is_dark);
}
m_current = Undefined;
@ -610,6 +610,10 @@ bool GLGizmosManager::wants_reslice_supports_on_undo() const
&& dynamic_cast<const GLGizmoSlaSupports*>(m_gizmos.at(SlaSupports).get())->has_backend_supports());
}
void GLGizmosManager::on_change_color_mode(bool is_dark) {
m_is_dark = is_dark;
}
void GLGizmosManager::render_current_gizmo() const
{
if (!m_enabled || m_current == Undefined)

View File

@ -144,6 +144,8 @@ private:
// key MENU_ICON_NAME, value = ImtextureID
std::map<int, void*> icon_list;
bool m_is_dark = false;
public:
std::unique_ptr<AssembleViewDataPool> m_assemble_view_data;
@ -278,6 +280,7 @@ public:
bool is_in_editing_mode(bool error_notification = false) const;
bool is_hiding_instances() const;
void on_change_color_mode(bool is_dark);
void render_current_gizmo() const;
void render_current_gizmo_for_picking_pass() const;
void render_painter_gizmo() const;

View File

@ -930,7 +930,7 @@ void NotificationManager::HintNotification::render_close_button(ImGuiWrapper& im
std::wstring button_text;
button_text = m_is_dark_mode ? ImGui::CloseNotifDarkButton : ImGui::CloseNotifButton;
button_text = m_is_dark ? ImGui::CloseNotifDarkButton : ImGui::CloseNotifButton;
ImVec2 button_pic_size = ImGui::CalcTextSize(into_u8(button_text).c_str());
ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f);
@ -939,7 +939,7 @@ void NotificationManager::HintNotification::render_close_button(ImGuiWrapper& im
ImVec2(win_pos.x, win_pos.y + win_size.y / 2 + button_pic_size.y),
true))
{
button_text = m_is_dark_mode ? ImGui::CloseNotifHoverDarkButton : ImGui::CloseNotifHoverButton;
button_text = m_is_dark ? ImGui::CloseNotifHoverDarkButton : ImGui::CloseNotifHoverButton;
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
close();
}
@ -974,12 +974,12 @@ void NotificationManager::HintNotification::render_preferences_button(ImGuiWrapp
push_style_color(ImGuiCol_TextSelectedBg, ImVec4(0, .75f, .75f, 1.f), m_state == EState::FadingOut, m_current_fade_opacity);
std::wstring button_text;
button_text = m_is_dark_mode ? ImGui::PreferencesDarkButton : ImGui::PreferencesButton;
button_text = m_is_dark ? ImGui::PreferencesDarkButton : ImGui::PreferencesButton;
//hover
if (ImGui::IsMouseHoveringRect(ImVec2(win_pos_x - m_window_width / 15.f, win_pos_y + m_window_height - 1.5f * m_line_height),
ImVec2(win_pos_x, win_pos_y + m_window_height),
true)) {
button_text = m_is_dark_mode ? ImGui::PreferencesHoverDarkButton : ImGui::PreferencesHoverButton;
button_text = m_is_dark ? ImGui::PreferencesHoverDarkButton : ImGui::PreferencesHoverButton;
// tooltip
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
ImGui::PushStyleColor(ImGuiCol_Border, { 0,0,0,0 });
@ -1017,7 +1017,7 @@ void NotificationManager::HintNotification::render_right_arrow_button(ImGuiWrapp
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
std::wstring button_text;
button_text = m_is_dark_mode ? ImGui::RightArrowDarkButton : ImGui::RightArrowButton;
button_text = m_is_dark ? ImGui::RightArrowDarkButton : ImGui::RightArrowButton;
ImVec2 button_pic_size = ImGui::CalcTextSize(into_u8(button_text).c_str());
ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f);
@ -1025,7 +1025,7 @@ void NotificationManager::HintNotification::render_right_arrow_button(ImGuiWrapp
ImVec2(win_pos_x - m_window_width / 15.f, win_pos_y + m_window_height),
true))
{
button_text = m_is_dark_mode ? ImGui::RightArrowHoverDarkButton : ImGui::RightArrowHoverButton;
button_text = m_is_dark ? ImGui::RightArrowHoverDarkButton : ImGui::RightArrowHoverButton;
// tooltip
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
ImGui::PushStyleColor(ImGuiCol_Border, { 0,0,0,0 });
@ -1068,7 +1068,7 @@ void NotificationManager::HintNotification::render_documentation_button(ImGuiWra
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
std::wstring button_text;
button_text = m_is_dark_mode ? ImGui::DocumentationDarkButton : ImGui::DocumentationButton;
button_text = m_is_dark ? ImGui::DocumentationDarkButton : ImGui::DocumentationButton;
std::string placeholder_text;
placeholder_text = ImGui::EjectButton;
@ -1078,7 +1078,7 @@ void NotificationManager::HintNotification::render_documentation_button(ImGuiWra
ImVec2(win_pos.x - m_line_height * 2.5f, win_pos.y + win_size.y / 2 + button_pic_size.y),
true))
{
button_text = m_is_dark_mode ? ImGui::DocumentationHoverDarkButton : ImGui::DocumentationHoverButton;
button_text = m_is_dark ? ImGui::DocumentationHoverDarkButton : ImGui::DocumentationHoverButton;
// tooltip
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
ImGui::PushStyleColor(ImGuiCol_Border, { 0,0,0,0 });

View File

@ -714,8 +714,8 @@ bool IMSlider::switch_one_layer_mode()
}
void IMSlider::draw_background(const ImRect& groove) {
const ImU32 bg_rect_col = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 groove_col = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(45, 45, 49, 255) : IM_COL32(206, 206, 206, 255);
const ImU32 bg_rect_col = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 groove_col = m_is_dark ? IM_COL32(45, 45, 49, 255) : IM_COL32(206, 206, 206, 255);
if (is_horizontal() || m_ticks.empty()) {
ImVec2 groove_padding = ImVec2(2.0f, 2.0f) * m_scale;
@ -764,9 +764,9 @@ bool IMSlider::horizontal_slider(const char* str_id, int* value, int v_min, int
float triangle_offsets[3] = {-3.5f * m_scale, 3.5f * m_scale, -6.06f * m_scale};
const ImU32 white_bg = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 white_bg = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 handle_clr = IM_COL32(0, 174, 66, 255);
const ImU32 handle_border_clr = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(248, 248, 248, 255);
const ImU32 handle_border_clr = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(248, 248, 248, 255);
// calc groove size
ImVec2 groove_start = ImVec2(pos.x + handle_dummy_width, pos.y + size.y - groove_y - bottom_dummy);
@ -827,7 +827,7 @@ void IMSlider::draw_colored_band(const ImRect& groove, const ImRect& slideable_r
if (m_ticks.empty())
return;
const ImU32 blank_col = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 blank_col = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
ImVec2 blank_padding = ImVec2(6.0f, 5.0f) * m_scale;
float blank_width = 1.0f * m_scale;
@ -900,7 +900,7 @@ void IMSlider::draw_ticks(const ImRect& slideable_region) {
ImVec2 icon_size = ImVec2(14.0f, 14.0f) * m_scale;
const ImU32 tick_clr = IM_COL32(144, 144, 144, 255);
const ImU32 tick_hover_box_clr = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(219, 253, 231, 255);
const ImU32 tick_hover_box_clr = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(219, 253, 231, 255);
auto get_tick_pos = [this, slideable_region](int tick)
{
@ -1001,9 +1001,9 @@ bool IMSlider::vertical_slider(const char* str_id, int* higher_value, int* lower
ImVec2 text_content_size;
ImVec2 text_size;
const ImU32 white_bg = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 white_bg = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(255, 255, 255, 255);
const ImU32 handle_clr = IM_COL32(0, 174, 66, 255);
const ImU32 handle_border_clr = wxGetApp().app_config->get("dark_color_mode") == "1" ? IM_COL32(65, 65, 71, 255) : IM_COL32(248, 248, 248, 255);
const ImU32 handle_border_clr = m_is_dark ? IM_COL32(65, 65, 71, 255) : IM_COL32(248, 248, 248, 255);
// calc slider groove size
ImVec2 groove_start = ImVec2(pos.x + size.x - groove_x - right_dummy, pos.y + text_dummy_height);
@ -1253,11 +1253,10 @@ bool IMSlider::render(int canvas_width, int canvas_height)
ImGui::Spacing();
ImGui::SameLine((VERTICAL_SLIDER_SIZE.x - ONE_LAYER_OFFSET.x) * scale * m_scale);
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
ImTextureID normal_id = dark_mode ?
ImTextureID normal_id = m_is_dark ?
is_one_layer() ? m_one_layer_on_dark_id : m_one_layer_off_dark_id :
is_one_layer() ? m_one_layer_on_id : m_one_layer_off_id;
ImTextureID hover_id = dark_mode ?
ImTextureID hover_id = m_is_dark ?
is_one_layer() ? m_one_layer_on_hover_dark_id : m_one_layer_off_hover_dark_id :
is_one_layer() ? m_one_layer_on_hover_id : m_one_layer_off_hover_id;
if (ImGui::ImageButton3(normal_id, hover_id, ImVec2(28 * m_scale, 28 * m_scale))) {
@ -1476,6 +1475,10 @@ void IMSlider::render_menu()
ImGuiWrapper::pop_menu_style();
}
void IMSlider::on_change_color_mode(bool is_dark) {
m_is_dark = is_dark;
}
void IMSlider::set_scale(float scale)
{
if(m_scale != scale) m_scale = scale;

View File

@ -282,6 +282,7 @@ public:
ExtrudersSequence m_extruders_sequence;
float m_scale = 1.0;
void set_scale(float scale = 1.0);
void on_change_color_mode(bool is_dark);
protected:
void add_custom_gcode(std::string custom_gcode);
@ -316,6 +317,8 @@ private:
std::array<int, 2> get_active_extruders_for_tick(int tick) const;
// Use those values to disable selection of active extruders
bool m_is_dark = false;
bool is_osx{false};
int m_min_value;
int m_max_value;
@ -346,6 +349,10 @@ private:
void *m_one_layer_on_hover_id;
void *m_one_layer_off_id;
void *m_one_layer_off_hover_id;
void* m_one_layer_on_light_id;
void* m_one_layer_on_hover_light_id;
void* m_one_layer_off_light_id;
void* m_one_layer_off_hover_light_id;
void* m_one_layer_on_dark_id;
void* m_one_layer_on_hover_dark_id;
void* m_one_layer_off_dark_id;

View File

@ -1671,9 +1671,16 @@ std::vector<unsigned char> ImGuiWrapper::load_svg(const std::string& bitmap_name
}
//BBS
static bool m_is_dark_mode = false;
void ImGuiWrapper::on_change_color_mode(bool is_dark)
{
m_is_dark_mode = is_dark;
}
void ImGuiWrapper::push_toolbar_style(const float scale)
{
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 10.0f) * scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 3.0f * scale);
@ -1732,7 +1739,7 @@ void ImGuiWrapper::pop_toolbar_style()
void ImGuiWrapper::push_menu_style(const float scale)
{
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGuiWrapper::push_toolbar_style(scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10.0f, 10.0f) * scale);
ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, 4.0f * scale);
@ -1761,7 +1768,7 @@ void ImGuiWrapper::pop_menu_style()
}
void ImGuiWrapper::push_common_window_style(const float scale) {
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20.0f, 10.0f) * scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowTitleAlign, ImVec2(0.05f, 0.50f) * scale);
@ -1811,7 +1818,7 @@ void ImGuiWrapper::pop_common_window_style() {
}
void ImGuiWrapper::push_confirm_button_style() {
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f / 255.f, 174.f / 255.f, 66.f / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.f / 255.f, 174.f / 255.f, 66.f / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(61.f / 255.f, 203.f / 255.f, 115.f / 255.f, 1.f));
@ -1834,7 +1841,7 @@ void ImGuiWrapper::pop_confirm_button_style() {
}
void ImGuiWrapper::push_cancel_button_style() {
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.f, 1.f, 1.f, 0.64f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(73 / 255.f, 73 / 255.f, 78 / 255.f, 1.f));
@ -1857,7 +1864,7 @@ void ImGuiWrapper::pop_cancel_button_style() {
}
void ImGuiWrapper::push_button_disable_style() {
if (wxGetApp().app_config->get("dark_color_mode") == "1") {
if (m_is_dark_mode) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(54 / 255.f, 54 / 255.f, 60 / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(54 / 255.f, 54 / 255.f, 60 / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 0.4f));

View File

@ -199,6 +199,7 @@ public:
static const ImVec4 COL_SEPARATOR_DARK;
//BBS
static void on_change_color_mode(bool is_dark);
static void push_toolbar_style(const float scale);
static void pop_toolbar_style();
static void push_menu_style(const float scale);

View File

@ -145,6 +145,8 @@ NotificationManager::PopNotification::PopNotification(const NotificationData &n,
, m_evt_handler (evt_handler)
, m_notification_start (GLCanvas3D::timestamp_now())
{
m_is_dark = wxGetApp().plater()->get_current_canvas3D()->get_dark_mode_status();
m_ErrorColor = ImVec4(0.9, 0.36, 0.36, 1);
m_WarnColor = ImVec4(0.99, 0.69, 0.455, 1);
m_NormalColor = ImVec4(0.03, 0.6, 0.18, 1);
@ -158,10 +160,13 @@ NotificationManager::PopNotification::PopNotification(const NotificationData &n,
m_WindowRadius = 4.0f * wxGetApp().plater()->get_current_canvas3D()->get_scale();
}
void NotificationManager::PopNotification::on_change_color_mode(bool is_dark)
{
m_is_dark = is_dark;
}
void NotificationManager::PopNotification::use_bbl_theme()
{
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
ImGuiStyle &OldStyle = ImGui::GetStyle();
m_DefaultTheme.mWindowPadding = OldStyle.WindowPadding;
@ -189,10 +194,10 @@ void NotificationManager::PopNotification::use_bbl_theme()
// OldStyle.Colors[ImGuiCol_WindowBg] = m_WindowBkgColor;
// OldStyle.Colors[ImGuiCol_Text] = m_TextColor;
m_WindowBkgColor = dark_mode ? ImVec4(45 / 255.f, 45 / 255.f, 49 / 255.f, 1.f) : ImVec4(1, 1, 1, 1);
m_TextColor = dark_mode ? ImVec4(224 / 255.f, 224 / 255.f, 224 / 255.f, 1.f) : ImVec4(.2f, .2f, .2f, 1.0f);
m_HyperTextColor = dark_mode ? ImVec4(0.03, 0.6, 0.18, 1) : ImVec4(0.03, 0.6, 0.18, 1);
dark_mode ? push_style_color(ImGuiCol_Border, {62 / 255.f, 62 / 255.f, 69 / 255.f, 1.f}, true, m_current_fade_opacity) : push_style_color(ImGuiCol_Border, m_CurrentColor, true, m_current_fade_opacity);
m_WindowBkgColor = m_is_dark ? ImVec4(45 / 255.f, 45 / 255.f, 49 / 255.f, 1.f) : ImVec4(1, 1, 1, 1);
m_TextColor = m_is_dark ? ImVec4(224 / 255.f, 224 / 255.f, 224 / 255.f, 1.f) : ImVec4(.2f, .2f, .2f, 1.0f);
m_HyperTextColor = m_is_dark ? ImVec4(0.03, 0.6, 0.18, 1) : ImVec4(0.03, 0.6, 0.18, 1);
m_is_dark ? push_style_color(ImGuiCol_Border, {62 / 255.f, 62 / 255.f, 69 / 255.f, 1.f}, true, m_current_fade_opacity) : push_style_color(ImGuiCol_Border, m_CurrentColor, true, m_current_fade_opacity);
push_style_color(ImGuiCol_WindowBg, m_WindowBkgColor, true, m_current_fade_opacity);
push_style_color(ImGuiCol_Text, m_TextColor, true, m_current_fade_opacity);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, m_WindowRadius / 4);
@ -279,8 +284,6 @@ void NotificationManager::PopNotification::render(GLCanvas3D& canvas, float init
use_bbl_theme();
m_is_dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
if (imgui.begin(name, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
ImVec2 win_size = ImGui::GetWindowSize();
@ -550,7 +553,7 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img
std::wstring button_text;
button_text = m_is_dark_mode ? ImGui::CloseNotifDarkButton : ImGui::CloseNotifButton;
button_text = m_is_dark ? ImGui::CloseNotifDarkButton : ImGui::CloseNotifButton;
//button_text = ImGui::PreferencesButton;
//if (ImGui::IsMouseHoveringRect(ImVec2(win_pos.x - win_size.x / 10.f, win_pos.y),
@ -558,7 +561,7 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img
// true))
if (ImGui::IsMouseHoveringRect(ImVec2(win_pos.x - win_size.x / 10.f, win_pos.y), ImVec2(win_pos.x, win_pos.y + 2 * m_line_height+10),true))
{
button_text = m_is_dark_mode ? ImGui::CloseNotifHoverDarkButton : ImGui::CloseNotifHoverButton;
button_text = m_is_dark ? ImGui::CloseNotifHoverDarkButton : ImGui::CloseNotifHoverButton;
}
ImVec2 button_pic_size = ImGui::CalcTextSize(into_u8(button_text).c_str());
ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f);
@ -634,12 +637,12 @@ void NotificationManager::PopNotification::render_minimize_button(ImGuiWrapper&
//button - if part if treggered
std::wstring button_text;
button_text = m_is_dark_mode ? ImGui::MinimalizeDarkButton : ImGui::MinimalizeButton;
button_text = m_is_dark ? ImGui::MinimalizeDarkButton : ImGui::MinimalizeButton;
if (ImGui::IsMouseHoveringRect(ImVec2(win_pos_x - m_window_width / 10.f, win_pos_y + m_window_height - 2 * m_line_height + 1),
ImVec2(win_pos_x, win_pos_y + m_window_height),
true))
{
button_text = m_is_dark_mode ? ImGui::MinimalizeHoverDarkButton : ImGui::MinimalizeHoverButton;
button_text = m_is_dark ? ImGui::MinimalizeHoverDarkButton : ImGui::MinimalizeHoverButton;
}
ImVec2 button_pic_size = ImGui::CalcTextSize(into_u8(button_text).c_str());
ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f);
@ -1544,6 +1547,13 @@ NotificationManager::NotificationManager(wxEvtHandler* evt_handler) :
{
}
void NotificationManager::on_change_color_mode(bool is_dark) {
m_is_dark = is_dark;
for (std::unique_ptr<PopNotification>& notification : m_pop_notifications){
notification->on_change_color_mode(is_dark);
}
}
void NotificationManager::push_notification(const NotificationType type, int timestamp)
{
auto it = std::find_if(std::begin(basic_notifications), std::end(basic_notifications),

View File

@ -166,6 +166,7 @@ public:
NotificationManager(wxEvtHandler* evt_handler);
~NotificationManager(){}
void on_change_color_mode(bool is_dark);
// init is called after canvas3d is created. Notifications added before init are not showed or updated
void init() { m_initialized = true; }
// Push a prefabricated notification from basic_notifications (see the table at the end of this file).
@ -394,8 +395,7 @@ private:
// set start of notification to now. Used by delayed notifications
void reset_timer() { m_notification_start = GLCanvas3D::timestamp_now(); m_state = EState::Shown; }
void set_Multiline(bool Multi) { m_multiline = Multi; }
bool m_is_dark_mode = false;
void on_change_color_mode(bool is_dark);
protected:
// Call after every size change
@ -432,6 +432,8 @@ private:
// used this function instead of reading directly m_data.duration. Some notifications might need to return changing value.
virtual int get_duration() { return m_data.duration; }
bool m_is_dark = false;
const NotificationData m_data;
// For reusing ImGUI windows.
NotificationIDProvider &m_id_provider;
@ -823,6 +825,7 @@ private:
}
}
bool m_is_dark = false;
// set by init(), until false notifications are only added not updated and frame is not requested after push
bool m_initialized{ false };
// Target for wxWidgets events sent by clicking on the hyperlink available at some notifications.

View File

@ -406,7 +406,7 @@ void PartPlate::render_background(bool force_default_color) const {
glsafe(::glColor4fv(PartPlate::SELECT_COLOR.data()));
}
else {
glsafe(wxGetApp().app_config->get("dark_color_mode") == "1" ? ::glColor4fv(PartPlate::UNSELECT_DARK_COLOR.data()) : ::glColor4fv(PartPlate::UNSELECT_COLOR.data()));
glsafe(m_partplate_list->m_is_dark ? ::glColor4fv(PartPlate::UNSELECT_DARK_COLOR.data()) : ::glColor4fv(PartPlate::UNSELECT_COLOR.data()));
}
}
else {
@ -607,15 +607,14 @@ void PartPlate::render_exclude_area(bool force_default_color) const {
void PartPlate::render_grid(bool bottom) const {
//glsafe(::glEnable(GL_MULTISAMPLE));
// draw grid
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
glsafe(::glLineWidth(1.0f * m_scale_factor));
if (bottom)
glsafe(::glColor4fv(LINE_BOTTOM_COLOR.data()));
else {
if (m_selected)
glsafe(dark_mode ? ::glColor4fv(LINE_TOP_SEL_DARK_COLOR.data()) : ::glColor4fv(LINE_TOP_SEL_COLOR.data()));
glsafe(m_partplate_list->m_is_dark ? ::glColor4fv(LINE_TOP_SEL_DARK_COLOR.data()) : ::glColor4fv(LINE_TOP_SEL_COLOR.data()));
else
glsafe(dark_mode ? ::glColor4fv(LINE_TOP_DARK_COLOR.data()) : ::glColor4fv(LINE_TOP_COLOR.data()));
glsafe(m_partplate_list->m_is_dark ? ::glColor4fv(LINE_TOP_DARK_COLOR.data()) : ::glColor4fv(LINE_TOP_COLOR.data()));
}
glsafe(::glVertexPointer(3, GL_FLOAT, m_gridlines.get_vertex_data_size(), (GLvoid*)m_gridlines.get_vertices_data()));
glsafe(::glDrawArrays(GL_LINES, 0, (GLsizei)m_gridlines.get_vertices_count()));
@ -2362,7 +2361,6 @@ Vec2d PartPlateList::compute_shape_position(int index, int cols)
//generate icon textures
void PartPlateList::generate_icon_textures()
{
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
// use higher resolution images if graphic card and opengl version allow
GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size();
std::string path = resources_dir() + "/images/";
@ -2370,7 +2368,7 @@ void PartPlateList::generate_icon_textures()
//if (m_del_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_close_dark.svg" : "plate_close.svg");
file_name = path + (m_is_dark ? "plate_close_dark.svg" : "plate_close.svg");
if (!m_del_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2378,7 +2376,7 @@ void PartPlateList::generate_icon_textures()
//if (m_del_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_close_hover_dark.svg" : "plate_close_hover.svg");
file_name = path + (m_is_dark ? "plate_close_hover_dark.svg" : "plate_close_hover.svg");
if (!m_del_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2386,7 +2384,7 @@ void PartPlateList::generate_icon_textures()
//if (m_arrange_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_arrange_dark.svg" : "plate_arrange.svg");
file_name = path + (m_is_dark ? "plate_arrange_dark.svg" : "plate_arrange.svg");
if (!m_arrange_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2394,7 +2392,7 @@ void PartPlateList::generate_icon_textures()
//if (m_arrange_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_arrange_hover_dark.svg" : "plate_arrange_hover.svg");
file_name = path + (m_is_dark ? "plate_arrange_hover_dark.svg" : "plate_arrange_hover.svg");
if (!m_arrange_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2402,7 +2400,7 @@ void PartPlateList::generate_icon_textures()
//if (m_orient_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_orient_dark.svg" : "plate_orient.svg");
file_name = path + (m_is_dark ? "plate_orient_dark.svg" : "plate_orient.svg");
if (!m_orient_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2410,7 +2408,7 @@ void PartPlateList::generate_icon_textures()
//if (m_orient_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_orient_hover_dark.svg" : "plate_orient_hover.svg");
file_name = path + (m_is_dark ? "plate_orient_hover_dark.svg" : "plate_orient_hover.svg");
if (!m_orient_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2418,7 +2416,7 @@ void PartPlateList::generate_icon_textures()
//if (m_locked_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_locked_dark.svg" : "plate_locked.svg");
file_name = path + (m_is_dark ? "plate_locked_dark.svg" : "plate_locked.svg");
if (!m_locked_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2426,7 +2424,7 @@ void PartPlateList::generate_icon_textures()
//if (m_locked_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_locked_hover_dark.svg" : "plate_locked_hover.svg");
file_name = path + (m_is_dark ? "plate_locked_hover_dark.svg" : "plate_locked_hover.svg");
if (!m_locked_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2434,7 +2432,7 @@ void PartPlateList::generate_icon_textures()
//if (m_lockopen_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_unlocked_dark.svg" : "plate_unlocked.svg");
file_name = path + (m_is_dark ? "plate_unlocked_dark.svg" : "plate_unlocked.svg");
if (!m_lockopen_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2442,7 +2440,7 @@ void PartPlateList::generate_icon_textures()
//if (m_lockopen_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_unlocked_hover_dark.svg" : "plate_unlocked_hover.svg");
file_name = path + (m_is_dark ? "plate_unlocked_hover_dark.svg" : "plate_unlocked_hover.svg");
if (!m_lockopen_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2450,7 +2448,7 @@ void PartPlateList::generate_icon_textures()
//if (m_bedtype_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_set_bedtype_dark.svg" : "plate_set_bedtype.svg");
file_name = path + (m_is_dark ? "plate_set_bedtype_dark.svg" : "plate_set_bedtype.svg");
if (!m_bedtype_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2458,7 +2456,7 @@ void PartPlateList::generate_icon_textures()
//if (m_bedtype_changed_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_set_bedtype_changed_dark.svg" : "plate_set_bedtype_changed.svg");
file_name = path + (m_is_dark ? "plate_set_bedtype_changed_dark.svg" : "plate_set_bedtype_changed.svg");
if (!m_bedtype_changed_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2466,7 +2464,7 @@ void PartPlateList::generate_icon_textures()
//if (m_bedtype_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_set_bedtype_hover_dark.svg" : "plate_set_bedtype_hover.svg");
file_name = path + (m_is_dark ? "plate_set_bedtype_hover_dark.svg" : "plate_set_bedtype_hover.svg");
if (!m_bedtype_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -2474,7 +2472,7 @@ void PartPlateList::generate_icon_textures()
//if (m_bedtype_changed_hovered_texture.get_id() == 0)
{
file_name = path + (dark_mode ? "plate_set_bedtype_changed_hover_dark.svg" : "plate_set_bedtype_changed_hover.svg");
file_name = path + (m_is_dark ? "plate_set_bedtype_changed_hover_dark.svg" : "plate_set_bedtype_changed_hover.svg");
if (!m_bedtype_changed_hovered_texture.load_from_svg_file(file_name, true, false, false, max_tex_size / 8)) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name;
}
@ -3771,10 +3769,9 @@ void PartPlateList::render(bool bottom, bool only_current, bool only_body, int h
plate_hover_action = hover_id % PartPlate::GRABBER_COUNT;
}
static bool last_dark_mode_tatus = wxGetApp().app_config->get("dark_color_mode") == "1";
bool dark_mode_status = wxGetApp().app_config->get("dark_color_mode") == "1";
if (dark_mode_status != last_dark_mode_tatus) {
last_dark_mode_tatus = dark_mode_status;
static bool last_dark_mode_status = m_is_dark;
if (m_is_dark != last_dark_mode_status) {
last_dark_mode_status = m_is_dark;
generate_icon_textures();
}else if(m_del_texture.get_id() == 0)
generate_icon_textures();

View File

@ -490,6 +490,8 @@ class PartPlateList : public ObjectBase
bool render_bedtype_logo = true;
bool render_bedtype_setting = true;
bool m_is_dark = false;
void init();
//compute the origin for printable plate with index i
Vec3d compute_origin(int index, int column_count);
@ -636,6 +638,7 @@ public:
void postprocess_arrange_polygon(arrangement::ArrangePolygon& arrange_polygon, bool selected);
/*rendering related functions*/
void on_change_color_mode(bool is_dark) { m_is_dark = is_dark; }
void render(bool bottom, bool only_current = false, bool only_body = false, int hover_id = -1);
void render_for_picking_pass();
void set_render_option(bool bedtype_texture, bool bedtype_settings);

View File

@ -162,7 +162,8 @@ wxDEFINE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);
wxDEFINE_EVENT(EVT_INSTALL_PLUGIN_NETWORKING, wxCommandEvent);
wxDEFINE_EVENT(EVT_INSTALL_PLUGIN_HINT, wxCommandEvent);
wxDEFINE_EVENT(EVT_PREVIEW_ONLY_MODE_HINT, wxCommandEvent);
//BBS: change light/dark mode
wxDEFINE_EVENT(EVT_GLCANVAS_COLOR_MODE_CHANGED, SimpleEvent);
bool Plater::has_illegal_filename_characters(const wxString& wxs_name)
@ -1707,6 +1708,8 @@ struct Plater::priv
static const std::regex pattern_any_amf;
static const std::regex pattern_prusa;
bool m_is_dark = false;
priv(Plater *q, MainFrame *main_frame);
~priv();
@ -1964,7 +1967,9 @@ struct Plater::priv
void on_action_export_sliced_file(SimpleEvent&);
void on_action_export_all_sliced_file(SimpleEvent&);
void on_action_select_sliced_plate(wxCommandEvent& evt);
//BBS: change dark/light mode
void on_change_color_mode(SimpleEvent& evt);
void on_apple_change_color_mode(wxSysColourChangedEvent& evt);
void on_update_geometry(Vec3dsEvent<2>&);
void on_3dcanvas_mouse_dragging_started(SimpleEvent&);
void on_3dcanvas_mouse_dragging_finished(SimpleEvent&);
@ -2150,6 +2155,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->q->Bind(EVT_INSTALL_PLUGIN_NETWORKING, &priv::install_network_plugin, this);
this->q->Bind(EVT_INSTALL_PLUGIN_HINT, &priv::show_install_plugin_hint, this);
this->q->Bind(EVT_PREVIEW_ONLY_MODE_HINT, &priv::show_preview_only_hint, this);
this->q->Bind(EVT_GLCANVAS_COLOR_MODE_CHANGED, &priv::on_change_color_mode, this);
this->q->Bind(wxEVT_SYS_COLOUR_CHANGED, &priv::on_apple_change_color_mode, this);
view3D = new View3D(q, bed, &model, config, &background_process);
//BBS: use partplater's gcode
@ -2196,6 +2203,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
menus.init(q);
// Events:
if (wxGetApp().is_editor()) {
@ -6105,6 +6113,20 @@ void Plater::priv::show_preview_only_hint(wxCommandEvent &event)
notification_manager->bbl_show_preview_only_notification(into_u8(_L("Preview only mode:\nThe loaded file contains gcode only, Can not enter the Prepare page")));
}
void Plater::priv::on_apple_change_color_mode(wxSysColourChangedEvent& evt) {
m_is_dark = wxSystemSettings::GetAppearance().IsDark();
view3D->get_canvas3d()->on_change_color_mode(m_is_dark);
preview->get_canvas3d()->on_change_color_mode(m_is_dark);
assemble_view->get_canvas3d()->on_change_color_mode(m_is_dark);
}
void Plater::priv::on_change_color_mode(SimpleEvent& evt) {
m_is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";
view3D->get_canvas3d()->on_change_color_mode(m_is_dark);
preview->get_canvas3d()->on_change_color_mode(m_is_dark);
assemble_view->get_canvas3d()->on_change_color_mode(m_is_dark);
}
void Plater::priv::on_right_click(RBtnEvent& evt)
{
int obj_idx = get_selected_object_idx();
@ -6492,10 +6514,8 @@ bool Plater::priv::init_collapse_toolbar()
// already initialized
return true;
bool dark_mode = wxGetApp().app_config->get("dark_color_mode") == "1";
BackgroundTexture::Metadata background_data;
background_data.filename = dark_mode ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png";
background_data.left = 16;
background_data.top = 16;
background_data.right = 16;

View File

@ -88,6 +88,7 @@ wxDECLARE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);
wxDECLARE_EVENT(EVT_INSTALL_PLUGIN_NETWORKING, wxCommandEvent);
wxDECLARE_EVENT(EVT_INSTALL_PLUGIN_HINT, wxCommandEvent);
wxDECLARE_EVENT(EVT_PREVIEW_ONLY_MODE_HINT, wxCommandEvent);
wxDECLARE_EVENT(EVT_GLCANVAS_COLOR_MODE_CHANGED, SimpleEvent);
const wxString DEFAULT_PROJECT_NAME = "Untitled";
@ -348,6 +349,7 @@ public:
void print_job_finished(wxCommandEvent &evt);
void send_job_finished(wxCommandEvent& evt);
void publish_job_finished(wxCommandEvent& evt);
void on_change_color_mode(SimpleEvent& evt);
void eject_drive();
void take_snapshot(const std::string &snapshot_name);

View File

@ -498,7 +498,8 @@ wxBoxSizer* PreferencesDialog::create_item_darkmode_checkbox(wxString title, wxW
wxGetApp().update_ui_from_settings();
set_dark_mode();
#endif
SimpleEvent evt = SimpleEvent(EVT_GLCANVAS_COLOR_MODE_CHANGED);
wxPostEvent(wxGetApp().plater(), evt);
e.Skip();
});