Search: 1.Select first item in the search list by default
2. Show "Search in English" checkbox only, when Slicer is localized 3. Suppress search window hiding when leave the 3D-scene
This commit is contained in:
parent
2daa12d467
commit
9189758992
7 changed files with 29 additions and 22 deletions
|
@ -3567,7 +3567,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
else if (evt.Leaving())
|
||||
{
|
||||
_deactivate_undo_redo_toolbar_items();
|
||||
_deactivate_search_toolbar_item();
|
||||
|
||||
// to remove hover on objects when the mouse goes out of this canvas
|
||||
m_mouse.position = Vec2d(-1.0, -1.0);
|
||||
|
@ -4386,7 +4385,6 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
|||
|
||||
int selected = -1;
|
||||
bool edited = false;
|
||||
bool check_changed = false;
|
||||
float em = static_cast<float>(wxGetApp().em_unit());
|
||||
#if ENABLE_RETINA_GL
|
||||
em *= m_retina_helper->get_scale_factor();
|
||||
|
@ -4400,7 +4398,7 @@ 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, m_mouse_wheel);
|
||||
selected, edited, m_mouse_wheel, wxGetApp().is_localized());
|
||||
|
||||
search_line = s;
|
||||
delete [] s;
|
||||
|
@ -4410,11 +4408,12 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
|
|||
if (edited)
|
||||
sidebar.search();
|
||||
|
||||
if (selected != size_t(-1)) {
|
||||
if (selected >= 0) {
|
||||
// selected == 9999 means that Esc kye was pressed
|
||||
if (selected != 9999)
|
||||
if (selected == 9999)
|
||||
action_taken = true;
|
||||
else
|
||||
sidebar.jump_to_option(selected);
|
||||
action_taken = true;
|
||||
}
|
||||
|
||||
imgui->end();
|
||||
|
|
|
@ -162,6 +162,7 @@ public:
|
|||
wxString current_language_code() const { return m_wxLocale->GetCanonicalName(); }
|
||||
// Translate the language code to a code, for which Prusa Research maintains translations. Defaults to "en_US".
|
||||
wxString current_language_code_safe() const;
|
||||
bool is_localized() const { return m_wxLocale->GetLocale() != "English"; }
|
||||
|
||||
virtual bool OnExceptionInMainLoop() override;
|
||||
|
||||
|
|
|
@ -627,8 +627,9 @@ 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, int& mouse_wheel)
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited, int& mouse_wheel, bool is_localized)
|
||||
{
|
||||
int& hovered_id = view_params.hovered_id;
|
||||
// ImGui::ListBoxHeader("", size);
|
||||
{
|
||||
// rewrote part of function to add a TextInput instead of label Text
|
||||
|
@ -668,7 +669,7 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
ImGui::InputTextEx("", NULL, search_str, 20, search_size, ImGuiInputTextFlags_AutoSelectAll, NULL, NULL);
|
||||
edited = ImGui::IsItemEdited();
|
||||
if (edited)
|
||||
view_params.hovered_id = -1;
|
||||
hovered_id = 0;
|
||||
|
||||
process_key_down(ImGuiKey_Escape, [&selected, search_str, str]() {
|
||||
// use 9999 to mark selection as a Esc key
|
||||
|
@ -684,7 +685,6 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
const char* item_text;
|
||||
const char* tooltip;
|
||||
int mouse_hovered = -1;
|
||||
int& hovered_id = view_params.hovered_id;
|
||||
|
||||
while (items_getter(i, &item_text, &tooltip))
|
||||
{
|
||||
|
@ -692,7 +692,7 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("%s", /*item_text*/tooltip);
|
||||
view_params.hovered_id = -1;
|
||||
hovered_id = -1;
|
||||
mouse_hovered = i;
|
||||
}
|
||||
|
||||
|
@ -701,8 +701,6 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
i++;
|
||||
}
|
||||
|
||||
scroll_y(mouse_hovered);
|
||||
|
||||
// Process mouse wheel
|
||||
if (mouse_hovered > 0)
|
||||
process_mouse_wheel(mouse_wheel);
|
||||
|
@ -712,7 +710,7 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
if (mouse_hovered > 0)
|
||||
scroll_up();
|
||||
else {
|
||||
if (hovered_id > 0 && hovered_id != size_t(-1))
|
||||
if (hovered_id > 0)
|
||||
--hovered_id;
|
||||
scroll_y(hovered_id);
|
||||
}
|
||||
|
@ -722,9 +720,9 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
if (mouse_hovered > 0)
|
||||
scroll_down();
|
||||
else {
|
||||
if (hovered_id == size_t(-1))
|
||||
if (hovered_id < 0)
|
||||
hovered_id = 0;
|
||||
else if (hovered_id < size_t(i - 1))
|
||||
else if (hovered_id < i - 1)
|
||||
++hovered_id;
|
||||
scroll_y(hovered_id);
|
||||
}
|
||||
|
@ -750,7 +748,8 @@ void ImGuiWrapper::search_list(const ImVec2& size_, bool (*items_getter)(int, co
|
|||
text(_L("Use for search")+":");
|
||||
check_box(_L("Category"), view_params.category);
|
||||
check_box(_L("Group"), view_params.group);
|
||||
check_box(_L("Search in English"), view_params.english);
|
||||
if (is_localized)
|
||||
check_box(_L("Search in English"), view_params.english);
|
||||
}
|
||||
|
||||
void ImGuiWrapper::disabled_begin(bool disabled)
|
||||
|
|
|
@ -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, int& mouse_wheel);
|
||||
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, int& mouse_wheel);
|
||||
Search::OptionViewParameters& view_params, int& selected, bool& edited, int& mouse_wheel, bool is_localized);
|
||||
|
||||
void disabled_begin(bool disabled);
|
||||
void disabled_end();
|
||||
|
|
|
@ -1267,7 +1267,12 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||
}
|
||||
// Show/Activate Settings Dialog
|
||||
if (m_settings_dialog->IsShown())
|
||||
#ifdef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
|
||||
m_settings_dialog->Hide();
|
||||
#else
|
||||
m_settings_dialog->SetFocus();
|
||||
else
|
||||
#endif
|
||||
m_settings_dialog->Show();
|
||||
}
|
||||
else if (m_layout == slNew) {
|
||||
|
|
|
@ -434,13 +434,15 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher)
|
|||
|
||||
check_category = new wxCheckBox(this, wxID_ANY, _L("Category"));
|
||||
check_group = new wxCheckBox(this, wxID_ANY, _L("Group"));
|
||||
check_english = new wxCheckBox(this, wxID_ANY, _L("Search in English"));
|
||||
if (GUI::wxGetApp().is_localized())
|
||||
check_english = new wxCheckBox(this, wxID_ANY, _L("Search in English"));
|
||||
|
||||
wxStdDialogButtonSizer* cancel_btn = this->CreateStdDialogButtonSizer(wxCANCEL);
|
||||
|
||||
check_sizer->Add(check_category, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, border);
|
||||
check_sizer->Add(check_group, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, border);
|
||||
check_sizer->Add(check_english, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, border);
|
||||
check_sizer->Add(check_group, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, border);
|
||||
if (GUI::wxGetApp().is_localized())
|
||||
check_sizer->Add(check_english, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, border);
|
||||
check_sizer->AddStretchSpacer(border);
|
||||
check_sizer->Add(cancel_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
|
@ -459,7 +461,8 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher)
|
|||
search_list->Bind(wxEVT_LEFT_UP, &SearchDialog::OnMouseClick, this);
|
||||
search_list->Bind(wxEVT_KEY_DOWN,&SearchDialog::OnKeyDown, this);
|
||||
|
||||
check_english ->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this);
|
||||
if (GUI::wxGetApp().is_localized())
|
||||
check_english ->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this);
|
||||
check_category->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this);
|
||||
check_group ->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ struct OptionViewParameters
|
|||
bool group {true };
|
||||
bool english {false};
|
||||
|
||||
int hovered_id {-1};
|
||||
int hovered_id {0};
|
||||
};
|
||||
|
||||
class OptionsSearcher
|
||||
|
|
Loading…
Reference in a new issue