mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Added "smart" setting of label color
This commit is contained in:
parent
6e870e8466
commit
d254c39a77
4 changed files with 37 additions and 22 deletions
|
@ -20,23 +20,18 @@ namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
void Field::PostInitialize(){
|
void Field::PostInitialize(){
|
||||||
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
m_Undo_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(16, 16), wxNO_BORDER);
|
||||||
m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
m_Undo_to_sys_btn = new wxButton(m_parent, wxID_ANY, "", wxDefaultPosition, wxSize(16, 16), wxNO_BORDER);
|
||||||
if (wxMSW) {
|
if (wxMSW) {
|
||||||
m_Undo_btn->SetBackgroundColour(color);
|
m_Undo_btn->SetBackgroundColour(color);
|
||||||
m_Undo_to_sys_btn->SetBackgroundColour(color);
|
m_Undo_to_sys_btn->SetBackgroundColour(color);
|
||||||
}
|
}
|
||||||
// m_Undo_btn->SetBitmap(wxBitmap(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG));
|
|
||||||
m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); }));
|
m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_initial_value(); }));
|
||||||
m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); }));
|
m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); }));
|
||||||
|
|
||||||
BUILD();
|
BUILD();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void Field::set_nonsys_btn_icon(const wxBitmap& icon){
|
|
||||||
// m_Undo_to_sys_btn->SetBitmap(icon);
|
|
||||||
// }
|
|
||||||
|
|
||||||
void Field::on_kill_focus(wxEvent& event) {
|
void Field::on_kill_focus(wxEvent& event) {
|
||||||
// Without this, there will be nasty focus bugs on Windows.
|
// Without this, there will be nasty focus bugs on Windows.
|
||||||
// Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all
|
// Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all
|
||||||
|
|
|
@ -90,9 +90,7 @@ public:
|
||||||
virtual void enable() = 0;
|
virtual void enable() = 0;
|
||||||
virtual void disable() = 0;
|
virtual void disable() = 0;
|
||||||
|
|
||||||
wxStaticText* m_Label = nullptr;
|
/// Fires the enable or disable function, based on the input.
|
||||||
|
|
||||||
/// Fires the enable or disable function, based on the input.
|
|
||||||
inline void toggle(bool en) { en ? enable() : disable(); }
|
inline void toggle(bool en) { en ? enable() : disable(); }
|
||||||
|
|
||||||
virtual wxString get_tooltip_text(const wxString& default_string);
|
virtual wxString get_tooltip_text(const wxString& default_string);
|
||||||
|
@ -137,6 +135,16 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool set_label_colour(const wxColour *clr) {
|
||||||
|
if (m_Label == nullptr) return false;
|
||||||
|
if (m_label_color != clr) {
|
||||||
|
m_label_color = clr;
|
||||||
|
m_Label->SetForegroundColour(*clr);
|
||||||
|
m_Label->Refresh(true);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxButton* m_Undo_btn = nullptr;
|
wxButton* m_Undo_btn = nullptr;
|
||||||
// Bitmap for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
|
// Bitmap for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
|
||||||
|
@ -145,6 +153,10 @@ protected:
|
||||||
// Bitmap for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
|
// Bitmap for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
|
||||||
const wxBitmap* m_undo_to_sys_bitmap = nullptr;
|
const wxBitmap* m_undo_to_sys_bitmap = nullptr;
|
||||||
|
|
||||||
|
wxStaticText* m_Label = nullptr;
|
||||||
|
// Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one.
|
||||||
|
const wxColour* m_label_color;
|
||||||
|
|
||||||
friend class OptionsGroup;
|
friend class OptionsGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
#include <wx/wupdlock.h>
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -115,6 +116,11 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
||||||
m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet);
|
m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet);
|
||||||
m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); }));
|
m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent){ on_back_to_sys_value(); }));
|
||||||
|
|
||||||
|
// Colors for ui "decoration"
|
||||||
|
m_sys_label_clr = get_sys_label_clr();
|
||||||
|
m_modified_label_clr = get_modified_label_clr();
|
||||||
|
m_default_text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||||
|
|
||||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(m_hsizer, 0, wxBOTTOM, 3);
|
sizer->Add(m_hsizer, 0, wxBOTTOM, 3);
|
||||||
m_hsizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
m_hsizer->Add(m_presets_choice, 1, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
||||||
|
@ -344,14 +350,14 @@ void Tab::update_changed_ui()
|
||||||
bool is_modified_value = true;
|
bool is_modified_value = true;
|
||||||
const wxBitmap *sys_icon = &m_bmp_value_lock;
|
const wxBitmap *sys_icon = &m_bmp_value_lock;
|
||||||
const wxBitmap *icon = &m_bmp_value_revert;
|
const wxBitmap *icon = &m_bmp_value_revert;
|
||||||
wxColour color = get_sys_label_clr();
|
const wxColour *color = &m_sys_label_clr;
|
||||||
if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) {
|
if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) {
|
||||||
is_nonsys_value = true;
|
is_nonsys_value = true;
|
||||||
sys_icon = m_bmp_non_system;
|
sys_icon = m_bmp_non_system;
|
||||||
if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end())
|
if(find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end())
|
||||||
color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
color = &m_default_text_clr;
|
||||||
else
|
else
|
||||||
color = get_modified_label_clr();
|
color = &m_modified_label_clr;
|
||||||
}
|
}
|
||||||
if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end())
|
if (find(m_dirty_options.begin(), m_dirty_options.end(), opt_key) == m_dirty_options.end())
|
||||||
{
|
{
|
||||||
|
@ -360,7 +366,7 @@ void Tab::update_changed_ui()
|
||||||
}
|
}
|
||||||
if (opt_key == "bed_shape" || opt_key == "compatible_printers") {
|
if (opt_key == "bed_shape" || opt_key == "compatible_printers") {
|
||||||
if (m_colored_Label != nullptr) {
|
if (m_colored_Label != nullptr) {
|
||||||
m_colored_Label->SetForegroundColour(color);
|
m_colored_Label->SetForegroundColour(*color);
|
||||||
m_colored_Label->Refresh(true);
|
m_colored_Label->Refresh(true);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -372,10 +378,7 @@ void Tab::update_changed_ui()
|
||||||
field->m_is_modified_value = is_modified_value;
|
field->m_is_modified_value = is_modified_value;
|
||||||
field->set_undo_bitmap(icon);
|
field->set_undo_bitmap(icon);
|
||||||
field->set_undo_to_sys_bitmap(sys_icon);
|
field->set_undo_to_sys_bitmap(sys_icon);
|
||||||
if (field->m_Label != nullptr){
|
field->set_label_colour(color);
|
||||||
field->m_Label->SetForegroundColour(color);
|
|
||||||
field->m_Label->Refresh(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Thaw();
|
Thaw();
|
||||||
|
|
||||||
|
@ -425,15 +428,13 @@ void Tab::update_full_options_list()
|
||||||
|
|
||||||
void Tab::update_sys_ui_after_sel_preset()
|
void Tab::update_sys_ui_after_sel_preset()
|
||||||
{
|
{
|
||||||
|
const wxColour* clr = &m_default_text_clr;
|
||||||
for (const auto opt_key : m_full_options_list){
|
for (const auto opt_key : m_full_options_list){
|
||||||
Field* field = get_field(opt_key);
|
Field* field = get_field(opt_key);
|
||||||
if (field != nullptr){
|
if (field != nullptr){
|
||||||
field->set_undo_to_sys_bitmap(m_bmp_non_system);
|
field->set_undo_to_sys_bitmap(m_bmp_non_system);
|
||||||
field->m_is_nonsys_value = true;
|
field->m_is_nonsys_value = true;
|
||||||
if (field->m_Label != nullptr){
|
field->set_label_colour(clr);
|
||||||
field->m_Label->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
|
||||||
field->m_Label->Refresh(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_sys_options.resize(0);
|
m_sys_options.resize(0);
|
||||||
|
@ -2039,6 +2040,8 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
|
||||||
void Tab::OnTreeSelChange(wxTreeEvent& event)
|
void Tab::OnTreeSelChange(wxTreeEvent& event)
|
||||||
{
|
{
|
||||||
if (m_disable_tree_sel_changed_event) return;
|
if (m_disable_tree_sel_changed_event) return;
|
||||||
|
wxWindowUpdateLocker noUpdates(this);
|
||||||
|
|
||||||
Page* page = nullptr;
|
Page* page = nullptr;
|
||||||
auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection());
|
auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection());
|
||||||
for (auto p : m_pages)
|
for (auto p : m_pages)
|
||||||
|
|
|
@ -112,6 +112,11 @@ protected:
|
||||||
wxBitmap m_bmp_value_revert;
|
wxBitmap m_bmp_value_revert;
|
||||||
wxBitmap m_bmp_value_unmodified;
|
wxBitmap m_bmp_value_unmodified;
|
||||||
|
|
||||||
|
// Colors for ui "decoration"
|
||||||
|
wxColour m_sys_label_clr;
|
||||||
|
wxColour m_modified_label_clr;
|
||||||
|
wxColour m_default_text_clr;
|
||||||
|
|
||||||
int m_icon_count;
|
int m_icon_count;
|
||||||
std::map<std::string, size_t> m_icon_index; // Map from an icon file name to its index
|
std::map<std::string, size_t> m_icon_index; // Map from an icon file name to its index
|
||||||
std::vector<PageShp> m_pages;
|
std::vector<PageShp> m_pages;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue