mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
ENH:uniform border width of buttons in monitor control
Change-Id: Ifc84992d7d0c161991a031a7d1a7329f4b87687f
This commit is contained in:
parent
60e96c2940
commit
802036fcd8
6 changed files with 36 additions and 99 deletions
|
@ -564,10 +564,11 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
||||||
|
|
||||||
wxWindowID nozzle_id = wxWindow::NewControlId();
|
wxWindowID nozzle_id = wxWindow::NewControlId();
|
||||||
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"),
|
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"),
|
||||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER | wxBORDER_NONE);
|
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
|
||||||
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||||
m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]);
|
m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]);
|
||||||
m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]);
|
m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]);
|
||||||
|
m_tempCtrl_nozzle->SetBorderWidth(FromDIP(2));
|
||||||
m_tempCtrl_nozzle->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
m_tempCtrl_nozzle->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||||
m_tempCtrl_nozzle->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
m_tempCtrl_nozzle->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
||||||
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||||
|
@ -581,10 +582,11 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
||||||
|
|
||||||
wxWindowID bed_id = wxWindow::NewControlId();
|
wxWindowID bed_id = wxWindow::NewControlId();
|
||||||
m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_bed_temp"), wxString("monitor_bed_temp_active"), wxDefaultPosition,
|
m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_bed_temp"), wxString("monitor_bed_temp_active"), wxDefaultPosition,
|
||||||
wxDefaultSize, wxALIGN_CENTER | wxBORDER_NONE);
|
wxDefaultSize, wxALIGN_CENTER);
|
||||||
m_tempCtrl_bed->SetMinTemp(bed_temp_range[0]);
|
m_tempCtrl_bed->SetMinTemp(bed_temp_range[0]);
|
||||||
m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]);
|
m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]);
|
||||||
m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||||
|
m_tempCtrl_bed->SetBorderWidth(FromDIP(2));
|
||||||
m_tempCtrl_bed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
m_tempCtrl_bed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||||
m_tempCtrl_bed->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
m_tempCtrl_bed->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
||||||
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||||
|
@ -596,9 +598,10 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
||||||
|
|
||||||
wxWindowID frame_id = wxWindow::NewControlId();
|
wxWindowID frame_id = wxWindow::NewControlId();
|
||||||
m_tempCtrl_frame = new TempInput(parent, frame_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_frame_temp"), wxString("monitor_frame_temp"), wxDefaultPosition,
|
m_tempCtrl_frame = new TempInput(parent, frame_id, TEMP_BLANK_STR, TEMP_BLANK_STR, wxString("monitor_frame_temp"), wxString("monitor_frame_temp"), wxDefaultPosition,
|
||||||
wxDefaultSize, wxALIGN_CENTER | wxBORDER_NONE);
|
wxDefaultSize, wxALIGN_CENTER);
|
||||||
m_tempCtrl_frame->SetReadOnly(true);
|
m_tempCtrl_frame->SetReadOnly(true);
|
||||||
m_tempCtrl_frame->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
m_tempCtrl_frame->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||||
|
m_tempCtrl_frame->SetBorderWidth(FromDIP(2));
|
||||||
m_tempCtrl_frame->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
m_tempCtrl_frame->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||||
m_tempCtrl_frame->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
m_tempCtrl_frame->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
|
||||||
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||||
|
@ -620,10 +623,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
||||||
wxBoxSizer *line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
/* create speed control */
|
/* create speed control */
|
||||||
m_switch_speed = new ImageSwitchButton(parent, m_bitmap_speed_active, m_bitmap_speed, wxBORDER_NONE);
|
m_switch_speed = new ImageSwitchButton(parent, m_bitmap_speed_active, m_bitmap_speed);
|
||||||
m_switch_speed->SetLabels(_L("100%"), _L("100%"));
|
m_switch_speed->SetLabels(_L("100%"), _L("100%"));
|
||||||
m_switch_speed->SetMinSize(MISC_BUTTON_SIZE);
|
m_switch_speed->SetMinSize(MISC_BUTTON_SIZE);
|
||||||
m_switch_speed->SetPadding(FromDIP(3));
|
m_switch_speed->SetPadding(FromDIP(3));
|
||||||
|
m_switch_speed->SetBorderWidth(FromDIP(2));
|
||||||
m_switch_speed->SetFont(Label::Head_13);
|
m_switch_speed->SetFont(Label::Head_13);
|
||||||
m_switch_speed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
m_switch_speed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||||
m_switch_speed->SetValue(false);
|
m_switch_speed->SetValue(false);
|
||||||
|
@ -635,10 +639,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
||||||
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
||||||
|
|
||||||
/* create lamp control */
|
/* create lamp control */
|
||||||
m_switch_lamp = new ImageSwitchButton(parent, m_bitmap_lamp_on, m_bitmap_lamp_off, wxBORDER_NONE);
|
m_switch_lamp = new ImageSwitchButton(parent, m_bitmap_lamp_on, m_bitmap_lamp_off);
|
||||||
m_switch_lamp->SetLabels(_L("Lamp"), _L("Lamp"));
|
m_switch_lamp->SetLabels(_L("Lamp"), _L("Lamp"));
|
||||||
m_switch_lamp->SetMinSize(MISC_BUTTON_SIZE);
|
m_switch_lamp->SetMinSize(MISC_BUTTON_SIZE);
|
||||||
m_switch_lamp->SetPadding(FromDIP(3));
|
m_switch_lamp->SetPadding(FromDIP(3));
|
||||||
|
m_switch_lamp->SetBorderWidth(FromDIP(2));
|
||||||
m_switch_lamp->SetFont(Label::Head_13);
|
m_switch_lamp->SetFont(Label::Head_13);
|
||||||
m_switch_lamp->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
m_switch_lamp->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
|
||||||
line_sizer->Add(m_switch_lamp, 1, wxALIGN_CENTER | wxALL, 0);
|
line_sizer->Add(m_switch_lamp, 1, wxALIGN_CENTER | wxALL, 0);
|
||||||
|
@ -649,11 +654,12 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
||||||
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
|
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
|
||||||
|
|
||||||
line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_switch_nozzle_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off, wxBORDER_NONE);
|
m_switch_nozzle_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||||
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_SIZE);
|
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||||
m_switch_nozzle_fan->SetValue(false);
|
m_switch_nozzle_fan->SetValue(false);
|
||||||
m_switch_nozzle_fan->SetLabels(_L("Part Cooling"), _L("Part Cooling"));
|
m_switch_nozzle_fan->SetLabels(_L("Part Cooling"), _L("Part Cooling"));
|
||||||
m_switch_nozzle_fan->SetPadding(FromDIP(3));
|
m_switch_nozzle_fan->SetPadding(FromDIP(3));
|
||||||
|
m_switch_nozzle_fan->SetBorderWidth(FromDIP(2));
|
||||||
m_switch_nozzle_fan->SetFont(SWITCH_FONT);
|
m_switch_nozzle_fan->SetFont(SWITCH_FONT);
|
||||||
m_switch_nozzle_fan->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int) StateColor::Normal)));
|
m_switch_nozzle_fan->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int) StateColor::Normal)));
|
||||||
|
|
||||||
|
@ -662,10 +668,11 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
||||||
line->SetLineColour(STATIC_BOX_LINE_COL);
|
line->SetLineColour(STATIC_BOX_LINE_COL);
|
||||||
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
||||||
|
|
||||||
m_switch_printing_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off, wxBORDER_NONE);
|
m_switch_printing_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||||
m_switch_printing_fan->SetValue(false);
|
m_switch_printing_fan->SetValue(false);
|
||||||
m_switch_printing_fan->SetMinSize(MISC_BUTTON_SIZE);
|
m_switch_printing_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||||
m_switch_printing_fan->SetPadding(FromDIP(3));
|
m_switch_printing_fan->SetPadding(FromDIP(3));
|
||||||
|
m_switch_printing_fan->SetBorderWidth(FromDIP(2));
|
||||||
m_switch_printing_fan->SetFont(SWITCH_FONT);
|
m_switch_printing_fan->SetFont(SWITCH_FONT);
|
||||||
m_switch_printing_fan->SetLabels(_L("Aux Cooling"), _L("Aux Cooling"));
|
m_switch_printing_fan->SetLabels(_L("Aux Cooling"), _L("Aux Cooling"));
|
||||||
m_switch_printing_fan->SetTextColor(
|
m_switch_printing_fan->SetTextColor(
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <wx/dcgraph.h>
|
#include <wx/dcgraph.h>
|
||||||
|
|
||||||
static const wxColour bd = wxColour(0x00AE42);
|
static const wxColour bd = wxColour(0, 174, 66);
|
||||||
static const wxColour BUTTON_BG_COL = wxColour(238, 238, 238);
|
static const wxColour BUTTON_BG_COL = wxColour(238, 238, 238);
|
||||||
static const wxColour BUTTON_IN_BG_COL = wxColour(206, 206, 206);
|
static const wxColour BUTTON_IN_BG_COL = wxColour(206, 206, 206);
|
||||||
static const wxColour blank_bg = wxColour(0xFFFFFF);
|
static const wxColour blank_bg = wxColour(0xFFFFFF);
|
||||||
|
@ -21,7 +21,7 @@ END_EVENT_TABLE()
|
||||||
#define OUTER_SIZE FromDIP(105)
|
#define OUTER_SIZE FromDIP(105)
|
||||||
#define INNER_SIZE FromDIP(58)
|
#define INNER_SIZE FromDIP(58)
|
||||||
#define HOME_SIZE FromDIP(23)
|
#define HOME_SIZE FromDIP(23)
|
||||||
#define BLANK_SIZE FromDIP(23)
|
#define BLANK_SIZE FromDIP(24)
|
||||||
#define GAP_SIZE FromDIP(4)
|
#define GAP_SIZE FromDIP(4)
|
||||||
|
|
||||||
AxisCtrlButton::AxisCtrlButton(wxWindow *parent, ScalableBitmap &icon, long stlye)
|
AxisCtrlButton::AxisCtrlButton(wxWindow *parent, ScalableBitmap &icon, long stlye)
|
||||||
|
|
|
@ -20,20 +20,18 @@ static const wxColour DEFAULT_PRESS_COL = wxColour(238, 238, 238);
|
||||||
|
|
||||||
ImageSwitchButton::ImageSwitchButton(wxWindow *parent, ScalableBitmap &img_on, ScalableBitmap &img_off, long style)
|
ImageSwitchButton::ImageSwitchButton(wxWindow *parent, ScalableBitmap &img_on, ScalableBitmap &img_off, long style)
|
||||||
: text_color(std::make_pair(0x6B6B6B, (int) StateColor::Disabled), std::make_pair(*wxBLACK, (int) StateColor::Normal))
|
: text_color(std::make_pair(0x6B6B6B, (int) StateColor::Disabled), std::make_pair(*wxBLACK, (int) StateColor::Normal))
|
||||||
, state_handler(this)
|
|
||||||
{
|
{
|
||||||
|
radius = 0;
|
||||||
m_padding = 0;
|
m_padding = 0;
|
||||||
m_on = img_on;
|
m_on = img_on;
|
||||||
m_off = img_off;
|
m_off = img_off;
|
||||||
bg_color = StateColor(std::make_pair(DEFAULT_PRESS_COL, (int) StateColor::Pressed),
|
background_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(DEFAULT_PRESS_COL, (int) StateColor::Pressed),
|
||||||
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||||
border_color = StateColor(std::make_pair(DEFAULT_HOVER_COL, (int) StateColor::Hovered));
|
border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(DEFAULT_HOVER_COL, (int) StateColor::Focused),
|
||||||
|
std::make_pair(DEFAULT_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||||
|
|
||||||
StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
|
StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
|
||||||
|
|
||||||
state_handler.attach({&bg_color});
|
|
||||||
state_handler.attach({&border_color});
|
|
||||||
state_handler.update_binds();
|
|
||||||
messureSize();
|
messureSize();
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -64,19 +62,6 @@ void ImageSwitchButton::SetTextColor(StateColor const &color)
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageSwitchButton::SetBorderColor(StateColor const &color)
|
|
||||||
{
|
|
||||||
border_color = color;
|
|
||||||
messureSize();
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageSwitchButton::SetBgColor(StateColor const &color) {
|
|
||||||
bg_color = color;
|
|
||||||
messureSize();
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageSwitchButton::SetValue(bool value)
|
void ImageSwitchButton::SetValue(bool value)
|
||||||
{
|
{
|
||||||
m_on_off = value;
|
m_on_off = value;
|
||||||
|
@ -110,16 +95,6 @@ void ImageSwitchButton::render(wxDC& dc)
|
||||||
int states = state_handler.states();
|
int states = state_handler.states();
|
||||||
wxSize size = GetSize();
|
wxSize size = GetSize();
|
||||||
|
|
||||||
if (pressedDown) {
|
|
||||||
dc.SetBrush(bg_color.colorForStates(StateColor::Pressed));
|
|
||||||
dc.DrawRectangle(wxRect(0, 0, size.x, size.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hover) {
|
|
||||||
dc.SetPen(border_color.colorForStates(StateColor::Hovered));
|
|
||||||
dc.DrawRectangle(wxRect(0, 0, size.x, size.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSize szIcon;
|
wxSize szIcon;
|
||||||
wxSize szContent = textSize;
|
wxSize szContent = textSize;
|
||||||
ScalableBitmap &icon = GetValue() ? m_on : m_off;
|
ScalableBitmap &icon = GetValue() ? m_on : m_off;
|
||||||
|
|
|
@ -17,8 +17,6 @@ public:
|
||||||
void SetLabels(wxString const & lbl_on, wxString const & lbl_off);
|
void SetLabels(wxString const & lbl_on, wxString const & lbl_off);
|
||||||
void SetImages(ScalableBitmap &img_on, ScalableBitmap &img_off);
|
void SetImages(ScalableBitmap &img_on, ScalableBitmap &img_off);
|
||||||
void SetTextColor(StateColor const &color);
|
void SetTextColor(StateColor const &color);
|
||||||
void SetBorderColor(StateColor const &color);
|
|
||||||
void SetBgColor(StateColor const &color);
|
|
||||||
void SetValue(bool value);
|
void SetValue(bool value);
|
||||||
void SetPadding(int padding);
|
void SetPadding(int padding);
|
||||||
|
|
||||||
|
@ -50,9 +48,6 @@ private:
|
||||||
|
|
||||||
wxString labels[2];
|
wxString labels[2];
|
||||||
StateColor text_color;
|
StateColor text_color;
|
||||||
StateColor bg_color;
|
|
||||||
StateColor border_color;
|
|
||||||
StateHandler state_handler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !slic3r_GUI_SwitchButton_hpp_
|
#endif // !slic3r_GUI_SwitchButton_hpp_
|
||||||
|
|
|
@ -19,18 +19,14 @@ END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
TempInput::TempInput()
|
TempInput::TempInput()
|
||||||
: state_handler(this)
|
: label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3D, (int) StateColor::Normal))
|
||||||
, border_color(std::make_pair(*wxWHITE, (int) StateColor::Disabled),
|
|
||||||
std::make_pair(0x00AE42, (int) StateColor::Focused),
|
|
||||||
std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
|
||||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
|
||||||
, label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3D, (int) StateColor::Normal))
|
|
||||||
, text_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal))
|
, text_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal))
|
||||||
, background_color(std::make_pair(*wxWHITE, (int) StateColor::Disabled),
|
|
||||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
|
||||||
{
|
{
|
||||||
hover = false;
|
hover = false;
|
||||||
radius = 0;
|
radius = 0;
|
||||||
|
border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Focused), std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||||
|
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||||
|
background_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||||
SetFont(Label::Body_12);
|
SetFont(Label::Body_12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,16 +40,17 @@ TempInput::TempInput(wxWindow *parent, int type, wxString text, wxString label,
|
||||||
|
|
||||||
void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString normal_icon, wxString actice_icon, const wxPoint &pos, const wxSize &size, long style)
|
void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString normal_icon, wxString actice_icon, const wxPoint &pos, const wxSize &size, long style)
|
||||||
{
|
{
|
||||||
wxWindow::Create(parent, wxID_ANY, pos, size, style);
|
StaticBox::Create(parent, wxID_ANY, pos, size, style);
|
||||||
wxWindow::SetLabel(label);
|
wxWindow::SetLabel(label);
|
||||||
style &= ~wxALIGN_CENTER_HORIZONTAL;
|
style &= ~wxALIGN_CENTER_HORIZONTAL;
|
||||||
state_handler.attach({&border_color, &text_color, &background_color});
|
state_handler.attach({&label_color, &text_color});
|
||||||
state_handler.update_binds();
|
state_handler.update_binds();
|
||||||
|
|
||||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {5, 5}, wxDefaultSize, wxTE_PROCESS_ENTER | wxBORDER_NONE, wxTextValidator(wxFILTER_NUMERIC), wxTextCtrlNameStr);
|
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {5, 5}, wxDefaultSize, wxTE_PROCESS_ENTER | wxBORDER_NONE, wxTextValidator(wxFILTER_NUMERIC), wxTextCtrlNameStr);
|
||||||
text_ctrl->SetMaxLength(3);
|
text_ctrl->SetMaxLength(3);
|
||||||
|
state_handler.attach_child(text_ctrl);
|
||||||
|
|
||||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||||
|
if (m_read_only) return;
|
||||||
e.SetId(GetId());
|
e.SetId(GetId());
|
||||||
ProcessEventLocally(e);
|
ProcessEventLocally(e);
|
||||||
|
|
||||||
|
@ -65,15 +62,6 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
|
||||||
|
|
||||||
if (wdialog != nullptr) { wdialog->Dismiss(); }
|
if (wdialog != nullptr) { wdialog->Dismiss(); }
|
||||||
});
|
});
|
||||||
text_ctrl->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
|
|
||||||
if (m_read_only) {SetCursor(wxCURSOR_ARROW);}
|
|
||||||
e.SetId(GetId());
|
|
||||||
ProcessEventLocally(e);
|
|
||||||
});
|
|
||||||
text_ctrl->Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
|
|
||||||
e.SetId(GetId());
|
|
||||||
ProcessEventLocally(e);
|
|
||||||
});
|
|
||||||
text_ctrl->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
|
text_ctrl->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
|
||||||
OnEdit();
|
OnEdit();
|
||||||
e.SetId(GetId());
|
e.SetId(GetId());
|
||||||
|
@ -271,12 +259,6 @@ void TempInput::SetMaxTemp(int temp) { max_temp = temp; }
|
||||||
|
|
||||||
void TempInput::SetMinTemp(int temp) { min_temp = temp; }
|
void TempInput::SetMinTemp(int temp) { min_temp = temp; }
|
||||||
|
|
||||||
void TempInput::SetCornerRadius(double radius)
|
|
||||||
{
|
|
||||||
this->radius = radius;
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TempInput::SetLabel(const wxString &label)
|
void TempInput::SetLabel(const wxString &label)
|
||||||
{
|
{
|
||||||
wxWindow::SetLabel(label);
|
wxWindow::SetLabel(label);
|
||||||
|
@ -284,12 +266,6 @@ void TempInput::SetLabel(const wxString &label)
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TempInput::SetBorderColor(StateColor const &color)
|
|
||||||
{
|
|
||||||
border_color = color;
|
|
||||||
state_handler.update_binds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TempInput::SetTextColor(StateColor const &color)
|
void TempInput::SetTextColor(StateColor const &color)
|
||||||
{
|
{
|
||||||
text_color = color;
|
text_color = color;
|
||||||
|
@ -302,12 +278,6 @@ void TempInput::SetLabelColor(StateColor const &color)
|
||||||
state_handler.update_binds();
|
state_handler.update_binds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TempInput::SetBackgroundColor(StateColor const &color)
|
|
||||||
{
|
|
||||||
background_color = color;
|
|
||||||
state_handler.update_binds();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TempInput::Rescale()
|
void TempInput::Rescale()
|
||||||
{
|
{
|
||||||
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
|
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
|
||||||
|
@ -393,18 +363,18 @@ void TempInput::paintEvent(wxPaintEvent &evt)
|
||||||
*/
|
*/
|
||||||
void TempInput::render(wxDC &dc)
|
void TempInput::render(wxDC &dc)
|
||||||
{
|
{
|
||||||
|
StaticBox::render(dc);
|
||||||
int states = state_handler.states();
|
int states = state_handler.states();
|
||||||
wxSize size = GetSize();
|
wxSize size = GetSize();
|
||||||
bool align_right = GetWindowStyle() & wxRIGHT;
|
bool align_right = GetWindowStyle() & wxRIGHT;
|
||||||
|
|
||||||
if (warning_mode) {
|
if (warning_mode) {
|
||||||
dc.SetPen(wxPen(wxColour(255, 111, 0)));
|
border_color = wxColour(255, 111, 0);
|
||||||
} else {
|
} else {
|
||||||
dc.SetPen(wxPen(border_color.colorForStates(states)));
|
border_color = StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(0x00AE42, (int) StateColor::Focused),
|
||||||
|
std::make_pair(0x00AE42, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.SetBrush(wxBrush(background_color.colorForStates(states)));
|
|
||||||
dc.DrawRoundedRectangle(0, 0, size.x, size.y, radius);
|
|
||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||||
// start draw
|
// start draw
|
||||||
wxPoint pt = {padding_left, 0};
|
wxPoint pt = {padding_left, 0};
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
#ifndef slic3r_GUI_TempInput_hpp_
|
#ifndef slic3r_GUI_TempInput_hpp_
|
||||||
#define slic3r_GUI_TempInput_hpp_
|
#define slic3r_GUI_TempInput_hpp_
|
||||||
|
|
||||||
#include <wx/textctrl.h>
|
|
||||||
#include "../wxExtensions.hpp"
|
#include "../wxExtensions.hpp"
|
||||||
#include "StateHandler.hpp"
|
#include <wx/textctrl.h>
|
||||||
|
#include "StaticBox.hpp"
|
||||||
|
|
||||||
wxDECLARE_EVENT(wxCUSTOMEVT_SET_TEMP_FINISH, wxCommandEvent);
|
wxDECLARE_EVENT(wxCUSTOMEVT_SET_TEMP_FINISH, wxCommandEvent);
|
||||||
|
|
||||||
class TempInput : public wxWindow
|
class TempInput : public wxNavigationEnabled<StaticBox>
|
||||||
{
|
{
|
||||||
bool hover;
|
bool hover;
|
||||||
double radius;
|
|
||||||
|
|
||||||
bool m_read_only{false};
|
bool m_read_only{false};
|
||||||
wxSize labelSize;
|
wxSize labelSize;
|
||||||
|
@ -18,11 +17,8 @@ class TempInput : public wxWindow
|
||||||
ScalableBitmap actice_icon;
|
ScalableBitmap actice_icon;
|
||||||
ScalableBitmap degree_icon;
|
ScalableBitmap degree_icon;
|
||||||
|
|
||||||
StateHandler state_handler;
|
|
||||||
StateColor label_color;
|
StateColor label_color;
|
||||||
StateColor text_color;
|
StateColor text_color;
|
||||||
StateColor border_color;
|
|
||||||
StateColor background_color;
|
|
||||||
|
|
||||||
wxTextCtrl * text_ctrl;
|
wxTextCtrl * text_ctrl;
|
||||||
wxStaticText *warning_text;
|
wxStaticText *warning_text;
|
||||||
|
@ -93,18 +89,12 @@ public:
|
||||||
wxString GetTagTemp() { return text_ctrl->GetValue(); }
|
wxString GetTagTemp() { return text_ctrl->GetValue(); }
|
||||||
wxString GetCurrTemp() { return GetLabel(); }
|
wxString GetCurrTemp() { return GetLabel(); }
|
||||||
|
|
||||||
void SetCornerRadius(double radius);
|
|
||||||
|
|
||||||
void SetLabel(const wxString &label);
|
void SetLabel(const wxString &label);
|
||||||
|
|
||||||
void SetBorderColor(StateColor const &color);
|
|
||||||
|
|
||||||
void SetTextColor(StateColor const &color);
|
void SetTextColor(StateColor const &color);
|
||||||
|
|
||||||
void SetLabelColor(StateColor const &color);
|
void SetLabelColor(StateColor const &color);
|
||||||
|
|
||||||
void SetBackgroundColor(StateColor const &color);
|
|
||||||
|
|
||||||
virtual void Rescale();
|
virtual void Rescale();
|
||||||
|
|
||||||
virtual bool Enable(bool enable = true) override;
|
virtual bool Enable(bool enable = true) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue