Add a OrcaSlicer badge in the thumbnail preview for published 3MF projects. Add a visual indicator in the publish dialog to show that something in the section is toggled

This commit is contained in:
Lam Wei Lun
2026-09-02 12:38:27 +08:00
parent f5984e7523
commit 4654d24f6f
8 changed files with 114 additions and 2 deletions
+35
View File
@@ -162,6 +162,15 @@ void Button::SetCenter(bool isCenter)
{
this->isCenter = isCenter; }
void Button::SetIndicator(bool on)
{
if (m_show_indicator == on)
return;
m_show_indicator = on;
messureSize();
Refresh();
}
void Button::SetVertical(bool vertical)
{
this->vertical = vertical;
@@ -324,6 +333,13 @@ void Button::render(wxDC& dc)
szContent.x -= d;
}
}
if (m_show_indicator) {
const int dot = FromDIP(6);
if (vertical)
szContent.y += dot + FromDIP(6);
else
szContent.x += dot + FromDIP(6);
}
// move to center
wxRect rcContent = { {0, 0}, size };
if (isCenter) {
@@ -364,6 +380,17 @@ void Button::render(wxDC& dc)
#endif
dc.DrawText(text, pt);
}
if (m_show_indicator) {
const int dot = FromDIP(6); // diameter
wxPoint dot_pt;
dot_pt.x = pt.x + (text.IsEmpty() ? 0 : textSize.x) + FromDIP(6) + dot / 2;
// Centre on the content vertically; a bitmap-only (empty-label) tab has no text row.
dot_pt.y = text.IsEmpty() ? rcContent.y + rcContent.height / 2 : pt.y + textSize.y / 2;
const wxColour c = StateColor::darkModeColorFor(m_indicator_color);
dc.SetBrush(wxBrush(c));
dc.SetPen(wxPen(c));
dc.DrawCircle(dot_pt, dot / 2);
}
}
void Button::messureSize()
@@ -388,6 +415,14 @@ void Button::messureSize()
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}
}
if (m_show_indicator) {
// Indicator dot sits to the right of the label: its diameter plus the gap from the text.
const int dot = FromDIP(6);
if (vertical)
szContent.y += dot + FromDIP(6);
else
szContent.x += dot + FromDIP(6);
}
wxSize size = szContent + paddingSize * 2;
if (minSize.GetHeight() > 0)
size.SetHeight(minSize.GetHeight());
+7
View File
@@ -4,6 +4,7 @@
#include "../wxExtensions.hpp"
#include "StaticBox.hpp"
#include <wx/tipwin.h>
#include <wx/colour.h>
class ButtonProps
{
@@ -44,6 +45,8 @@ class Button : public StaticBox
bool canFocus = true;
bool isCenter = true;
bool vertical = false;
bool m_show_indicator = false;
wxColour m_indicator_color = wxColour("#009688");
static const int buttonWidth = 200;
static const int buttonHeight = 50;
@@ -75,6 +78,10 @@ public:
void SetSelected(bool selected = true) { m_selected = selected; }
// Show a small coloured dot to the right of the label (used by TabCtrl tabs to flag that
// the tab's category has a selected/toggled setting).
void SetIndicator(bool on);
// Only meant to be used by inspector, not public API
ButtonStyle GetStyle() const { return m_style; }
ButtonType GetType() const { return m_type; }
+8
View File
@@ -171,6 +171,14 @@ void TabCtrl::SetItemBitmap(unsigned int item, const wxBitmap& bitmap)
relayout();
}
void TabCtrl::SetItemIndicator(unsigned int item, bool on)
{
if (item >= btns.size())
return;
btns[item]->SetIndicator(on);
relayout();
}
bool TabCtrl::GetItemBold(unsigned int item) const
{
if (item >= btns.size())
+3
View File
@@ -46,6 +46,9 @@ public:
void SetItemText(unsigned int item, wxString const& value);
void SetItemBitmap(unsigned int item, const wxBitmap& bitmap);
// Show/hide the small "has selection" dot next to a tab's text.
void SetItemIndicator(unsigned int item, bool on);
bool GetItemBold(unsigned int item) const;
void SetItemBold(unsigned int item, bool bold);