OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
MultiSwitchButton Class Reference

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

Inheritance diagram for MultiSwitchButton:
Collaboration diagram for MultiSwitchButton:

Public Member Functions

 MultiSwitchButton (wxWindow *parent=nullptr, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
 ~MultiSwitchButton ()
int AppendOption (const wxString &option, void *clientData=nullptr)
void SetOptions (const std::vector< wxString > &options)
void DeleteAllOptions ()
unsigned int GetCount () const
int GetSelection () const
void SetSelection (int index)
wxString GetSelectedText () const
Button * GetButton (unsigned int index) const
wxString GetOptionText (unsigned int index) const
void SetOptionText (unsigned int index, const wxString &text)
void * GetOptionData (unsigned int index) const
void SetOptionData (unsigned int index, void *clientData)
void SetBackgroundColor (const StateColor &color)
void SetTextColor (const StateColor &color)
void SetButtonTextColor (int index, const StateColor &color)
void SetModified (int index, bool modified)
void SetButtonCornerRadius (double radius)
void SetButtonPadding (const wxSize &padding)
void SetFitToOptions (bool fit=true)
void Rescale ()
bool Create (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
void SetCornerRadius (double radius)
void SetBorderWidth (int width)
void SetTopMargin (int margin)
void SetBorderColor (StateColor const &color)
void SetBorderColorNormal (wxColor const &color)
void SetBorderStyle (wxPenStyle style)
void SetBackgroundColorNormal (wxColor const &color)
void SetBackgroundColor2 (StateColor const &color)
void ShowBadge (bool show)

Static Public Member Functions

static wxColor GetParentBackgroundColor (wxWindow *parent)

Protected Member Functions

void button_clicked (wxCommandEvent &event)
void update_button_styles ()
bool send_selection_event ()
void eraseEvent (wxEraseEvent &evt)
void sizeEvent (wxSizeEvent &evt)
void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)
virtual void doRender (wxDC &dc)

Protected Attributes

double radius
int border_width = 1
int top_margin = 0
wxPenStyle border_style = wxPENSTYLE_SOLID
StateHandler state_handler
StateColor border_color
StateColor background_color
StateColor background_color2
ScalableBitmap badge

Private Member Functions

int options_height () const
void update_scroll_range ()
int scrollbar_height (int options_width) const
void scroll_option_into_view (Button *btn)
void on_size (wxSizeEvent &evt)

Private Attributes

std::vector< Button * > btns
std::vector< bool > btns_modified
wxScrolledWindow * m_scroll = nullptr
wxBoxSizer * sizer = nullptr
bool m_fit_to_options = false
int sel = -1
StateColor m_bg_color
StateColor m_text_color
StateColor m_br_color_modified
StateColor m_fg_color_modified
double m_button_radius
wxSize m_button_padding

Detailed Description

Constructor & Destructor Documentation

◆ MultiSwitchButton()

MultiSwitchButton::MultiSwitchButton ( wxWindow * parent = nullptr,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
651 : StaticBox(parent, id, pos, size, style)
652 , m_bg_color(StateColor(
653 std::make_pair(0xD9D9D9, (int) StateColor::NotChecked),
654 std::make_pair(0x009688, (int) StateColor::Normal)))
655 , m_text_color(StateColor(
656 std::make_pair(0x6B6B6B, (int) StateColor::NotChecked),
657 std::make_pair(0xFFFFFE, (int) StateColor::Normal)))
658 , m_br_color_modified(StateColor(
659 std::make_pair(0xD9D9D9, (int) StateColor::NotChecked),
660 std::make_pair(0xF1754F, (int) StateColor::Normal)))
661 , m_fg_color_modified(StateColor(
662 std::make_pair(0xF1754E, (int) StateColor::NotChecked),
663 std::make_pair(0xFFFFFE, (int) StateColor::Normal)))
664 , m_button_radius(10.0)
665 , m_button_padding(11, 3)
666{
669
670 // Orca: a switch can hold more buttons than the layout has room for (a toolchanger lists one per
671 // tool), so they live in a scrolled area: the caller caps the switch at its natural width and
672 // this scrolls horizontally instead of clipping the last buttons.
673 m_scroll = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxBORDER_NONE);
674 //m_scroll->SetBackgroundColour(wxColour("#D9D9D9"));
675 m_scroll->SetBackgroundColour(GetBackgroundColour());
676 // The buttons are a single row, so only the horizontal bar may ever appear: a vertical one would
677 // eat into the row's height.
678 m_scroll->ShowScrollbars(wxSHOW_SB_DEFAULT, wxSHOW_SB_NEVER);
679 m_scroll->EnableScrolling(true, false);
680 m_scroll->SetScrollRate(FromDIP(10), 0);
681
682 sizer = new wxBoxSizer(wxHORIZONTAL);
683 m_scroll->SetSizer(sizer);
684
685 auto *hsizer = new wxBoxSizer(wxVERTICAL);
686 hsizer->Add(m_scroll, 1, wxEXPAND);
687 SetSizer(hsizer);
688 SetMinSize(wxSize(-1, options_height()));
689
690 Bind(wxEVT_SIZE, &MultiSwitchButton::on_size, this);
691 Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MultiSwitchButton::button_clicked, this);
692 // The tags name a tool and its volume type only, so they stay compact.
693 SetFont(Label::Body_10);
694}
#define style
Definition WipeTowerDialog.cpp:101
static wxFont Body_10
Definition Label.hpp:56
int options_height() const
Definition SwitchButton.cpp:701
StateColor m_text_color
Definition SwitchButton.hpp:209
wxScrolledWindow * m_scroll
Definition SwitchButton.hpp:203
wxSize m_button_padding
Definition SwitchButton.hpp:213
StateColor m_br_color_modified
Definition SwitchButton.hpp:210
void on_size(wxSizeEvent &evt)
Definition SwitchButton.cpp:735
void button_clicked(wxCommandEvent &event)
Definition SwitchButton.cpp:934
double m_button_radius
Definition SwitchButton.hpp:212
wxBoxSizer * sizer
Definition SwitchButton.hpp:204
StateColor m_bg_color
Definition SwitchButton.hpp:208
StateColor m_fg_color_modified
Definition SwitchButton.hpp:211
@ NotChecked
Definition StateColor.hpp:23
@ Normal
Definition StateColor.hpp:16
void SetCornerRadius(double radius)
Definition StaticBox.cpp:62
void SetBorderWidth(int width)
Definition StaticBox.cpp:81
StaticBox()
Definition StaticBox.cpp:33

