Search: Code cleaning
+ Reverted "Plater" tab to the Settings Notepad
This commit is contained in:
parent
3ba4a2cf3d
commit
f9b3f2d45e
@ -4519,18 +4519,15 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
||||
|
||||
imgui->search_list(ImVec2(45 * em, 30 * em), &search_string_getter, s,
|
||||
sidebar.get_searcher().view_params,
|
||||
selected, edited, check_changed);
|
||||
selected, edited);
|
||||
|
||||
search_line = s;
|
||||
delete [] s;
|
||||
|
||||
if (edited)
|
||||
sidebar.search_and_apply_tab_search_lines();
|
||||
|
||||
if (check_changed) {
|
||||
if (edited) {
|
||||
if (search_line == _u8L("Type here to search"))
|
||||
search_line.clear();
|
||||
sidebar.search_and_apply_tab_search_lines(true);
|
||||
sidebar.search();
|
||||
}
|
||||
|
||||
if (selected != size_t(-1))
|
||||
@ -5261,6 +5258,9 @@ bool GLCanvas3D::_init_collapse_toolbar()
|
||||
if (!m_collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_collapse_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
item.name = "print";
|
||||
item.icon_filename = "cog.svg";
|
||||
item.tooltip = _utf8(L("Switch to Print Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "2]";
|
||||
|
@ -602,7 +602,7 @@ static void process_key_down(ImGuiKey imgui_key, std::function<void()> f)
|
||||
}
|
||||
|
||||
void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, const char** label, const char** tooltip), char* search_str,
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited, bool& check_changed)
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited)
|
||||
{
|
||||
// ImGui::ListBoxHeader("", size);
|
||||
{
|
||||
@ -707,13 +707,13 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
||||
|
||||
ImGui::ListBoxFooter();
|
||||
|
||||
auto check_box = [&check_changed, this](const wxString& label, bool& check) {
|
||||
auto check_box = [&edited, this](const wxString& label, bool& check) {
|
||||
ImGui::SameLine();
|
||||
bool ch = check;
|
||||
checkbox(label, ch);
|
||||
if (ImGui::IsItemClicked()) {
|
||||
check = !check;
|
||||
check_changed = true;
|
||||
edited = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
bool combo(const wxString& label, const std::vector<std::string>& options, int& selection); // Use -1 to not mark any option as selected
|
||||
bool undo_redo_list(const ImVec2& size, const bool is_undo, bool (*items_getter)(const bool, int, const char**), int& hovered, int& selected);
|
||||
void search_list(const ImVec2& size, bool (*items_getter)(int, const char** label, const char** tooltip), char* search_str,
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited, bool& check_changed);
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited);
|
||||
|
||||
void disabled_begin(bool disabled);
|
||||
void disabled_end();
|
||||
|
@ -306,6 +306,8 @@ void MainFrame::init_tabpanel()
|
||||
// before the MainFrame is fully set up.
|
||||
static_cast<Tab*>(panel)->OnActivate();
|
||||
}
|
||||
else
|
||||
select_tab(0);
|
||||
});
|
||||
|
||||
//! m_plater = new Slic3r::GUI::Plater(m_tabpanel, this);
|
||||
@ -313,6 +315,7 @@ void MainFrame::init_tabpanel()
|
||||
|
||||
wxGetApp().plater_ = m_plater;
|
||||
// m_tabpanel->AddPage(m_plater, _(L("Plater")));
|
||||
m_tabpanel->AddPage(new wxPanel(m_tabpanel), _L("Plater")); // empty panel just for Plater tab
|
||||
|
||||
wxGetApp().obj_list()->create_popup_menus();
|
||||
|
||||
@ -756,7 +759,7 @@ void MainFrame::init_menubar()
|
||||
//! size_t tab_offset = 0;
|
||||
if (m_plater) {
|
||||
append_menu_item(windowMenu, wxID_HIGHEST + 1, _(L("&Plater Tab")) + "\tCtrl+1", _(L("Show the plater")),
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab((size_t)(-1)); }, "plater", nullptr,
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*(size_t)(-1)*/0); }, "plater", nullptr,
|
||||
[this]() {return true; }, this);
|
||||
//! tab_offset += 1;
|
||||
//! }
|
||||
@ -764,14 +767,14 @@ void MainFrame::init_menubar()
|
||||
windowMenu->AppendSeparator();
|
||||
}
|
||||
append_menu_item(windowMenu, wxID_HIGHEST + 2, _(L("P&rint Settings Tab")) + "\tCtrl+2", _(L("Show the print settings")),
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + */0); }, "cog", nullptr,
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + 0*/1); }, "cog", nullptr,
|
||||
[this]() {return true; }, this);
|
||||
wxMenuItem* item_material_tab = append_menu_item(windowMenu, wxID_HIGHEST + 3, _(L("&Filament Settings Tab")) + "\tCtrl+3", _(L("Show the filament settings")),
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + */1); }, "spool", nullptr,
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + 1*/2); }, "spool", nullptr,
|
||||
[this]() {return true; }, this);
|
||||
m_changeable_menu_items.push_back(item_material_tab);
|
||||
wxMenuItem* item_printer_tab = append_menu_item(windowMenu, wxID_HIGHEST + 4, _(L("Print&er Settings Tab")) + "\tCtrl+4", _(L("Show the printer settings")),
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + */2); }, "printer", nullptr,
|
||||
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + 2*/3); }, "printer", nullptr,
|
||||
[this]() {return true; }, this);
|
||||
m_changeable_menu_items.push_back(item_printer_tab);
|
||||
if (m_plater) {
|
||||
@ -1237,7 +1240,7 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
|
||||
|
||||
void MainFrame::select_tab(size_t tab)
|
||||
{
|
||||
if (tab == (size_t)(-1)) {
|
||||
if (tab == /*(size_t)(-1)*/0) {
|
||||
if (m_plater && !m_plater->IsShown())
|
||||
this->switch_to(true);
|
||||
}
|
||||
|
@ -726,7 +726,6 @@ struct Sidebar::priv
|
||||
|
||||
bool is_collapsed {false};
|
||||
Search::OptionsSearcher searcher;
|
||||
std::string search_line;
|
||||
|
||||
priv(Plater *plater) : plater(plater) {}
|
||||
~priv();
|
||||
@ -1096,10 +1095,9 @@ void Sidebar::msw_rescale()
|
||||
p->scrolled->Layout();
|
||||
}
|
||||
|
||||
void Sidebar::search_and_apply_tab_search_lines(bool force/* = false*/)
|
||||
void Sidebar::search()
|
||||
{
|
||||
if (p->searcher.search(p->search_line, force))
|
||||
;//apply_search_line_on_tabs();
|
||||
p->searcher.search();
|
||||
}
|
||||
|
||||
void Sidebar::jump_to_option(size_t selected)
|
||||
@ -1382,16 +1380,6 @@ static std::vector<Search::InputInfo> get_search_inputs(ConfigOptionMode mode)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Sidebar::apply_search_line_on_tabs()
|
||||
{
|
||||
auto& tabs_list = wxGetApp().tabs_list;
|
||||
auto print_tech = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology();
|
||||
|
||||
for (auto tab : tabs_list)
|
||||
if (tab->supports_printer_technology(print_tech))
|
||||
tab->set_search_line(p->search_line);
|
||||
}
|
||||
|
||||
void Sidebar::update_searcher()
|
||||
{
|
||||
p->searcher.init(get_search_inputs(m_mode));
|
||||
@ -1442,7 +1430,7 @@ Search::OptionsSearcher& Sidebar::get_searcher()
|
||||
|
||||
std::string& Sidebar::get_search_line()
|
||||
{
|
||||
return p->search_line;
|
||||
return p->searcher.search_string();
|
||||
}
|
||||
|
||||
// Plater::DropTarget
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
void update_mode_sizer() const;
|
||||
void update_reslice_btn_tooltip() const;
|
||||
void msw_rescale();
|
||||
void search_and_apply_tab_search_lines(bool force = false);
|
||||
void search();
|
||||
void jump_to_option(size_t selected);
|
||||
|
||||
ObjectManipulation* obj_manipul();
|
||||
@ -132,7 +132,6 @@ public:
|
||||
void update_mode();
|
||||
bool is_collapsed();
|
||||
void collapse(bool collapse);
|
||||
void apply_search_line_on_tabs();
|
||||
void update_searcher();
|
||||
|
||||
std::vector<PresetComboBox*>& combos_filament();
|
||||
|
@ -215,6 +215,11 @@ static void clear_marked_string(wxString& str)
|
||||
str.Replace(delete_string, wxEmptyString, true);
|
||||
}
|
||||
|
||||
bool OptionsSearcher::search()
|
||||
{
|
||||
return search(search_line, true);
|
||||
}
|
||||
|
||||
bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
|
||||
{
|
||||
if (search_line == search && !force)
|
||||
@ -277,7 +282,9 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
|
||||
if (!full_list)
|
||||
sort_found();
|
||||
|
||||
search_line = search;
|
||||
if (search_line != search)
|
||||
search_line = search;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -404,110 +411,6 @@ void SearchComboPopup::OnKeyDown(wxKeyEvent& event)
|
||||
event.Skip(); // !Needed to have EVT_CHAR generated as well
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
// SearchCtrl
|
||||
//------------------------------------------
|
||||
|
||||
SearchCtrl::SearchCtrl(wxWindow* parent) :
|
||||
wxComboCtrl(parent, wxID_ANY, _L("Type here to search"), wxDefaultPosition, wxSize(25 * GUI::wxGetApp().em_unit(), -1), wxTE_PROCESS_ENTER)
|
||||
{
|
||||
default_string = _L("Type here to search");
|
||||
|
||||
this->UseAltPopupWindow();
|
||||
|
||||
wxBitmap bmp_norm = create_scaled_bitmap("search_gray");
|
||||
wxBitmap bmp_hov = create_scaled_bitmap("search");
|
||||
this->SetButtonBitmaps(bmp_norm, true, bmp_hov, bmp_hov, bmp_norm);
|
||||
|
||||
popupListBox = new SearchComboPopup();
|
||||
|
||||
// It is important to call SetPopupControl() as soon as possible
|
||||
this->SetPopupControl(popupListBox);
|
||||
|
||||
this->Bind(wxEVT_TEXT, &SearchCtrl::OnInputText, this);
|
||||
this->Bind(wxEVT_TEXT_ENTER, &SearchCtrl::PopupList, this);
|
||||
this->Bind(wxEVT_COMBOBOX_DROPDOWN, &SearchCtrl::PopupList, this);
|
||||
|
||||
this->GetTextCtrl()->Bind(wxEVT_LEFT_UP, &SearchCtrl::OnLeftUpInTextCtrl, this);
|
||||
popupListBox->Bind(wxEVT_LISTBOX, &SearchCtrl::OnSelect, this);
|
||||
}
|
||||
|
||||
void SearchCtrl::OnInputText(wxCommandEvent& )
|
||||
{
|
||||
if (prevent_update)
|
||||
return;
|
||||
|
||||
this->GetTextCtrl()->SetInsertionPointEnd();
|
||||
|
||||
wxString input_string = this->GetValue();
|
||||
if (input_string == default_string)
|
||||
input_string.Clear();
|
||||
|
||||
GUI::wxGetApp().sidebar().get_search_line() = into_u8(input_string);
|
||||
|
||||
editing = true;
|
||||
GUI::wxGetApp().sidebar().search_and_apply_tab_search_lines();
|
||||
editing = false;
|
||||
}
|
||||
|
||||
void SearchCtrl::PopupList(wxCommandEvent& e)
|
||||
{
|
||||
update_list(GUI::wxGetApp().sidebar().get_searcher().found_options());
|
||||
if (e.GetEventType() == wxEVT_TEXT_ENTER)
|
||||
this->Popup();
|
||||
|
||||
e.Skip();
|
||||
}
|
||||
|
||||
void SearchCtrl::set_search_line(const std::string& line)
|
||||
{
|
||||
prevent_update = true;
|
||||
this->SetValue(line.empty() && !editing ? default_string : from_u8(line));
|
||||
prevent_update = false;
|
||||
}
|
||||
|
||||
void SearchCtrl::msw_rescale()
|
||||
{
|
||||
wxSize size = wxSize(25 * GUI::wxGetApp().em_unit(), -1);
|
||||
// Set rescaled min height to correct layout
|
||||
this->SetMinSize(size);
|
||||
|
||||
wxBitmap bmp_norm = create_scaled_bitmap("search_gray");
|
||||
wxBitmap bmp_hov = create_scaled_bitmap("search");
|
||||
this->SetButtonBitmaps(bmp_norm, true, bmp_hov, bmp_hov, bmp_norm);
|
||||
}
|
||||
|
||||
void SearchCtrl::OnSelect(wxCommandEvent& event)
|
||||
{
|
||||
int selection = event.GetSelection();
|
||||
if (selection < 0)
|
||||
return;
|
||||
|
||||
prevent_update = true;
|
||||
GUI::wxGetApp().sidebar().jump_to_option(selection);
|
||||
prevent_update = false;
|
||||
}
|
||||
|
||||
void SearchCtrl::update_list(const std::vector<FoundOption>& filters)
|
||||
{
|
||||
if (!filters.empty() && popupListBox->GetCount() == filters.size() &&
|
||||
popupListBox->GetString(0) == filters[0].label &&
|
||||
popupListBox->GetString(popupListBox->GetCount()-1) == filters[filters.size()-1].label)
|
||||
return;
|
||||
|
||||
popupListBox->Clear();
|
||||
for (const FoundOption& item : filters)
|
||||
popupListBox->Append(item.label);
|
||||
}
|
||||
|
||||
void SearchCtrl::OnLeftUpInTextCtrl(wxEvent &event)
|
||||
{
|
||||
if (this->GetValue() == default_string)
|
||||
this->SetValue("");
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// SearchDialog
|
||||
@ -603,9 +506,7 @@ void SearchDialog::OnInputText(wxCommandEvent&)
|
||||
if (input_string == default_string)
|
||||
input_string.Clear();
|
||||
|
||||
GUI::wxGetApp().sidebar().get_search_line() = into_u8(input_string);
|
||||
|
||||
GUI::wxGetApp().sidebar().search_and_apply_tab_search_lines();
|
||||
searcher->search(into_u8(input_string));
|
||||
|
||||
update_list();
|
||||
}
|
||||
@ -684,7 +585,7 @@ void SearchDialog::OnCheck(wxCommandEvent& event)
|
||||
params.category = check_category->GetValue();
|
||||
params.group = check_group->GetValue();
|
||||
|
||||
searcher->search(searcher->search_string(), true);
|
||||
searcher->search();
|
||||
update_list();
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,7 @@ public:
|
||||
void apply(DynamicPrintConfig *config,
|
||||
Preset::Type type,
|
||||
ConfigOptionMode mode);
|
||||
bool search();
|
||||
bool search(const std::string& search, bool force = false);
|
||||
|
||||
void add_key(const std::string& opt_key, const wxString& group, const wxString& category);
|
||||
@ -135,7 +136,7 @@ public:
|
||||
|
||||
const std::vector<FoundOption>& found_options() { return found; }
|
||||
const GroupAndCategory& get_group_and_category (const std::string& opt_key) { return groups_and_categories[opt_key]; }
|
||||
const std::string& search_string() { return search_line; }
|
||||
std::string& search_string() { return search_line; }
|
||||
};
|
||||
|
||||
|
||||
@ -171,30 +172,6 @@ protected:
|
||||
wxString m_input_string;
|
||||
};
|
||||
|
||||
class SearchCtrl : public wxComboCtrl
|
||||
{
|
||||
SearchComboPopup* popupListBox {nullptr};
|
||||
|
||||
bool prevent_update { false };
|
||||
wxString default_string;
|
||||
bool editing {false};
|
||||
|
||||
void PopupList(wxCommandEvent& event);
|
||||
void OnInputText(wxCommandEvent& event);
|
||||
|
||||
void OnSelect(wxCommandEvent& event);
|
||||
void OnLeftUpInTextCtrl(wxEvent& event);
|
||||
|
||||
public:
|
||||
SearchCtrl(wxWindow* parent);
|
||||
~SearchCtrl() {}
|
||||
|
||||
void set_search_line(const std::string& search_line);
|
||||
void msw_rescale();
|
||||
|
||||
void update_list(const std::vector<FoundOption>& filters);
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// SearchDialog
|
||||
|
@ -845,8 +845,6 @@ void Tab::msw_rescale()
|
||||
m_em_unit = wxGetApp().em_unit();
|
||||
|
||||
m_mode_sizer->msw_rescale();
|
||||
// m_search_cb->msw_rescale();
|
||||
m_search->msw_rescale();
|
||||
|
||||
m_presets_choice->SetSize(35 * m_em_unit, -1);
|
||||
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
|
||||
@ -949,11 +947,6 @@ static wxString pad_combo_value_for_config(const DynamicPrintConfig &config)
|
||||
return config.opt_bool("pad_enable") ? (config.opt_bool("pad_around_object") ? _("Around object") : _("Below object")) : _("None");
|
||||
}
|
||||
|
||||
void Tab::set_search_line(const std::string& search_line)
|
||||
{
|
||||
m_search->set_search_line(search_line);
|
||||
}
|
||||
|
||||
void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
{
|
||||
if (wxGetApp().plater() == nullptr) {
|
||||
|
@ -122,7 +122,6 @@ protected:
|
||||
std::string m_name;
|
||||
const wxString m_title;
|
||||
PresetBitmapComboBox* m_presets_choice;
|
||||
Search::SearchCtrl* m_search;
|
||||
ScalableButton* m_search_btn;
|
||||
ScalableButton* m_btn_save_preset;
|
||||
ScalableButton* m_btn_delete_preset;
|
||||
@ -331,8 +330,6 @@ public:
|
||||
PresetCollection* get_presets() { return m_presets; }
|
||||
size_t get_selected_preset_item() { return m_selected_preset_item; }
|
||||
|
||||
void set_search_line(const std::string& search_line);
|
||||
|
||||
void on_value_change(const std::string& opt_key, const boost::any& value);
|
||||
|
||||
void update_wiping_button_visibility();
|
||||
|
Loading…
Reference in New Issue
Block a user