Implemented palettes for mode markers
This commit is contained in:
parent
12ec008950
commit
033af199a3
10
resources/icons/mode.svg
Normal file
10
resources/icons/mode.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||
<g id="hex_x5F_green">
|
||||
<g>
|
||||
<polygon fill="#ED6B21" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 462 B |
@ -1,5 +1,6 @@
|
||||
#include "ButtonsDescription.hpp"
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/clrpicker.h>
|
||||
@ -7,11 +8,82 @@
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "OptionsGroup.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
//static ModePaletteComboBox::PalettesMap MODE_PALETTES =
|
||||
static std::vector<std::pair<std::string, std::vector<std::string>>> MODE_PALETTES =
|
||||
{
|
||||
{ L("Palette 1"), { "#7DF028", "#FFDC00", "#E70000" } },
|
||||
{ L("Palette 2"), { "#FC766A", "#B0B8B4", "#184A45" } },
|
||||
{ L("Palette 3"), { "#567572", "#964F4C", "#696667" } },
|
||||
{ L("Palette 4"), { "#DA291C", "#56A8CB", "#53A567" } },
|
||||
{ L("Palette 5"), { "#F65058", "#FBDE44", "#28334A" } },
|
||||
{ L("Palette 6"), { "#FF3EA5", "#EDFF00", "#00A4CC" } },
|
||||
{ L("Palette 7"), { "#E95C20", "#006747", "#4F2C1D" } },
|
||||
{ L("Palette 8"), { "#D9514E", "#2A2B2D", "#2DA8D8" } }
|
||||
};
|
||||
|
||||
ModePaletteComboBox::ModePaletteComboBox(wxWindow* parent) :
|
||||
BitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY)
|
||||
{
|
||||
for (const auto& palette : MODE_PALETTES)
|
||||
Append(_(palette.first), *get_bmp(palette.second));
|
||||
}
|
||||
|
||||
void ModePaletteComboBox::UpdateSelection(const std::vector<wxColour> &palette_in)
|
||||
{
|
||||
for (size_t idx = 0; idx < MODE_PALETTES.size(); ++idx ) {
|
||||
const auto& palette = MODE_PALETTES[idx].second;
|
||||
|
||||
bool is_selected = true;
|
||||
for (size_t mode = 0; mode < palette_in.size(); mode++)
|
||||
if (wxColour(palette[mode]) != palette_in[mode]) {
|
||||
is_selected = false;
|
||||
break;
|
||||
}
|
||||
if (is_selected) {
|
||||
Select(int(idx));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Select(-1);
|
||||
}
|
||||
|
||||
BitmapCache& ModePaletteComboBox::bitmap_cache()
|
||||
{
|
||||
static BitmapCache bmps;
|
||||
return bmps;
|
||||
}
|
||||
|
||||
wxBitmapBundle * ModePaletteComboBox::get_bmp(const std::vector<std::string> &palette)
|
||||
{
|
||||
std::string bitmap_key;
|
||||
for (const auto& color : palette)
|
||||
bitmap_key += color + "+";
|
||||
|
||||
const int icon_height = wxOSX ? 10 : 12;
|
||||
|
||||
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
|
||||
if (bmp_bndl == nullptr) {
|
||||
// Create the bitmap with color bars.
|
||||
std::vector<wxBitmapBundle*> bmps;
|
||||
for (const auto& color : palette) {
|
||||
bmps.emplace_back(get_bmp_bundle("mode", icon_height, color));
|
||||
bmps.emplace_back(get_empty_bmp_bundle(wxOSX ? 5 : 6, icon_height));
|
||||
}
|
||||
bmp_bndl = bitmap_cache().insert_bndl(bitmap_key, bmps);
|
||||
}
|
||||
|
||||
return bmp_bndl;
|
||||
}
|
||||
|
||||
|
||||
void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour)
|
||||
{
|
||||
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(3, 5, 5);
|
||||
@ -48,13 +120,81 @@ void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWi
|
||||
|
||||
grid_sizer->Add(*color_picker, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
grid_sizer->Add(btn, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
grid_sizer->Add(sys_label, 0, wxALIGN_CENTRE_VERTICAL | wxEXPAND);
|
||||
grid_sizer->Add(sys_label, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
};
|
||||
|
||||
add_color(sys_colour, wxGetApp().get_label_clr_sys(), wxGetApp().get_label_default_clr_system(), _L("Value is the same as the system value"));
|
||||
add_color(mod_colour, wxGetApp().get_label_clr_modified(),wxGetApp().get_label_default_clr_modified(), _L("Value was changed and is not equal to the system value or the last saved preset"));
|
||||
}
|
||||
|
||||
void ButtonsDescription::FillSizerWithModeColorDescriptions(
|
||||
wxSizer* sizer, wxWindow* parent,
|
||||
std::vector<wxColourPickerCtrl**> clr_pickers,
|
||||
std::vector<wxColour>& mode_palette)
|
||||
{
|
||||
const int margin = em_unit(parent);
|
||||
|
||||
auto palette_cb = new ModePaletteComboBox(parent);
|
||||
palette_cb->UpdateSelection(mode_palette);
|
||||
|
||||
palette_cb->Bind(wxEVT_COMBOBOX, [clr_pickers, &mode_palette](wxCommandEvent& evt) {
|
||||
const int selection = evt.GetSelection();
|
||||
if (selection < 0)
|
||||
return;
|
||||
const auto& palette = MODE_PALETTES[selection];
|
||||
for (int mode = 0; mode < 3; mode++)
|
||||
if (*clr_pickers[mode]) {
|
||||
wxColour clr = wxColour(palette.second[mode]);
|
||||
(*clr_pickers[mode])->SetColour(clr);
|
||||
mode_palette[mode] = clr;
|
||||
}
|
||||
});
|
||||
|
||||
wxBoxSizer* h_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
h_sizer->Add(new wxStaticText(parent, wxID_ANY, _L("Default palette for mode markers") + ": "), 0, wxALIGN_CENTER_VERTICAL);
|
||||
h_sizer->Add(palette_cb, 1, wxEXPAND);
|
||||
|
||||
sizer->Add(h_sizer, 0, wxEXPAND | wxBOTTOM, margin);
|
||||
|
||||
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(9, 5, 5);
|
||||
sizer->Add(grid_sizer, 0, wxEXPAND);
|
||||
|
||||
const std::vector<wxString> names = { _L("Simple"), _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), _L("Expert") };
|
||||
|
||||
for (size_t mode = 0; mode < names.size(); ++mode) {
|
||||
wxColour& color = mode_palette[mode];
|
||||
|
||||
wxColourPickerCtrl** color_picker = clr_pickers[mode];
|
||||
*color_picker = new wxColourPickerCtrl(parent, wxID_ANY, color);
|
||||
wxGetApp().UpdateDarkUI((*color_picker)->GetPickerCtrl(), true);
|
||||
|
||||
(*color_picker)->Bind(wxEVT_COLOURPICKER_CHANGED, [color_picker, &color, palette_cb, &mode_palette](wxCommandEvent&) {
|
||||
const wxColour new_color = (*color_picker)->GetColour();
|
||||
if (new_color != color) {
|
||||
color = new_color;
|
||||
palette_cb->UpdateSelection(mode_palette);
|
||||
}
|
||||
});
|
||||
|
||||
wxColour def_color = color;
|
||||
auto btn = new ScalableButton(parent, wxID_ANY, "undo");
|
||||
btn->SetToolTip(_L("Revert color"));
|
||||
|
||||
btn->Bind(wxEVT_BUTTON, [color_picker, &color, def_color, palette_cb, &mode_palette](wxEvent& event) {
|
||||
color = def_color;
|
||||
(*color_picker)->SetColour(def_color);
|
||||
palette_cb->UpdateSelection(mode_palette);
|
||||
});
|
||||
parent->Bind(wxEVT_UPDATE_UI, [color_picker, def_color](wxUpdateUIEvent& evt) {
|
||||
evt.Enable((*color_picker)->GetColour() != def_color);
|
||||
}, btn->GetId());
|
||||
|
||||
grid_sizer->Add(*color_picker, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
grid_sizer->Add(btn, 0, wxALIGN_CENTRE_VERTICAL);
|
||||
grid_sizer->Add(new wxStaticText(parent, wxID_ANY, names[mode]), 0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 2*margin);
|
||||
}
|
||||
}
|
||||
|
||||
ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry> &entries) :
|
||||
wxDialog(parent, wxID_ANY, _(L("Buttons And Text Colors Description")), wxDefaultPosition, wxDefaultSize),
|
||||
m_entries(entries)
|
||||
@ -74,13 +214,20 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
|
||||
auto description = new wxStaticText(this, wxID_ANY, _(entry.symbol));
|
||||
grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL);
|
||||
description = new wxStaticText(this, wxID_ANY, _(entry.explanation));
|
||||
grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL | wxEXPAND);
|
||||
grid_sizer->Add(description, -1, wxALIGN_CENTRE_VERTICAL);
|
||||
}
|
||||
|
||||
// Text color description
|
||||
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
FillSizerWithTextColorDescriptions(sizer, this, &sys_colour, &mod_colour);
|
||||
main_sizer->Add(sizer, 0, wxEXPAND | wxALL, 20);
|
||||
main_sizer->Add(sizer, 0, wxEXPAND | wxALL, 20);
|
||||
|
||||
// Mode color markers description
|
||||
mode_palette = wxGetApp().get_mode_palette();
|
||||
|
||||
wxSizer* mode_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
FillSizerWithModeColorDescriptions(mode_sizer, this, { &simple, &advanced, &expert }, mode_palette);
|
||||
main_sizer->Add(mode_sizer, 0, wxEXPAND | wxALL, 20);
|
||||
|
||||
auto buttons = CreateStdDialogButtonSizer(wxOK|wxCANCEL);
|
||||
main_sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
|
||||
@ -89,8 +236,10 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, const std::vector<Entry
|
||||
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) {
|
||||
wxGetApp().set_label_clr_sys(sys_colour->GetColour());
|
||||
wxGetApp().set_label_clr_modified(mod_colour->GetColour());
|
||||
wxGetApp().set_mode_palette(mode_palette);
|
||||
|
||||
EndModal(wxID_OK);
|
||||
});
|
||||
});
|
||||
|
||||
wxGetApp().UpdateDarkUI(btn);
|
||||
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(FindWindowById(wxID_CANCEL, this)));
|
||||
|
@ -4,16 +4,48 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/bmpbndl.h>
|
||||
|
||||
#include "BitmapComboBox.hpp"
|
||||
|
||||
class ScalableBitmap;
|
||||
class wxColourPickerCtrl;
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class BitmapCache;
|
||||
|
||||
// ---------------------------------
|
||||
// *** PaletteComboBox ***
|
||||
// ---------------------------------
|
||||
|
||||
// BitmapComboBox used to palets list in GUI Preferences
|
||||
class ModePaletteComboBox : public BitmapComboBox
|
||||
{
|
||||
public:
|
||||
ModePaletteComboBox(wxWindow* parent);
|
||||
~ModePaletteComboBox() = default;
|
||||
|
||||
void UpdateSelection(const std::vector<wxColour>& palette_in);
|
||||
|
||||
protected:
|
||||
// Caching bitmaps for the all bitmaps, used in preset comboboxes
|
||||
static BitmapCache& bitmap_cache();
|
||||
wxBitmapBundle* get_bmp( const std::vector<std::string>& palette);
|
||||
};
|
||||
|
||||
|
||||
class ButtonsDescription : public wxDialog
|
||||
{
|
||||
wxColourPickerCtrl* sys_colour{ nullptr };
|
||||
wxColourPickerCtrl* mod_colour{ nullptr };
|
||||
|
||||
wxColourPickerCtrl* simple { nullptr };
|
||||
wxColourPickerCtrl* advanced { nullptr };
|
||||
wxColourPickerCtrl* expert { nullptr };
|
||||
|
||||
std::vector<wxColour> mode_palette;
|
||||
public:
|
||||
struct Entry {
|
||||
Entry(ScalableBitmap *bitmap, const std::string &symbol, const std::string &explanation) : bitmap(bitmap), symbol(symbol), explanation(explanation) {}
|
||||
@ -27,6 +59,9 @@ public:
|
||||
~ButtonsDescription() {}
|
||||
|
||||
static void FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWindow* parent, wxColourPickerCtrl** sys_colour, wxColourPickerCtrl** mod_colour);
|
||||
static void FillSizerWithModeColorDescriptions(wxSizer* sizer, wxWindow* parent,
|
||||
std::vector<wxColourPickerCtrl**> clr_pickers,
|
||||
std::vector<wxColour>& mode_palette);
|
||||
|
||||
private:
|
||||
std::vector<Entry> m_entries;
|
||||
|
@ -1127,7 +1127,7 @@ bool GUI_App::on_init_inner()
|
||||
NppDarkMode::InitDarkMode(init_dark_color_mode, init_sys_menu_enabled);
|
||||
#endif
|
||||
// initialize label colors and fonts
|
||||
init_label_colours();
|
||||
init_ui_colours();
|
||||
init_fonts();
|
||||
|
||||
std::string older_data_dir_path;
|
||||
@ -1145,8 +1145,8 @@ bool GUI_App::on_init_inner()
|
||||
if (bool new_dark_color_mode = app_config->get("dark_color_mode") == "1";
|
||||
init_dark_color_mode != new_dark_color_mode) {
|
||||
NppDarkMode::SetDarkMode(new_dark_color_mode);
|
||||
init_label_colours();
|
||||
update_label_colours_from_appconfig();
|
||||
init_ui_colours();
|
||||
update_ui_colours_from_appconfig();
|
||||
}
|
||||
if (bool new_sys_menu_enabled = app_config->get("sys_menu_enabled") == "1";
|
||||
init_sys_menu_enabled != new_sys_menu_enabled)
|
||||
@ -1431,10 +1431,16 @@ const wxColour GUI_App::get_label_default_clr_modified()
|
||||
return dark_mode() ? wxColour(253, 111, 40) : wxColour(252, 77, 1);
|
||||
}
|
||||
|
||||
void GUI_App::init_label_colours()
|
||||
const std::vector<std::string> GUI_App::get_mode_default_palette()
|
||||
{
|
||||
return { "#7DF028", "#FFDC00", "#E70000" };
|
||||
}
|
||||
|
||||
void GUI_App::init_ui_colours()
|
||||
{
|
||||
m_color_label_modified = get_label_default_clr_modified();
|
||||
m_color_label_sys = get_label_default_clr_system();
|
||||
m_mode_palette = get_mode_default_palette();
|
||||
|
||||
bool is_dark_mode = dark_mode();
|
||||
#ifdef _WIN32
|
||||
@ -1450,19 +1456,30 @@ void GUI_App::init_label_colours()
|
||||
m_color_window_default = is_dark_mode ? wxColour(43, 43, 43) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
}
|
||||
|
||||
void GUI_App::update_label_colours_from_appconfig()
|
||||
void GUI_App::update_ui_colours_from_appconfig()
|
||||
{
|
||||
// load label colors
|
||||
if (app_config->has("label_clr_sys")) {
|
||||
auto str = app_config->get("label_clr_sys");
|
||||
if (str != "")
|
||||
if (!str.empty())
|
||||
m_color_label_sys = wxColour(str);
|
||||
}
|
||||
|
||||
if (app_config->has("label_clr_modified")) {
|
||||
auto str = app_config->get("label_clr_modified");
|
||||
if (str != "")
|
||||
if (!str.empty())
|
||||
m_color_label_modified = wxColour(str);
|
||||
}
|
||||
|
||||
// load mode markers colors
|
||||
if (app_config->has("mode_palette")) {
|
||||
const auto colors = app_config->get("mode_palette");
|
||||
if (!colors.empty()) {
|
||||
m_mode_palette.clear();
|
||||
if (!unescape_strings_cstyle(colors, m_mode_palette))
|
||||
m_mode_palette = get_mode_default_palette();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_App::update_label_colours()
|
||||
@ -1649,6 +1666,39 @@ void GUI_App::set_label_clr_sys(const wxColour& clr)
|
||||
app_config->save();
|
||||
}
|
||||
|
||||
const std::string& GUI_App::get_mode_btn_color(int mode_id)
|
||||
{
|
||||
assert(0 <= mode_id && size_t(mode_id) < m_mode_palette.size());
|
||||
return m_mode_palette[mode_id];
|
||||
}
|
||||
|
||||
std::vector<wxColour> GUI_App::get_mode_palette()
|
||||
{
|
||||
return { wxColor(m_mode_palette[0]),
|
||||
wxColor(m_mode_palette[1]),
|
||||
wxColor(m_mode_palette[2]) };
|
||||
}
|
||||
|
||||
void GUI_App::set_mode_palette(const std::vector<wxColour>& palette)
|
||||
{
|
||||
bool save = false;
|
||||
|
||||
for (size_t mode = 0; mode < palette.size(); ++mode) {
|
||||
const wxColour& clr = palette[mode];
|
||||
std::string color_str = clr == wxTransparentColour ? std::string("") : encode_color(ColorRGB(clr.Red(), clr.Green(), clr.Blue()));
|
||||
if (m_mode_palette[mode] != color_str) {
|
||||
m_mode_palette[mode] = color_str;
|
||||
save = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (save) {
|
||||
mainframe->update_mode_markers();
|
||||
app_config->set("mode_palette", escape_strings_cstyle(m_mode_palette));
|
||||
app_config->save();
|
||||
}
|
||||
}
|
||||
|
||||
bool GUI_App::tabs_as_menu() const
|
||||
{
|
||||
return app_config->get("tabs_as_menu") == "1"; // || dark_mode();
|
||||
|
@ -139,6 +139,7 @@ private:
|
||||
wxColour m_color_selected_btn_bg;
|
||||
bool m_force_colors_update { false };
|
||||
#endif
|
||||
std::vector<std::string> m_mode_palette;
|
||||
|
||||
wxFont m_small_font;
|
||||
wxFont m_bold_font;
|
||||
@ -194,8 +195,9 @@ public:
|
||||
static bool dark_mode();
|
||||
const wxColour get_label_default_clr_system();
|
||||
const wxColour get_label_default_clr_modified();
|
||||
void init_label_colours();
|
||||
void update_label_colours_from_appconfig();
|
||||
const std::vector<std::string> get_mode_default_palette();
|
||||
void init_ui_colours();
|
||||
void update_ui_colours_from_appconfig();
|
||||
void update_label_colours();
|
||||
// update color mode for window
|
||||
void UpdateDarkUI(wxWindow *window, bool highlited = false, bool just_font = false);
|
||||
@ -215,6 +217,9 @@ public:
|
||||
const wxColour& get_label_clr_default() { return m_color_label_default; }
|
||||
const wxColour& get_window_default_clr(){ return m_color_window_default; }
|
||||
|
||||
const std::string& get_mode_btn_color(int mode_id);
|
||||
std::vector<wxColour> get_mode_palette();
|
||||
void set_mode_palette(const std::vector<wxColour> &palette);
|
||||
|
||||
#ifdef _WIN32
|
||||
const wxColour& get_label_highlight_clr() { return m_color_highlight_label_default; }
|
||||
|
@ -715,6 +715,8 @@ void MainFrame::update_title()
|
||||
|
||||
void MainFrame::init_tabpanel()
|
||||
{
|
||||
wxGetApp().update_ui_colours_from_appconfig();
|
||||
|
||||
// wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10
|
||||
// with multiple high resolution displays connected.
|
||||
#ifdef _MSW_DARK_MODE
|
||||
@ -847,7 +849,6 @@ void MainFrame::register_win32_callbacks()
|
||||
|
||||
void MainFrame::create_preset_tabs()
|
||||
{
|
||||
wxGetApp().update_label_colours_from_appconfig();
|
||||
add_created_tab(new TabPrint(m_tabpanel), "cog");
|
||||
add_created_tab(new TabFilament(m_tabpanel), "spool");
|
||||
add_created_tab(new TabSLAPrint(m_tabpanel), "cog");
|
||||
@ -1091,7 +1092,9 @@ void MainFrame::on_sys_color_changed()
|
||||
wxBusyCursor wait;
|
||||
|
||||
// update label colors in respect to the system mode
|
||||
wxGetApp().init_label_colours();
|
||||
wxGetApp().init_ui_colours();
|
||||
// but if there are some ui colors in appconfig, they have to be applied
|
||||
wxGetApp().update_ui_colours_from_appconfig();
|
||||
#ifdef __WXMSW__
|
||||
wxGetApp().UpdateDarkUI(m_tabpanel);
|
||||
// m_statusbar->update_dark_ui();
|
||||
@ -1114,6 +1117,24 @@ void MainFrame::on_sys_color_changed()
|
||||
this->Refresh();
|
||||
}
|
||||
|
||||
void MainFrame::update_mode_markers()
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// update markers in common mode sizer
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->UpdateModeMarkers();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// update mode markers on side_bar
|
||||
wxGetApp().sidebar().update_mode_markers();
|
||||
|
||||
// update mode markers in tabs
|
||||
for (auto tab : wxGetApp().tabs_list)
|
||||
tab->update_mode_markers();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// \xA0 is a non-breaking space. It is entered here to spoil the automatic accelerators,
|
||||
// as the simple numeric accelerators spoil all numeric data entry.
|
||||
|
@ -143,6 +143,7 @@ public:
|
||||
~MainFrame() = default;
|
||||
|
||||
void update_layout();
|
||||
void update_mode_markers();
|
||||
|
||||
// Called when closing the application and when switching the application language.
|
||||
void shutdown();
|
||||
|
@ -109,9 +109,16 @@ void ButtonsListCtrl::OnColorsChanged()
|
||||
for (ScalableButton* btn : m_pageButtons)
|
||||
btn->sys_color_changed();
|
||||
|
||||
m_mode_sizer->sys_color_changed();
|
||||
|
||||
m_sizer->Layout();
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::UpdateModeMarkers()
|
||||
{
|
||||
m_mode_sizer->update_mode_markers();
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::SetSelection(int sel)
|
||||
{
|
||||
if (m_selection == sel)
|
||||
|
@ -22,6 +22,7 @@ public:
|
||||
void UpdateMode();
|
||||
void Rescale();
|
||||
void OnColorsChanged();
|
||||
void UpdateModeMarkers();
|
||||
bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = "");
|
||||
void RemovePage(size_t n);
|
||||
bool SetPageImage(size_t n, const std::string& bmp_name) const;
|
||||
@ -251,6 +252,11 @@ public:
|
||||
GetBtnsListCtrl()->OnColorsChanged();
|
||||
}
|
||||
|
||||
void UpdateModeMarkers()
|
||||
{
|
||||
GetBtnsListCtrl()->UpdateModeMarkers();
|
||||
}
|
||||
|
||||
void OnNavigationKey(wxNavigationKeyEvent& event)
|
||||
{
|
||||
if (event.IsWindowChange()) {
|
||||
|
@ -45,7 +45,7 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
|
||||
m_v_gap = lround(1.0 * m_em_unit);
|
||||
m_h_gap = lround(0.2 * m_em_unit);
|
||||
|
||||
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
|
||||
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode", wxOSX ? 10 : 12), this);
|
||||
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("search_blink"), this);
|
||||
|
||||
init_ctrl_lines();// from og.lines()
|
||||
@ -418,7 +418,7 @@ void OG_CustomCtrl::msw_rescale()
|
||||
m_v_gap = lround(1.0 * m_em_unit);
|
||||
m_h_gap = lround(0.2 * m_em_unit);
|
||||
|
||||
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
|
||||
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode", wxOSX ? 10 : 12), this);
|
||||
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("search_blink"), this);
|
||||
|
||||
init_max_win_width();
|
||||
@ -666,9 +666,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_mode_bmp(wxDC& dc, wxCoord v_pos)
|
||||
return ctrl->m_h_gap;
|
||||
|
||||
ConfigOptionMode mode = og_line.get_options()[0].opt.mode;
|
||||
const std::string& bmp_name = mode == ConfigOptionMode::comSimple ? "mode_simple" :
|
||||
mode == ConfigOptionMode::comAdvanced ? "mode_advanced" : "mode_expert";
|
||||
wxBitmapBundle* bmp = get_bmp_bundle(bmp_name, wxOSX ? 10 : 12);
|
||||
wxBitmapBundle* bmp = get_bmp_bundle("mode", wxOSX ? 10 : 12, wxGetApp().get_mode_btn_color(mode));
|
||||
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp, ctrl).GetHeight()) / 2);
|
||||
|
||||
if (og_line.get_options().front().opt.gui_type != ConfigOptionDef::GUIType::legend)
|
||||
|
@ -1183,6 +1183,12 @@ void Sidebar::sys_color_changed()
|
||||
p->searcher.dlg_sys_color_changed();
|
||||
}
|
||||
|
||||
void Sidebar::update_mode_markers()
|
||||
{
|
||||
if (p->mode_sizer)
|
||||
p->mode_sizer->update_mode_markers();
|
||||
}
|
||||
|
||||
void Sidebar::search()
|
||||
{
|
||||
p->searcher.search();
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
void update_reslice_btn_tooltip() const;
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
void update_mode_markers();
|
||||
void search();
|
||||
void jump_to_option(size_t selected);
|
||||
void jump_to_option(const std::string& opt_key, Preset::Type type, const std::wstring& category);
|
||||
|
@ -80,9 +80,15 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
|
||||
m_use_custom_toolbar_size = get_app_config()->get("use_custom_toolbar_size") == "1";
|
||||
|
||||
if (wxGetApp().is_editor()) {
|
||||
// update colors for color pickers
|
||||
// update colors for color pickers of the labels
|
||||
update_color(m_sys_colour, wxGetApp().get_label_clr_sys());
|
||||
update_color(m_mod_colour, wxGetApp().get_label_clr_modified());
|
||||
|
||||
// update color pickers for mode palette
|
||||
const auto palette = wxGetApp().get_mode_palette();
|
||||
std::vector<wxColourPickerCtrl*> color_pickres = {m_mode_simple, m_mode_advanced, m_mode_expert};
|
||||
for (size_t mode = 0; mode < color_pickres.size(); ++mode)
|
||||
update_color(color_pickres[mode], palette[mode]);
|
||||
}
|
||||
|
||||
this->ShowModal();
|
||||
@ -506,6 +512,7 @@ void PreferencesDialog::build()
|
||||
|
||||
create_settings_mode_widget();
|
||||
create_settings_text_color_widget();
|
||||
create_settings_mode_color_widget();
|
||||
|
||||
#if ENABLE_ENVIRONMENT_MAP
|
||||
// Add "Render" tab
|
||||
@ -660,6 +667,7 @@ void PreferencesDialog::accept(wxEvent&)
|
||||
if (wxGetApp().is_editor()) {
|
||||
wxGetApp().set_label_clr_sys(m_sys_colour->GetColour());
|
||||
wxGetApp().set_label_clr_modified(m_mod_colour->GetColour());
|
||||
wxGetApp().set_mode_palette(m_mode_palette);
|
||||
}
|
||||
|
||||
EndModal(wxID_OK);
|
||||
@ -935,6 +943,33 @@ void PreferencesDialog::create_settings_text_color_widget()
|
||||
append_preferences_option_to_searcer(m_optgroup_gui, opt_key, title);
|
||||
}
|
||||
|
||||
void PreferencesDialog::create_settings_mode_color_widget()
|
||||
{
|
||||
wxWindow* parent = m_optgroup_gui->parent();
|
||||
|
||||
wxString title = L("Mode markers");
|
||||
wxStaticBox* stb = new wxStaticBox(parent, wxID_ANY, _(title));
|
||||
wxGetApp().UpdateDarkUI(stb);
|
||||
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
|
||||
std::string opt_key = "mode_markers";
|
||||
m_blinkers[opt_key] = new BlinkingBitmap(parent);
|
||||
|
||||
wxSizer* stb_sizer = new wxStaticBoxSizer(stb, wxVERTICAL);
|
||||
|
||||
// Mode color markers description
|
||||
m_mode_palette = wxGetApp().get_mode_palette();
|
||||
ButtonsDescription::FillSizerWithModeColorDescriptions(stb_sizer, parent, { &m_mode_simple, &m_mode_advanced, &m_mode_expert }, m_mode_palette);
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(m_blinkers[opt_key], 0, wxRIGHT, 2);
|
||||
sizer->Add(stb_sizer, 1, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxTOP, em_unit());
|
||||
|
||||
append_preferences_option_to_searcer(m_optgroup_gui, opt_key, title);
|
||||
}
|
||||
|
||||
void PreferencesDialog::init_highlighter(const t_config_option_key& opt_key)
|
||||
{
|
||||
if (m_blinkers.find(opt_key) != m_blinkers.end())
|
||||
|
@ -48,6 +48,12 @@ class PreferencesDialog : public DPIDialog
|
||||
|
||||
wxColourPickerCtrl* m_sys_colour {nullptr};
|
||||
wxColourPickerCtrl* m_mod_colour {nullptr};
|
||||
|
||||
std::vector<wxColour> m_mode_palette;
|
||||
wxColourPickerCtrl* m_mode_simple { nullptr };
|
||||
wxColourPickerCtrl* m_mode_advanced { nullptr };
|
||||
wxColourPickerCtrl* m_mode_expert { nullptr };
|
||||
|
||||
wxBookCtrlBase* tabs {nullptr};
|
||||
|
||||
bool isOSX {false};
|
||||
@ -81,6 +87,7 @@ protected:
|
||||
void create_icon_size_slider();
|
||||
void create_settings_mode_widget();
|
||||
void create_settings_text_color_widget();
|
||||
void create_settings_mode_color_widget();
|
||||
void init_highlighter(const t_config_option_key& opt_key);
|
||||
std::vector<ConfigOptionsGroup*> optgroups();
|
||||
|
||||
|
@ -892,6 +892,16 @@ void Tab::update_mode()
|
||||
update_changed_tree_ui();
|
||||
}
|
||||
|
||||
void Tab::update_mode_markers()
|
||||
{
|
||||
// update mode for ModeSizer
|
||||
if (m_mode_sizer)
|
||||
m_mode_sizer->update_mode_markers();
|
||||
|
||||
if (m_active_page)
|
||||
m_active_page->refresh();
|
||||
}
|
||||
|
||||
void Tab::update_visibility()
|
||||
{
|
||||
Freeze(); // There is needed Freeze/Thaw to avoid a flashing after Show/Layout
|
||||
|
@ -355,6 +355,7 @@ public:
|
||||
void load_config(const DynamicPrintConfig& config);
|
||||
virtual void reload_config();
|
||||
void update_mode();
|
||||
void update_mode_markers();
|
||||
void update_visibility();
|
||||
virtual void msw_rescale();
|
||||
virtual void sys_color_changed();
|
||||
|
@ -416,7 +416,7 @@ static int scale()
|
||||
}
|
||||
#endif // __WXGTK2__
|
||||
|
||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/)
|
||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/, const std::string& new_color/* = std::string()*/)
|
||||
{
|
||||
#ifdef __WXGTK2__
|
||||
px_cnt *= scale();
|
||||
@ -428,7 +428,7 @@ wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16
|
||||
boost::replace_last(bmp_name, ".png", "");
|
||||
|
||||
// Try loading an SVG first, then PNG if SVG is not found:
|
||||
wxBitmapBundle* bmp = cache.from_svg(bmp_name, px_cnt, px_cnt, Slic3r::GUI::wxGetApp().dark_mode());
|
||||
wxBitmapBundle* bmp = cache.from_svg(bmp_name, px_cnt, px_cnt, Slic3r::GUI::wxGetApp().dark_mode(), new_color);
|
||||
if (bmp == nullptr) {
|
||||
bmp = cache.from_png(bmp_name, px_cnt, px_cnt);
|
||||
if (!bmp)
|
||||
@ -655,6 +655,17 @@ ModeButton::ModeButton( wxWindow* parent,
|
||||
Init(mode);
|
||||
}
|
||||
|
||||
ModeButton::ModeButton( wxWindow* parent,
|
||||
int mode_id,/*ConfigOptionMode*/
|
||||
const wxString& mode /*= wxEmptyString*/,
|
||||
int px_cnt /*= = 16*/) :
|
||||
ScalableButton(parent, wxID_ANY, "", mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt),
|
||||
m_mode_id(mode_id)
|
||||
{
|
||||
update_bitmap();
|
||||
Init(mode);
|
||||
}
|
||||
|
||||
void ModeButton::Init(const wxString &mode)
|
||||
{
|
||||
std::string mode_str = std::string(mode.ToUTF8());
|
||||
@ -684,6 +695,15 @@ void ModeButton::SetState(const bool state)
|
||||
SetToolTip(state ? m_tt_selected : m_tt_focused);
|
||||
}
|
||||
|
||||
void ModeButton::update_bitmap()
|
||||
{
|
||||
m_bmp = *get_bmp_bundle("mode", m_px_cnt, Slic3r::GUI::wxGetApp().get_mode_btn_color(m_mode_id));
|
||||
|
||||
SetBitmap(m_bmp);
|
||||
SetBitmapCurrent(m_bmp);
|
||||
SetBitmapPressed(m_bmp);
|
||||
}
|
||||
|
||||
void ModeButton::focus_button(const bool focus)
|
||||
{
|
||||
const wxFont& new_font = focus ?
|
||||
@ -709,6 +729,12 @@ void ModeButton::focus_button(const bool focus)
|
||||
Update();
|
||||
}
|
||||
|
||||
void ModeButton::sys_color_changed()
|
||||
{
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
|
||||
update_bitmap();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ModeSizer
|
||||
@ -721,21 +747,15 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 0*/) :
|
||||
{
|
||||
SetFlexibleDirection(wxHORIZONTAL);
|
||||
|
||||
std::vector < std::pair < wxString, std::string >> buttons = {
|
||||
{_(L("Simple")), "mode_simple"},
|
||||
// {_(L("Advanced")), "mode_advanced"},
|
||||
{_CTX(L_CONTEXT("Advanced", "Mode"), "Mode"), "mode_advanced"},
|
||||
{_(L("Expert")), "mode_expert"},
|
||||
};
|
||||
|
||||
auto modebtnfn = [](wxCommandEvent &event, int mode_id) {
|
||||
Slic3r::GUI::wxGetApp().save_mode(mode_id);
|
||||
event.Skip();
|
||||
};
|
||||
|
||||
m_mode_btns.reserve(3);
|
||||
for (const auto& button : buttons) {
|
||||
m_mode_btns.push_back(new ModeButton(parent, button.first, button.second, mode_icon_px_size()));
|
||||
int mode_id = 0;
|
||||
for (const wxString& label : {_L("Simple"), _CTX(L_CONTEXT("Advanced", "Mode"), "Mode"),_L("Expert")}) {
|
||||
m_mode_btns.push_back(new ModeButton(parent, mode_id++, label, mode_icon_px_size()));
|
||||
|
||||
m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, int(m_mode_btns.size() - 1)));
|
||||
Add(m_mode_btns.back());
|
||||
@ -762,8 +782,14 @@ void ModeSizer::set_items_border(int border)
|
||||
|
||||
void ModeSizer::sys_color_changed()
|
||||
{
|
||||
for (size_t m = 0; m < m_mode_btns.size(); m++)
|
||||
m_mode_btns[m]->sys_color_changed();
|
||||
for (ModeButton* btn : m_mode_btns)
|
||||
btn->sys_color_changed();
|
||||
}
|
||||
|
||||
void ModeSizer::update_mode_markers()
|
||||
{
|
||||
for (ModeButton* btn : m_mode_btns)
|
||||
btn->update_bitmap();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -50,7 +50,7 @@ void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<
|
||||
int em_unit(wxWindow* win);
|
||||
int mode_icon_px_size();
|
||||
|
||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16);
|
||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16, const std::string& new_color_rgb = std::string());
|
||||
wxBitmapBundle* get_empty_bmp_bundle(int width, int height);
|
||||
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color);
|
||||
|
||||
@ -247,7 +247,7 @@ public:
|
||||
void SetBitmapDisabled_(const ScalableBitmap &bmp);
|
||||
int GetBitmapHeight();
|
||||
|
||||
void sys_color_changed();
|
||||
virtual void sys_color_changed();
|
||||
|
||||
private:
|
||||
wxWindow* m_parent { nullptr };
|
||||
@ -256,6 +256,7 @@ private:
|
||||
int m_width {-1}; // should be multiplied to em_unit
|
||||
int m_height{-1}; // should be multiplied to em_unit
|
||||
|
||||
protected:
|
||||
// bitmap dimensions
|
||||
int m_px_cnt{ 16 };
|
||||
bool m_has_border {false};
|
||||
@ -283,6 +284,12 @@ public:
|
||||
const std::string& icon_name = "",
|
||||
int px_cnt = 16);
|
||||
|
||||
ModeButton(
|
||||
wxWindow* parent,
|
||||
int mode_id,/*ConfigOptionMode*/
|
||||
const wxString& mode = wxEmptyString,
|
||||
int px_cnt = 16);
|
||||
|
||||
~ModeButton() {}
|
||||
|
||||
void Init(const wxString& mode);
|
||||
@ -292,16 +299,20 @@ public:
|
||||
void OnLeaveBtn(wxMouseEvent& event) { focus_button(m_is_selected); event.Skip(); }
|
||||
|
||||
void SetState(const bool state);
|
||||
void update_bitmap();
|
||||
bool is_selected() { return m_is_selected; }
|
||||
void sys_color_changed() override;
|
||||
|
||||
protected:
|
||||
void focus_button(const bool focus);
|
||||
|
||||
private:
|
||||
bool m_is_selected = false;
|
||||
bool m_is_selected {false};
|
||||
int m_mode_id {-1};
|
||||
|
||||
wxString m_tt_selected;
|
||||
wxString m_tt_focused;
|
||||
wxBitmapBundle m_bmp;
|
||||
};
|
||||
|
||||
|
||||
@ -322,6 +333,7 @@ public:
|
||||
void set_items_border(int border);
|
||||
|
||||
void sys_color_changed();
|
||||
void update_mode_markers();
|
||||
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user