mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 02:22:17 +00:00
ENH: add badge for StaticBox and StaticGroup
Change-Id: I8b6e7938de524102809784b078de337da789cde8 Jira: STUDIO-8858 (cherry picked from commit 9733ef0144aebb0c6e711b7d56c36a3d187f628a)
This commit is contained in:
@@ -42,6 +42,8 @@ set(SLIC3R_GUI_SOURCES
|
||||
GUI/Widgets/LabeledStaticBox.hpp
|
||||
GUI/Widgets/StaticBox.cpp
|
||||
GUI/Widgets/StaticBox.hpp
|
||||
GUI/Widgets/StaticGroup.cpp
|
||||
GUI/Widgets/StaticGroup.hpp
|
||||
GUI/Widgets/ImageSwitchButton.cpp
|
||||
GUI/Widgets/ImageSwitchButton.hpp
|
||||
GUI/Widgets/SwitchButton.cpp
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
#include "Widgets/RadioGroup.hpp"
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StaticGroup.hpp"
|
||||
|
||||
#include "GUI_ObjectTable.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
@@ -917,6 +918,8 @@ Sidebar::Sidebar(Plater *parent)
|
||||
p->m_panel_printer_content->SetBackgroundColour(wxColour(255, 255, 255));
|
||||
|
||||
PlaterPresetComboBox* combo_printer = new PlaterPresetComboBox(p->m_panel_printer_content, Preset::TYPE_PRINTER);
|
||||
combo_printer->SetBorderWidth(0);
|
||||
combo_printer->ShowBadge(true);
|
||||
ScalableButton* edit_btn = new ScalableButton(p->m_panel_printer_content, wxID_ANY, "edit");
|
||||
edit_btn->SetToolTip(_L("Click to edit preset"));
|
||||
edit_btn->Bind(wxEVT_BUTTON, [this, combo_printer](wxCommandEvent)
|
||||
@@ -1009,9 +1012,10 @@ Sidebar::Sidebar(Plater *parent)
|
||||
p->m_dual_extruder_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
auto add_extruder = [this](int index, wxString const & title) {
|
||||
wxStaticBox * static_box = new wxStaticBox(p->m_panel_printer_content, wxID_ANY, title);
|
||||
StaticGroup *static_box = new StaticGroup(p->m_panel_printer_content, wxID_ANY, title);
|
||||
static_box->SetFont(Label::Body_10);
|
||||
static_box->SetForegroundColour("#909090");
|
||||
static_box->ShowBadge(true);
|
||||
wxStaticBoxSizer *static_box_sizer = new wxStaticBoxSizer(static_box, wxVERTICAL);
|
||||
// AMS count
|
||||
wxBoxSizer * ams_count_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -1357,6 +1361,7 @@ void Sidebar::create_printer_preset()
|
||||
void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filament_idx)
|
||||
{
|
||||
*combo = new PlaterPresetComboBox(p->m_panel_filament_content, Slic3r::Preset::TYPE_FILAMENT);
|
||||
(*combo)->ShowBadge(true);
|
||||
(*combo)->set_filament_idx(filament_idx);
|
||||
|
||||
auto combo_and_btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
@@ -22,7 +22,7 @@ StaticBox::StaticBox()
|
||||
, radius(8)
|
||||
{
|
||||
border_color = StateColor(
|
||||
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
|
||||
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
|
||||
std::make_pair(0x303A3C, (int) StateColor::Normal));
|
||||
}
|
||||
|
||||
@@ -110,6 +110,15 @@ wxColor StaticBox::GetParentBackgroundColor(wxWindow* parent)
|
||||
return *wxWHITE;
|
||||
}
|
||||
|
||||
void StaticBox::ShowBadge(bool show)
|
||||
{
|
||||
if (show)
|
||||
badge = ScalableBitmap(this, "badge", 18);
|
||||
else
|
||||
badge = ScalableBitmap {};
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void StaticBox::eraseEvent(wxEraseEvent& evt)
|
||||
{
|
||||
// for transparent background, but not work
|
||||
@@ -218,4 +227,9 @@ void StaticBox::doRender(wxDC& dc)
|
||||
lb += db; while (lb >= size.y) { ++b, lb -= size.y; } while (lb <= -size.y) { --b, lb += size.y; }
|
||||
}
|
||||
}
|
||||
|
||||
if (badge.bmp().IsOk()) {
|
||||
auto s = badge.bmp().GetScaledSize();
|
||||
dc.DrawBitmap(badge.bmp(), size.x - s.x, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ public:
|
||||
StaticBox(wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0);
|
||||
|
||||
bool Create(wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0);
|
||||
|
||||
void SetCornerRadius(double radius);
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
|
||||
static wxColor GetParentBackgroundColor(wxWindow * parent);
|
||||
|
||||
void ShowBadge(bool show);
|
||||
|
||||
protected:
|
||||
void eraseEvent(wxEraseEvent& evt);
|
||||
|
||||
@@ -55,6 +57,7 @@ protected:
|
||||
StateColor border_color;
|
||||
StateColor background_color;
|
||||
StateColor background_color2;
|
||||
ScalableBitmap badge;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
33
src/slic3r/GUI/Widgets/StaticGroup.cpp
Normal file
33
src/slic3r/GUI/Widgets/StaticGroup.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "StaticGroup.hpp"
|
||||
|
||||
StaticGroup::StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label)
|
||||
: wxStaticBox(parent, id, label)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
Bind(wxEVT_PAINT, &StaticGroup::OnPaint, this);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
void StaticGroup::ShowBadge(bool show)
|
||||
{
|
||||
if (show)
|
||||
badge = ScalableBitmap(this, "badge", 18);
|
||||
else
|
||||
badge = ScalableBitmap{};
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
||||
void StaticGroup::OnPaint(wxPaintEvent &evt)
|
||||
{
|
||||
wxStaticBox::OnPaint(evt);
|
||||
if (badge.bmp().IsOk()) {
|
||||
auto s = badge.bmp().GetScaledSize();
|
||||
wxPaintDC dc(this);
|
||||
dc.DrawBitmap(badge.bmp(), GetSize().x - s.x, 8);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
25
src/slic3r/GUI/Widgets/StaticGroup.hpp
Normal file
25
src/slic3r/GUI/Widgets/StaticGroup.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef slic3r_GUI_StaticGroup_hpp_
|
||||
#define slic3r_GUI_StaticGroup_hpp_
|
||||
|
||||
#include "../wxExtensions.hpp"
|
||||
|
||||
#include <wx/statbox.h>
|
||||
|
||||
class StaticGroup : public wxStaticBox
|
||||
{
|
||||
public:
|
||||
StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label);
|
||||
|
||||
public:
|
||||
void ShowBadge(bool show);
|
||||
|
||||
private:
|
||||
#ifdef __WXMSW__
|
||||
void OnPaint(wxPaintEvent &evt);
|
||||
#endif
|
||||
|
||||
private:
|
||||
ScalableBitmap badge;
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_StaticGroup_hpp_
|
||||
Reference in New Issue
Block a user