OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Search::SearchDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Search.hpp>

Inheritance diagram for Slic3r::Search::SearchDialog:
Collaboration diagram for Slic3r::Search::SearchDialog:

Public Member Functions

void OnInputText (wxCommandEvent &event)
void OnLeftUpInTextCtrl (wxEvent &event)
void update_list ()
 SearchDialog (OptionsSearcher *searcher, Preset::Type type, wxWindow *parent, TextInput *input, wxWindow *search_btn)
 ~SearchDialog ()
void Popup (wxWindow *focus=nullptr) override
void OnDismiss () override
void Dismiss () override
void Die ()
void msw_rescale ()
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Public Attributes

wxColour m_bg_colour
wxColour m_thumb_color
wxBoxSizer * m_sizer_body {nullptr}
wxBoxSizer * m_sizer_main {nullptr}
wxBoxSizer * m_sizer_border {nullptr}
wxWindow * m_border_panel {nullptr}
wxWindow * m_client_panel {nullptr}
wxWindow * m_event_tag {nullptr}
wxWindow * m_search_item_tag {nullptr}
int em
const int POPUP_WIDTH = 38
const int POPUP_HEIGHT = 40
TextInput * search_line {nullptr}
wxTextCtrl * search_line2 {nullptr}
Preset::Type search_type = Preset::TYPE_INVALID
ScrolledWindow * m_scrolledWindow {nullptr}
OptionsSearcher * searcher {nullptr}

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Detailed Description

Constructor & Destructor Documentation

◆ SearchDialog()

Slic3r::Search::SearchDialog::SearchDialog ( OptionsSearcher * searcher,
Preset::Type type,
wxWindow * parent,
TextInput * input,
wxWindow * search_btn )
443 : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), searcher(searcher)
444{
445 m_event_tag = parent;
446 search_line = input;
447 search_type = type;
448
449 m_search_item_tag = search_btn;
450
451 // set border color
452 Freeze();
453 SetBackgroundColour(wxColour(238, 238, 238));
454
455 em = GUI::wxGetApp().em_unit();
456
457 m_bg_colour = wxColour(255, 255, 255);
458 m_thumb_color = wxColour(196, 196, 196);
459
460 SetFont(GUI::wxGetApp().normal_font());
461 SetSizeHints(wxDefaultSize, wxDefaultSize);
462
463 m_sizer_border = new wxBoxSizer(wxVERTICAL);
464 m_sizer_main = new wxBoxSizer(wxVERTICAL);
465 m_sizer_body = new wxBoxSizer(wxVERTICAL);
466
467 // border
468 m_border_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em, POPUP_HEIGHT * em), wxTAB_TRAVERSAL);
469 m_border_panel->SetBackgroundColour(m_bg_colour);
470
471 // client
472 m_client_panel = new wxPanel(m_border_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em, POPUP_HEIGHT * em), wxTAB_TRAVERSAL);
473 m_client_panel->SetBackgroundColour(m_bg_colour);
474
475 // search line
476 //search_line = new wxTextCtrl(m_client_panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
477#ifdef __WXGTK__
478 search_line = new TextInput(m_client_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
479 search_line->SetBackgroundColour(wxColour(238, 238, 238));
480 search_line->SetForegroundColour(wxColour(43, 52, 54));
481 search_line->SetFont(GUI::wxGetApp().bold_font());
482#endif
483
484 search_line->Bind(wxEVT_TEXT, &SearchDialog::OnInputText, this);
485 search_line->Bind(wxEVT_LEFT_UP, &SearchDialog::OnLeftUpInTextCtrl, this);
486 search_line2 = search_line->GetTextCtrl();
487
488 // scroll window
489 m_scrolledWindow = new ScrolledWindow(m_client_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em - (em + em /2), POPUP_HEIGHT * em), wxVSCROLL, 6, 6);
490 m_scrolledWindow->SetMarginColor(m_bg_colour);
491 m_scrolledWindow->SetScrollbarColor(m_thumb_color);
492 m_scrolledWindow->SetBackgroundColour(m_bg_colour);
493
494 auto m_listsizer = new wxBoxSizer(wxVERTICAL);
495 auto m_listPanel = new wxWindow(m_scrolledWindow->GetPanel(), -1);
496 m_listPanel->SetBackgroundColour(m_bg_colour);
497 m_listPanel->SetSize(wxSize(m_scrolledWindow->GetSize().GetWidth(), -1));
498
499 m_listPanel->SetSizer(m_listsizer);
500 m_listPanel->Fit();
501 m_scrolledWindow->SetScrollbars(1, 1, 0, m_listPanel->GetSize().GetHeight());
502
503#ifdef __WXGTK__
504 m_sizer_body->Add(search_line, 0, wxEXPAND | wxALL, em / 2);
505 search_line = input;
506#endif
507 m_sizer_body->Add(m_scrolledWindow, 0, wxEXPAND | wxALL, em);
508
509 m_client_panel->SetSizer(m_sizer_body);
510 m_client_panel->Layout();
512 m_sizer_main->Add(m_client_panel, 1, wxEXPAND, 0);
513
514 m_border_panel->SetSizer(m_sizer_main);
515 m_border_panel->Layout();
516 m_sizer_border->Add(m_border_panel, 1, wxEXPAND | wxALL, 1);
517
518 SetSizer(m_sizer_border);
519 Layout();
520 m_sizer_border->Fit(this);
521 Thaw();
522
523 // check_category->Bind(wxEVT_CHECKBOX, &SearchDialog::OnCheck, this);
524 // Bind(wxEVT_MOTION, &SearchDialog::OnMotion, this);
525 // Bind(wxEVT_LEFT_DOWN, &SearchDialog::OnLeftDown, this);
526
527 // SetSizer(topSizer);
528 // topSizer->SetSizeHints(this);
529 GUI::wxGetApp().UpdateDarkUIWin(this);
530}
PopupWindow()
Definition PopupWindow.hpp:10
OptionsSearcher * searcher
Definition Search.hpp:177
Preset::Type search_type
Definition Search.hpp:173
wxBoxSizer * m_sizer_main
Definition Search.hpp:158
const int POPUP_WIDTH
Definition Search.hpp:168
int em
Definition Search.hpp:167
TextInput * search_line
Definition Search.hpp:171
ScrolledWindow * m_scrolledWindow
Definition Search.hpp:175
void OnInputText(wxCommandEvent &event)
Definition Search.cpp:596
wxBoxSizer * m_sizer_body
Definition Search.hpp:157
wxBoxSizer * m_sizer_border
Definition Search.hpp:159
wxWindow * m_search_item_tag
Definition Search.hpp:165
wxColour m_bg_colour
Definition Search.hpp:154
const int POPUP_HEIGHT
Definition Search.hpp:169
wxTextCtrl * search_line2
Definition Search.hpp:172
wxColour m_thumb_color
Definition Search.hpp:155
void OnLeftUpInTextCtrl(wxEvent &event)
Definition Search.cpp:605
wxWindow * m_client_panel
Definition Search.hpp:162
wxWindow * m_event_tag
Definition Search.hpp:164
wxWindow * m_border_panel
Definition Search.hpp:161

References PopupWindow::PopupWindow(), em, m_bg_colour, m_border_panel, m_client_panel, m_event_tag, m_scrolledWindow, m_search_item_tag, m_sizer_body, m_sizer_border, m_sizer_main, m_thumb_color, OnInputText(), OnLeftUpInTextCtrl(), POPUP_HEIGHT, POPUP_WIDTH, search_line, search_line2, search_type, and searcher.

Here is the call graph for this function:

◆ ~SearchDialog()

Slic3r::Search::SearchDialog::~SearchDialog ( )
532{}

Member Function Documentation

◆ Create()

bool PopupWindow::Create ( wxWindow * parent,
int flags = wxBORDER_NONE )
inherited
22{
23 if (!wxPopupTransientWindow::Create(parent, style))
24 return false;
25#ifdef __WXGTK__
26 GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
27#endif
28#ifdef __WXOSX__
29 if (style & wxPU_CONTAINS_CONTROLS)
30 for (auto evt : {wxEVT_LEFT_DOWN, wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK, wxEVT_MOTION, wxEVT_MOUSEWHEEL})
31 Bind(evt, &PopupWindow::OnMouseEvent2, this);
32#endif
33 return true;
34}
static wxWindow * GetTopParent(wxWindow *pWindow)
Definition PopupWindow.cpp:10
#define style
Definition WipeTowerDialog.cpp:101

