mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Add filament color next to tab button in filament setting
This commit is contained in:
@@ -80,6 +80,7 @@ bool Button::SetFont(const wxFont& font)
|
||||
|
||||
void Button::SetIcon(const wxString& icon)
|
||||
{
|
||||
custom_icon = wxNullBitmap;
|
||||
auto tmpBitmap = ScalableBitmap(this, icon.ToStdString(), this->active_icon.px_cnt());
|
||||
if (!icon.IsEmpty()) {
|
||||
//BBS set button icon default size to 20
|
||||
@@ -95,6 +96,13 @@ void Button::SetIcon(const wxString& icon)
|
||||
}
|
||||
}
|
||||
|
||||
void Button::SetBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
custom_icon = bitmap;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Button::SetInactiveIcon(const wxString &icon)
|
||||
{
|
||||
if (!icon.IsEmpty()) {
|
||||
@@ -311,7 +319,8 @@ void Button::render(wxDC& dc)
|
||||
}
|
||||
}
|
||||
auto szContent = textSize;
|
||||
if (icon.bmp().IsOk()) {
|
||||
const bool has_custom_icon = custom_icon.IsOk();
|
||||
if (has_custom_icon || icon.bmp().IsOk()) {
|
||||
if (szContent.y > 0) {
|
||||
//BBS norrow size between text and icon
|
||||
if (vertical)
|
||||
@@ -319,7 +328,7 @@ void Button::render(wxDC& dc)
|
||||
else
|
||||
szContent.x += spacing;
|
||||
}
|
||||
szIcon = icon.GetBmpSize();
|
||||
szIcon = has_custom_icon ? custom_icon.GetSize() : icon.GetBmpSize();
|
||||
if (vertical) {
|
||||
szContent.y += szIcon.y;
|
||||
if (szIcon.x > szContent.x) szContent.x = szIcon.x;
|
||||
@@ -342,12 +351,12 @@ void Button::render(wxDC& dc)
|
||||
}
|
||||
// start draw
|
||||
wxPoint pt = rcContent.GetLeftTop();
|
||||
if (icon.bmp().IsOk()) {
|
||||
if (has_custom_icon || icon.bmp().IsOk()) {
|
||||
if (vertical)
|
||||
pt.x += (rcContent.width - szIcon.x) / 2;
|
||||
else
|
||||
pt.y += (rcContent.height - szIcon.y) / 2;
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
dc.DrawBitmap(has_custom_icon ? custom_icon : icon.bmp(), pt);
|
||||
//BBS norrow size between text and icon
|
||||
if (vertical) {
|
||||
pt.y += szIcon.y + spacing;
|
||||
@@ -380,7 +389,7 @@ void Button::messureSize()
|
||||
wxClientDC dc(this);
|
||||
dc.GetTextExtent(GetLabel(), &textSize.width, &textSize.height, &textSize.x, &textSize.y);
|
||||
wxSize szContent = textSize.GetSize();
|
||||
if (this->active_icon.bmp().IsOk()) {
|
||||
if (custom_icon.IsOk() || this->active_icon.bmp().IsOk()) {
|
||||
if (szContent.y > 0) {
|
||||
//BBS norrow size between text and icon
|
||||
if (vertical)
|
||||
@@ -388,7 +397,7 @@ void Button::messureSize()
|
||||
else
|
||||
szContent.x += 5;
|
||||
}
|
||||
wxSize szIcon = this->active_icon.GetBmpSize();
|
||||
wxSize szIcon = custom_icon.IsOk() ? custom_icon.GetSize() : this->active_icon.GetBmpSize();
|
||||
if (vertical) {
|
||||
szContent.y += szIcon.y;
|
||||
if (szIcon.x > szContent.x) szContent.x = szIcon.x;
|
||||
|
||||
@@ -35,6 +35,7 @@ class Button : public StaticBox
|
||||
wxSize paddingSize;
|
||||
ScalableBitmap active_icon;
|
||||
ScalableBitmap inactive_icon;
|
||||
wxBitmap custom_icon;
|
||||
|
||||
StateColor text_color;
|
||||
|
||||
@@ -61,6 +62,7 @@ public:
|
||||
bool SetFont(const wxFont& font) override;
|
||||
|
||||
void SetIcon(const wxString& icon);
|
||||
void SetBitmap(const wxBitmap& bitmap);
|
||||
|
||||
void SetInactiveIcon(const wxString& icon);
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ void TabCtrl::Rescale()
|
||||
{
|
||||
for (auto & b : btns)
|
||||
b->Rescale();
|
||||
relayout();
|
||||
}
|
||||
|
||||
bool TabCtrl::SetFont(wxFont const& font)
|
||||
@@ -117,6 +118,13 @@ int TabCtrl::AppendItem(const wxString &item,
|
||||
return btns.size() - 1;
|
||||
}
|
||||
|
||||
int TabCtrl::AppendItem(const wxString& item, const wxBitmap& bitmap, void* clientData)
|
||||
{
|
||||
const int index = AppendItem(item, -1, -1, clientData);
|
||||
SetItemBitmap(index, bitmap);
|
||||
return index;
|
||||
}
|
||||
|
||||
bool TabCtrl::DeleteItem(int item)
|
||||
{
|
||||
if (item < 0 || item >= btns.size()) {
|
||||
@@ -170,6 +178,14 @@ void TabCtrl::SetItemText(unsigned int item, wxString const &value)
|
||||
btns[item]->SetLabel(value);
|
||||
}
|
||||
|
||||
void TabCtrl::SetItemBitmap(unsigned int item, const wxBitmap& bitmap)
|
||||
{
|
||||
if (item >= btns.size())
|
||||
return;
|
||||
btns[item]->SetBitmap(bitmap);
|
||||
relayout();
|
||||
}
|
||||
|
||||
bool TabCtrl::GetItemBold(unsigned int item) const
|
||||
{
|
||||
if (item >= btns.size()) return false;
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
|
||||
public:
|
||||
int AppendItem(const wxString &item, int image = -1, int selImage = -1, void *clientData = nullptr);
|
||||
int AppendItem(const wxString &item, const wxBitmap& bitmap, void *clientData = nullptr);
|
||||
|
||||
bool DeleteItem(int item);
|
||||
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
|
||||
wxString GetItemText(unsigned int item) const;
|
||||
void SetItemText(unsigned int item, wxString const &value);
|
||||
void SetItemBitmap(unsigned int item, const wxBitmap& bitmap);
|
||||
|
||||
bool GetItemBold(unsigned int item) const;
|
||||
void SetItemBold(unsigned int item, bool bold);
|
||||
|
||||
Reference in New Issue
Block a user