mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
NEW:ams control support for more gradient colors
Change-Id: I3e7e7e1f340a443200b9225b142f6398b4824513
This commit is contained in:
parent
e3d89f2154
commit
ee2ef44dc7
5 changed files with 72 additions and 1 deletions
|
@ -536,6 +536,13 @@ void AMSMaterialsSetting::set_color(wxColour color)
|
|||
m_clr_picker->set_color(color);
|
||||
}
|
||||
|
||||
void AMSMaterialsSetting::set_colors(std::vector<wxColour> colors)
|
||||
{
|
||||
//m_clrData->SetColour(color);
|
||||
m_clr_picker->set_colors(colors);
|
||||
}
|
||||
|
||||
|
||||
void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event)
|
||||
{
|
||||
unsigned int color_num = event.GetInt();
|
||||
|
@ -836,6 +843,7 @@ ColorPicker::ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos /*=
|
|||
|
||||
wxWindow::Create(parent, id, pos, size);
|
||||
Bind(wxEVT_PAINT, &ColorPicker::paintEvent, this);
|
||||
m_bitmap_border = create_scaled_bitmap("color_picker_border", nullptr, 25);
|
||||
}
|
||||
|
||||
ColorPicker::~ColorPicker(){}
|
||||
|
@ -846,6 +854,12 @@ void ColorPicker::set_color(wxColour col)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void ColorPicker::set_colors(std::vector<wxColour> cols)
|
||||
{
|
||||
m_cols = cols;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void ColorPicker::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
@ -894,6 +908,24 @@ void ColorPicker::doRender(wxDC& dc)
|
|||
dc.SetPen(wxPen(wxColour(0x6B6B6B)));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawCircle(size.x / 2, size.x / 2, radius);
|
||||
|
||||
if (m_cols.size() > 1) {
|
||||
int left = FromDIP(0);
|
||||
float total_width = size.x;
|
||||
int gwidth = std::round(total_width / (m_cols.size() - 1));
|
||||
|
||||
for (int i = 0; i < m_cols.size() - 1; i++) {
|
||||
|
||||
if ((left + gwidth) > (size.x)) {
|
||||
gwidth = size.x - left;
|
||||
}
|
||||
|
||||
auto rect = wxRect(left, 0, gwidth, size.y);
|
||||
dc.GradientFillLinear(rect, m_cols[i], m_cols[i + 1], wxEAST);
|
||||
left += gwidth;
|
||||
}
|
||||
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue