ENH: add badge for StaticBox and StaticGroup
Change-Id: I8b6e7938de524102809784b078de337da789cde8 Jira: STUDIO-8858
This commit is contained in:
parent
557f5dcbbe
commit
9733ef0144
|
@ -0,0 +1,4 @@
|
|||
<svg width="19" height="18" viewBox="0 0 19 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.410156 0H18.4102V18L9.09255 8.93403L0.410156 0Z" fill="#00AE42"/>
|
||||
<path d="M16.7686 3.1416C16.9574 3.3304 16.9574 3.63568 16.7686 3.82247L11.4662 9.12687C11.2774 9.31567 10.9721 9.31567 10.7853 9.12687L8.05175 6.39534C7.86296 6.20654 7.86296 5.90125 8.05175 5.71446C8.24055 5.52767 8.54584 5.52566 8.73263 5.71446L11.1227 8.10455L16.0857 3.1416C16.2745 2.9528 16.5798 2.9528 16.7666 3.1416H16.7686Z" fill="white"/>
|
||||
</svg>
|
After Width: | Height: | Size: 530 B |
|
@ -38,6 +38,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/Widgets/ScrolledWindow.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
|
||||
|
|
|
@ -120,6 +120,7 @@
|
|||
#include "Widgets/RadioBox.hpp"
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/StaticGroup.hpp"
|
||||
|
||||
#include "GUI_ObjectTable.hpp"
|
||||
#include "libslic3r/Thread.hpp"
|
||||
|
@ -882,6 +883,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)
|
||||
|
@ -975,9 +978,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);
|
||||
// Nozzle
|
||||
wxBoxSizer * nozzle_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -1329,6 +1333,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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
};
|
||||
|
|
|
@ -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
|
|
@ -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_
|
Loading…
Reference in New Issue