References StaticBox::StaticBox(), Label::Body_10, button_clicked(), m_bg_color, m_br_color_modified, m_button_padding, m_button_radius, m_fg_color_modified, m_scroll, m_text_color, on_size(), options_height(), StaticBox::SetBorderWidth(), StaticBox::SetCornerRadius(), sizer, and style.

Here is the call graph for this function:

◆ ~MultiSwitchButton()

MultiSwitchButton::~MultiSwitchButton ( )
697{
699}
void DeleteAllOptions()
Definition SwitchButton.cpp:809

References DeleteAllOptions().

Here is the call graph for this function:

Member Function Documentation

◆ AppendOption()

int MultiSwitchButton::AppendOption ( const wxString & option,
void * clientData = nullptr )
780{
781 Button *btn = new Button();
782 btn->Create(m_scroll, option);
783 btn->SetFont(GetFont());
788 btn->SetPaddingSize(FromDIP(m_button_padding));
789 btn->SetClientData(clientData);
790
791 btns.push_back(btn);
792 btns_modified.push_back(false);
793 sizer->Add(btn, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
794
795 return int(btns.size()) - 1;
796}
void SetTextColor(StateColor const &color)
Definition Button.cpp:137
bool Create(wxWindow *parent, wxString text, wxString icon="", long style=0, int iconSize=0, wxWindowID btn_id=wxID_ANY)
Definition Button.cpp:56
void SetPaddingSize(const wxSize &size)
Definition Button.cpp:124
bool SetFont(const wxFont &font) override
Definition Button.cpp:81
std::vector< Button * > btns
Definition SwitchButton.hpp:199
std::vector< bool > btns_modified
Definition SwitchButton.hpp:200
void SetBorderColor(StateColor const &color)
Definition StaticBox.cpp:87
void SetBackgroundColor(StateColor const &color)
Definition StaticBox.cpp:102

References btns, btns_modified, Button::Create(), m_bg_color, m_button_padding, m_button_radius, m_scroll, m_text_color, StaticBox::SetBackgroundColor(), StaticBox::SetBorderColor(), StaticBox::SetCornerRadius(), Button::SetFont(), Button::SetPaddingSize(), Button::SetTextColor(), and sizer.

Referenced by SetOptions().

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

◆ button_clicked()

void MultiSwitchButton::button_clicked ( wxCommandEvent & event)
protected
935{
936 SetFocus();
937 auto *btn = event.GetEventObject();
938 auto iter = std::find(btns.begin(), btns.end(), btn);
939 SetSelection(iter == btns.end() ? -1 : int(iter - btns.begin()));
940}
void SetSelection(int index)
Definition SwitchButton.cpp:832

References btns, and SetSelection().

Referenced by MultiSwitchButton().

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

◆ Create()

bool StaticBox::Create ( wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
inherited
52{
53 if (style & wxBORDER_NONE)
54 border_width = 0;
55 wxWindow::Create(parent, id, pos, size, style);
57 state_handler.update_binds();
58 SetBackgroundColour(GetParentBackgroundColor(parent));
59 return true;
60}
StateColor border_color
Definition StaticBox.hpp:72
int border_width
Definition StaticBox.hpp:68
static wxColor GetParentBackgroundColor(wxWindow *parent)
Definition StaticBox.cpp:122
StateHandler state_handler
Definition StaticBox.hpp:71
StateColor background_color
Definition StaticBox.hpp:73
StateColor background_color2
Definition StaticBox.hpp:74

References background_color, background_color2, border_color, border_width, GetParentBackgroundColor(), state_handler, and style.

Referenced by FanSwitchButton::FanSwitchButton(), ImageSwitchButton::ImageSwitchButton(), ModeSwitchButton::ModeSwitchButton(), StaticBox(), Button::Create(), SpinInput::Create(), TabButton::Create(), TempInput::Create(), and TextInput::Create().

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

◆ DeleteAllOptions()

void MultiSwitchButton::DeleteAllOptions ( )
810{
811 sel = -1;
812 for (auto *btn : btns) {
813 if (btn)
814 btn->Destroy();
815 }
816 btns.clear();
817 btns_modified.clear();
818 if (sizer)
819 sizer->Clear();
820}
int sel
Definition SwitchButton.hpp:206

References btns, btns_modified, sel, and sizer.

Referenced by ~MultiSwitchButton(), and SetOptions().

Here is the caller graph for this function:

◆ doRender()

void StaticBox::doRender ( wxDC & dc)
protectedvirtualinherited

Reimplemented in FilamentStepIndicator, ModeSwitchButton, StepCtrl, StepIndicator, and TabCtrl.

215{
216 wxSize size = GetSize();
217 int states = state_handler.states();
218 if (background_color2.count() == 0) {
219 if ((border_width && border_color.count() > 0) || background_color.count() > 0) {
220 int topM = top_margin > 0 ? top_margin : 0;
221 wxRect rc(0, topM, size.x, size.y - topM);
222 if (border_width && border_color.count() > 0) {
223 const double scale = dc.GetContentScaleFactor();
224
225 // Snap rect edges to physical pixel boundaries so the 1px pen doesn't straddle a pixel boundary
226 auto snap = [&](int logical) -> int {
227 return (int)(ceil(logical * scale) / scale);
228 };
229
230 int deflate = snap(border_width / 2.0); // at 175%: snap(0.5) = snap→1/1.75 ≈ 1
231 rc.x += deflate;
232 rc.y += deflate;
233 rc.width -= deflate * 2;
234 rc.height -= deflate * 2;
235 dc.SetPen(wxPen(border_color.colorForStates(states), border_width, border_style));
236 } else {
237 dc.SetPen(wxPen(background_color.colorForStates(states)));
238 }
239 if (background_color.count() > 0)
240 dc.SetBrush(wxBrush(background_color.colorForStates(states)));
241 else
242 dc.SetBrush(wxBrush(GetBackgroundColour()));
243 if (radius == 0) {
244 dc.DrawRectangle(rc);
245 }
246 else {
247 dc.DrawRoundedRectangle(rc, radius - border_width);
248 }
249 }
250 }
251 else {
252 wxColor start = background_color.colorForStates(states);
253 wxColor stop = background_color2.colorForStates(states);
254 int r = start.Red(), g = start.Green(), b = start.Blue();
255 int dr = (int) stop.Red() - r, dg = (int) stop.Green() - g, db = (int) stop.Blue() - b;
256 int lr = 0, lg = 0, lb = 0;
257 for (int y = 0; y < size.y; ++y) {
258 dc.SetPen(wxPen(wxColor(r, g, b)));
259 dc.DrawLine(0, y, size.x, y);
260 lr += dr; while (lr >= size.y) { ++r, lr -= size.y; } while (lr <= -size.y) { --r, lr += size.y; }
261 lg += dg; while (lg >= size.y) { ++g, lg -= size.y; } while (lg <= -size.y) { --g, lg += size.y; }
262 lb += db; while (lb >= size.y) { ++b, lb -= size.y; } while (lb <= -size.y) { --b, lb += size.y; }
263 }
264 }
265
266 if (badge.bmp().IsOk()) {
267 auto s = badge.bmp().GetScaledSize();
268 dc.DrawBitmap(badge.bmp(), size.x - s.x, top_margin > 0 ? top_margin : 0);
269 }
270}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
ScalableBitmap badge
Definition StaticBox.hpp:75
int top_margin
Definition StaticBox.hpp:69
double radius
Definition StaticBox.hpp:67
wxPenStyle border_style
Definition StaticBox.hpp:70

References background_color, background_color2, badge, border_color, border_style, border_width, radius, scale(), state_handler, and top_margin.

Referenced by FilamentStepIndicator::doRender(), StepCtrl::doRender(), StepIndicator::doRender(), and render().

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

◆ eraseEvent()

void StaticBox::eraseEvent ( wxEraseEvent & evt)
protectedinherited
153{
154 // for transparent background, but not work
155#ifdef __WXMSW__
156 wxDC *dc = evt.GetDC();
157 wxSize size = GetSize();
158 wxClientDC dc2(GetParent());
159 dc->Blit({0, 0}, size, &dc2, GetPosition());
160#endif
161}

◆ GetButton()

Button * MultiSwitchButton::GetButton ( unsigned int index) const
inline
154 {
155 return index >= 0 && index < btns.size() ? btns[index] : nullptr;
156 }

References btns.

◆ GetCount()

unsigned int MultiSwitchButton::GetCount ( ) const
823{
824 return (unsigned int) btns.size();
825}

References btns.

◆ GetOptionData()

void * MultiSwitchButton::GetOptionData ( unsigned int index) const
864{
865 return index < btns.size() ? btns[index]->GetClientData() : nullptr;
866}

References btns.

◆ GetOptionText()

wxString MultiSwitchButton::GetOptionText ( unsigned int index) const
851{
852 return index < btns.size() ? btns[index]->GetLabel() : wxString();
853}

References btns.

Referenced by Slic3r::GUI::PublishSettingsDialog::refresh_tab_indicators().

Here is the caller graph for this function:

◆ GetParentBackgroundColor()

wxColor StaticBox::GetParentBackgroundColor ( wxWindow * parent)
staticinherited
123{
124 if (auto box = dynamic_cast<StaticBox*>(parent)) {
125 if (box->background_color.count() > 0) {
126 if (box->background_color2.count() == 0)
127 return box->background_color.defaultColor();
128 auto s = box->background_color.defaultColor();
129 auto e = box->background_color2.defaultColor();
130 int r = (s.Red() + e.Red()) / 2;
131 int g = (s.Green() + e.Green()) / 2;
132 int b = (s.Blue() + e.Blue()) / 2;
133 return wxColor(r, g, b);
134 }
135 }
136 if (parent)
137 return parent->GetBackgroundColour();
138 return *wxWHITE;
139}

References StaticBox().

Referenced by Label::Label(), ModeSwitchButton::ModeSwitchButton(), ScalableButton::ScalableButton(), SwitchButton::SwitchButton(), Create(), and SwitchButton::Rescale().

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

◆ GetSelectedText()

wxString MultiSwitchButton::GetSelectedText ( ) const
846{
847 return sel >= 0 && sel < (int) btns.size() ? btns[sel]->GetLabel() : wxString();
848}

References btns, and sel.

Referenced by send_selection_event().

Here is the caller graph for this function:

◆ GetSelection()

int MultiSwitchButton::GetSelection ( ) const
828{
829 return sel;
830}

References sel.

◆ on_size()

void MultiSwitchButton::on_size ( wxSizeEvent & evt)
private
736{
737 evt.Skip();
738
739 // The row resized, so the buttons may now overflow it (or no longer fit in it) and the room the
740 // bar needs changed with that. Width does not depend on height, so this settles in one pass.
741 const int height = options_height() + scrollbar_height(sizer->CalcMin().x);
742 if (GetMinSize().y != height) {
743 SetMinSize(wxSize(GetMinSize().x, height));
744 // The switch sits in a row of this tab, and the tab in a panel that shares its height
745 // with the page view, so both have to lay out again for the taller row to get its room.
746 if (wxWindow *tab = GetParent()) {
747 tab->Layout();
748 if (wxWindow *panel = tab->GetParent())
749 panel->Layout();
750 }
751 }
752}
int scrollbar_height(int options_width) const
Definition SwitchButton.cpp:723
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References options_height(), scrollbar_height(), and sizer.

Referenced by MultiSwitchButton().

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

◆ options_height()

int MultiSwitchButton::options_height ( ) const
private
702{
703 // With no button to measure yet, keep the placeholder height the switch starts with.
704 return btns.empty() ? FromDIP(20) : btns.front()->GetMinSize().y;
705}

References btns.

Referenced by MultiSwitchButton(), on_size(), and update_scroll_range().

Here is the caller graph for this function:

◆ paintEvent()

void StaticBox::paintEvent ( wxPaintEvent & evt)
protectedinherited
170{
171 // depending on your system you may need to look at double-buffered dcs
172 wxPaintDC dc(this);
173 render(dc);
174}
void render(wxDC &dc)
Definition StaticBox.cpp:181

References render().

Here is the call graph for this function:

◆ render()

void StaticBox::render ( wxDC & dc)
protectedinherited
182{
183#ifdef __WXMSW__
184 if (radius == 0) {
185 doRender(dc);
186 return;
187 }
188
189 wxSize size = GetSize();
190 if (size.x <= 0 || size.y <= 0)
191 return;
192 wxMemoryDC memdc(&dc);
193 if (!memdc.IsOk()) {
194 doRender(dc);
195 return;
196 }
197 wxBitmap bmp(size.x, size.y);
198 memdc.SelectObject(bmp);
199 //memdc.Blit({0, 0}, size, &dc, {0, 0});
200 memdc.SetBackground(wxBrush(GetBackgroundColour()));
201 memdc.Clear();
202 {
203 wxGCDC dc2(memdc);
204 doRender(dc2);
205 }
206
207 memdc.SelectObject(wxNullBitmap);
208 dc.DrawBitmap(bmp, 0, 0);
209#else
210 doRender(dc);
211#endif
212}
virtual void doRender(wxDC &dc)
Definition StaticBox.cpp:214

References doRender(), and radius.

Referenced by paintEvent(), Button::render(), FanSwitchButton::render(), ImageSwitchButton::render(), SpinInput::render(), TabButton::render(), TempInput::render(), and TextInput::render().

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

◆ Rescale()

void MultiSwitchButton::Rescale ( )
925{
926 for (auto *btn : btns) {
927 btn->SetPaddingSize(FromDIP(m_button_padding));
928 btn->Rescale();
929 }
930 // Rescaling can change how the labels measure, and the scrollbar range follows the buttons.
932}
void update_scroll_range()
Definition SwitchButton.cpp:707

References btns, m_button_padding, and update_scroll_range().

Referenced by Slic3r::GUI::PublishSettingsDialog::on_dpi_changed().

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

◆ scroll_option_into_view()

void MultiSwitchButton::scroll_option_into_view ( Button * btn)
private
755{
756 const int width = m_scroll->GetClientSize().x;
757 const int view_x = m_scroll->GetViewStartPixels().x;
758 if (width <= 0) // not laid out yet: there is no view to scroll
759 return;
760
761 const wxRect rect = btn->GetRect();
762 const int right = rect.GetRight() + 1;
763 int target = view_x;
764 if (rect.x < view_x)
765 target = rect.x;
766 else if (right > view_x + width)
767 target = right - width;
768
769 if (target == view_x)
770 return;
771
772 // Scroll() counts scroll units; round up so the whole button ends up inside the view rather
773 // than a few pixels short of it.
774 int step = 1;
775 m_scroll->GetScrollPixelsPerUnit(&step, nullptr);
776 m_scroll->Scroll((target + step - 1) / step, -1);
777}
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
void step(Coord &crd, const Dir d, const long n=1)
Definition MarchingSquares.hpp:213
@ right
Definition MarchingSquares.hpp:190

References m_scroll.

Referenced by SetSelection().

Here is the caller graph for this function:

◆ scrollbar_height()

int MultiSwitchButton::scrollbar_height ( int options_width) const
private
724{
725 // The bar is drawn inside the switch, so while the buttons need more width than the row gave us
726 // the switch has to be taller by the bar's height, or the bar sits on top of the buttons.
727 const int width = GetClientSize().x;
728 if (width <= 0 || options_width <= width)
729 return 0;
730
731 const int bar = wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y, this);
732 return bar > 0 ? bar : 0;
733}

Referenced by on_size(), and update_scroll_range().

Here is the caller graph for this function:

◆ send_selection_event()

bool MultiSwitchButton::send_selection_event ( )
protected
943{
944 wxCommandEvent evt(wxCUSTOMEVT_MULTISWITCH_SELECTION, GetId());
945 evt.SetEventObject(this);
946 evt.SetInt(sel);
947 evt.SetString(GetSelectedText());
948 GetEventHandler()->ProcessEvent(evt);
949 return true;
950}
wxString GetSelectedText() const
Definition SwitchButton.cpp:845

References GetSelectedText(), and sel.

Referenced by SetSelection().

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

◆ SetBackgroundColor()

void MultiSwitchButton::SetBackgroundColor ( const StateColor & color)
886{
887 m_bg_color = color;
889}
void update_button_styles()
Definition SwitchButton.cpp:875

References m_bg_color, and update_button_styles().

Here is the call graph for this function:

◆ SetBackgroundColor2()

void StaticBox::SetBackgroundColor2 ( StateColor const & color)
inherited
116{
117 background_color2 = color;
118 state_handler.update_binds();
119 Refresh();
120}

References background_color2, and state_handler.

◆ SetBackgroundColorNormal()

void StaticBox::SetBackgroundColorNormal ( wxColor const & color)
inherited
110{
111 background_color.setColorForStates(color, 0);
112 Refresh();
113}

References background_color.

Referenced by Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), and Slic3r::GUI::HotEndTable::CreateNozzleBox().

