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

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

Inheritance diagram for Slic3r::GUI::PrintOptionItem:
Collaboration diagram for Slic3r::GUI::PrintOptionItem:

Public Member Functions

 PrintOptionItem (wxWindow *parent, std::vector< POItem > ops, std::string param="")
 ~PrintOptionItem ()
void setValue (std::string value)
std::string getValue () const
void update_options (std::vector< POItem > ops)
bool is_enabled () const
void enable (bool able)
void msw_rescale ()

Private Member Functions

void OnPaint (wxPaintEvent &event)
void render (wxDC &dc)
void on_left_down (wxMouseEvent &evt)
void doRender (wxDC &dc)

Private Attributes

ScalableBitmap m_selected_bk
ScalableBitmap m_selected_bk_dark
ScalableBitmap m_selected_disabled_bk
ScalableBitmap m_selected_disabled_bk_dark
std::vector< POItem > m_ops
std::string selected_key
std::string m_param
bool m_enable = true

Detailed Description

Constructor & Destructor Documentation

◆ PrintOptionItem()

Slic3r::GUI::PrintOptionItem::PrintOptionItem ( wxWindow * parent,
std::vector< POItem > ops,
std::string param = "" )
6729 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
6730{
6731#ifdef __WINDOWS__
6732 SetDoubleBuffered(true);
6733#endif //__WINDOWS__
6734
6735 m_param = param;
6736 SetBackgroundColour(PRINT_OPT_ITEM_BG_GRAY);
6737
6738 Bind(wxEVT_PAINT, &PrintOptionItem::OnPaint, this);
6739 Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); });
6740 Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_ARROW); });
6741 Bind(wxEVT_LEFT_DOWN, &PrintOptionItem::on_left_down, this);
6742
6743 m_selected_bk = ScalableBitmap(this, "print_options_bg", 22);
6744 m_selected_bk_dark = ScalableBitmap(this, "print_options_bg_dark", 22);
6745 m_selected_disabled_bk = ScalableBitmap(this, "print_options_bg_disabled", 22);
6746 m_selected_disabled_bk_dark = ScalableBitmap(this, "print_options_bg_disabled_dark", 22);
6747
6748 // update the options
6749 update_options(ops);
6750}
#define PRINT_OPT_ITEM_BG_GRAY
Definition SelectMachine.hpp:73
ScalableBitmap m_selected_bk
Definition SelectMachine.hpp:212
void on_left_down(wxMouseEvent &evt)
Definition SelectMachine.cpp:6779
void OnPaint(wxPaintEvent &event)
Definition SelectMachine.cpp:6752
ScalableBitmap m_selected_bk_dark
Definition SelectMachine.hpp:213
ScalableBitmap m_selected_disabled_bk
Definition SelectMachine.hpp:214
std::string m_param
Definition SelectMachine.hpp:218
void update_options(std::vector< POItem > ops)
Definition SelectMachine.hpp:180
ScalableBitmap m_selected_disabled_bk_dark
Definition SelectMachine.hpp:215

References m_param, m_selected_bk, m_selected_bk_dark, m_selected_disabled_bk, m_selected_disabled_bk_dark, on_left_down(), OnPaint(), PRINT_OPT_ITEM_BG_GRAY, and update_options().

Here is the call graph for this function:

◆ ~PrintOptionItem()

Slic3r::GUI::PrintOptionItem::~PrintOptionItem ( )
inline
175{};

Member Function Documentation

◆ doRender()

void Slic3r::GUI::PrintOptionItem::doRender ( wxDC & dc)
private
6812{
6813 auto size = GetSize();
6814 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
6815 dc.SetBrush(GetBackgroundColour());
6816 dc.DrawRoundedRectangle(0, 0, size.x, size.y, FromDIP(5));
6817
6818 auto left = FromDIP(4);
6819
6820 int selected = 0;
6821 for (const auto& entry : m_ops)
6822 {
6823 if (entry.key == selected_key)
6824 {
6825 break;
6826 }
6827 selected++;
6828 }
6829
6830 /*selected*/
6831 auto selected_left = selected * PRINT_OPT_WIDTH + FromDIP(4);
6832 if (m_enable) {
6833 if (!wxGetApp().dark_mode()) {
6834 dc.DrawBitmap(m_selected_bk.bmp(), selected_left, (size.y - m_selected_bk.GetBmpHeight()) / 2);
6835 } else {
6836 dc.DrawBitmap(m_selected_bk_dark.bmp(), selected_left, (size.y - m_selected_bk_dark.GetBmpHeight()) / 2);
6837 }
6838
6839 } else {
6840 if (!wxGetApp().dark_mode()) {
6841 dc.DrawBitmap(m_selected_disabled_bk.bmp(), selected_left, (size.y - m_selected_disabled_bk.GetBmpHeight()) / 2);
6842 } else {
6843 dc.DrawBitmap(m_selected_bk_dark.bmp(), selected_left, (size.y - m_selected_bk_dark.GetBmpHeight()) / 2);
6844 }
6845 }
6846
6847 for (auto it = m_ops.begin(); it != m_ops.end(); ++it)
6848 {
6849 auto text_key = it->key;
6850 auto text_value = it->value;
6851
6852 if (text_key == selected_key)
6853 {
6854 const wxColour& clr = m_enable ? StateColor::darkModeColorFor("#009688") : StateColor::darkModeColorFor(wxColour(144, 144, 144));
6855 dc.SetPen(wxPen(clr));
6856 dc.SetTextForeground(clr);
6857
6858 dc.SetFont(::Label::Body_13);
6859 auto text_size = dc.GetTextExtent(text_value);
6860 auto text_left = left + (PRINT_OPT_WIDTH - text_size.x) / 2;
6861 auto text_top = (size.y - text_size.y) / 2;
6862 dc.DrawText(text_value, wxPoint(text_left, text_top));
6863 }
6864 else
6865 {
6866 const wxColour& clr = m_enable ? StateColor::darkModeColorFor("#262E30") : StateColor::darkModeColorFor(wxColour(144, 144, 144));
6867 dc.SetPen(wxPen(clr));
6868 dc.SetTextForeground(clr);
6869
6870 dc.SetFont(::Label::Body_13);
6871 auto text_size = dc.GetTextExtent(text_value);
6872 auto text_left = left + (PRINT_OPT_WIDTH - text_size.x) / 2;
6873 auto text_top = (size.y - text_size.y) / 2;
6874 dc.DrawText(text_value, wxPoint(text_left, text_top));
6875 }
6876
6878 }
6879}
#define PRINT_OPT_WIDTH
Definition SelectMachine.hpp:170
static wxFont Body_13
Definition Label.hpp:54
std::vector< POItem > m_ops
Definition SelectMachine.hpp:216
bool m_enable
Definition SelectMachine.hpp:220
std::string selected_key
Definition SelectMachine.hpp:217
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
@ left
Definition MarchingSquares.hpp:188

References Label::Body_13, StateColor::darkModeColorFor(), m_enable, m_ops, m_selected_bk, m_selected_bk_dark, m_selected_disabled_bk, PRINT_OPT_WIDTH, and selected_key.

Referenced by OnPaint(), and render().

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

◆ enable()

void Slic3r::GUI::PrintOptionItem::enable ( bool able)
inline
195 {
196 if (m_enable != able)
197 {
198 m_enable = able;
199 Refresh();
200 }
201 }

References m_enable.

◆ getValue()

std::string Slic3r::GUI::PrintOptionItem::getValue ( ) const
inline
179{ return selected_key; }

References selected_key.

◆ is_enabled()

bool Slic3r::GUI::PrintOptionItem::is_enabled ( ) const
inline
194{ return m_enable; }

References m_enable.

◆ msw_rescale()

void Slic3r::GUI::PrintOptionItem::msw_rescale ( )
inline
203{ m_selected_bk.msw_rescale(); Refresh(); };

References m_selected_bk.

◆ on_left_down()

void Slic3r::GUI::PrintOptionItem::on_left_down ( wxMouseEvent & evt)
private
6780{
6781 if (!m_enable)
6782 {
6783 return;
6784 }
6785
6786 auto pos = ClientToScreen(evt.GetPosition());
6787 auto rect = ClientToScreen(wxPoint(0, 0));
6788 auto select_size = GetSize().x / m_ops.size();
6789
6790 int i = 0;
6791 for (const auto& entry : m_ops)
6792 {
6793 auto left_edge = rect.x + i * select_size;
6794 auto right_edge = rect.x + (i + 1) * select_size;
6795
6796 if (pos.x > left_edge && pos.x < right_edge)
6797 {
6798 selected_key = entry.key;
6799 }
6800 i++;
6801 }
6802
6803 wxCommandEvent event(EVT_SWITCH_PRINT_OPTION);
6804 event.SetString(selected_key);
6805 event.SetEventObject(GetParent());
6806 wxPostEvent(GetParent(), event);
6807
6808 Refresh();
6809}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References m_enable, m_ops, selected_key, and Slic3r::GUI::wxMouseEvent.

Referenced by PrintOptionItem().

Here is the caller graph for this function:

◆ OnPaint()

void Slic3r::GUI::PrintOptionItem::OnPaint ( wxPaintEvent & event)
private
6753{
6754 wxPaintDC dc(this);
6755 doRender(dc);
6756}
void doRender(wxDC &dc)
Definition SelectMachine.cpp:6811

References doRender().

Referenced by PrintOptionItem().

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

◆ render()

void Slic3r::GUI::PrintOptionItem::render ( wxDC & dc)
private
6759{
6760#ifdef __WXMSW__
6761 wxSize size = GetSize();
6762 wxMemoryDC memdc;
6763 wxBitmap bmp(size.x, size.y);
6764 memdc.SelectObject(bmp);
6765 memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
6766
6767 {
6768 wxGCDC dc2(memdc);
6769 doRender(dc2);
6770 }
6771
6772 memdc.SelectObject(wxNullBitmap);
6773 dc.DrawBitmap(bmp, 0, 0);
6774#else
6775 doRender(dc);
6776#endif
6777}

References doRender().

Here is the call graph for this function:

◆ setValue()

void Slic3r::GUI::PrintOptionItem::setValue ( std::string value)
6882{
6883 if (selected_key != value) {
6884 selected_key = value;
6885 Refresh();
6886 }
6887}

References selected_key.

◆ update_options()

void Slic3r::GUI::PrintOptionItem::update_options ( std::vector< POItem > ops)
inline
180 {
181 if (m_ops != ops)
182 {
183 m_ops = ops;
184 selected_key = "";
185
186 auto width = ops.size() * PRINT_OPT_WIDTH + FromDIP(8);
187 auto height = FromDIP(22) + FromDIP(8);
188 SetMinSize(wxSize(width, height));
189 SetMaxSize(wxSize(width, height));
190 Refresh();
191 }
192 };
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References m_ops, PRINT_OPT_WIDTH, and selected_key.

Referenced by PrintOptionItem().

Here is the caller graph for this function:

Member Data Documentation

◆ m_enable

bool Slic3r::GUI::PrintOptionItem::m_enable = true
private

◆ m_ops

std::vector<POItem> Slic3r::GUI::PrintOptionItem::m_ops
private

◆ m_param

std::string Slic3r::GUI::PrintOptionItem::m_param
private

Referenced by PrintOptionItem().

◆ m_selected_bk

ScalableBitmap Slic3r::GUI::PrintOptionItem::m_selected_bk
private

◆ m_selected_bk_dark

ScalableBitmap Slic3r::GUI::PrintOptionItem::m_selected_bk_dark
private

Referenced by PrintOptionItem(), and doRender().

◆ m_selected_disabled_bk

ScalableBitmap Slic3r::GUI::PrintOptionItem::m_selected_disabled_bk
private

Referenced by PrintOptionItem(), and doRender().

◆ m_selected_disabled_bk_dark

ScalableBitmap Slic3r::GUI::PrintOptionItem::m_selected_disabled_bk_dark
private

Referenced by PrintOptionItem().

◆ selected_key

std::string Slic3r::GUI::PrintOptionItem::selected_key
private

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