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

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

Inheritance diagram for Slic3r::GUI::ColorPanel:
Collaboration diagram for Slic3r::GUI::ColorPanel:

Public Member Functions

 ColorPanel (DragDropPanel *parent, const wxColour &color, int filament_id, const std::string &type)
wxColour GetColor () const
int GetFilamentId () const
std::string GetType () const

Private Member Functions

void OnLeftDown (wxMouseEvent &event)
void OnLeftUp (wxMouseEvent &event)
void OnPaint (wxPaintEvent &event)

Private Attributes

DragDropPanel * m_parent
wxColor m_color
std::string m_type
int m_filament_id

Detailed Description

Constructor & Destructor Documentation

◆ ColorPanel()

Slic3r::GUI::ColorPanel::ColorPanel ( DragDropPanel * parent,
const wxColour & color,
int filament_id,
const std::string & type )
121 : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(32, 40), wxBORDER_NONE), m_parent(parent), m_color(color), m_filament_id(filament_id), m_type(type)
122{
123 Bind(wxEVT_LEFT_DOWN, &ColorPanel::OnLeftDown, this);
124 Bind(wxEVT_LEFT_UP, &ColorPanel::OnLeftUp, this);
125 Bind(wxEVT_PAINT, &ColorPanel::OnPaint, this);
126}
void OnLeftUp(wxMouseEvent &event)
Definition DragDropPanel.cpp:134
DragDropPanel * m_parent
Definition DragDropPanel.hpp:73
void OnLeftDown(wxMouseEvent &event)
Definition DragDropPanel.cpp:128
void OnPaint(wxPaintEvent &event)
Definition DragDropPanel.cpp:136
std::string m_type
Definition DragDropPanel.hpp:75
int m_filament_id
Definition DragDropPanel.hpp:76
wxColor m_color
Definition DragDropPanel.hpp:74

References m_color, m_filament_id, m_parent, m_type, OnLeftDown(), OnLeftUp(), and OnPaint().

Here is the call graph for this function:

Member Function Documentation

◆ GetColor()

wxColour Slic3r::GUI::ColorPanel::GetColor ( ) const
inline
64{ return m_color; }

References m_color.

Referenced by OnLeftDown().

Here is the caller graph for this function:

◆ GetFilamentId()

int Slic3r::GUI::ColorPanel::GetFilamentId ( ) const
inline
65{ return m_filament_id; }

References m_filament_id.

Referenced by Slic3r::GUI::DragDropPanel::GetAllFilaments(), and OnLeftDown().

Here is the caller graph for this function:

◆ GetType()

std::string Slic3r::GUI::ColorPanel::GetType ( ) const
inline
66{ return m_type; }

References m_type.

Referenced by OnLeftDown().

Here is the caller graph for this function:

◆ OnLeftDown()

void Slic3r::GUI::ColorPanel::OnLeftDown ( wxMouseEvent & event)
private
129{
130 m_parent->set_is_draging(true);
131 m_parent->DoDragDrop(this, GetColor(), GetType(), GetFilamentId());
132}
int GetFilamentId() const
Definition DragDropPanel.hpp:65
wxColour GetColor() const
Definition DragDropPanel.hpp:64
std::string GetType() const
Definition DragDropPanel.hpp:66

References GetColor(), GetFilamentId(), GetType(), m_parent, and Slic3r::GUI::wxMouseEvent.

Referenced by ColorPanel().

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

◆ OnLeftUp()

void Slic3r::GUI::ColorPanel::OnLeftUp ( wxMouseEvent & event)
private
134{ m_parent->set_is_draging(false); }

References m_parent, and Slic3r::GUI::wxMouseEvent.

Referenced by ColorPanel().

Here is the caller graph for this function:

◆ OnPaint()

void Slic3r::GUI::ColorPanel::OnPaint ( wxPaintEvent & event)
private
137{
138 wxPaintDC dc(this);
139 wxSize size = GetSize();
140 // If it matches the parent's width, it will not be displayed completely
141 int svg_size = size.GetWidth();
142 int type_label_height = FromDIP(10);
143 wxString type_label(m_type);
144 int type_label_margin = FromDIP(3);
145
146 std::string replace_color = m_color.GetAsString(wxC2S_HTML_SYNTAX).ToStdString();
147 std::string svg_name = "outlined_rect";
148 if (replace_color == "#FFFFFF00") {
149 svg_name = "outlined_rect_transparent";
150 }
151 static Slic3r::GUI::BitmapCache cache;
152 wxBitmap* bmp = cache.load_svg(svg_name, 0, svg_size, false, false, replace_color, 0.f);
153 //wxBitmap bmp = ScalableBitmap(this, svg_name, svg_size, false, false, false, { replace_color }).bmp();
154 // ScalableBitmap is not drawn at position (0, 0) by default, why?
155 dc.DrawBitmap(*bmp, wxPoint(0,0));
156
157 //dc.SetPen(wxPen(*wxBLACK, 1));
158 //dc.DrawRectangle(0, 0, svg_size, svg_size);
159
160 wxString label = wxString::Format(wxT("%d"), m_filament_id);
161 dc.SetTextForeground(m_color.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK); // set text color
162 dc.DrawLabel(label, wxRect(0, 0, svg_size, svg_size), wxALIGN_CENTER);
163
164 if(m_parent)
165 dc.SetTextForeground(this->m_parent->GetBackgroundColour().GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
166 else
167 dc.SetTextForeground(*wxBLACK);
168 if (type_label.length() > 4) {
169 // text is too long
170 wxString first = type_label.Mid(0, 4);
171 wxString rest = type_label.Mid(4);
172 dc.DrawLabel(first, wxRect(0, svg_size + type_label_margin, svg_size, type_label_height), wxALIGN_CENTER);
173 dc.DrawLabel(rest, wxRect(0, svg_size + type_label_height + type_label_margin, svg_size, type_label_height), wxALIGN_CENTER);
174 }else {
175 dc.DrawLabel(type_label, wxRect(0, svg_size + type_label_margin, svg_size, type_label_height), wxALIGN_CENTER);
176 }
177}
wxBitmap * load_svg(const std::string &bitmap_key, unsigned width=0, unsigned height=0, const bool grayscale=false, const bool dark_mode=false, const std::string &new_color="", const float scale_in_center=0.f)
Definition BitmapCache.cpp:326

References Slic3r::GUI::BitmapCache::load_svg(), m_color, m_filament_id, m_parent, and m_type.

Referenced by ColorPanel().

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

Member Data Documentation

◆ m_color

wxColor Slic3r::GUI::ColorPanel::m_color
private

Referenced by ColorPanel(), GetColor(), and OnPaint().

◆ m_filament_id

int Slic3r::GUI::ColorPanel::m_filament_id
private

Referenced by ColorPanel(), GetFilamentId(), and OnPaint().

◆ m_parent

DragDropPanel* Slic3r::GUI::ColorPanel::m_parent
private

◆ m_type

std::string Slic3r::GUI::ColorPanel::m_type
private

Referenced by ColorPanel(), GetType(), and OnPaint().


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