19#include <glibmm/i18n.h>
20#include <gtkmm/grid.h>
21#include <sigc++/adaptors/bind.h>
22#include <sigc++/functors/mem_fun.h>
66 bool usecurrent = val.
getBool();
68 path =
"/desktop/style";
69 css = prefs->getStyle(path);
70 const auto &al =
css->attributeList();
80 css = prefs->getInheritedStyle(path);
92 :
Gtk::Box(
Gtk::Orientation::HORIZONTAL),
95 _table(
Gtk::make_managed<
Gtk::Grid>()),
97 _stroke(
Gtk::Orientation::HORIZONTAL)
99 set_name(
"StyleSwatch");
104 _label[i].set_halign(Gtk::Align::START);
105 _label[i].set_valign(Gtk::Align::CENTER);
106 _label[i].set_margin_top(0);
107 _label[i].set_margin_bottom(0);
108 _label[i].set_margin_start(0);
109 _label[i].set_margin_end(0);
121 _table->set_column_spacing(2);
122 _table->set_row_spacing(0);
143 _table->set_column_spacing(4);
163 _table->set_tooltip_text(main_tip);
176 int ,
double ,
double )
181 return Gtk::EventSequenceState::CLAIMED;
222 Glib::ustring css_string;
226 if (!css_string.empty()) {
240 auto const place = &
_place[i];
244 paint = &(query->
fill);
250 SPPaintServer *server = (i ==
SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
252 if (is<SPLinearGradient>(server)) {
253 _value[i].set_markup(_(
"L Gradient"));
255 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Linear gradient (fill)")) : (_(
"Linear gradient (stroke)")));
256 }
else if (is<SPRadialGradient>(server)) {
257 _value[i].set_markup(_(
"R Gradient"));
259 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Radial gradient (fill)")) : (_(
"Radial gradient (stroke)")));
260 }
else if (is<SPPattern>(server)) {
261 _value[i].set_markup(_(
"Pattern"));
263 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Pattern (fill)")) : (_(
"Pattern (stroke)")));
271 tip = g_strdup_printf (_(
"Fill: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color));
273 tip = g_strdup_printf (_(
"Stroke: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color));
275 place->set_tooltip_text(tip);
277 }
else if (paint->
set && paint->
isNone()) {
278 _value[i].set_markup(C_(
"Fill and stroke",
"<i>None</i>"));
280 place->set_tooltip_text((i ==
SS_FILL)? (C_(
"Fill and stroke",
"No fill")) : (C_(
"Fill and stroke",
"No stroke")));
282 }
else if (!paint->
set) {
283 _value[i].set_markup(_(
"<b>Unset</b>"));
285 place->set_tooltip_text((i ==
SS_FILL)? (_(
"Unset fill")) : (_(
"Unset stroke")));
293 Glib::ustring swidth =
"<small>";
294 swidth += _(
"Hairline");
295 swidth +=
"</small>";
308 gchar *str = g_strdup_printf(
" %.3g",
w);
309 Glib::ustring swidth =
"<small>";
311 swidth +=
"</small>";
316 gchar *str = g_strdup_printf(_(
"Stroke width: %.5g%s"),
328 gdouble op = SP_SCALE24_TO_FLOAT(query->
opacity.value);
332 str = g_strdup_printf(_(
"O: %2.0f"), (op*100.0));
333 Glib::ustring opacity =
"<small>";
335 opacity +=
"</small>";
340 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.
guint32 toRGBA32(int alpha) const
Convert SPColor with integer alpha value to 32bit RGBA value.
To do: update description of desktop.
SPDocument * getDocument() const
InkscapeWindow const * getInkscapeWindow() const
Paint type internal to SPStyle.
bool isPaintserver() const
struct SPIPaint::@48 value
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)
D2< T > compose(D2< T > const &a, T const &b)
Gtk::GestureClick & add_click(Gtk::Widget &widget, ClickSlot on_pressed, ClickSlot on_released, Button const button, Gtk::PropagationPhase const phase, When const when)
Create a click gesture for the given widget; by default claim sequence.
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.
@ VERTICAL
The y-dimension (1).
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.