References GetTopParent(), and style.

Referenced by PopupWindow(), and DropDown::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Die()

void Slic3r::Search::SearchDialog::Die ( )
590{
591 PopupWindow::Dismiss();
592 wxCommandEvent event(wxCUSTOMEVT_EXIT_SEARCH);
593 wxPostEvent(search_line, event);
594}

References search_line.

Referenced by Dismiss().

Here is the caller graph for this function:

◆ Dismiss()

void Slic3r::Search::SearchDialog::Dismiss ( )
override
566{
567 auto focus_window = wxWindow::FindFocus();
568 if (!focus_window) {
569 Die();
570 return;
571 }
572#if defined(__WXGTK__)
573 // On Wayland, wxGetMousePosition() returns unreliable global coords.
574 // Rely on focus tracking instead: if focus moved to a window outside
575 // this dialog and its related controls, dismiss.
576 if (Slic3r::GUI::is_running_on_wayland()) {
577 if (focus_left_popup(this, focus_window, m_event_tag, m_search_item_tag, search_line)) {
578 Die();
579 }
580 return;
581 }
582#endif
583 auto pos = wxGetMousePosition();
584 if (!m_event_tag->GetScreenRect().Contains(pos) && !this->GetScreenRect().Contains(pos) && !m_search_item_tag->GetScreenRect().Contains(pos)) {
585 Die();
586 }
587}
void Die()
Definition Search.cpp:589
bool focus_left_popup(wxWindow *popup, wxWindow *focus_window, wxWindow *related_window_1=nullptr, wxWindow *related_window_2=nullptr, wxWindow *related_window_3=nullptr)
Definition Search.cpp:68
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References Die(), m_event_tag, m_search_item_tag, and search_line.

Here is the call graph for this function:

◆ msw_rescale()

void Slic3r::Search::SearchDialog::msw_rescale ( )
650{
651}

◆ OnDismiss()

void Slic3r::Search::SearchDialog::OnDismiss ( )
override
563{ }

◆ OnInputText()

void Slic3r::Search::SearchDialog::OnInputText ( wxCommandEvent & event)
597{
598 search_line2->SetInsertionPointEnd();
599 wxString input_string = search_line2->GetValue();
600 if (input_string == wxEmptyString) input_string.Clear();
601 searcher->search(into_u8(input_string), true, search_type);
602 update_list();
603}
void update_list()
Definition Search.cpp:611
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References Slic3r::into_u8(), search_line2, search_type, searcher, and update_list().

Referenced by SearchDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnLeftUpInTextCtrl()

void Slic3r::Search::SearchDialog::OnLeftUpInTextCtrl ( wxEvent & event)
606{
607 if (search_line2->GetValue() == wxEmptyString) search_line2->SetValue("");
608 event.Skip();
609}

References search_line2.

Referenced by SearchDialog().

Here is the caller graph for this function:

◆ Popup()

void Slic3r::Search::SearchDialog::Popup ( wxWindow * focus = nullptr)
override
535{
536 /* const std::string& line = searcher->search_string();
537 search_line->SetValue(line.empty() ? default_string : from_u8(line));
538
539 update_list();
540
541 const OptionViewParameters& params = searcher->view_params;
542 check_category->SetValue(params.category);*/
543
544 //const std::string &line = searcher->search_string();
545 //search_line->SetValue(line.empty() ? default_string : from_u8(line));
546 search_line2->SetValue(wxString(""));
547 //const std::string &line = searcher->search_string();
548 //searcher->search(into_u8(line), true);
549 PopupWindow::Popup(focus);
550 search_line2->SetFocus();
551 update_list();
552}

References search_line2, and update_list().

Here is the call graph for this function:

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

◆ update_list()

