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

Public Member Functions

 HoverLabel (wxWindow *parent, const wxString &label)
void EnableEdit (bool enable)
void SetOnHoverClick (std::function< void()> on_click)
void SetCount (int count)
void SetTitle (const wxString &title)
void Rescale ()
void sys_color_changed ()

Private Member Functions

void UpdateSizing ()

Private Attributes

wxStaticText * m_label
wxStaticText * m_brace_left
wxStaticText * m_count
wxStaticText * m_brace_right
ScalableButton * m_hover_btn
std::function< void()> m_hover_on_click
bool m_enabled {false}

Detailed Description

Constructor & Destructor Documentation

◆ HoverLabel()

Slic3r::GUI::HoverLabel::HoverLabel ( wxWindow * parent,
const wxString & label )
inline
620 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
621 {
622 SetBackgroundColour(extruder_group_chip_bg());
623 auto sizer = new wxBoxSizer(wxHORIZONTAL);
624
625 auto label_color = StateColor::darkModeColorFor(wxColour("#363636"));
626
627 m_label = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
628 m_label->SetFont(Label::Body_12);
629 m_label->SetForegroundColour(label_color);
630
631 m_brace_left = new wxStaticText(this, wxID_ANY, "(", wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
633 m_brace_left->SetForegroundColour(label_color);
634 m_brace_left->Hide();
635
636 m_count = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
637 m_count->SetFont(Label::Body_12.Bold());
638 m_count->SetForegroundColour(label_color);
639 m_count->Hide();
640
641 m_brace_right = new wxStaticText(this, wxID_ANY, ")", wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
643 m_brace_right->SetForegroundColour(label_color);
644 m_brace_right->Hide();
645
646 m_hover_btn = new ScalableButton(this, wxID_ANY, "edit_12px", wxEmptyString, FromDIP(wxSize(12,12)), wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 12);
647 m_hover_btn->SetBackgroundColour(extruder_group_chip_bg());
648 m_hover_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &evt) {
651 });
652
653 sizer->Add(m_label , 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, FromDIP(4));
654 sizer->Add(m_brace_left , 0, wxALIGN_CENTER_VERTICAL);
655 sizer->Add(m_count , 0, wxALIGN_CENTER_VERTICAL);
656 sizer->Add(m_brace_right, 0, wxALIGN_CENTER_VERTICAL);
657 sizer->Add(m_hover_btn , 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, FromDIP(4));
658
659 // No SetSizerAndFit: that would record the count-hidden width as an explicit min size,
660 // which outranks best size in sizer allocation, so once the count is shown any ancestor
661 // Layout() would shrink the row back and clip the trailing edit button.
662 SetSizer(sizer);
663 Layout();
664 }
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Body_12
Definition Label.hpp:55
wxStaticText * m_brace_left
Definition Plater.cpp:727
std::function< void()> m_hover_on_click
Definition Plater.cpp:732
bool m_enabled
Definition Plater.cpp:733
wxStaticText * m_brace_right
Definition Plater.cpp:729
ScalableButton * m_hover_btn
Definition Plater.cpp:730
wxStaticText * m_count
Definition Plater.cpp:728
wxStaticText * m_label
Definition Plater.cpp:726
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
static wxColour extruder_group_chip_bg()
Definition Plater.cpp:609

References Label::Body_12, StateColor::darkModeColorFor(), Slic3r::GUI::extruder_group_chip_bg(), m_brace_left, m_brace_right, m_count, m_enabled, m_hover_btn, m_hover_on_click, m_label, and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ EnableEdit()

void Slic3r::GUI::HoverLabel::EnableEdit ( bool enable)
inline
667 {
668 m_enabled = enable;
669 //m_hover_btn->SetBitmap_(enable ? "edit_12px" : "dot"); // it causes crash if icon sizes not matches
670 }

References m_enabled.

◆ Rescale()

void Slic3r::GUI::HoverLabel::Rescale ( )
inline
697 {
698 m_hover_btn->msw_rescale();
699 UpdateSizing();
700 }
void UpdateSizing()
Definition Plater.cpp:717

References m_hover_btn, and UpdateSizing().

Here is the call graph for this function:

◆ SetCount()

void Slic3r::GUI::HoverLabel::SetCount ( int count)
inline
675 {
676 if (count < 0) {
677 m_count->Hide();
678 m_brace_left->Hide();
679 m_brace_right->Hide();
680 m_hover_btn->Hide();
681 } else {
682 m_count->SetLabel(wxString::Format("%d", count));
683 m_count->Show();
684 m_brace_left->Show();
685 m_brace_right->Show();
686 m_hover_btn->Show();
687 }
688 UpdateSizing();
689 }
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246

References count, m_brace_left, m_brace_right, m_count, m_hover_btn, and UpdateSizing().

Here is the call graph for this function:

◆ SetOnHoverClick()

void Slic3r::GUI::HoverLabel::SetOnHoverClick ( std::function< void()> on_click)
inline
672{ m_hover_on_click = std::move(on_click); }

References m_hover_on_click.

◆ SetTitle()

void Slic3r::GUI::HoverLabel::SetTitle ( const wxString & title)
inline
692 {
693 m_label->SetLabel(title);
694 UpdateSizing();
695 }

References m_label, and UpdateSizing().

Here is the call graph for this function:

◆ sys_color_changed()

void Slic3r::GUI::HoverLabel::sys_color_changed ( )
inline
704 {
705 SetBackgroundColour(extruder_group_chip_bg());
706 auto label_color = StateColor::darkModeColorFor(wxColour("#363636"));
707 m_label->SetForegroundColour(label_color);
709 t->SetForegroundColour(label_color);
710 m_hover_btn->SetBackgroundColour(extruder_group_chip_bg());
711 Refresh();
712 }

References StateColor::darkModeColorFor(), Slic3r::GUI::extruder_group_chip_bg(), m_brace_left, m_brace_right, m_count, m_hover_btn, and m_label.

Here is the call graph for this function:

◆ UpdateSizing()

void Slic3r::GUI::HoverLabel::UpdateSizing ( )
inlineprivate
718 {
719 InvalidateBestSize();
720 Layout();
721 Fit();
722 if (GetParent())
723 GetParent()->Layout();
724 }

Referenced by Rescale(), SetCount(), and SetTitle().

Here is the caller graph for this function:

Member Data Documentation

◆ m_brace_left

wxStaticText* Slic3r::GUI::HoverLabel::m_brace_left
private

◆ m_brace_right

wxStaticText* Slic3r::GUI::HoverLabel::m_brace_right
private

◆ m_count

wxStaticText* Slic3r::GUI::HoverLabel::m_count
private

◆ m_enabled

bool Slic3r::GUI::HoverLabel::m_enabled {false}
private
733{false};

Referenced by HoverLabel(), and EnableEdit().

◆ m_hover_btn

ScalableButton* Slic3r::GUI::HoverLabel::m_hover_btn
private

◆ m_hover_on_click

std::function<void()> Slic3r::GUI::HoverLabel::m_hover_on_click
private

Referenced by HoverLabel(), and SetOnHoverClick().

◆ m_label

wxStaticText* Slic3r::GUI::HoverLabel::m_label
private

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