24#include <glibmm/i18n.h>
25#include <gtkmm/adjustment.h>
26#include <gtkmm/entry.h>
27#include <gtkmm/grid.h>
28#include <gtkmm/label.h>
29#include <gtkmm/togglebutton.h>
66 while (*p !=
'\0' && *p !=
'#') {
70 if (*p ==
'\0' || p[1] ==
'\0') {
76 while (p[
c] !=
'\0' && p[
c] !=
')') {
84 gchar* b = g_strdup(p);
100static Gtk::Label *
spw_label(Gtk::Grid *table,
const gchar *label_text,
int col,
int row,
103 auto const label_widget = Gtk::make_managed<Gtk::Label>();
104 g_assert(label_widget !=
nullptr);
105 if (target !=
nullptr) {
106 label_widget->set_text_with_mnemonic(label_text);
107 label_widget->set_mnemonic_widget(*target);
109 label_widget->set_text(label_text);
111 label_widget->set_visible(
true);
113 label_widget->set_halign(Gtk::Align::START);
114 label_widget->set_valign(Gtk::Align::CENTER);
115 label_widget->set_margin_start(4);
116 label_widget->set_margin_end(4);
118 table->attach(*label_widget, col, row, 1, 1);
130 auto const hb = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL, 4);
131 g_assert(hb !=
nullptr);
132 hb->set_visible(
true);
134 hb->set_halign(Gtk::Align::FILL);
135 hb->set_valign(Gtk::Align::CENTER);
136 table->attach(*hb, col, row,
width, 1);
151 gchar
const *stroke_style)
153 button_type(button_type),
154 stroke_style(stroke_style)
164 g_assert(px !=
nullptr);
165 px->set_visible(
true);
170 std::vector<double> output;
171 if (input.empty())
return output;
173 std::istringstream stream(input.c_str());
178 output.push_back(val);
204 set_name(
"StrokeSelector");
205 table = Gtk::make_managed<Gtk::Grid>();
206 table->set_margin(4);
207 table->set_row_spacing(4);
208 table->set_hexpand(
false);
209 table->set_halign(Gtk::Align::CENTER);
210 table->set_visible(
true);
224 widthAdj = Gtk::Adjustment::create(1.0, 0.0, 1000.0, 0.1, 10.0, 0.0);
226 widthSpin->set_tooltip_text(_(
"Stroke width"));
290 _pattern_label->set_tooltip_text(_(
"Repeating \"dash gap ...\" pattern"));
304 startMarkerCombo->set_tooltip_text(_(
"Start Markers are drawn on the first node of a path or shape"));
312 midMarkerCombo->set_tooltip_text(_(
"Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
320 endMarkerCombo->set_tooltip_text(_(
"End Markers are drawn on the last node of a path or shape"));
335 Gtk::ToggleButton *joinGrp =
nullptr;
343 joinBevel->set_tooltip_text(_(
"Bevel join"));
351 joinRound->set_tooltip_text(_(
"Round join"));
359 joinMiter->set_tooltip_text(_(
"Miter join"));
369 miterLimitAdj = Gtk::Adjustment::create(4.0, 0.0, 100000.0, 0.1, 10.0, 0.0);
371 miterLimitSpin->set_tooltip_text(_(
"Maximum length of the miter (in units of stroke width)"));
388 Gtk::ToggleButton *capGrp =
nullptr;
395 capButt->set_tooltip_text(_(
"Butt cap"));
402 capRound->set_tooltip_text(_(
"Round cap"));
409 capSquare->set_tooltip_text(_(
"Square cap"));
419 Gtk::ToggleButton *paintOrderGrp =
nullptr;
423 paintOrderFSM->set_tooltip_text(_(
"1.Fill, 2.Stroke, 3.Markers"));
427 paintOrderSFM->set_tooltip_text(_(
"1.Stroke, 2.Fill, 3.Markers"));
431 paintOrderFMS->set_tooltip_text(_(
"1.Fill, 2.Markers, 3.Stroke"));
439 paintOrderMFS->set_tooltip_text(_(
"1.Markers, 2.Fill, 3.Stroke"));
443 paintOrderSMF->set_tooltip_text(_(
"1.Stroke, 2.Markers, 3.Fill"));
447 paintOrderMSF->set_tooltip_text(_(
"1.Markers, 2.Stroke, 3.Fill"));
458 if (this->desktop !=
desktop) {
482 combo->setDocument(document);
504 gchar
const *stroke_style)
506 g_assert(icon !=
nullptr);
507 g_assert(hb !=
nullptr);
509 auto const tb = Gtk::make_managed<StrokeStyleButton>(grp, icon, button_type, stroke_style);
511 tb->signal_toggled().connect(sigc::bind(
559 gchar
const *combo_id = marker_combo->
get_id();
563 if (!is<SPShape>(
item)) {
576 DocumentUndo::done(document, _(
"Set markers"), INKSCAPE_ICON(
"dialog-fill-and-stroke"));
581 mt->editMarkerMode = which;
625 INKSCAPE_ICON(
"dialog-fill-and-stroke"));
649 if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG)) {
674 std::vector<double> ret;
677 double scaledash = 1.0;
678 if (prefs->getBool(
"/options/dash/scale",
true) && style->
stroke_width.computed) {
683 for (
unsigned i = 0; i <
len; i++) {
711 std::ostringstream ost;
733 Gtk::ToggleButton *tb =
nullptr;
746 std::cerr <<
"StrokeStyle::setJoinType(): Invalid value: " << jointype << std::endl;
759 Gtk::ToggleButton *tb =
nullptr;
772 std::cerr <<
"StrokeStyle::setCapType(): Invalid value: " << captype << std::endl;
788 temp.
read( paint_order );
827 auto *widg = get_parent()->get_parent()->get_parent()->get_parent();
829 if (dialogbase && !dialogbase->getShowing()) {
839 table->set_sensitive(
false);
849 SPStyle query(SP_ACTIVE_DOCUMENT);
860 table->set_sensitive(
true);
899 capButt->set_sensitive(is_enabled);
900 capRound->set_sensitive(is_enabled);
929 std::vector<SPItem*>
const objects(sel->
items().begin(), sel->
items().end());
930 if (objects.size()) {
931 SPObject *
const object = objects[0];
932 SPStyle *
const style =
object->style;
939 table->set_sensitive(
true);
949 int ndash,
const double *dash,
double offset,
954 for (
int i = 0; i < ndash; i++) {
955 osarray << dash[i] *
scale;
956 if (i < (ndash - 1)) {
973 if (unit->
abbr ==
"%") {
976 return (old_w * width_typed / 100) *
scale;
988 double width_typed =
widthAdj->get_value();
1016 if (prefs->getBool(
"/options/dash/scale",
true)) {
1028 INKSCAPE_ICON(
"dialog-fill-and-stroke"));
1030 if (unit->abbr ==
"%") {
1059 if(prefs->getBool(
"/options/dash/scale",
true)) {
1070 INKSCAPE_ICON(
"dialog-fill-and-stroke"));
1092 INKSCAPE_ICON(
"dialog-fill-and-stroke"));
1120 if (tb->get_active()) {
1197 if (is<SPGroup>(element)) {
1202 simple_list.push_back(element);
1220 bool all_texts =
true;
1222 auto simplified_list = std::vector<SPObject *>();
1227 for (
SPObject *
object : simplified_list) {
1228 if (!is<SPText>(
object)) {
1237 for (
auto const &markertype : keyloc) {
1256 for (
SPObject *
object : simplified_list) {
1260 if (value ==
nullptr)
Coord descrim() const
Calculate the descriminant.
A thin wrapper around std::ostringstream, but writing floating point numbers in the format required b...
static void done(SPDocument *document, 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 isEmpty()
Returns true if no items are selected.
static Preferences * get()
Access the singleton Preferences object.
The set of selected SPObjects for a given document and layer model.
DialogBase is the base class for the dialog system.
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
Interface for refcounted XML nodes.
To do: update description of desktop.
sigc::connection connectDocumentReplaced(F &&slot)
SPDocument * getDocument() const
SPNamedView * getNamedView() const
Inkscape::Selection * getSelection() const
Inkscape::UI::Tools::ToolBase * getTool() const
Typed SVG document implementation.
SPObject * getObjectById(std::string const &id) const
int ensureUpToDate(unsigned int object_modified_tag=0)
Repeatedly works on getting the document updated, since sometimes it takes more than one pass to get ...
Paint order type internal to SPStyle.
void read(gchar const *str) override
SPPaintOrderLayer layer[PAINT_ORDER_LAYERS]
Paint type internal to SPStyle.
char const * value() const
Get value if set, or inherited value, or default value (may be NULL)
Base class for visual SVG elements.
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
Inkscape::Util::Unit const * display_units
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void requestModified(unsigned int flags)
Requests that a modification notification signal be emitted later (e.g.
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
T< SPAttr::STROKE_DASHARRAY, SPIDashArray > stroke_dasharray
stroke-dasharray
T< SPAttr::PAINT_ORDER, SPIPaintOrder > paint_order
T< SPAttr::STROKE_WIDTH, SPILength > stroke_width
stroke-width
T< SPAttr::STROKE_LINEJOIN, SPIEnum< SPStrokeJoinType > > stroke_linejoin
stroke-linejoin
SPIPaint * getFillOrStroke(bool fill_)
Get either the fill or the stroke property.
T< SPAttr::STROKE_MITERLIMIT, SPIFloat > stroke_miterlimit
stroke-miterlimit
T< SPAttr::STROKE_LINECAP, SPIEnum< SPStrokeCapType > > stroke_linecap
stroke-linecap
SPIString * marker_ptrs[SP_MARKER_LOC_QTY]
T< SPAttr::STROKE_DASHOFFSET, SPILength > stroke_dashoffset
stroke-dashoffset
T< SPAttr::STROKE_EXTENSIONS, SPIStrokeExtensions > stroke_extensions
-inkscape-stroke
TODO: insert short description here.
std::shared_ptr< Css const > css
std::vector< double > dash_pattern
A widget for selecting dash patterns and setting the dash offset.
void sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
Apply style on object and children, recursively.
void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current, bool switch_style)
Apply style on selection on desktop.
int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
Query the subselection (if any) or selection on the given desktop for the given property,...
@ QUERY_STYLE_PROPERTY_STROKEWIDTH
@ QUERY_STYLE_PROPERTY_STROKEMITERLIMIT
@ QUERY_STYLE_PROPERTY_PAINTORDER
@ QUERY_STYLE_PROPERTY_STROKEJOIN
@ QUERY_STYLE_PROPERTY_STROKECAP
@ QUERY_STYLE_MULTIPLE_AVERAGED
A base class for all dialogs.
void sp_dialog_defocus_on_enter(Gtk::Entry *e)
Event handler for dialog windows.
TODO: insert short description here.
Definition of the FillOrStroke enum.
Gtk::Image * sp_get_icon_image(Glib::ustring const &icon_name, int size)
Macro for icon names used in Inkscape.
Combobox for selecting dash patterns - implementation.
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.
bool contains_focus(Gtk::Widget &widget)
Returns if widget or one of its descendants has focus.
@ UNIT_TYPE_DIMENSIONLESS
static void append(std::vector< T > &target, std::vector< T > &&source)
bool is_query_style_updateable(const int style)
static cairo_user_data_key_t key
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_set_property_double(SPCSSAttr *css, gchar const *name, double value)
Set a style property to a new float value (e.g.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
void sp_repr_css_change_recursive(Node *repr, SPCSSAttr *css, gchar const *attr)
void sp_repr_css_unset_property(SPCSSAttr *css, gchar const *name)
Set a style property to "inkscape:unset".
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
SPMarkerLoc
These enums are to allow us to have 4-element arrays that represent a set of marker locations (all,...
TODO: insert short description here.
SPObject * getMarkerObj(gchar const *n, SPDocument *doc)
Extract the actual name of the link e.g.
Widgets used in the stroke style dialog.
@ SP_STROKE_LINEJOIN_MITER
@ SP_STROKE_LINEJOIN_BEVEL
@ SP_STROKE_LINEJOIN_ROUND
@ SP_STROKE_LINECAP_SQUARE
@ SP_STROKE_LINECAP_ROUND
@ SP_CSS_PAINT_ORDER_STROKE
@ SP_CSS_PAINT_ORDER_FILL
@ SP_CSS_PAINT_ORDER_NORMAL
Common utility functions for manipulating style.