30#include <glibmm/i18n.h>
31#include <gtkmm/adjustment.h>
33#include <gtkmm/label.h>
34#include <gtkmm/togglebutton.h>
64 , _tracker{
std::make_unique<UI::Widget::UnitTracker>(
Util::UNIT_TYPE_LINEAR)}
71 {3, _(
"triangle/tri-star")},
72 {4, _(
"square/quad-star")},
73 {5, _(
"pentagon/five-pointed star")},
74 {6, _(
"hexagon/six-pointed star")},
83 {0.010, _(
"thin-ray star")},
85 {0.382, _(
"pentagram")},
86 {0.577, _(
"hexagram")},
87 {0.692, _(
"heptagram")},
88 {0.765, _(
"octagram")},
89 {1.000, _(
"regular polygon")}
93 {-1.0 , _(
"stretched")},
94 {-0.2 , _(
"twisted")},
95 {-0.03, _(
"slightly pinched")},
96 { 0.0 , _(
"NOT rounded")},
97 { 0.05, _(
"slightly rounded")},
98 { 0.1 , _(
"visibly rounded")},
99 { 0.2 , _(
"well rounded")},
100 { 0.3 , _(
"amply rounded")},
102 { 1.0 , _(
"stretched")},
103 {10.0 , _(
"blown up")}
107 { 0.00, _(
"NOT randomized")},
108 { 0.01, _(
"slightly irregular")},
109 { 0.10, _(
"visibly randomized")},
110 { 0.50, _(
"strongly randomized")},
111 {10.00, _(
"blown up")}
130 get_widget<Gtk::Button>(
builder,
"reset_btn")
136 auto unit_menu =
_tracker->create_tool_item(_(
"Units"), (
""));
137 get_widget<Gtk::Box>(
builder,
"unit_menu_box").append(*unit_menu);
164 auto const path =
"/tools/shapes/star/" +
name;
167 auto adj = btn.get_adjustment();
169 adj->signal_value_changed().connect(sigc::mem_fun(*
this, value_changed_mem_fun));
202 bool const flat =
mode == 0;
220 if (is<SPStar>(
item)) {
223 int sides = adj->get_value();
225 repr->setAttributeInt(
"sodipodi:sides", 3);
228 repr->setAttribute(
"inkscape:flatsided", flat ?
"true" :
"false");
234 adj->set_lower(flat ? 3 : 2);
235 if (flat && adj->get_value() < 3) {
263 if (is<SPStar>(
item)) {
266 double arg1 = repr->getAttributeDouble(
"sodipodi:arg1", 0.5);
267 repr->setAttributeSvgDouble(
"sodipodi:arg2", arg1 + M_PI / adj->get_value());
282 if (!std::isnan(adj->get_value())) {
296 if (is<SPStar>(
item)) {
300 double r2 = repr->getAttributeDouble(
"sodipodi:r2", 1.0);
303 repr->setAttributeSvgDouble(
"sodipodi:r2", r1 * adj->get_value());
305 repr->setAttributeSvgDouble(
"sodipodi:r1", r2 * adj->get_value());
334 if (is<SPStar>(
item)) {
363 if (is<SPStar>(
item)) {
387 if (
auto star = cast<SPStar>(
item)) {
388 star -> setSideLength(value);
402 double randomized = 0;
434 if (
auto star = cast<SPStar>(
item)) {
437 lengths += star->getSideLength();
441 _mode_item.set_markup(n_selected == 0 ? _(
"<b>New:</b>") : _(
"<b>Change:</b>"));
444 if (n_selected == 1) {
460 if (
auto star = cast<SPStar>(
item)) {
462 lengths += star->getSideLength();
465 if (n_selected > 0) {
467 length_adj->set_value(value);
481 auto const name = g_quark_to_string(name_);
491 if (!strcmp(
name,
"inkscape:randomized")) {
494 }
else if (!strcmp(
name,
"inkscape:rounded")) {
497 }
else if (!strcmp(
name,
"inkscape:flatsided")) {
499 if (flatsides && !strcmp(flatsides,
"false")) {
502 mag_adj->set_lower(2);
506 mag_adj->set_lower(3);
508 }
else if (!strcmp(
name,
"sodipodi:r1") || !strcmp(
name,
"sodipodi:r2") && !isFlatSided) {
513 spoke_adj->set_value(r2 / r1);
515 spoke_adj->set_value(r1 / r2);
517 }
else if (!strcmp(
name,
"sodipodi:sides")) {
519 mag_adj->set_value(sides);
525 if (
auto star = cast<SPStar>(
item)) {
527 lengths += star->getSideLength();
531 if (n_selected > 0) {
533 length_adj->set_value(value);
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
static bool getUndoSensitive(SPDocument const *document)
static void maybeDone(SPDocument *document, const gchar *keyconst, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
SPItemRange items()
Returns a range of selected SPItems.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
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.
void setInt(Glib::ustring const &pref_path, int value)
Set an integer value.
void setBool(Glib::ustring const &pref_path, bool value)
Set a Boolean value.
The set of selected SPObjects for a given document and layer model.
sigc::connection connectChanged(sigc::slot< void(Selection *)> slot)
Connects a slot to be notified of selection changes.
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
Interface for refcounted XML nodes.
virtual void synthesizeEvents(NodeObserver &observer)=0
Generate a sequence of events corresponding to the state of this node.
double getAttributeDouble(Util::const_char_ptr key, double default_value=0.0) const
bool setAttributeInt(Util::const_char_ptr key, int val)
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual void addObserver(NodeObserver &observer)=0
Add an object that will be notified of the changes to this node.
int getAttributeInt(Util::const_char_ptr key, int default_value=0) const
virtual void removeObserver(NodeObserver &observer)=0
Remove an object from the list of observers.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
To do: update description of desktop.
SPDocument * getDocument() const
Inkscape::Selection * getSelection() const
Inkscape::XML::Node * updateRepr(unsigned int flags=SP_OBJECT_WRITE_EXT)
Updates the object's repr based on the object's state.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
Editable view implementation.
TODO: insert short description here.
Macro for icon names used in Inkscape.
static R & anchor(R &r)
Increments the reference count of a anchored object.
static R & release(R &r)
Decrements the reference count of a anchored object.
W & get_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id)
W & get_derived_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id, Args &&... args)
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
Miscellaneous supporting code.
Glib::RefPtr< Gtk::Builder > builder