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

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

Inheritance diagram for Slic3r::Search::SearchObjectDialog:
Collaboration diagram for Slic3r::Search::SearchObjectDialog:

Public Member Functions

 SearchObjectDialog (GUI::ObjectList *object_list, wxWindow *parent, TextInput *input)
 ~SearchObjectDialog ()
void Popup (wxWindow *focus=nullptr) override
void OnDismiss () override
void Dismiss () override
void Die ()
void OnInputText (wxCommandEvent &event)
void OnLeftUpInTextCtrl (wxEvent &event)
void update_list ()
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Public Attributes

GUI::ObjectList * m_object_list { nullptr }
int em
const int POPUP_WIDTH = 41
const int POPUP_HEIGHT = 45
TextInput * search_line {nullptr}
wxTextCtrl * search_line2 {nullptr}
ScrolledWindow * m_scrolledWindow { nullptr }
wxColour m_bg_color
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 }

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Private Attributes

bool m_is_dismissing { false }

Detailed Description

Constructor & Destructor Documentation

◆ SearchObjectDialog()

Slic3r::Search::SearchObjectDialog::SearchObjectDialog ( GUI::ObjectList * object_list,
wxWindow * parent,
TextInput * input )
702 : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_object_list(object_list)
703{
704 search_line = input;
705
706 Freeze();
707 SetBackgroundColour(wxColour(238, 238, 238));
708
709 em = GUI::wxGetApp().em_unit();
710
711 m_bg_color = wxColour(255, 255, 255);
712 m_thumb_color = wxColour(196, 196, 196);
713
714 SetFont(GUI::wxGetApp().normal_font());
715 SetSizeHints(wxDefaultSize, wxDefaultSize);
716
717 m_sizer_border = new wxBoxSizer(wxVERTICAL);
718 m_sizer_main = new wxBoxSizer(wxVERTICAL);
719 m_sizer_body = new wxBoxSizer(wxVERTICAL);
720
721 // border
722 m_border_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em, POPUP_HEIGHT * em), wxTAB_TRAVERSAL);
723 m_border_panel->SetBackgroundColour(m_bg_color);
724
725 // client
726 m_client_panel = new wxPanel(m_border_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em, POPUP_HEIGHT * em), wxTAB_TRAVERSAL);
727 m_client_panel->SetBackgroundColour(m_bg_color);
728
729 // search line
730#ifdef __WXGTK__
731 search_line = new TextInput(m_client_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
732 search_line->SetBackgroundColour(wxColour(238, 238, 238));
733 search_line->SetForegroundColour(wxColour(43, 52, 54));
734 search_line->SetFont(GUI::wxGetApp().bold_font());
735#endif
736
737 search_line->Bind(wxEVT_TEXT, &SearchObjectDialog::OnInputText, this);
738 search_line->Bind(wxEVT_LEFT_UP, &SearchObjectDialog::OnLeftUpInTextCtrl, this);
739 search_line2 = search_line->GetTextCtrl();
740
741
742 // scroll window
743 m_scrolledWindow = new ScrolledWindow(m_client_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em - (em + em / 2), POPUP_HEIGHT * em), wxVSCROLL, 6, 6);
744 m_scrolledWindow->SetMarginColor(m_bg_color);
745 m_scrolledWindow->SetScrollbarColor(m_thumb_color);
746 m_scrolledWindow->SetBackgroundColour(m_bg_color);
747 auto m_listsizer = new wxBoxSizer(wxVERTICAL);
748 auto m_listPanel = new wxWindow(m_scrolledWindow->GetPanel(), -1);
749 m_listPanel->SetBackgroundColour(m_bg_color);
750 m_listPanel->SetSize(wxSize(m_scrolledWindow->GetSize().GetWidth(), -1));
751
752 m_listPanel->SetSizer(m_listsizer);
753 m_listPanel->Fit();
754 m_scrolledWindow->SetScrollbars(1, 1, 0, m_listPanel->GetSize().GetHeight());
755
756#ifdef __WXGTK__
757 m_sizer_body->Add(search_line, 0, wxEXPAND | wxALL, em / 2);
758 search_line = input;
759#endif
760 m_sizer_body->Add(m_scrolledWindow, 0, wxEXPAND | wxALL, em);
761
762 m_client_panel->SetSizer(m_sizer_body);
763 m_client_panel->Layout();
765 m_sizer_main->Add(m_client_panel, 1, wxEXPAND, 0);
766
767 m_border_panel->SetSizer(m_sizer_main);
768 m_border_panel->Layout();
769 m_sizer_border->Add(m_border_panel, 1, wxEXPAND | wxALL, 1);
770
771 SetSizer(m_sizer_border);
772 Layout();
773 m_sizer_border->Fit(this);
774 Thaw();
775
776 GUI::wxGetApp().UpdateDarkUIWin(this);
777}
PopupWindow()
Definition PopupWindow.hpp:10
ScrolledWindow * m_scrolledWindow
Definition Search.hpp:257
wxBoxSizer * m_sizer_body
Definition Search.hpp:262
wxBoxSizer * m_sizer_border
Definition Search.hpp:264
TextInput * search_line
Definition Search.hpp:254
wxColour m_bg_color
Definition Search.hpp:259
GUI::ObjectList * m_object_list
Definition Search.hpp:248
wxColour m_thumb_color
Definition Search.hpp:260
void OnInputText(wxCommandEvent &event)
Definition Search.cpp:844
wxWindow * m_border_panel
Definition Search.hpp:266
wxBoxSizer * m_sizer_main
Definition Search.hpp:263
const int POPUP_HEIGHT
Definition Search.hpp:252
const int POPUP_WIDTH
Definition Search.hpp:251
void OnLeftUpInTextCtrl(wxEvent &event)
Definition Search.cpp:857
wxWindow * m_client_panel
Definition Search.hpp:267
int em
Definition Search.hpp:250
wxTextCtrl * search_line2
Definition Search.hpp:255