Here is the caller graph for this function:

◆ SetBorderColor()

◆ SetBorderColorNormal()

void StaticBox::SetBorderColorNormal ( wxColor const & color)
inherited
97{
98 border_color.setColorForStates(color, 0);
99 Refresh();
100}

References border_color.

Referenced by Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), and Slic3r::GUI::HotEndTable::CreateNozzleBox().

Here is the caller graph for this function:

◆ SetBorderStyle()

void StaticBox::SetBorderStyle ( wxPenStyle style)
inherited
76{
78 Refresh();
79}

References border_style, and style.

◆ SetBorderWidth()

void StaticBox::SetBorderWidth ( int width)
inherited
82{
84 Refresh();
85}

References border_width.

Referenced by MultiSwitchButton::MultiSwitchButton(), Slic3r::GUI::KBShortcutsDialog::create_page(), and Button::SetStyle().

Here is the caller graph for this function:

◆ SetButtonCornerRadius()

void MultiSwitchButton::SetButtonCornerRadius ( double radius)
898{
901 for (auto *btn : btns)
902 btn->SetCornerRadius(radius);
903 Layout();
904 Refresh();
905}

References btns, m_button_radius, StaticBox::radius, and StaticBox::SetCornerRadius().

Here is the call graph for this function:

◆ SetButtonPadding()

void MultiSwitchButton::SetButtonPadding ( const wxSize & padding)
908{
909 m_button_padding = padding;
910 for (auto *btn : btns)
911 btn->SetPaddingSize(FromDIP(padding));
913 Layout();
914 Refresh();
915}

References btns, m_button_padding, and update_scroll_range().

Here is the call graph for this function:

◆ SetButtonTextColor()

void MultiSwitchButton::SetButtonTextColor ( int index,
const StateColor & color )
inline
167 {
168 if (index >= btns.size()) return;
169
170 btns[index]->SetTextColor(color);
171 btns[index]->Refresh();
172 }

References btns.

◆ SetCornerRadius()

◆ SetFitToOptions()

void MultiSwitchButton::SetFitToOptions ( bool fit = true)
inline
bool m_fit_to_options
Definition SwitchButton.hpp:205

References m_fit_to_options, and update_scroll_range().

Referenced by Slic3r::GUI::PublishSettingsDialog::setup_variant_switch().

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

◆ SetModified()

void MultiSwitchButton::SetModified ( int index,
bool modified )
917 {
918 if(index < 0 || index >= btns_modified.size())
919 return;
920 btns_modified[index] = modified;
922}

References btns_modified, and update_button_styles().

Here is the call graph for this function:

◆ SetOptionData()

