FIX: ui style of base widgets
Change-Id: Ie0cff84d7a6f19c9830ce60f2a188fe9a7df545c
This commit is contained in:
parent
5f4f859337
commit
a478abd88a
8 changed files with 43 additions and 14 deletions
|
@ -26,6 +26,7 @@ Button::Button()
|
|||
, text_color(*wxBLACK)
|
||||
{
|
||||
background_color = StateColor(
|
||||
std::make_pair(0xF0F0F0, (int) StateColor::Disabled),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Checked),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
|
||||
std::make_pair(0x37EE7C, (int) StateColor::Hovered | StateColor::Checked),
|
||||
|
|
|
@ -44,6 +44,8 @@ ComboBox::ComboBox(wxWindow * parent,
|
|||
TextInput::SetBackgroundColor(StateColor(std::make_pair(0xF0F0F0, (int) StateColor::Disabled),
|
||||
std::make_pair(0xEDFAF2, (int) StateColor::Focused),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal)));
|
||||
TextInput::SetLabelColor(StateColor(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
std::make_pair(0x262E30, (int) StateColor::Normal)));
|
||||
} else {
|
||||
GetTextCtrl()->Bind(wxEVT_KEY_DOWN, &ComboBox::keyDown, this);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ SpinInput::SpinInput()
|
|||
, border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||
std::make_pair(0xDBDBDB, (int) StateColor::Normal))
|
||||
, text_color(std::make_pair(0xACACAC, (int) StateColor::Disabled), std::make_pair(*wxBLACK, (int) StateColor::Normal))
|
||||
, label_color(std::make_pair(0x909090, (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal))
|
||||
, text_color(std::make_pair(0x909090, (int) StateColor::Disabled), std::make_pair(0x262E30, (int) StateColor::Normal))
|
||||
, background_color(std::make_pair(0xF0F0F0, (int) StateColor::Disabled), std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
||||
{
|
||||
hover = false;
|
||||
|
@ -60,10 +61,12 @@ void SpinInput::Create(wxWindow *parent,
|
|||
wxWindow::Create(parent, wxID_ANY, pos, size);
|
||||
SetFont(Label::Body_12);
|
||||
wxWindow::SetLabel(label);
|
||||
state_handler.attach({&border_color, &text_color, &background_color});
|
||||
state_handler.attach({&border_color, &label_color, &text_color, &background_color});
|
||||
state_handler.update_binds();
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {20, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER, wxTextValidator(wxFILTER_DIGITS));
|
||||
text_ctrl->SetFont(Label::Body_14);
|
||||
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
|
@ -106,6 +109,12 @@ void SpinInput::SetLabel(const wxString &label)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void SpinInput::SetLabelColor(StateColor const &color)
|
||||
{
|
||||
label_color = color;
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void SpinInput::SetTextColor(StateColor const &color)
|
||||
{
|
||||
text_color = color;
|
||||
|
@ -171,6 +180,9 @@ bool SpinInput::Enable(bool enable)
|
|||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(e);
|
||||
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
|
||||
button_inc->Enable(enable);
|
||||
button_dec->Enable(enable);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -205,7 +217,7 @@ void SpinInput::render(wxDC& dc)
|
|||
pt.x = size.x - labelSize.x - 5;
|
||||
pt.y = (size.y - labelSize.y) / 2;
|
||||
dc.SetFont(GetFont());
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
dc.SetTextForeground(label_color.colorForStates(states));
|
||||
dc.DrawText(text, pt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ class SpinInput : public wxNavigationEnabled<wxWindow>
|
|||
wxSize labelSize;
|
||||
double radius;
|
||||
StateHandler state_handler;
|
||||
StateColor label_color;
|
||||
StateColor text_color;
|
||||
StateColor border_color;
|
||||
StateColor background_color;
|
||||
|
@ -55,7 +56,9 @@ public:
|
|||
|
||||
void SetLabel(const wxString &label) wxOVERRIDE;
|
||||
|
||||
void SetTextColor(StateColor const & color);
|
||||
void SetLabelColor(StateColor const &color);
|
||||
|
||||
void SetTextColor(StateColor const &color);
|
||||
|
||||
void SetBackgroundColor(StateColor const & color);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ StaticLine::StaticLine(wxWindow* parent, bool vertical, const wxString& label)
|
|||
, vertical(vertical)
|
||||
{
|
||||
wxWindow::SetBackgroundColour(parent->GetBackgroundColour());
|
||||
this->pen = wxPen(wxColour("#C4C4C4"));
|
||||
this->pen = wxPen(wxColour("#EEEEEE"));
|
||||
DisableFocusFromKeyboard();
|
||||
SetFont(Label::Body_14);
|
||||
SetLabel(label);
|
||||
|
|
|
@ -80,7 +80,7 @@ void SwitchButton::Rescale()
|
|||
if (size.x > thumbSize.x) thumbSize.x = size.x;
|
||||
else size.x = thumbSize.x;
|
||||
thumbSize.x += BS * 12;
|
||||
thumbSize.y += BS * 2;
|
||||
thumbSize.y += BS * 6;
|
||||
trackSize.x = thumbSize.x + size.x + BS * 10;
|
||||
trackSize.y = thumbSize.y + BS * 2;
|
||||
auto maxWidth = GetMaxWidth();
|
||||
|
|
|
@ -28,8 +28,10 @@ TextInput::TextInput()
|
|||
, border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled),
|
||||
std::make_pair(0x00AE42, (int) StateColor::Hovered),
|
||||
std::make_pair(0xDBDBDB, (int) StateColor::Normal))
|
||||
, text_color(std::make_pair(0xACACAC, (int) StateColor::Disabled),
|
||||
std::make_pair(0x363636, (int) StateColor::Normal))
|
||||
, label_color(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
std::make_pair(0x6B6B6B, (int) StateColor::Normal))
|
||||
, text_color(std::make_pair(0x909090, (int) StateColor::Disabled),
|
||||
std::make_pair(0x262E30, (int) StateColor::Normal))
|
||||
, background_color(std::make_pair(0xF0F0F0, (int) StateColor::Disabled),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal))
|
||||
{
|
||||
|
@ -62,11 +64,13 @@ void TextInput::Create(wxWindow * parent,
|
|||
wxWindow::Create(parent, wxID_ANY, pos, size, style);
|
||||
wxWindow::SetLabel(label);
|
||||
style &= ~wxRIGHT;
|
||||
state_handler.attach({&border_color, &text_color, &background_color});
|
||||
state_handler.attach({&border_color, &label_color, & text_color, &background_color});
|
||||
state_handler.update_binds();
|
||||
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE);
|
||||
text_ctrl->SetFont(Label::Body_14);
|
||||
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
|
||||
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
|
||||
e.SetId(GetId());
|
||||
ProcessEventLocally(e);
|
||||
|
@ -121,6 +125,12 @@ void TextInput::SetBorderColor(StateColor const& color)
|
|||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TextInput::SetLabelColor(StateColor const &color)
|
||||
{
|
||||
label_color = color;
|
||||
state_handler.update_binds();
|
||||
}
|
||||
|
||||
void TextInput::SetTextColor(StateColor const& color)
|
||||
{
|
||||
text_color= color;
|
||||
|
@ -149,6 +159,7 @@ bool TextInput::Enable(bool enable)
|
|||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(e);
|
||||
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
|
||||
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -219,7 +230,7 @@ void TextInput::render(wxDC& dc)
|
|||
wxSize szIcon = icon.GetBmpSize();
|
||||
pt.y = (size.y - szIcon.y) / 2;
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.x += szIcon.x + 5;
|
||||
pt.x += szIcon.x + 0;
|
||||
}
|
||||
auto text = wxWindow::GetLabel();
|
||||
if (!text.IsEmpty()) {
|
||||
|
@ -232,7 +243,7 @@ void TextInput::render(wxDC& dc)
|
|||
pt.x += textSize.x;
|
||||
pt.y = (size.y + textSize.y) / 2 - labelSize.y;
|
||||
}
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
dc.SetTextForeground(label_color.colorForStates(states));
|
||||
dc.SetFont(GetFont());
|
||||
dc.DrawText(text, pt);
|
||||
}
|
||||
|
@ -244,9 +255,6 @@ void TextInput::messureSize()
|
|||
wxClientDC dc(this);
|
||||
labelSize = dc.GetTextExtent(wxWindow::GetLabel());
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
#ifdef __WXOSX__
|
||||
textSize.y -= 3; // TODO:
|
||||
#endif
|
||||
int h = textSize.y + 8;
|
||||
if (size.y < h) {
|
||||
size.y = h;
|
||||
|
|
|
@ -13,6 +13,7 @@ class TextInput : public wxNavigationEnabled<wxWindow>
|
|||
ScalableBitmap icon;
|
||||
double radius;
|
||||
StateHandler state_handler;
|
||||
StateColor label_color;
|
||||
StateColor text_color;
|
||||
StateColor border_color;
|
||||
StateColor background_color;
|
||||
|
@ -49,6 +50,8 @@ public:
|
|||
|
||||
void SetBorderColor(StateColor const & color);
|
||||
|
||||
void SetLabelColor(StateColor const &color);
|
||||
|
||||
void SetTextColor(StateColor const &color);
|
||||
|
||||
void SetBackgroundColor(StateColor const &color);
|
||||
|
|
Loading…
Reference in a new issue