References PopupWindow::PopupWindow(), em, m_bg_color, m_border_panel, m_client_panel, m_object_list, m_scrolledWindow, m_sizer_body, m_sizer_border, m_sizer_main, m_thumb_color, OnInputText(), OnLeftUpInTextCtrl(), POPUP_HEIGHT, POPUP_WIDTH, search_line, and search_line2.

Here is the call graph for this function:

◆ ~SearchObjectDialog()

Slic3r::Search::SearchObjectDialog::~SearchObjectDialog ( )
779{}

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::SearchObjectDialog::Die ( )
835{
836 m_is_dismissing = true;
837 m_object_list->SetFocus();
838 PopupWindow::Dismiss();
839 wxCommandEvent event(wxCUSTOMEVT_EXIT_SEARCH);
840 wxPostEvent(m_object_list, event);
841 m_is_dismissing = false;
842}
bool m_is_dismissing
Definition Search.hpp:270

References m_is_dismissing, and m_object_list.

Referenced by Dismiss().

Here is the caller graph for this function:

◆ Dismiss()

void Slic3r::Search::SearchObjectDialog::Dismiss ( )
override
811{
812 auto focus_window = wxWindow::FindFocus();
813 if (!focus_window) {
814 Die();
815 return;
816 }
817#if defined(__WXGTK__)
818 // On Wayland, wxGetMousePosition() returns unreliable global coords.
819 // Rely on focus tracking instead: if focus moved to a window outside
820 // this dialog and its related controls, dismiss.
821 if (Slic3r::GUI::is_running_on_wayland()) {
822 if (focus_left_popup(this, focus_window, search_line)) {
823 Die();
824 }
825 return;
826 }
827#endif
828 auto pos = wxGetMousePosition();
829 if (!search_line->GetScreenRect().Contains(pos) && !this->GetScreenRect().Contains(pos)) {
830 Die();
831 }
832}
void Die()
Definition Search.cpp:834
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(), and search_line.

Here is the call graph for this function:

◆ OnDismiss()

void Slic3r::Search::SearchObjectDialog::OnDismiss ( )
override
808{}

◆ OnInputText()

void Slic3r::Search::SearchObjectDialog::OnInputText ( wxCommandEvent & event)
845{
846 search_line2->SetInsertionPointEnd();
847 wxString input_string = search_line2->GetValue();
848 if (input_string == wxEmptyString)
849 input_string.Clear();
850
851 m_object_list->assembly_plate_object_name();
852 m_object_list->GetModel()->search_object(input_string);
853
854 update_list();
855}
void update_list()
Definition Search.cpp:864

References m_object_list, search_line2, and update_list().

Referenced by SearchObjectDialog().

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

◆ OnLeftUpInTextCtrl()

void Slic3r::Search::SearchObjectDialog::OnLeftUpInTextCtrl ( wxEvent & event)
858{
859 if (search_line2->GetValue() == wxEmptyString)
860 search_line2->SetValue("");
861 event.Skip();
862}

References search_line2.

Referenced by SearchObjectDialog().

Here is the caller graph for this function:

◆ Popup()

void Slic3r::Search::SearchObjectDialog::Popup ( wxWindow * focus = nullptr)
override
782{
783 if (m_is_dismissing || this->IsShown()) {
784 return;
785 }
786 search_line2->SetValue(wxString(""));
787#ifdef __WXOSX__
788 // On macOS we need to remove the focus from the text input before popping up the
789 // dropdown list, otherwise the text input won't be usable
790 m_object_list->SetFocus();
791#endif
792 PopupWindow::Popup(focus);
793 search_line2->SetFocus();
794
795 m_object_list->assembly_plate_object_name();
796 m_object_list->GetModel()->search_object(wxEmptyString);
797 update_list();
798}

