mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 16:15:52 +08:00
TopBar: Added "Search" control
+ Deleted old search controls from tab and canvas3D
This commit is contained in:
parent
4263ca6283
commit
e065f0c83b
@ -2858,7 +2858,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||
int keyCode = evt.GetKeyCode();
|
||||
int ctrlMask = wxMOD_CONTROL;
|
||||
int shiftMask = wxMOD_SHIFT;
|
||||
if (keyCode == WXK_ESCAPE && (_deactivate_undo_redo_toolbar_items() || _deactivate_search_toolbar_item() || _deactivate_arrange_menu()))
|
||||
if (keyCode == WXK_ESCAPE && (_deactivate_undo_redo_toolbar_items() || _deactivate_arrange_menu()))
|
||||
return;
|
||||
|
||||
if (m_gizmos.on_char(evt)) {
|
||||
@ -2890,14 +2890,6 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||
#endif /* __APPLE__ */
|
||||
post_event(SimpleEvent(EVT_GLTOOLBAR_COPY));
|
||||
break;
|
||||
#ifdef __APPLE__
|
||||
case 'f':
|
||||
case 'F':
|
||||
#else /* __APPLE__ */
|
||||
case WXK_CONTROL_F:
|
||||
#endif /* __APPLE__ */
|
||||
_activate_search_toolbar_item();
|
||||
break;
|
||||
#ifdef __APPLE__
|
||||
case 'm':
|
||||
case 'M':
|
||||
@ -3354,10 +3346,9 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
||||
}
|
||||
}
|
||||
|
||||
// If the Search window or Undo/Redo list is opened,
|
||||
// If Undo/Redo list is opened,
|
||||
// update them according to the event
|
||||
if (m_main_toolbar.is_item_pressed("search") ||
|
||||
m_undoredo_toolbar.is_item_pressed("undo") ||
|
||||
if (m_undoredo_toolbar.is_item_pressed("undo") ||
|
||||
m_undoredo_toolbar.is_item_pressed("redo")) {
|
||||
m_mouse_wheel = int((double)evt.GetWheelRotation() / (double)evt.GetWheelDelta());
|
||||
return;
|
||||
@ -3664,7 +3655,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||
m_dirty = true;
|
||||
}
|
||||
else if (evt.LeftDown() || evt.RightDown() || evt.MiddleDown()) {
|
||||
if (_deactivate_undo_redo_toolbar_items() || _deactivate_search_toolbar_item() || _deactivate_arrange_menu())
|
||||
if (_deactivate_undo_redo_toolbar_items() || _deactivate_arrange_menu())
|
||||
return;
|
||||
|
||||
// If user pressed left or right button we first check whether this happened
|
||||
@ -4765,73 +4756,6 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
||||
return action_taken;
|
||||
}
|
||||
|
||||
// Getter for the const char*[] for the search list
|
||||
static bool search_string_getter(int idx, const char** label, const char** tooltip)
|
||||
{
|
||||
const Search::OptionsSearcher& search_list = wxGetApp().searcher();
|
||||
if (0 <= idx && (size_t)idx < search_list.size()) {
|
||||
search_list[idx].get_marked_label_and_tooltip(label, tooltip);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_render_search_list(float pos_x)
|
||||
{
|
||||
bool action_taken = false;
|
||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||
|
||||
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||
std::string title = L("Search");
|
||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
int selected = -1;
|
||||
bool edited = false;
|
||||
float em = static_cast<float>(wxGetApp().em_unit());
|
||||
#if ENABLE_RETINA_GL
|
||||
em *= m_retina_helper->get_scale_factor();
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
// update searcher before show imGui search dialog on the plater, if printer technology or mode was changed
|
||||
wxGetApp().check_and_update_searcher(wxGetApp().get_mode());
|
||||
Search::OptionsSearcher& searcher = wxGetApp().searcher();
|
||||
|
||||
std::string& search_line = searcher.search_string();
|
||||
char *s = new char[255];
|
||||
strcpy(s, search_line.empty() ? _u8L("Enter a search term").c_str() : search_line.c_str());
|
||||
|
||||
imgui->search_list(ImVec2(45 * em, 30 * em), &search_string_getter, s,
|
||||
wxGetApp().searcher().view_params,
|
||||
selected, edited, m_mouse_wheel, wxGetApp().is_localized());
|
||||
|
||||
search_line = s;
|
||||
delete [] s;
|
||||
if (search_line == _u8L("Enter a search term"))
|
||||
search_line.clear();
|
||||
|
||||
if (edited)
|
||||
searcher.search();
|
||||
|
||||
if (selected >= 0) {
|
||||
// selected == 9999 means that Esc kye was pressed
|
||||
/*// revert commit https://github.com/prusa3d/PrusaSlicer/commit/91897589928789b261ca0dc735ffd46f2b0b99f2
|
||||
if (selected == 9999)
|
||||
action_taken = true;
|
||||
else
|
||||
sidebar.jump_to_option(selected);*/
|
||||
if (selected != 9999) {
|
||||
imgui->end(); // end imgui before the jump to option
|
||||
wxGetApp().jump_to_option(selected);
|
||||
return true;
|
||||
}
|
||||
action_taken = true;
|
||||
}
|
||||
|
||||
imgui->end();
|
||||
|
||||
return action_taken;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||
{
|
||||
m_arrange_settings_dialog.render(pos_x, m_main_toolbar.get_height());
|
||||
@ -5395,30 +5319,6 @@ bool GLCanvas3D::_init_main_toolbar()
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
/*
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
*/
|
||||
|
||||
item.name = "search";
|
||||
item.icon_filename = "search_.svg";
|
||||
item.tooltip = _u8L("Search") + " [" + GUI::shortkey_ctrl_prefix() + "F]";
|
||||
item.sprite_id = 11;
|
||||
item.left.toggable = true;
|
||||
item.left.render_callback = [this](float left, float right, float, float) {
|
||||
if (m_canvas != nullptr) {
|
||||
if (!m_canvas->HasFocus())
|
||||
m_canvas->SetFocus();
|
||||
if (_render_search_list(0.5f * (left + right)))
|
||||
_deactivate_search_toolbar_item();
|
||||
}
|
||||
};
|
||||
item.left.action_callback = GLToolbarItem::Default_Action_Callback;
|
||||
item.visibility_callback = GLToolbarItem::Default_Visibility_Callback;
|
||||
item.enabling_callback = [this]()->bool { return m_gizmos.get_current_type() == GLGizmosManager::Undefined; };
|
||||
if (!m_main_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
if (!m_main_toolbar.add_separator())
|
||||
return false;
|
||||
|
||||
@ -7653,11 +7553,6 @@ bool GLCanvas3D::_deactivate_undo_redo_toolbar_items()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_search_pressed() const
|
||||
{
|
||||
return m_main_toolbar.is_item_pressed("search");
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_deactivate_arrange_menu()
|
||||
{
|
||||
if (m_main_toolbar.is_item_pressed("arrange")) {
|
||||
@ -7668,26 +7563,6 @@ bool GLCanvas3D::_deactivate_arrange_menu()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_deactivate_search_toolbar_item()
|
||||
{
|
||||
if (is_search_pressed()) {
|
||||
m_main_toolbar.force_left_action(m_main_toolbar.get_item_id("search"), *this);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_activate_search_toolbar_item()
|
||||
{
|
||||
if (!m_main_toolbar.is_item_pressed("search")) {
|
||||
m_main_toolbar.force_left_action(m_main_toolbar.get_item_id("search"), *this);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_deactivate_collapse_toolbar_items()
|
||||
{
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
|
@ -780,7 +780,6 @@ public:
|
||||
|
||||
bool is_layers_editing_enabled() const;
|
||||
bool is_layers_editing_allowed() const;
|
||||
bool is_search_pressed() const;
|
||||
|
||||
void reset_layer_height_profile();
|
||||
void adaptive_layer_height_profile(float quality_factor);
|
||||
@ -1064,7 +1063,6 @@ private:
|
||||
void _render_sla_slices();
|
||||
void _render_selection_sidebar_hints();
|
||||
bool _render_undo_redo_stack(const bool is_undo, float pos_x);
|
||||
bool _render_search_list(float pos_x);
|
||||
bool _render_arrange_menu(float pos_x);
|
||||
void _render_thumbnail_internal(ThumbnailData& thumbnail_data, const ThumbnailsParams& thumbnail_params, const GLVolumeCollection& volumes, Camera::EType camera_type);
|
||||
// render thumbnail using an off-screen framebuffer
|
||||
@ -1113,8 +1111,6 @@ private:
|
||||
void _update_selection_from_hover();
|
||||
|
||||
bool _deactivate_undo_redo_toolbar_items();
|
||||
bool _deactivate_search_toolbar_item();
|
||||
bool _activate_search_toolbar_item();
|
||||
bool _deactivate_collapse_toolbar_items();
|
||||
bool _deactivate_arrange_menu();
|
||||
|
||||
|
@ -1829,7 +1829,7 @@ bool GUI_App::suppress_round_corners() const
|
||||
|
||||
wxSize GUI_App::get_min_size(wxWindow* display_win) const
|
||||
{
|
||||
wxSize min_size(76*m_em_unit, 49 * m_em_unit);
|
||||
wxSize min_size(120 * m_em_unit, 49 * m_em_unit);
|
||||
|
||||
const wxDisplay display = wxDisplay(display_win);
|
||||
wxRect display_rect = display.GetGeometry();
|
||||
|
@ -1516,7 +1516,7 @@ void MainFrame::init_menubar_as_editor()
|
||||
|
||||
editMenu->AppendSeparator();
|
||||
append_menu_item(editMenu, wxID_ANY, _L("Searc&h") + "\tCtrl+F",
|
||||
_L("Search in settings"), [this](wxCommandEvent&) { m_plater->IsShown() ? m_plater->search() : wxGetApp().show_search_dialog(); },
|
||||
_L("Search in settings"), [this](wxCommandEvent&) { wxGetApp().show_search_dialog(); },
|
||||
"search", nullptr, []() {return true; }, this);
|
||||
}
|
||||
|
||||
@ -2055,9 +2055,6 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
||||
if (tab==0) {
|
||||
if (m_settings_dialog.IsShown())
|
||||
this->SetFocus();
|
||||
// plater should be focused for correct navigation inside search window
|
||||
if (m_plater->canvas3D()->is_search_pressed())
|
||||
m_plater->SetFocus();
|
||||
return;
|
||||
}
|
||||
// Show/Activate Settings Dialog
|
||||
|
@ -6552,23 +6552,6 @@ void Plater::paste_from_clipboard()
|
||||
p->view3D->get_canvas3d()->get_selection().paste_from_clipboard();
|
||||
}
|
||||
|
||||
void Plater::search()
|
||||
{
|
||||
if (is_preview_shown())
|
||||
return;
|
||||
// plater should be focused for correct navigation inside search window
|
||||
this->SetFocus();
|
||||
|
||||
wxKeyEvent evt;
|
||||
#ifdef __APPLE__
|
||||
evt.m_keyCode = 'f';
|
||||
#else /* __APPLE__ */
|
||||
evt.m_keyCode = WXK_CONTROL_F;
|
||||
#endif /* __APPLE__ */
|
||||
evt.SetControlDown(true);
|
||||
canvas3D()->on_char(evt);
|
||||
}
|
||||
|
||||
void Plater::msw_rescale()
|
||||
{
|
||||
p->preview->msw_rescale();
|
||||
|
@ -284,7 +284,6 @@ public:
|
||||
|
||||
void copy_selection_to_clipboard();
|
||||
void paste_from_clipboard();
|
||||
void search();
|
||||
void mirror(Axis axis);
|
||||
void split_object();
|
||||
void split_volume();
|
||||
|
@ -306,6 +306,7 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/)
|
||||
|
||||
OptionsSearcher::OptionsSearcher()
|
||||
{
|
||||
default_string = _L("Enter a search term");
|
||||
}
|
||||
|
||||
OptionsSearcher::~OptionsSearcher()
|
||||
@ -423,18 +424,22 @@ Option OptionsSearcher::get_option(const std::string& opt_key, const wxString& l
|
||||
|
||||
void OptionsSearcher::show_dialog()
|
||||
{
|
||||
if (!search_dialog) {
|
||||
if (!search_dialog)
|
||||
search_dialog = new SearchDialog(this);
|
||||
|
||||
auto parent = search_dialog->GetParent();
|
||||
wxPoint pos = parent->ClientToScreen(wxPoint(0, 0));
|
||||
pos.x += em_unit(parent) * 40;
|
||||
pos.y += em_unit(parent) * 4;
|
||||
wxSize srch_sz = search_input->GetSize();
|
||||
if (search_dialog->GetPosition().x != search_input->GetPosition().x)
|
||||
search_dialog->SetPosition(search_input->GetScreenPosition() + wxPoint(0, srch_sz.y));
|
||||
|
||||
search_dialog->SetPosition(pos);
|
||||
}
|
||||
wxSize dlg_sz = search_dialog->GetSize();
|
||||
if (dlg_sz.x < srch_sz.x)
|
||||
search_dialog->SetSize(wxSize(srch_sz.x, dlg_sz.y));
|
||||
|
||||
search_string();
|
||||
search_input->SetSelection(-1,-1);
|
||||
|
||||
search_dialog->Popup();
|
||||
search_input->SetFocus();
|
||||
}
|
||||
|
||||
void OptionsSearcher::dlg_sys_color_changed()
|
||||
@ -449,6 +454,42 @@ void OptionsSearcher::dlg_msw_rescale()
|
||||
search_dialog->msw_rescale();
|
||||
}
|
||||
|
||||
void OptionsSearcher::set_search_input(TextInput* input_ctrl)
|
||||
{
|
||||
search_input = input_ctrl;
|
||||
|
||||
search_input->Bind(wxEVT_TEXT, [this](wxEvent& e)
|
||||
{
|
||||
if (search_dialog && search_dialog->IsShown())
|
||||
search_dialog->input_text(search_input->GetValue());
|
||||
else {
|
||||
GUI::wxGetApp().check_and_update_searcher(GUI::wxGetApp().get_mode());
|
||||
show_dialog();
|
||||
}
|
||||
});
|
||||
|
||||
wxTextCtrl* ctrl = search_input->GetTextCtrl();
|
||||
ctrl->SetToolTip(GUI::format_wxstr(_L("Search in settings [%1%]"), "Ctrl+F"));
|
||||
|
||||
ctrl->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& e)
|
||||
{
|
||||
if (e.GetKeyCode() == WXK_TAB)
|
||||
search_input->Navigate(e.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward);
|
||||
else if (e.GetKeyCode() == WXK_ESCAPE)
|
||||
search_dialog->EndModal(wxID_CLOSE);
|
||||
else if (search_dialog)
|
||||
search_dialog->KeyDown(e);
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
ctrl->Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& event)
|
||||
{
|
||||
if (search_input->GetValue() == default_string)
|
||||
search_input->SetValue("");
|
||||
event.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
void OptionsSearcher::add_key(const std::string& opt_key, Preset::Type type, const wxString& group, const wxString& category)
|
||||
{
|
||||
groups_and_categories[get_key(opt_key, type)] = GroupAndCategory{group, category};
|
||||
@ -469,7 +510,7 @@ static const std::map<const char, int> icon_idxs = {
|
||||
};
|
||||
|
||||
SearchDialog::SearchDialog(OptionsSearcher* searcher)
|
||||
: GUI::DPIDialog(GUI::wxGetApp().tab_panel(), wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||
: GUI::DPIDialog(GUI::wxGetApp().tab_panel(), wxID_ANY, _L("Search"), wxDefaultPosition, wxDefaultSize, wxSTAY_ON_TOP | wxRESIZE_BORDER),
|
||||
searcher(searcher)
|
||||
{
|
||||
SetFont(GUI::wxGetApp().normal_font());
|
||||
@ -479,13 +520,9 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher)
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif
|
||||
|
||||
default_string = _L("Enter a search term");
|
||||
int border = 10;
|
||||
int em = em_unit();
|
||||
|
||||
search_line = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
||||
GUI::wxGetApp().UpdateDarkUI(search_line);
|
||||
|
||||
search_list = new wxDataViewCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(em * 40, em * 30), wxDV_NO_HEADER | wxDV_SINGLE
|
||||
#ifdef _WIN32
|
||||
| wxBORDER_SIMPLE
|
||||
@ -531,15 +568,9 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher)
|
||||
|
||||
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
topSizer->Add(search_line, 0, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, border);
|
||||
topSizer->Add(search_list, 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, border);
|
||||
topSizer->Add(check_sizer, 0, wxEXPAND | wxALL, border);
|
||||
|
||||
search_line->Bind(wxEVT_TEXT, &SearchDialog::OnInputText, this);
|
||||
search_line->Bind(wxEVT_LEFT_UP, &SearchDialog::OnLeftUpInTextCtrl, this);
|
||||
// process wxEVT_KEY_DOWN to navigate inside search_list, if ArrowUp/Down was pressed
|
||||
search_line->Bind(wxEVT_KEY_DOWN,&SearchDialog::OnKeyDown, this);
|
||||
|
||||
search_list->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &SearchDialog::OnSelect, this);
|
||||
search_list->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &SearchDialog::OnActivate, this);
|
||||
#ifdef __WXMSW__
|
||||
@ -573,11 +604,6 @@ SearchDialog::~SearchDialog()
|
||||
|
||||
void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/)
|
||||
{
|
||||
const std::string& line = searcher->search_string();
|
||||
search_line->SetValue(line.empty() ? default_string : from_u8(line));
|
||||
search_line->SetFocus();
|
||||
search_line->SelectAll();
|
||||
|
||||
update_list();
|
||||
|
||||
const OptionViewParameters& params = searcher->view_params;
|
||||
@ -587,7 +613,7 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/)
|
||||
|
||||
if (position != wxDefaultPosition)
|
||||
this->SetPosition(position);
|
||||
this->ShowModal();
|
||||
this->Show();
|
||||
}
|
||||
|
||||
void SearchDialog::ProcessSelection(wxDataViewItem selection)
|
||||
@ -606,10 +632,9 @@ void SearchDialog::ProcessSelection(wxDataViewItem selection)
|
||||
wxPostEvent(GUI::wxGetApp().mainframe, event);
|
||||
}
|
||||
|
||||
void SearchDialog::OnInputText(wxCommandEvent&)
|
||||
void SearchDialog::input_text(wxString input_string)
|
||||
{
|
||||
wxString input_string = search_line->GetValue();
|
||||
if (input_string == default_string)
|
||||
if (input_string == searcher->default_string)
|
||||
input_string.Clear();
|
||||
|
||||
searcher->search(into_u8(input_string));
|
||||
@ -617,14 +642,6 @@ void SearchDialog::OnInputText(wxCommandEvent&)
|
||||
update_list();
|
||||
}
|
||||
|
||||
void SearchDialog::OnLeftUpInTextCtrl(wxEvent& event)
|
||||
{
|
||||
if (search_line->GetValue() == default_string)
|
||||
search_line->SetValue("");
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void SearchDialog::OnKeyDown(wxKeyEvent& event)
|
||||
{
|
||||
int key = event.GetKeyCode();
|
||||
@ -749,7 +766,7 @@ void SearchDialog::on_sys_color_changed()
|
||||
#ifdef _WIN32
|
||||
GUI::wxGetApp().UpdateAllStaticTextDarkUI(this);
|
||||
GUI::wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)), true);
|
||||
for (wxWindow* win : std::vector<wxWindow*> {search_line, search_list, check_category, check_english})
|
||||
for (wxWindow* win : std::vector<wxWindow*> {search_list, check_category, check_english})
|
||||
if (win) GUI::wxGetApp().UpdateDarkUI(win);
|
||||
#endif
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
|
||||
class CheckBox;
|
||||
class TextInput;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -91,6 +92,8 @@ class OptionsSearcher
|
||||
std::map<std::string, GroupAndCategory> groups_and_categories;
|
||||
PrinterTechnology printer_technology {ptAny};
|
||||
ConfigOptionMode mode{ comUndef };
|
||||
TextInput* search_input { nullptr };
|
||||
SearchDialog* search_dialog { nullptr };
|
||||
|
||||
std::vector<Option> options {};
|
||||
std::vector<Option> preferences_options {};
|
||||
@ -112,8 +115,7 @@ class OptionsSearcher
|
||||
|
||||
public:
|
||||
OptionViewParameters view_params;
|
||||
|
||||
SearchDialog* search_dialog { nullptr };
|
||||
wxString default_string;
|
||||
|
||||
OptionsSearcher();
|
||||
~OptionsSearcher();
|
||||
@ -148,6 +150,8 @@ public:
|
||||
void show_dialog();
|
||||
void dlg_sys_color_changed();
|
||||
void dlg_msw_rescale();
|
||||
|
||||
void set_search_input(TextInput* input_ctrl);
|
||||
};
|
||||
|
||||
|
||||
@ -158,11 +162,9 @@ class SearchListModel;
|
||||
class SearchDialog : public GUI::DPIDialog
|
||||
{
|
||||
wxString search_str;
|
||||
wxString default_string;
|
||||
|
||||
bool prevent_list_events {false};
|
||||
|
||||
wxTextCtrl* search_line { nullptr };
|
||||
wxDataViewCtrl* search_list { nullptr };
|
||||
SearchListModel* search_list_model { nullptr };
|
||||
CheckBox* check_category { nullptr };
|
||||
@ -170,8 +172,6 @@ class SearchDialog : public GUI::DPIDialog
|
||||
|
||||
OptionsSearcher* searcher { nullptr };
|
||||
|
||||
void OnInputText(wxCommandEvent& event);
|
||||
void OnLeftUpInTextCtrl(wxEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
|
||||
void OnActivate(wxDataViewEvent& event);
|
||||
@ -193,6 +193,9 @@ public:
|
||||
void msw_rescale();
|
||||
void on_sys_color_changed() override;
|
||||
|
||||
void input_text(wxString input);
|
||||
void KeyDown(wxKeyEvent& event) { OnKeyDown(event); }
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override { msw_rescale(); }
|
||||
};
|
||||
|
@ -204,9 +204,6 @@ void Tab::create_preset_tab()
|
||||
m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n"
|
||||
"or click this button.")));
|
||||
|
||||
add_scaled_button(panel, &m_search_btn, "search");
|
||||
m_search_btn->SetToolTip(format_wxstr(_L("Search in settings [%1%]"), "Ctrl+F"));
|
||||
|
||||
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
|
||||
add_scaled_bitmap(this, m_bmp_value_lock , "lock_closed");
|
||||
add_scaled_bitmap(this, m_bmp_value_unlock, "lock_open");
|
||||
@ -230,7 +227,6 @@ void Tab::create_preset_tab()
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
wxGetApp().update_label_colours();
|
||||
});
|
||||
m_search_btn->Bind(wxEVT_BUTTON, [](wxCommandEvent) { wxGetApp().show_search_dialog(); });
|
||||
|
||||
// Colors for ui "decoration"
|
||||
m_sys_label_clr = wxGetApp().get_label_clr_sys();
|
||||
@ -260,8 +256,6 @@ void Tab::create_preset_tab()
|
||||
m_h_buttons_sizer->AddSpacer(int(32 * scale_factor));
|
||||
m_h_buttons_sizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_h_buttons_sizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_h_buttons_sizer->AddSpacer(int(32 * scale_factor));
|
||||
m_h_buttons_sizer->Add(m_search_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
m_h_buttons_sizer->AddSpacer(int(8*scale_factor));
|
||||
m_h_buttons_sizer->Add(m_btn_compare_preset, 0, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
|
@ -184,7 +184,6 @@ protected:
|
||||
std::string m_name;
|
||||
const wxString m_title;
|
||||
TabPresetComboBox* m_presets_choice;
|
||||
ScalableButton* m_search_btn;
|
||||
ScalableButton* m_btn_compare_preset;
|
||||
ScalableButton* m_btn_save_preset;
|
||||
ScalableButton* m_btn_rename_preset;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Search.hpp"
|
||||
#include "UserAccount.hpp"
|
||||
//#include "wxExtensions.hpp"
|
||||
#include "format.hpp"
|
||||
@ -181,6 +182,13 @@ void TopBarItemsCtrl::UpdateAuthMenu()
|
||||
m_user_menu_item->SetItemLabel(user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymus"));
|
||||
}
|
||||
|
||||
void TopBarItemsCtrl::CreateSearch()
|
||||
{
|
||||
m_search = new ::TextInput(this, wxGetApp().searcher().default_string, "", "search", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
||||
wxGetApp().UpdateDarkUI(m_search);
|
||||
wxGetApp().searcher().set_search_input(m_search);
|
||||
}
|
||||
|
||||
TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL)
|
||||
{
|
||||
@ -217,6 +225,10 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
m_buttons_sizer = new wxFlexGridSizer(1, m_btn_margin, m_btn_margin);
|
||||
left_sizer->Add(m_buttons_sizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 2 * m_btn_margin);
|
||||
|
||||
CreateSearch();
|
||||
|
||||
left_sizer->Add(m_search, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 3 * m_btn_margin);
|
||||
|
||||
m_sizer->Add(left_sizer, 1, wxEXPAND);
|
||||
|
||||
wxBoxSizer* right_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@ -259,6 +271,7 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
void TopBarItemsCtrl::OnPaint(wxPaintEvent&)
|
||||
{
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
m_search->Refresh();
|
||||
return;
|
||||
const wxSize sz = GetSize();
|
||||
wxPaintDC dc(this);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <wx/bookctrl.h>
|
||||
#include "wxExtensions.hpp"
|
||||
#include "Widgets/TextInput.hpp"
|
||||
|
||||
class ModeSizer;
|
||||
//class ScalableButton;
|
||||
@ -55,6 +56,8 @@ class TopBarItemsCtrl : public wxControl
|
||||
wxMenuItem* m_login_menu_item{ nullptr };
|
||||
wxMenuItem* m_connect_dummy_menu_item{ nullptr };
|
||||
|
||||
::TextInput* m_search{ nullptr };
|
||||
|
||||
public:
|
||||
TopBarItemsCtrl(wxWindow* parent);
|
||||
~TopBarItemsCtrl() {}
|
||||
@ -76,6 +79,9 @@ public:
|
||||
void ApplyWorkspacesMenu();
|
||||
void CreateAuthMenu();
|
||||
void UpdateAuthMenu();
|
||||
void CreateSearch();
|
||||
|
||||
wxWindow* GetSearchCtrl() { return m_search->GetTextCtrl(); }
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
@ -332,7 +338,16 @@ public:
|
||||
const bool isFromSelf = event.GetEventObject() == (wxObject*)this;
|
||||
const bool isForward = event.GetDirection();
|
||||
|
||||
if (isFromSelf && !isForward)
|
||||
wxWindow* search_win = (dynamic_cast<TopBarItemsCtrl*>(m_bookctrl)->GetSearchCtrl());
|
||||
const bool isFromSearch = event.GetEventObject() == (wxObject*)search_win;
|
||||
if (isFromSearch)
|
||||
{
|
||||
// find the target window in the siblings list
|
||||
wxWindowList& siblings = m_bookctrl->GetChildren();
|
||||
wxWindowList::compatibility_iterator i = siblings.Find(search_win->GetParent());
|
||||
i->GetNext()->GetData()->SetFocus();
|
||||
}
|
||||
else if (isFromSelf && !isForward)
|
||||
{
|
||||
// focus is currently on notebook tab and should leave
|
||||
// it backwards (Shift-TAB)
|
||||
@ -393,7 +408,6 @@ public:
|
||||
GetTopBarItemsCtrl()->AppendMenuSeparaorItem();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual void UpdateSelectedPage(size_t WXUNUSED(newsel)) override
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user