ENH:optimize the save presets dialog
Change-Id: I7cd954d27db96a461e4e6b8a10c904dbb892b002
This commit is contained in:
parent
4d8d4cb69c
commit
f54e2d2a00
|
@ -74,32 +74,30 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
||||||
// combo_sizer->Add(m_combo, 1, wxEXPAND, BORDER_W);
|
// combo_sizer->Add(m_combo, 1, wxEXPAND, BORDER_W);
|
||||||
|
|
||||||
|
|
||||||
StateColor box_border_colour(std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Normal));
|
|
||||||
m_input_area = new StaticBox(m_parent, wxID_ANY, wxDefaultPosition, SAVE_PRESET_DIALOG_INPUT_SIZE, wxBORDER_NONE);
|
|
||||||
m_input_area->SetMinSize(SAVE_PRESET_DIALOG_INPUT_SIZE);
|
|
||||||
m_input_area->SetBorderColor(box_border_colour);
|
|
||||||
m_input_area->SetBackgroundColor(box_border_colour);
|
|
||||||
m_input_area->SetCornerRadius(FromDIP(3));
|
|
||||||
|
|
||||||
wxBoxSizer *input_sizer_h = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *input_sizer_h = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxBoxSizer *input_sizer_v = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *input_sizer_v = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
m_input_ctrl = new wxTextCtrl(m_input_area, -1, from_u8(preset_name), wxDefaultPosition, wxSize(SAVE_PRESET_DIALOG_INPUT_SIZE.x - 2, SAVE_PRESET_DIALOG_INPUT_SIZE.y - 2), 0 | wxBORDER_NONE);
|
/*m_input_ctrl = new wxTextCtrl(this, wxID_ANY, from_u8(preset_name), wxDefaultPosition, wxDefaultSize,wxBORDER_NONE);*/
|
||||||
//m_input_ctrl->SetBackgroundColour(GetParent()->GetBackgroundColour());
|
|
||||||
|
|
||||||
|
m_input_ctrl = new ::TextInput(parent, from_u8(preset_name), wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
||||||
|
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled), std::pair<wxColour, int>(*wxWHITE, StateColor::Enabled));
|
||||||
|
m_input_ctrl->SetBackgroundColor(input_bg);
|
||||||
m_input_ctrl->Bind(wxEVT_TEXT, [this](wxCommandEvent &) { update(); });
|
m_input_ctrl->Bind(wxEVT_TEXT, [this](wxCommandEvent &) { update(); });
|
||||||
|
m_input_ctrl->SetMinSize(wxSize(SAVE_PRESET_DIALOG_INPUT_SIZE));
|
||||||
|
m_input_ctrl->SetMaxSize(wxSize(SAVE_PRESET_DIALOG_INPUT_SIZE));
|
||||||
|
|
||||||
|
|
||||||
input_sizer_v->Add(m_input_ctrl, 0, wxALL, 1);
|
input_sizer_v->Add(m_input_ctrl, 1, wxEXPAND, 0);
|
||||||
input_sizer_h->Add(input_sizer_v, 0, wxALL, 1);
|
input_sizer_h->Add(input_sizer_v, 1, wxALIGN_CENTER, 0);
|
||||||
|
input_sizer_h->Layout();
|
||||||
m_input_area->SetSizer(input_sizer_h);
|
|
||||||
m_input_area->Layout();
|
|
||||||
|
|
||||||
m_valid_label = new wxStaticText(m_parent, wxID_ANY, "");
|
m_valid_label = new wxStaticText(m_parent, wxID_ANY, "");
|
||||||
m_valid_label->SetForegroundColour(wxColor(255, 111, 0));
|
m_valid_label->SetForegroundColour(wxColor(255, 111, 0));
|
||||||
|
|
||||||
sizer->Add(label_top, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, BORDER_W);
|
sizer->Add(label_top, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, BORDER_W);
|
||||||
sizer->Add(m_input_area, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, BORDER_W);
|
sizer->Add(input_sizer_h, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, BORDER_W);
|
||||||
sizer->Add(m_valid_label, 0, wxEXPAND | wxLEFT | wxRIGHT, BORDER_W);
|
sizer->Add(m_valid_label, 0, wxEXPAND | wxLEFT | wxRIGHT, BORDER_W);
|
||||||
|
|
||||||
if (m_type == Preset::TYPE_PRINTER) m_parent->add_info_for_edit_ph_printer(sizer);
|
if (m_type == Preset::TYPE_PRINTER) m_parent->add_info_for_edit_ph_printer(sizer);
|
||||||
|
@ -176,7 +174,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
|
||||||
|
|
||||||
void SavePresetDialog::Item::update()
|
void SavePresetDialog::Item::update()
|
||||||
{
|
{
|
||||||
m_preset_name = into_u8(m_input_ctrl->GetValue());
|
m_preset_name = into_u8(m_input_ctrl->GetTextCtrl()->GetValue());
|
||||||
|
|
||||||
m_valid_type = Valid;
|
m_valid_type = Valid;
|
||||||
wxString info_line;
|
wxString info_line;
|
||||||
|
@ -255,7 +253,6 @@ void SavePresetDialog::Item::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_valid_label->SetLabel(info_line);
|
m_valid_label->SetLabel(info_line);
|
||||||
m_input_area->Refresh();
|
|
||||||
m_valid_label->Show(!info_line.IsEmpty());
|
m_valid_label->Show(!info_line.IsEmpty());
|
||||||
|
|
||||||
// update_valid_bmp();
|
// update_valid_bmp();
|
||||||
|
@ -395,7 +392,7 @@ std::string SavePresetDialog::get_name(Preset::Type type)
|
||||||
void SavePresetDialog::input_name_from_other(std::string new_preset_name) {
|
void SavePresetDialog::input_name_from_other(std::string new_preset_name) {
|
||||||
//only work for one-item
|
//only work for one-item
|
||||||
Item* curr_item = m_items[0];
|
Item* curr_item = m_items[0];
|
||||||
curr_item->m_input_ctrl->SetValue(new_preset_name);
|
curr_item->m_input_ctrl->GetTextCtrl()->SetValue(new_preset_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavePresetDialog::confirm_from_other() {
|
void SavePresetDialog::confirm_from_other() {
|
||||||
|
|
|
@ -56,7 +56,6 @@ class SavePresetDialog : public DPIDialog
|
||||||
//BBS: add project embedded preset relate logic
|
//BBS: add project embedded preset relate logic
|
||||||
bool save_to_project() const { return m_save_to_project; }
|
bool save_to_project() const { return m_save_to_project; }
|
||||||
|
|
||||||
StaticBox* m_input_area {nullptr};
|
|
||||||
Preset::Type m_type;
|
Preset::Type m_type;
|
||||||
ValidationType m_valid_type;
|
ValidationType m_valid_type;
|
||||||
std::string m_preset_name;
|
std::string m_preset_name;
|
||||||
|
@ -64,7 +63,7 @@ class SavePresetDialog : public DPIDialog
|
||||||
SavePresetDialog* m_parent {nullptr};
|
SavePresetDialog* m_parent {nullptr};
|
||||||
wxStaticBitmap* m_valid_bmp {nullptr};
|
wxStaticBitmap* m_valid_bmp {nullptr};
|
||||||
wxComboBox* m_combo {nullptr};
|
wxComboBox* m_combo {nullptr};
|
||||||
wxTextCtrl* m_input_ctrl {nullptr};
|
TextInput* m_input_ctrl {nullptr};
|
||||||
wxStaticText* m_valid_label {nullptr};
|
wxStaticText* m_valid_label {nullptr};
|
||||||
|
|
||||||
PresetCollection* m_presets {nullptr};
|
PresetCollection* m_presets {nullptr};
|
||||||
|
|
Loading…
Reference in New Issue