References m_is_dismissing, m_object_list, 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::SearchObjectDialog::update_list ( )
865{
866#ifndef __WXGTK__
867 Freeze();
868#endif
869 m_scrolledWindow->Destroy();
870
871 m_scrolledWindow = new ScrolledWindow(m_client_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em - (em + em / 2), POPUP_HEIGHT * em - em), wxVSCROLL, 6, 6);
875
876 auto m_listsizer = new wxBoxSizer(wxVERTICAL);
877 auto m_listPanel = new wxWindow(m_scrolledWindow->GetPanel(), -1);
878 m_listPanel->SetBackgroundColour(StateColor::darkModeColorFor(m_bg_color));
879 m_listPanel->SetSize(wxSize(m_scrolledWindow->GetSize().GetWidth(), -1));
880
881 const std::vector<std::tuple<GUI::ObjectDataViewModelNode*, wxString, wxString>>& found = m_object_list->GetModel()->get_found_list();
882 auto index = 0;
883 for (const auto& [model_node, name, tip] : found) {
884 auto tmp = new SearchItem(m_listPanel, name, index, nullptr, this, tip);
885 tmp->m_item = model_node;
886 m_listsizer->Add(tmp, 0, wxEXPAND, 0);
887 index++;
888 }
889
890 m_listPanel->SetSizer(m_listsizer);
891 m_listPanel->Fit();
892 m_scrolledWindow->SetScrollbars(1, 1, 0, m_listPanel->GetSize().GetHeight());
893
894 m_sizer_body->Add(m_scrolledWindow, 0, wxEXPAND | wxALL, em);
896 m_sizer_body->Layout();
897#ifndef __WXGTK__
898 Thaw();
899#endif
900}
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor(), em, m_bg_color, m_client_panel, m_object_list, m_scrolledWindow, m_sizer_body, m_thumb_color, POPUP_HEIGHT, and POPUP_WIDTH.

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::SearchObjectDialog::em

Referenced by SearchObjectDialog(), and update_list().

◆ m_bg_color

wxColour Slic3r::Search::SearchObjectDialog::m_bg_color

Referenced by SearchObjectDialog(), and update_list().

◆ m_border_panel

wxWindow* Slic3r::Search::SearchObjectDialog::m_border_panel { nullptr }
266{ nullptr };

Referenced by SearchObjectDialog().

◆ m_client_panel

wxWindow* Slic3r::Search::SearchObjectDialog::m_client_panel { nullptr }
267{ nullptr };

Referenced by SearchObjectDialog(), and update_list().

◆ m_is_dismissing

bool Slic3r::Search::SearchObjectDialog::m_is_dismissing { false }
private
270{ false };

Referenced by Die(), and Popup().

◆ m_object_list

GUI::ObjectList* Slic3r::Search::SearchObjectDialog::m_object_list { nullptr }
248{ nullptr };

Referenced by SearchObjectDialog(), Die(), OnInputText(), Popup(), and update_list().

◆ m_scrolledWindow

ScrolledWindow* Slic3r::Search::SearchObjectDialog::m_scrolledWindow { nullptr }
257{ nullptr };

Referenced by SearchObjectDialog(), and update_list().

◆ m_sizer_body

wxBoxSizer* Slic3r::Search::SearchObjectDialog::m_sizer_body { nullptr }
262{ nullptr };

Referenced by SearchObjectDialog(), and update_list().

◆ m_sizer_border

wxBoxSizer* Slic3r::Search::SearchObjectDialog::m_sizer_border { nullptr }
264{ nullptr };

Referenced by SearchObjectDialog().

◆ m_sizer_main

wxBoxSizer* Slic3r::Search::SearchObjectDialog::m_sizer_main { nullptr }
263{ nullptr };

Referenced by SearchObjectDialog().

◆ m_thumb_color

wxColour Slic3r::Search::SearchObjectDialog::m_thumb_color

Referenced by SearchObjectDialog(), and update_list().

◆ POPUP_HEIGHT

const int Slic3r::Search::SearchObjectDialog::POPUP_HEIGHT = 45

Referenced by SearchObjectDialog(), and update_list().

◆ POPUP_WIDTH

const int Slic3r::Search::SearchObjectDialog::POPUP_WIDTH = 41

Referenced by SearchObjectDialog(), and update_list().

◆ search_line

TextInput* Slic3r::Search::SearchObjectDialog::search_line {nullptr}
254{nullptr};

Referenced by SearchObjectDialog(), and Dismiss().

◆ search_line2

wxTextCtrl* Slic3r::Search::SearchObjectDialog::search_line2 {nullptr}
255{nullptr};

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


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