void MultiSwitchButton::SetOptionData ( unsigned int index,
void * clientData )
869{
870 if (index >= btns.size())
871 return;
872 btns[index]->SetClientData(clientData);
873}

References btns.

◆ SetOptions()

void MultiSwitchButton::SetOptions ( const std::vector< wxString > & options)
799{
801 for (const auto &option : options)
802 AppendOption(option);
803
805 Layout();
806 Refresh();
807}
int AppendOption(const wxString &option, void *clientData=nullptr)
Definition SwitchButton.cpp:779

References AppendOption(), DeleteAllOptions(), and update_scroll_range().

Referenced by Slic3r::GUI::PublishSettingsDialog::setup_variant_switch().

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

◆ SetOptionText()

void MultiSwitchButton::SetOptionText ( unsigned int index,
const wxString & text )
856{
857 if (index >= btns.size())
858 return;
859 btns[index]->SetLabel(text);
861}

References btns, and update_scroll_range().

Referenced by Slic3r::GUI::PublishSettingsDialog::refresh_tab_indicators().

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

◆ SetSelection()

void MultiSwitchButton::SetSelection ( int index)
833{
834 if (index < 0 || index >= (int) btns.size() || index == sel)
835 return;
836
837 sel = index;
840 // The selected button may be scrolled out of sight, e.g. when the tab restores the active tool.
842 Refresh();
843}
bool send_selection_event()
Definition SwitchButton.cpp:942
void scroll_option_into_view(Button *btn)
Definition SwitchButton.cpp:754