void Slic3r::Search::SearchDialog::update_list ( )
612{
613#ifndef __WXGTK__
614 Freeze();
615#endif
616 m_scrolledWindow->Destroy();
617
618 m_scrolledWindow = new ScrolledWindow(m_client_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em - (em + em / 2), POPUP_HEIGHT * em - em), wxVSCROLL, 6, 6);
622
623 auto m_listsizer = new wxBoxSizer(wxVERTICAL);
624 auto m_listPanel = new wxWindow(m_scrolledWindow->GetPanel(), -1);
625 m_listPanel->SetBackgroundColour(StateColor::darkModeColorFor(m_bg_colour));
626 m_listPanel->SetSize(wxSize(m_scrolledWindow->GetSize().GetWidth(), -1));
627
628 const std::vector<FoundOption> &filters = searcher->found_options();
629 auto index = 0;
630 for (const FoundOption &item : filters) {
631 wxString str = from_u8(item.label).Remove(0, 1);
632 auto tmp = new SearchItem(m_listPanel, str, index, this);
633 m_listsizer->Add(tmp, 0, wxEXPAND, 0);
634 index++;
635 }
636
637 m_listPanel->SetSizer(m_listsizer);
638 m_listPanel->Fit();
639 m_scrolledWindow->SetScrollbars(1, 1, 0, m_listPanel->GetSize().GetHeight());
640
641 m_sizer_body->Add(m_scrolledWindow, 0, wxEXPAND | wxALL, em);
643 m_sizer_body->Layout();
644#ifndef __WXGTK__
645 Thaw();
646#endif
647}
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References StateColor::darkModeColorFor(), em, Slic3r::from_u8(), m_bg_colour, m_client_panel, m_scrolledWindow, m_sizer_body, m_thumb_color, POPUP_HEIGHT, POPUP_WIDTH, and searcher.

Referenced by OnInputText(), and Popup().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ em

int Slic3r::Search::SearchDialog::em

Referenced by SearchDialog(), and update_list().

◆ m_bg_colour

wxColour Slic3r::Search::SearchDialog::m_bg_colour

Referenced by SearchDialog(), and update_list().

◆ m_border_panel

wxWindow* Slic3r::Search::SearchDialog::m_border_panel {nullptr}
161{nullptr};

Referenced by SearchDialog().

◆ m_client_panel

wxWindow* Slic3r::Search::SearchDialog::m_client_panel {nullptr}
162{nullptr};

Referenced by SearchDialog(), and update_list().

◆ m_event_tag

wxWindow* Slic3r::Search::SearchDialog::m_event_tag {nullptr}
164{nullptr};

Referenced by SearchDialog(), and Dismiss().

◆ m_scrolledWindow

ScrolledWindow* Slic3r::Search::SearchDialog::m_scrolledWindow {nullptr}
175{nullptr};

Referenced by SearchDialog(), and update_list().

◆ m_search_item_tag

wxWindow* Slic3r::Search::SearchDialog::m_search_item_tag {nullptr}
165{nullptr};

Referenced by SearchDialog(), and Dismiss().

◆ m_sizer_body

wxBoxSizer* Slic3r::Search::SearchDialog::m_sizer_body {nullptr}
157{nullptr};

Referenced by SearchDialog(), and update_list().

◆ m_sizer_border

wxBoxSizer* Slic3r::Search::SearchDialog::m_sizer_border {nullptr}
159{nullptr};

Referenced by SearchDialog().

◆ m_sizer_main

wxBoxSizer* Slic3r::Search::SearchDialog::m_sizer_main {nullptr}
158{nullptr};

Referenced by SearchDialog().

◆ m_thumb_color

wxColour Slic3r::Search::SearchDialog::m_thumb_color

Referenced by SearchDialog(), and update_list().

◆ POPUP_HEIGHT

const int Slic3r::Search::SearchDialog::POPUP_HEIGHT = 40

Referenced by SearchDialog(), and update_list().

◆ POPUP_WIDTH

const int Slic3r::Search::SearchDialog::POPUP_WIDTH = 38

Referenced by SearchDialog(), and update_list().

◆ search_line

TextInput* Slic3r::Search::SearchDialog::search_line {nullptr}
171{nullptr};

Referenced by SearchDialog(), Die(), and Dismiss().

◆ search_line2

wxTextCtrl* Slic3r::Search::SearchDialog::search_line2 {nullptr}
172{nullptr};

Referenced by SearchDialog(), OnInputText(), OnLeftUpInTextCtrl(), and Popup().

◆ search_type

Preset::Type Slic3r::Search::SearchDialog::search_type = Preset::TYPE_INVALID

Referenced by SearchDialog(), and OnInputText().

◆ searcher

OptionsSearcher* Slic3r::Search::SearchDialog::searcher {nullptr}
177{nullptr};

Referenced by SearchDialog(), OnInputText(), and update_list().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Search.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Search.cpp