OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::FilamentMapBtnPanel Class Reference

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

Inheritance diagram for Slic3r::GUI::FilamentMapBtnPanel:
Collaboration diagram for Slic3r::GUI::FilamentMapBtnPanel:

Public Member Functions

 FilamentMapBtnPanel (wxWindow *parent, const wxString &label, const wxString &detail, const std::string &icon_path)
bool Show (bool show=true) override
void Select (bool selected)
bool Enable (bool enable) override
bool IsEnabled () const

Protected Member Functions

void OnPaint (wxPaintEvent &event)

Private Member Functions

void OnEnterWindow (wxMouseEvent &event)
void OnLeaveWindow (wxMouseEvent &evnet)
void UpdateStatus ()

Private Attributes

wxBitmap icon_enabled
wxBitmap icon_disabled
wxBitmapButton * m_btn
wxStaticText * m_label
Label * m_disable_tip
Label * m_detail
std::string m_icon_path
bool m_enabled { true }
bool m_hover {false}
bool m_selected {false}

Detailed Description

Constructor & Destructor Documentation

◆ FilamentMapBtnPanel()

Slic3r::GUI::GUI::FilamentMapBtnPanel::FilamentMapBtnPanel ( wxWindow * parent,
const wxString & label,
const wxString & detail,
const std::string & icon_path )
516 : wxPanel(parent)
517{
518 SetBackgroundColour(*wxWHITE);
519 SetBackgroundStyle(wxBG_STYLE_PAINT);
520 m_hover = false;
521
522 const int horizontal_margin = FromDIP(12);
523
524 auto sizer = new wxBoxSizer(wxVERTICAL);
525
526 icon_enabled = create_scaled_bitmap(icon, nullptr, 20);
527 icon_disabled = create_scaled_bitmap(icon + "_disabled", nullptr, 20);
528
529 m_btn = new wxBitmapButton(this, wxID_ANY, icon_enabled, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
530 m_btn->SetBackgroundStyle(wxBG_STYLE_PAINT);
531
532 auto icon_sizer = new wxBoxSizer(wxVERTICAL);
533 icon_sizer->Add(m_btn , 0, wxLEFT, horizontal_margin);
534
535 m_label = new wxStaticText(this, wxID_ANY, label);
536 m_label->SetFont(Label::Head_14);
537 m_label->SetForegroundColour(TextNormalBlackColor);
538
539 auto label_sizer = new wxBoxSizer(wxVERTICAL);
540 label_sizer->Add(m_label, 0, wxLEFT, horizontal_margin);
541
542 m_disable_tip = new Label(this, _L("(Sync with printer)"));
544 label_sizer->AddSpacer(FromDIP(2));
545 label_sizer->Add(m_disable_tip, 0, wxLEFT, horizontal_margin);
546
547 sizer->AddSpacer(FromDIP(15));
548 sizer->Add(icon_sizer, 0, wxEXPAND);
549 sizer->AddSpacer(FromDIP(10));
550 sizer->Add(label_sizer, 0, wxEXPAND);
551 sizer->AddSpacer(FromDIP(6));
552
553 auto detail_sizer = new wxBoxSizer(wxHORIZONTAL);
554 m_detail = new Label(this, detail);
555 m_detail->SetFont(Label::Body_12);
556 m_detail->SetForegroundColour(TextNormalGreyColor);
557 m_detail->Wrap(FromDIP(180));
558
559 detail_sizer->AddStretchSpacer();
560 detail_sizer->Add(m_detail, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, horizontal_margin);
561 detail_sizer->AddStretchSpacer();
562
563 sizer->Add(detail_sizer, 0, wxEXPAND);
564 sizer->AddSpacer(FromDIP(10));
565
566 SetSizer(sizer);
567 Layout();
568 Fit();
569
570 GUI::wxGetApp().UpdateDarkUIWin(this);
571
572 auto forward_click_to_parent = [this](wxMouseEvent &event) {
573 wxCommandEvent click_event(wxEVT_LEFT_DOWN, GetId());
574 click_event.SetEventObject(this);
575 this->ProcessEvent(click_event);
576 };
577
578 m_btn->Bind(wxEVT_LEFT_DOWN, forward_click_to_parent);
579 m_label->Bind(wxEVT_LEFT_DOWN, forward_click_to_parent);
580 m_detail->Bind(wxEVT_LEFT_DOWN, forward_click_to_parent);
581
582 Bind(wxEVT_PAINT, &FilamentMapBtnPanel::OnPaint, this);
583 Bind(wxEVT_ENTER_WINDOW, &FilamentMapBtnPanel::OnEnterWindow, this);
584 Bind(wxEVT_LEAVE_WINDOW, &FilamentMapBtnPanel::OnLeaveWindow, this);
585}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
static wxFont Head_14
Definition Label.hpp:45
static wxFont Body_12
Definition Label.hpp:55
void OnEnterWindow(wxMouseEvent &event)
Definition FilamentMapPanel.cpp:643
wxBitmap icon_enabled
Definition FilamentMapPanel.hpp:91
void OnLeaveWindow(wxMouseEvent &evnet)
Definition FilamentMapPanel.cpp:653
Label * m_detail
Definition FilamentMapPanel.hpp:97
wxStaticText * m_label
Definition FilamentMapPanel.hpp:95
Label * m_disable_tip
Definition FilamentMapPanel.hpp:96
void OnPaint(wxPaintEvent &event)
Definition FilamentMapPanel.cpp:587
bool m_hover
Definition FilamentMapPanel.hpp:100
wxBitmapButton * m_btn
Definition FilamentMapPanel.hpp:94
wxBitmap icon_disabled
Definition FilamentMapPanel.hpp:92
wxMouseEvent
Definition CameraPopup.cpp:47
static const wxColour TextNormalGreyColor
Definition FilamentMapPanel.cpp:41
static const wxColour TextNormalBlackColor
Definition FilamentMapPanel.cpp:40
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References _L, Label::Body_12, create_scaled_bitmap(), Label::Head_14, icon_disabled, icon_enabled, m_btn, m_detail, m_disable_tip, m_hover, m_label, OnEnterWindow(), OnLeaveWindow(), OnPaint(), Slic3r::GUI::TextNormalBlackColor, Slic3r::GUI::TextNormalGreyColor, Slic3r::GUI::wxMouseEvent, and wxStaticText.

Here is the call graph for this function:

Member Function Documentation

◆ Enable()

bool Slic3r::GUI::FilamentMapBtnPanel::Enable ( bool enable)
override
666{
667 m_enabled = enable;
668 UpdateStatus();
669 Refresh();
670 return true;
671}
void UpdateStatus()
Definition FilamentMapPanel.cpp:610
bool m_enabled
Definition FilamentMapPanel.hpp:99

References m_enabled, and UpdateStatus().

Here is the call graph for this function:

◆ IsEnabled()

bool Slic3r::GUI::FilamentMapBtnPanel::IsEnabled ( ) const
inline
82{ return m_enabled; }

References m_enabled.

◆ OnEnterWindow()

void Slic3r::GUI::FilamentMapBtnPanel::OnEnterWindow ( wxMouseEvent & event)
private
644{
645 if (!m_hover && m_enabled) {
646 m_hover = true;
647 UpdateStatus();
648 Refresh();
649 event.Skip();
650 }
651}

References m_enabled, m_hover, UpdateStatus(), and Slic3r::GUI::wxMouseEvent.

Referenced by FilamentMapBtnPanel().

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

◆ OnLeaveWindow()

void Slic3r::GUI::FilamentMapBtnPanel::OnLeaveWindow ( wxMouseEvent & evnet)
private
654{
655 if (m_hover) {
656 wxPoint pos = this->ScreenToClient(wxGetMousePosition());
657 if (this->GetClientRect().Contains(pos)) return;
658 m_hover = false;
659 UpdateStatus();
660 Refresh();
661 event.Skip();
662 }
663}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References m_hover, UpdateStatus(), and Slic3r::GUI::wxMouseEvent.

Referenced by FilamentMapBtnPanel().

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

◆ OnPaint()

void Slic3r::GUI::FilamentMapBtnPanel::OnPaint ( wxPaintEvent & event)
protected
588{
589 wxAutoBufferedPaintDC dc(this);
590 wxGraphicsContext *gc = wxGraphicsContext::Create(dc);
591
592 if (gc) {
593 dc.Clear();
594 wxRect rect = GetClientRect();
595 gc->SetBrush(wxTransparentColour);
596 gc->DrawRoundedRectangle(0, 0, rect.width, rect.height, 0);
598
599 wxColour border_color = m_hover || m_selected ? BorderSelectedColor : BorderNormalColor;
600
602 border_color = StateColor::darkModeColorFor(border_color);
603 gc->SetBrush(wxBrush(bg_color));
604 gc->SetPen(wxPen(border_color, 1));
605 gc->DrawRoundedRectangle(1, 1, rect.width - 2, rect.height - 2, 8);
606 delete gc;
607 }
608}
bool m_selected
Definition FilamentMapPanel.hpp:101
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
wxColour bg_color()
Definition SpeedDialDialog.cpp:69
static const wxColour BorderNormalColor
Definition CapsuleButton.cpp:24
static const wxColour BgNormalColor
Definition CapsuleButton.cpp:18
static const wxColour BgSelectColor
Definition CapsuleButton.cpp:19
static const wxColour BorderSelectedColor
Definition FilamentMapPanel.cpp:37

References Slic3r::GUI::BgNormalColor, Slic3r::GUI::BgSelectColor, Slic3r::GUI::BorderNormalColor, Slic3r::GUI::BorderSelectedColor, StateColor::darkModeColorFor(), m_hover, and m_selected.

Referenced by FilamentMapBtnPanel().

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

◆ Select()

void Slic3r::GUI::FilamentMapBtnPanel::Select ( bool selected)
674{
675 m_selected = selected;
676 UpdateStatus();
677 Refresh();
678}

References m_selected, and UpdateStatus().

Here is the call graph for this function:

◆ Show()

bool Slic3r::GUI::GUI::FilamentMapBtnPanel::Show ( bool show = true)
override
681{
682 m_btn->Show(show);
683 m_label->Show(show);
684 m_detail->Show(show);
685 return wxPanel::Show(show);
686}

References m_btn, m_detail, and m_label.

◆ UpdateStatus()

void Slic3r::GUI::FilamentMapBtnPanel::UpdateStatus ( )
private
611{
612 if (m_selected) {
613 m_btn->SetBackgroundColour(BgSelectColor);
614 m_label->SetBackgroundColour(BgSelectColor);
615 m_detail->SetBackgroundColour(BgSelectColor);
616 m_disable_tip->SetBackgroundColour(BgSelectColor);
617 }
618 else {
619 m_btn->SetBackgroundColour(BgNormalColor);
620 m_label->SetBackgroundColour(BgNormalColor);
621 m_detail->SetBackgroundColour(BgNormalColor);
622 m_disable_tip->SetBackgroundColour(BgNormalColor);
623 }
624 if (!m_enabled) {
625 m_disable_tip->SetLabel(_L("(Sync with printer)"));
626 m_disable_tip->SetForegroundColour(TextDisableColor);
627 m_btn->SetBitmap(icon_disabled);
628 m_btn->SetForegroundColour(BgDisableColor);
629 m_label->SetForegroundColour(TextDisableColor);
630 m_detail->SetForegroundColour(TextDisableColor);
631 }
632 else {
633 m_disable_tip->SetLabel("");
634 m_disable_tip->SetForegroundColour(TextNormalBlackColor);
635 m_btn->SetBitmap(icon_enabled);
636 m_btn->SetForegroundColour(BgNormalColor);
637 m_label->SetForegroundColour(TextNormalBlackColor);
638 m_detail->SetForegroundColour(TextNormalGreyColor);
639 }
640 GUI::wxGetApp().UpdateDarkUIWin(this);
641}
static const wxColour TextDisableColor
Definition FilamentMapPanel.cpp:42
static const wxColour BgDisableColor
Definition FilamentMapPanel.cpp:34

References _L, Slic3r::GUI::BgDisableColor, Slic3r::GUI::BgNormalColor, Slic3r::GUI::BgSelectColor, icon_disabled, icon_enabled, m_btn, m_detail, m_disable_tip, m_enabled, m_label, m_selected, Slic3r::GUI::TextDisableColor, Slic3r::GUI::TextNormalBlackColor, and Slic3r::GUI::TextNormalGreyColor.

Referenced by Enable(), OnEnterWindow(), OnLeaveWindow(), and Select().

Here is the caller graph for this function:

Member Data Documentation

◆ icon_disabled

wxBitmap Slic3r::GUI::FilamentMapBtnPanel::icon_disabled
private

◆ icon_enabled

wxBitmap Slic3r::GUI::FilamentMapBtnPanel::icon_enabled
private

◆ m_btn

wxBitmapButton* Slic3r::GUI::FilamentMapBtnPanel::m_btn
private

◆ m_detail

Label* Slic3r::GUI::FilamentMapBtnPanel::m_detail
private

◆ m_disable_tip

Label* Slic3r::GUI::FilamentMapBtnPanel::m_disable_tip
private

◆ m_enabled

bool Slic3r::GUI::FilamentMapBtnPanel::m_enabled { true }
private
99{ true };

Referenced by Enable(), IsEnabled(), OnEnterWindow(), and UpdateStatus().

◆ m_hover

bool Slic3r::GUI::FilamentMapBtnPanel::m_hover {false}
private

◆ m_icon_path

std::string Slic3r::GUI::FilamentMapBtnPanel::m_icon_path
private

◆ m_label

wxStaticText* Slic3r::GUI::FilamentMapBtnPanel::m_label
private

◆ m_selected

bool Slic3r::GUI::FilamentMapBtnPanel::m_selected {false}
private
101{false};

Referenced by OnPaint(), Select(), and UpdateStatus().


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