References btns, scroll_option_into_view(), sel, send_selection_event(), and update_button_styles().

Referenced by button_clicked(), Slic3r::GUI::PublishSettingsDialog::setup_variant_switch(), and Slic3r::GUI::PublishSettingsDialog::show_inner_page().

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

◆ SetTextColor()

void MultiSwitchButton::SetTextColor ( const StateColor & color)
892{
893 m_text_color = color;
895}

References m_text_color, and update_button_styles().

Here is the call graph for this function:

◆ SetTopMargin()

void StaticBox::SetTopMargin ( int margin)
inherited
70{
71 this->top_margin = margin;
72 Refresh();
73}

References top_margin.

Referenced by Slic3r::GUI::ExtruderGroup::ExtruderGroup().

Here is the caller graph for this function:

◆ ShowBadge()

void StaticBox::ShowBadge ( bool show)
inherited
142{
143 if (show && badge.name() != "badge") {
144 badge = ScalableBitmap(this, "badge", 18);
145 Refresh();
146 } else if (!show && !badge.name().empty()) {
147 badge = ScalableBitmap {};
148 Refresh();
149 }
150}

References badge.

Referenced by Slic3r::GUI::ExtruderGroup::ExtruderGroup().

Here is the caller graph for this function:

◆ sizeEvent()

