14#include <gtkmm/adjustment.h>
16#include <gtkmm/label.h>
44 _min = g_ascii_strtod(
min,
nullptr);
49 _max = g_ascii_strtod(
max,
nullptr);
72 g_warning(
"Invalid value ('%s') for appearance of parameter '%s' in extension '%s'",
109 _value = g_ascii_strtod(in.c_str(),
nullptr);
113class ParamFloatAdjustment :
public Gtk::Adjustment {
116 sigc::signal<void ()> *_changeSignal;
120 ParamFloatAdjustment(
ParamFloat *param, sigc::signal<
void ()> *changeSignal)
121 :
Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0)
123 , _changeSignal(changeSignal) {
124 this->set_value(_pref->
get());
125 this->signal_value_changed().connect(sigc::mem_fun(*
this, &ParamFloatAdjustment::val_changed));
132 static Glib::RefPtr<ParamFloatAdjustment>
create(ParamFloat* param, sigc::signal<
void ()>* changeSignal) {
133 return Glib::make_refptr_for_instance(
new ParamFloatAdjustment(param, changeSignal));
144void ParamFloatAdjustment::val_changed()
146 _pref->
set(this->get_value());
147 if (_changeSignal !=
nullptr) {
148 _changeSignal->emit();
166 auto fadjust = ParamFloatAdjustment::create(
this, changeSignal);
171 if (
_text !=
nullptr)
173 auto const scale = Gtk::make_managed<UI::Widget::SpinScale>(text, fadjust,
_precision);
174 scale->set_size_request(400, -1);
175 scale->set_visible(
true);
181 auto const label = Gtk::make_managed<Gtk::Label>(
_text, Gtk::Align::START);
182 label->set_visible(
true);
185 auto const spin = Gtk::make_managed<Inkscape::UI::Widget::SpinButton>(fadjust, 0.1,
_precision);
186 spin->set_visible(
true);
190 hbox->set_visible(
true);
The object that is the basis for the Extension system.
char const * get_id() const
Get the ID of this extension - not a copy don't delete!
A class to represent the parameter of an extension.
char * _name
The name of this parameter.
static constexpr int GUI_PARAM_WIDGETS_SPACING
Recommended spacing between the widgets making up a single Parameter (e.g.
Glib::ustring pref_name() const
Build preference name for the current parameter.
char * _text
Parameter text to show as the GUI label.
AppearanceMode _mode
appearance mode
double get() const
Returns _value.
double set(double in)
A function to set the _value.
ParamFloat(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext)
void string_to_value(const std::string &in) override
Sets the current value of the parameter from a string.
std::string value_to_string() const override
Gets the current value of the parameter in a string form.
Gtk::Widget * get_widget(sigc::signal< void()> *changeSignal) override
Creates a Float Adjustment for a float parameter.
double _value
Internal value.
int _precision
numeric precision (i.e.
Preference storage class.
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
void setDouble(Glib::ustring const &pref_path, double value)
Set a floating point value.
Interface for refcounted XML nodes.
virtual Node * firstChild()=0
Get the first child of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual char const * content() const =0
Get the content of a text or comment node.
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
void pack_start(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the start of box.
Glib::ustring format_classic(T const &... args)
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
Singleton class to access the preferences file in a convenient way.
Derived from and replaces SpinSlider.