BBL Port Color Mix Base

This commit is contained in:
Ian Bassi
2026-08-23 22:11:48 +08:00
committed by SoftFever
parent 550e234a37
commit 8fea099d99
75 changed files with 34174 additions and 51 deletions
+22 -6
View File
@@ -87,10 +87,18 @@ void ComboBox::SetSelection(int n)
return;
drop.SetSelection(n);
SetLabel(drop.GetValue());
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk())
SetIcon(items[drop.selection].icon_textctrl);
else
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk()) {
if (m_keep_drop_arrow) {
SetIcon("drop_down");
SetIcon_1(items[drop.selection].icon_textctrl);
} else {
SetIcon(items[drop.selection].icon_textctrl);
}
} else {
SetIcon("drop_down");
if (m_keep_drop_arrow)
SetIcon_1(wxNullBitmap);
}
if (drop.selection >= 0) {
SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
@@ -120,10 +128,18 @@ void ComboBox::SetValue(const wxString &value)
{
drop.SetValue(value);
SetLabel(value);
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk())
SetIcon(items[drop.selection].icon_textctrl);
else
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk()) {
if (m_keep_drop_arrow) {
SetIcon("drop_down");
SetIcon_1(items[drop.selection].icon_textctrl);
} else {
SetIcon(items[drop.selection].icon_textctrl);
}
} else {
SetIcon("drop_down");
if (m_keep_drop_arrow)
SetIcon_1(wxNullBitmap);
}
if (drop.selection >= 0) {
SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
+6
View File
@@ -16,6 +16,7 @@ class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
bool drop_down = false;
bool text_off = false;
bool is_replace_text_to_image = false;
bool m_keep_drop_arrow = false; // When true, item icon goes to icon_1, keeping drop_down arrow
wxString replace_text;
wxString image_for_text;
@@ -31,6 +32,11 @@ public:
DropDown & GetDropDown() { return drop; }
// When true, item icon is shown as icon_1 (secondary), preserving drop_down arrow.
// Note: item bitmaps are set via raw wxBitmap (not ScalableBitmap), so they won't
// auto-rescale on DPI change. Caller should recreate items after DPI change.
void SetKeepDropArrow(bool keep) { m_keep_drop_arrow = keep; }
virtual bool SetFont(wxFont const & font) override;
public:
+4 -1
View File
@@ -360,6 +360,9 @@ void DropDown::render(wxDC &dc)
for (int i = 0; i < items.size(); ++i) {
auto &item = items[i];
int states2 = states;
// Dimmed items stay selectable but render greyed out (used by the mixed-filament
// dialog to show components that are already consumed by another mix).
bool is_dimmed = (item.style & DD_ITEM_STYLE_DIMMED) != 0;
if ((item.style & DD_ITEM_STYLE_DISABLED) != 0)
states2 &= ~StateColor::Enabled;
// Skip by group
@@ -427,7 +430,7 @@ void DropDown::render(wxDC &dc)
}
pt.y += (rcContent.height - textSize.y) / 2;
dc.SetFont(GetFont());
dc.SetTextForeground(text_color.colorForStates(states2));
dc.SetTextForeground(is_dimmed ? wxColour(0xCE, 0xCE, 0xCE) : text_color.colorForStates(states2));
dc.DrawText(text, pt);
if (group.IsEmpty() && !item.group_key.IsEmpty()) {
auto szBmp = arrow_bitmap.GetBmpSize();
+1
View File
@@ -13,6 +13,7 @@
#define DD_ITEM_STYLE_SPLIT_ITEM 0x0001 // ----text----, text with horizontal line arounds
#define DD_ITEM_STYLE_DISABLED 0x0002 // ----text----, text with horizontal line arounds
#define DD_ITEM_STYLE_DIMMED 0x0004 // gray text, but still selectable
wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
+16
View File
@@ -9,6 +9,8 @@
#include "../GUI_Utils.hpp"
#endif
wxDEFINE_EVENT(EVT_SPINCTRL_TEXT, wxCommandEvent);
BEGIN_EVENT_TABLE(SpinInput, StaticBox)
EVT_KEY_DOWN(SpinInput::keyPressed)
@@ -74,6 +76,7 @@ void SpinInput::Create(wxWindow *parent,
state_handler.attach_child(text_ctrl);
text_ctrl->Bind(wxEVT_KILL_FOCUS, &SpinInput::onTextLostFocus, this);
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
text_ctrl->Bind(wxEVT_TEXT, &SpinInput::onTextChanged, this);
text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, this);
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
button_inc = createButton(true);
@@ -300,6 +303,19 @@ void SpinInput::onTextEnter(wxCommandEvent &event)
ProcessEventLocally(event);
}
void SpinInput::onTextChanged(wxCommandEvent &event)
{
long value;
if (text_ctrl->GetValue().ToLong(&value)) {
wxCommandEvent e(EVT_SPINCTRL_TEXT, GetId());
e.SetEventObject(this);
e.SetInt((int) value);
e.SetString(text_ctrl->GetValue());
GetEventHandler()->ProcessEvent(e);
}
event.Skip();
}
void SpinInput::mouseWheelMoved(wxMouseEvent &event)
{
auto delta = event.GetWheelRotation() < 0 ? 1 : -1;
+5
View File
@@ -9,6 +9,10 @@
class Button;
// Fired on every keystroke that leaves a parseable integer in the field, so callers can
// react live rather than only on commit (wxEVT_SPINCTRL) or Enter. Ported from BambuStudio.
wxDECLARE_EVENT(EVT_SPINCTRL_TEXT, wxCommandEvent);
class SpinInput : public wxNavigationEnabled<StaticBox>
{
wxSize labelSize;
@@ -98,6 +102,7 @@ private:
void keyPressed(wxKeyEvent& event);
void onTimer(wxTimerEvent &evnet);
void onTextLostFocus(wxEvent &event);
void onTextChanged(wxCommandEvent &event);
void onTextEnter(wxCommandEvent &event);
void sendSpinEvent();
+9
View File
@@ -139,6 +139,15 @@ void TextInput::SetIcon_1(const wxString &icon) {
Rescale();
}
// Set icon_1 from a raw bitmap. Note: won't auto-rescale on DPI change
// since ScalableBitmap::name() will be empty. Caller should re-set after DPI change.
void TextInput::SetIcon_1(const wxBitmap &icon) {
this->icon_1 = ScalableBitmap();
if (icon.IsOk())
this->icon_1.bmp() = icon;
Rescale();
}
void TextInput::SetLabelColor(StateColor const &color)
{
label_color = color;
+1
View File
@@ -54,6 +54,7 @@ public:
void SetIcon(const wxString & icon);
void SetIcon_1(const wxString &icon);
void SetIcon_1(const wxBitmap &icon);
void SetLabelColor(StateColor const &color);