feat: sidebar plugin config UI

This commit is contained in:
Ian Chua
2026-07-13 20:39:41 +08:00
parent 0c69b9982d
commit 5b3e1b921c
27 changed files with 2263 additions and 290 deletions
+45
View File
@@ -32,6 +32,10 @@
#define wxMSW false
#endif
// Orca's styled button (Widgets/Button.hpp), used by PluginConfigField. Declared at global scope,
// which is where the widget lives.
class Button;
namespace Slic3r { namespace GUI {
class Field;
@@ -517,6 +521,47 @@ private:
std::function<std::string()> m_selector;
};
// A settings row whose value is a raw JSON document that nobody should type by hand: the row shows a
// button, the button opens PluginsConfigDialog, and the document it hands back becomes the field's
// value. Routing the edit through the ordinary Field value/on_change_field path is what earns the row
// the same dirty state and revert arrow as every other setting — the dialog itself never touches the
// preset.
class PluginConfigField : public Field {
using Field::Field;
public:
PluginConfigField(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
PluginConfigField(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
~PluginConfigField() {}
void BUILD() override;
// Which preset's capabilities the dialog lists. Supplied by the option group, which already
// carries its Tab's type; an int for the same reason OptionsGroup::m_config_type is one — it
// keeps Preset.hpp out of this header.
void set_preset_type(int type) { m_preset_type = type; }
void set_value(const boost::any& value, bool change_event = false) override;
boost::any& get_value() override;
void enable() override;
void disable() override;
// Window-field: the button is the whole field, so it is the window the option group sizes and
// positions (the ColourPicker idiom). A container panel would be sized but never laid out.
wxWindow* getWindow() override { return window; }
void msw_rescale() override;
private:
void open_dialog();
void update_button_label();
wxWindow* window { nullptr }; // == m_button; the base class hands this to the option group
::Button* m_button { nullptr };
std::string m_json; // the option's raw text; "" when the preset overrides nothing
int m_preset_type { -1 };
};
class ColourPicker : public Field {
using Field::Field;