void StaticBox::sizeEvent ( wxSizeEvent & evt)
protectedinherited
164{
165 Refresh();
166 evt.Skip();
167}

◆ update_button_styles()

void MultiSwitchButton::update_button_styles ( )
protected
876{
877 for (int i = 0; i < (int) btns.size(); ++i) {
878 btns[i]->SetValue(i == sel);
879 btns[i]->SetBorderColor(btns_modified[i] ? m_br_color_modified : m_bg_color );
880 btns[i]->SetTextColor( btns_modified[i] ? m_fg_color_modified : m_text_color);
881 btns[i]->Refresh();
882 }
883}

References btns, btns_modified, m_bg_color, m_br_color_modified, m_fg_color_modified, m_text_color, and sel.

Referenced by SetBackgroundColor(), SetModified(), SetSelection(), and SetTextColor().

Here is the caller graph for this function:

◆ update_scroll_range()

void MultiSwitchButton::update_scroll_range ( )
private
708{
709 // The scrollbar range is measured against the virtual size, so it has to follow the buttons
710 // whenever their labels or count change.
711 m_scroll->InvalidateBestSize();
712 m_scroll->FitInside();
713
714 // A scrolled window reports its min size plus a scrollbar as its best size, never the width of
715 // the buttons it holds, so the layout has to be given that width explicitly. It is also the
716 // widest this switch wants to be: a row with less room squeezes it below this and it scrolls.
717 const wxSize content = sizer->CalcMin();
718 SetMinSize(wxSize(content.x, options_height() + scrollbar_height(content.x)));
719 SetMaxSize(m_fit_to_options ? wxSize(content.x, -1) : wxDefaultSize);
720 InvalidateBestSize();
721}

References m_fit_to_options, m_scroll, options_height(), scrollbar_height(), and sizer.

Referenced by Rescale(), SetButtonPadding(), SetFitToOptions(), SetOptions(), and SetOptionText().

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

Member Data Documentation

◆ background_color

◆ background_color2

StateColor StaticBox::background_color2
protectedinherited

◆ badge

ScalableBitmap StaticBox::badge
protectedinherited

Referenced by doRender(), and ShowBadge().

◆ border_color

◆ border_style

wxPenStyle StaticBox::border_style = wxPENSTYLE_SOLID
protectedinherited

Referenced by doRender(), and SetBorderStyle().

◆ border_width

◆ btns

◆ btns_modified

std::vector<bool> MultiSwitchButton::btns_modified
private

◆ m_bg_color

StateColor MultiSwitchButton::m_bg_color
private

◆ m_br_color_modified

StateColor MultiSwitchButton::m_br_color_modified
private

◆ m_button_padding

wxSize MultiSwitchButton::m_button_padding
private

◆ m_button_radius

double MultiSwitchButton::m_button_radius
private

◆ m_fg_color_modified

StateColor MultiSwitchButton::m_fg_color_modified
private

◆ m_fit_to_options

bool MultiSwitchButton::m_fit_to_options = false
private

◆ m_scroll

wxScrolledWindow* MultiSwitchButton::m_scroll = nullptr
private

◆ m_text_color

StateColor MultiSwitchButton::m_text_color
private

◆ radius

◆ sel

◆ sizer

wxBoxSizer* MultiSwitchButton::sizer = nullptr
private

◆ state_handler

◆ top_margin

int StaticBox::top_margin = 0
protectedinherited

Referenced by doRender(), and SetTopMargin().


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