18#include <gtkmm/enums.h>
20#include <glibmm/i18n.h>
21#include <gtkmm/grid.h>
22#include <sigc++/adaptors/bind.h>
23#include <sigc++/functors/mem_fun.h>
67 bool usecurrent = val.
getBool();
69 path =
"/desktop/style";
70 css = prefs->getStyle(path);
71 const auto &al =
css->attributeList();
81 css = prefs->getInheritedStyle(path);
96 _table(
Gtk::make_managed<
Gtk::Grid>()),
100 set_name(
"StyleSwatch");
101 add_css_class(orient == Gtk::Orientation::HORIZONTAL ?
"horizontal" :
"vertical");
106 _label[i].set_halign(Gtk::Align::START);
107 _label[i].set_valign(Gtk::Align::CENTER);
108 _label[i].set_margin_top(0);
109 _label[i].set_margin_bottom(0);
110 _label[i].set_margin_start(0);
111 _label[i].set_margin_end(0);
123 _table->set_column_spacing(2);
124 _table->set_row_spacing(0);
133 if (orient == Gtk::Orientation::VERTICAL) {
145 _table->set_column_spacing(4);
163 _table->set_tooltip_text(main_tip);
211 Glib::ustring css_string;
215 if (!css_string.empty()) {
229 auto const place = &
_place[i];
233 paint = &(query->
fill);
239 SPPaintServer *server = (i ==
SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
241 if (is<SPLinearGradient>(server)) {
242 _value[i].set_markup(_(
"L Gradient"));
244 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Linear gradient (fill)")) : (_(
"Linear gradient (stroke)")));
245 }
else if (is<SPRadialGradient>(server)) {
246 _value[i].set_markup(_(
"R Gradient"));
248 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Radial gradient (fill)")) : (_(
"Radial gradient (stroke)")));
249 }
else if (is<SPPattern>(server)) {
250 _value[i].set_markup(_(
"Pattern"));
252 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Pattern (fill)")) : (_(
"Pattern (stroke)")));
261 tip = g_strdup_printf (_(
"Fill: %s"), color.toString().c_str());
263 tip = g_strdup_printf (_(
"Stroke: %s"), color.toString().c_str());
265 place->set_tooltip_text(tip);
267 }
else if (paint->
set && paint->
isNone()) {
268 _value[i].set_markup(C_(
"Fill and stroke",
"<i>None</i>"));
270 place->set_tooltip_text((i ==
SS_FILL)? (C_(
"Fill and stroke",
"No fill")) : (C_(
"Fill and stroke",
"No stroke")));
272 }
else if (!paint->
set) {
273 _value[i].set_markup(_(
"<b>Unset</b>"));
275 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Unset fill")) : (_(
"Unset stroke")));
283 Glib::ustring swidth =
"<small>";
284 swidth += _(
"Hairline");
285 swidth +=
"</small>";
287 auto str = Glib::ustring::compose(_(
"Stroke width: %1"), _(
"Hairline"));
298 gchar *str = g_strdup_printf(
" %.3g",
w);
299 Glib::ustring swidth =
"<small>";
301 swidth +=
"</small>";
306 gchar *str = g_strdup_printf(_(
"Stroke width: %.5g%s"),
318 gdouble op = SP_SCALE24_TO_FLOAT(query->
opacity.value);
322 str = g_strdup_printf(_(
"O: %2.0f"), (op*100.0));
323 Glib::ustring opacity =
"<small>";
325 opacity +=
"</small>";
330 gchar *str = g_strdup_printf(_(
"Opacity: %2.1f %%"), (op*100.0));
Data type representing a typeless value of a preference.
bool getBool(bool def=false) const
Interpret the preference as a Boolean value.
SPCSSAttr * getInheritedStyle() const
Interpret the preference as a CSS style with directory-based inheritance.
static std::unique_ptr< PreferencesObserver > create(Glib::ustring path, std::function< void(const Preferences::Entry &new_value)> callback)
static Preferences * get()
Access the singleton Preferences object.
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
To do: update description of desktop.
SPDocument * getDocument() const
Paint type internal to SPStyle.
bool isPaintserver() const
Colors::Color const & getColor() const
T< SPAttr::FILL, SPIPaint > fill
fill
T< SPAttr::STROKE, SPIPaint > stroke
stroke
T< SPAttr::STROKE_WIDTH, SPILength > stroke_width
stroke-width
T< SPAttr::FILL_OPACITY, SPIScale24 > fill_opacity
fill-opacity
T< SPAttr::STROKE_OPACITY, SPIScale24 > stroke_opacity
stroke-opacity
void mergeString(char const *p)
Parses a style="..." string and merges it with an existing SPStyle.
T< SPAttr::OPACITY, SPIScale24 > opacity
opacity
T< SPAttr::STROKE_EXTENSIONS, SPIStrokeExtensions > stroke_extensions
-inkscape-stroke
Utilities to more easily use Gtk::EventController & subclasses like Gesture.
std::shared_ptr< Css const > css
static bool has_stroke(SPObject *source)
void remove_all_children(Widget &widget)
For each child in get_children(widget), call widget.remove(*child). May not cause delete child!
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.
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_write_string(SPCSSAttr *css, Glib::ustring &str)
Write a style attribute string from a list of properties stored in an SPCSAttr object.
void sp_repr_css_merge(SPCSSAttr *dst, SPCSSAttr *src)
Merges two SPCSSAttr's.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
SPCSSAttr - interface for CSS Attributes.
TODO: insert short description here.
SVG <pattern> implementation.
TODO: insert short description here.
static constexpr int STYLE_SWATCH_WIDTH
Static style swatch (fill, stroke, opacity)
SPStyle - a style object for SPItem objects.