OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::AutoMixSelectPopup Class Reference
Inheritance diagram for Slic3r::GUI::AutoMixSelectPopup:
Collaboration diagram for Slic3r::GUI::AutoMixSelectPopup:

Public Member Functions

 AutoMixSelectPopup (wxWindow *parent, TextureAutoMixMode current_mode, int popup_width, int font_point_size, std::function< void(TextureAutoMixMode)> on_select, std::function< void()> on_close)
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Private Member Functions

void OnDismiss () override
wxPanel * create_item_row (wxWindow *parent, TextureAutoMixMode mode, int row_h)

Private Attributes

TextureAutoMixMode m_current_mode
int m_font_point_size = 10
int m_hover_idx = -1
std::function< void(TextureAutoMixMode)> m_on_select
std::function< void()> m_on_close

Detailed Description

Constructor & Destructor Documentation

◆ AutoMixSelectPopup()

Slic3r::GUI::AutoMixSelectPopup::AutoMixSelectPopup ( wxWindow * parent,
TextureAutoMixMode current_mode,
int popup_width,
int font_point_size,
std::function< void(TextureAutoMixMode)> on_select,
std::function< void()> on_close )
inline
912 : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS)
913 , m_current_mode(current_mode)
914 , m_font_point_size(font_point_size)
915 , m_on_select(std::move(on_select))
916 , m_on_close(std::move(on_close))
917 {
918 wxColour pop_bg = StateColor::darkModeColorFor(*wxWHITE);
919 SetBackgroundColour(pop_bg);
920
921 // ORCA add border for popups. it required to add this controls because it covers all background
922 Bind(wxEVT_PAINT, [this](wxPaintEvent& evt) {
923 wxPaintDC dc(this);
924 dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour("#DBDBDB")), FromDIP(1)));
925 dc.SetBrush(*wxTRANSPARENT_BRUSH);
926 dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
927 });
928
929 auto* content = new wxPanel(this, wxID_ANY);
930 content->SetBackgroundColour(pop_bg);
931 content->SetBackgroundStyle(wxBG_STYLE_PAINT);
932
933 auto* sizer = new wxBoxSizer(wxVERTICAL);
934 const int row_h = FromDIP(32);
935 const int pop_w = std::max(FromDIP(216), popup_width);
936 sizer->Add(create_item_row(content, TextureAutoMixMode::CMYW, row_h), 0, wxEXPAND);
937 sizer->Add(create_item_row(content, TextureAutoMixMode::RYBW, row_h), 0, wxEXPAND);
938 content->SetSizer(sizer);
939 content->SetMinSize(wxSize(pop_w, row_h * 2));
940
941 auto* top_sizer = new wxBoxSizer(wxVERTICAL);
942 top_sizer->Add(content, 0, wxEXPAND | wxALL, FromDIP(4));
943 SetSizerAndFit(top_sizer);
944 SetSize(pop_w, top_sizer->GetMinSize().y);
945 }
PopupWindow()
Definition PopupWindow.hpp:10
TextureAutoMixMode m_current_mode
Definition TextureImportDialog.cpp:1025
std::function< void(TextureAutoMixMode)> m_on_select
Definition TextureImportDialog.cpp:1028
std::function< void()> m_on_close
Definition TextureImportDialog.cpp:1029
wxPanel * create_item_row(wxWindow *parent, TextureAutoMixMode mode, int row_h)
Definition TextureImportDialog.cpp:956
int m_font_point_size
Definition TextureImportDialog.cpp:1026
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
@ RYBW
Definition TextureImportDialog.hpp:51
@ CMYW
Definition TextureImportDialog.hpp:50

References PopupWindow::PopupWindow(), Slic3r::GUI::CMYW, create_item_row(), StateColor::darkModeColorFor(), m_current_mode, m_font_point_size, m_on_close, m_on_select, and Slic3r::GUI::RYBW.

Here is the call graph for this function:

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:

◆ create_item_row()

wxPanel * Slic3r::GUI::AutoMixSelectPopup::create_item_row ( wxWindow * parent,
TextureAutoMixMode mode,
int row_h )
inlineprivate
957 {
958 wxColour row_bg = StateColor::darkModeColorFor(*wxWHITE);
959 wxColour checked_bg = StateColor::darkModeColorFor(wxColour("#BFE1DE"));
960 wxColour text_fg = texture_import_text_colour();
961 wxColour accent = StateColor::darkModeColorFor(wxColour("#009688"));
962
963 wxPanel* row = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, row_h),
964 wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE);
965 row->SetBackgroundColour(row_bg);
966 row->SetBackgroundStyle(wxBG_STYLE_PAINT);
967 row->SetCursor(wxCursor(wxCURSOR_HAND));
968
969 const int row_idx = mode == TextureAutoMixMode::CMYW ? 0 : 1;
970 row->Bind(wxEVT_PAINT, [this, row_bg, checked_bg, text_fg, accent, mode, row_idx](wxPaintEvent& e) {
971 auto* p = static_cast<wxPanel*>(e.GetEventObject());
972 wxAutoBufferedPaintDC dc(p);
973 wxSize sz = p->GetClientSize();
974 const bool hovered = (m_hover_idx == row_idx);
975 const bool selected = (m_current_mode == mode);
976
977 // ORCA Match look with combo box dropdown
978 dc.SetBrush(wxBrush(selected ? checked_bg : row_bg));
979 dc.SetPen(hovered ? wxPen(accent) : *wxTRANSPARENT_PEN);
980 dc.DrawRectangle(0, 0, sz.x, sz.y);
981
982 wxFont font = p->GetFont();
983 font.SetPointSize(m_font_point_size);
984 dc.SetFont(font);
985 dc.SetTextForeground(text_fg);
986 wxString label = auto_mix_mode_label(mode);
987 wxSize tsz = dc.GetTextExtent(label);
988 dc.DrawText(label, p->FromDIP(12), (sz.y - tsz.y) / 2);
989
990 /*
991 if (selected) {
992 wxFont check_font = p->GetFont();
993 check_font.SetPointSize(12);
994 check_font.MakeBold();
995 dc.SetFont(check_font);
996 dc.SetTextForeground(accent);
997 wxString check = wxString::FromUTF8("✓");
998 wxSize csz = dc.GetTextExtent(check);
999 dc.DrawText(check, sz.x - p->FromDIP(16) - csz.x, (sz.y - csz.y) / 2);
1000 }
1001 */
1002 });
1003
1004 row->Bind(wxEVT_MOTION, [this, row, row_idx](wxMouseEvent& evt) {
1005 if (m_hover_idx != row_idx) {
1006 m_hover_idx = row_idx;
1007 row->Refresh();
1008 }
1009 evt.Skip();
1010 });
1011 row->Bind(wxEVT_LEAVE_WINDOW, [this, row](wxMouseEvent& evt) {
1012 m_hover_idx = -1;
1013 row->Refresh();
1014 evt.Skip();
1015 });
1016 row->Bind(wxEVT_LEFT_DOWN, [this, mode](wxMouseEvent&) {
1017 if (m_on_select)
1018 m_on_select(mode);
1019 Dismiss();
1020 });
1021
1022 return row;
1023 }
static wxColour texture_import_text_colour()
Definition TextureImportDialog.cpp:92
int m_hover_idx
Definition TextureImportDialog.cpp:1027
wxMouseEvent
Definition CameraPopup.cpp:47
static wxString auto_mix_mode_label(TextureAutoMixMode mode)
Definition TextureImportDialog.cpp:483
@ hovered
Definition GLGizmoEmboss.cpp:223

References Slic3r::GUI::auto_mix_mode_label(), Slic3r::GUI::CMYW, StateColor::darkModeColorFor(), m_current_mode, m_font_point_size, m_hover_idx, m_on_select, texture_import_text_colour(), and Slic3r::GUI::wxMouseEvent.

Referenced by AutoMixSelectPopup().

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

◆ OnDismiss()

void Slic3r::GUI::AutoMixSelectPopup::OnDismiss ( )
inlineoverrideprivate
949 {
950 if (m_on_close)
951 m_on_close();
952 wxPopupTransientWindow::OnDismiss();
953 CallAfter([this]() { Destroy(); });
954 }

References m_on_close.

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

Member Data Documentation

◆ m_current_mode

TextureAutoMixMode Slic3r::GUI::AutoMixSelectPopup::m_current_mode
private

◆ m_font_point_size

int Slic3r::GUI::AutoMixSelectPopup::m_font_point_size = 10
private

◆ m_hover_idx

int Slic3r::GUI::AutoMixSelectPopup::m_hover_idx = -1
private

Referenced by create_item_row().

◆ m_on_close

std::function<void()> Slic3r::GUI::AutoMixSelectPopup::m_on_close
private

Referenced by AutoMixSelectPopup(), and OnDismiss().

◆ m_on_select

std::function<void(TextureAutoMixMode)> Slic3r::GUI::AutoMixSelectPopup::m_on_select
private

The documentation for this class was generated from the following file: