Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
desktop-style.h File Reference

Go to the source code of this file.

Namespaces

namespace  Inkscape
 Helper class to stream background task notifications as a series of messages.
 
namespace  Inkscape::XML
 @Inkscape XML tree.
 
namespace  Inkscape::Colors
 A set of useful color modifying functions which do not fit as generic methods on the color class itself but which are used in various places.
 
namespace  Glib
 

Enumerations

enum  {
  QUERY_STYLE_NOTHING , QUERY_STYLE_SINGLE , QUERY_STYLE_MULTIPLE_SAME , QUERY_STYLE_MULTIPLE_DIFFERENT ,
  QUERY_STYLE_MULTIPLE_AVERAGED
}
 
enum  {
  QUERY_STYLE_PROPERTY_EVERYTHING , QUERY_STYLE_PROPERTY_FILL , QUERY_STYLE_PROPERTY_STROKE , QUERY_STYLE_PROPERTY_STROKEWIDTH ,
  QUERY_STYLE_PROPERTY_STROKEMITERLIMIT , QUERY_STYLE_PROPERTY_STROKEJOIN , QUERY_STYLE_PROPERTY_STROKECAP , QUERY_STYLE_PROPERTY_STROKESTYLE ,
  QUERY_STYLE_PROPERTY_PAINTORDER , QUERY_STYLE_PROPERTY_FONT_SPECIFICATION , QUERY_STYLE_PROPERTY_FONTFAMILY , QUERY_STYLE_PROPERTY_FONTSTYLE ,
  QUERY_STYLE_PROPERTY_FONTVARIANTS , QUERY_STYLE_PROPERTY_FONTFEATURESETTINGS , QUERY_STYLE_PROPERTY_FONTNUMBERS , QUERY_STYLE_PROPERTY_BASELINES ,
  QUERY_STYLE_PROPERTY_WRITINGMODES , QUERY_STYLE_PROPERTY_MASTEROPACITY , QUERY_STYLE_PROPERTY_ISOLATION , QUERY_STYLE_PROPERTY_BLEND ,
  QUERY_STYLE_PROPERTY_BLUR
}
 

Functions

void sp_desktop_apply_css_recursive (SPObject *o, SPCSSAttr *css, bool skip_lines)
 Apply style on object and children, recursively.
 
void sp_desktop_set_color (SPDesktop *desktop, Color const &color, bool is_relative, bool fill)
 
void sp_desktop_set_style (Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *css, bool change=true, bool write_current=true, bool switch_style=false)
 
void sp_desktop_set_style (SPDesktop *desktop, SPCSSAttr *css, bool change=true, bool write_current=true, bool switch_style=false)
 Apply style on selection on desktop.
 
SPCSSAttrsp_desktop_get_style (SPDesktop *desktop, bool with_text)
 Return the desktop's current style.
 
double sp_desktop_get_master_opacity_tool (SPDesktop *desktop, Glib::ustring const &tool, bool *has_opacity=nullptr)
 
double sp_desktop_get_opacity_tool (SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
 
std::optional< Colorsp_desktop_get_color (SPDesktop *desktop, bool is_fill)
 Return the desktop's current color.
 
std::optional< Colorsp_desktop_get_color_tool (SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
 
double sp_desktop_get_font_size_tool (SPDesktop *desktop)
 Returns the font size (in SVG pixels) of the text tool style (if text tool uses its own style) or desktop style (otherwise).
 
void sp_desktop_apply_style_tool (SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text)
 Apply the desktop's current style or the tool style to repr.
 
gdouble stroke_average_width (const std::vector< SPItem * > &objects)
 Determine average stroke width, simple method.
 
int objects_query_fillstroke (const std::vector< SPItem * > &objects, SPStyle *style_res, bool const isfill)
 Write to style_res the average fill or stroke of list of objects, if applicable.
 
int objects_query_fontnumbers (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average font size and spacing of objects.
 
int objects_query_fontstyle (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average font style of objects.
 
int objects_query_fontfamily (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average font family of objects.
 
int objects_query_fontvariants (const std::vector< SPItem * > &objects, SPStyle *style_res)
 
int objects_query_opacity (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average opacity of a list of objects.
 
int objects_query_strokewidth (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average stroke width of a list of objects.
 
int objects_query_miterlimit (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average miter limit of a list of objects.
 
int objects_query_strokecap (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the stroke cap of a list of objects.
 
int objects_query_strokejoin (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the stroke join of a list of objects.
 
int objects_query_blur (const std::vector< SPItem * > &objects, SPStyle *style_res)
 Write to style_res the average blurring of a list of objects.
 
int objects_query_blend (const std::vector< SPItem * > &objects, SPStyle *style_res)
 
int sp_desktop_query_style_from_list (const std::vector< SPItem * > &list, SPStyle *style, int property)
 Query the given list of objects for the given property, write the result to style, return appropriate flag.
 
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, write the result to style, return appropriate flag.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
QUERY_STYLE_NOTHING 
QUERY_STYLE_SINGLE 
QUERY_STYLE_MULTIPLE_SAME 
QUERY_STYLE_MULTIPLE_DIFFERENT 
QUERY_STYLE_MULTIPLE_AVERAGED 

Definition at line 42 of file desktop-style.h.

◆ anonymous enum

anonymous enum
Enumerator
QUERY_STYLE_PROPERTY_EVERYTHING 
QUERY_STYLE_PROPERTY_FILL 
QUERY_STYLE_PROPERTY_STROKE 
QUERY_STYLE_PROPERTY_STROKEWIDTH 
QUERY_STYLE_PROPERTY_STROKEMITERLIMIT 
QUERY_STYLE_PROPERTY_STROKEJOIN 
QUERY_STYLE_PROPERTY_STROKECAP 
QUERY_STYLE_PROPERTY_STROKESTYLE 
QUERY_STYLE_PROPERTY_PAINTORDER 
QUERY_STYLE_PROPERTY_FONT_SPECIFICATION 
QUERY_STYLE_PROPERTY_FONTFAMILY 
QUERY_STYLE_PROPERTY_FONTSTYLE 
QUERY_STYLE_PROPERTY_FONTVARIANTS 
QUERY_STYLE_PROPERTY_FONTFEATURESETTINGS 
QUERY_STYLE_PROPERTY_FONTNUMBERS 
QUERY_STYLE_PROPERTY_BASELINES 
QUERY_STYLE_PROPERTY_WRITINGMODES 
QUERY_STYLE_PROPERTY_MASTEROPACITY 
QUERY_STYLE_PROPERTY_ISOLATION 
QUERY_STYLE_PROPERTY_BLEND 
QUERY_STYLE_PROPERTY_BLUR 

Definition at line 50 of file desktop-style.h.

Function Documentation

◆ objects_query_blend()

◆ objects_query_blur()

int objects_query_blur ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

◆ objects_query_fillstroke()

◆ objects_query_fontfamily()

int objects_query_fontfamily ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

Write to style_res the average font family of objects.

Definition at line 1506 of file desktop-style.cpp.

References SPStyle::font_family, isTextualItem(), QUERY_STYLE_MULTIPLE_DIFFERENT, QUERY_STYLE_MULTIPLE_SAME, QUERY_STYLE_NOTHING, and QUERY_STYLE_SINGLE.

Referenced by sp_desktop_query_style_from_list().

◆ objects_query_fontnumbers()

int objects_query_fontnumbers ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

◆ objects_query_fontstyle()

int objects_query_fontstyle ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

◆ objects_query_fontvariants()

◆ objects_query_miterlimit()

int objects_query_miterlimit ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

Write to style_res the average miter limit of a list of objects.

Definition at line 749 of file desktop-style.cpp.

References QUERY_STYLE_MULTIPLE_AVERAGED, QUERY_STYLE_MULTIPLE_SAME, QUERY_STYLE_NOTHING, QUERY_STYLE_SINGLE, SPStyle::stroke, and SPStyle::stroke_miterlimit.

Referenced by sp_desktop_query_style_from_list().

◆ objects_query_opacity()

int objects_query_opacity ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

Write to style_res the average opacity of a list of objects.

Definition at line 617 of file desktop-style.cpp.

References SPStyle::opacity, QUERY_STYLE_MULTIPLE_AVERAGED, QUERY_STYLE_MULTIPLE_SAME, QUERY_STYLE_NOTHING, and QUERY_STYLE_SINGLE.

Referenced by sp_desktop_query_style_from_list().

◆ objects_query_strokecap()

int objects_query_strokecap ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

◆ objects_query_strokejoin()

int objects_query_strokejoin ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

◆ objects_query_strokewidth()

int objects_query_strokewidth ( const std::vector< SPItem * > &  objects,
SPStyle style_res 
)

◆ sp_desktop_apply_css_recursive()

◆ sp_desktop_apply_style_tool()

◆ sp_desktop_get_color()

std::optional< Color > sp_desktop_get_color ( SPDesktop desktop,
bool  is_fill 
)

◆ sp_desktop_get_color_tool()

◆ sp_desktop_get_font_size_tool()

double sp_desktop_get_font_size_tool ( SPDesktop desktop)

Returns the font size (in SVG pixels) of the text tool style (if text tool uses its own style) or desktop style (otherwise).

Definition at line 398 of file desktop-style.cpp.

References desktop, SPStyle::font_size, Inkscape::Preferences::get(), Inkscape::Preferences::getBool(), Inkscape::Preferences::getString(), and SPStyle::mergeString().

Referenced by Inkscape::UI::Tools::TextTool::root_handler().

◆ sp_desktop_get_master_opacity_tool()

◆ sp_desktop_get_opacity_tool()

◆ sp_desktop_get_style()

◆ sp_desktop_query_style()

◆ sp_desktop_query_style_from_list()

int sp_desktop_query_style_from_list ( const std::vector< SPItem * > &  list,
SPStyle style,
int  property 
)

◆ sp_desktop_set_color()

void sp_desktop_set_color ( SPDesktop desktop,
Color const &  color,
bool  is_relative,
bool  fill 
)

◆ sp_desktop_set_style() [1/2]

void sp_desktop_set_style ( Inkscape::ObjectSet set,
SPDesktop desktop,
SPCSSAttr css,
bool  change = true,
bool  write_current = true,
bool  switch_style = false 
)
Todo:
FIXME: in set_style, compensate pattern and gradient fills, stroke width, rect corners, font size for the object's own transform so that pasting fills does not depend on preserve/optimize.

Definition at line 179 of file desktop-style.cpp.

References SPDesktop::_set_style_signal, css, SPDesktop::current, desktop, Inkscape::Preferences::get(), SPDesktop::getTool(), isTextualItem(), item, Inkscape::Preferences::mergeStyle(), set, sp_css_attr_unset_text(), sp_css_attr_unset_uris(), sp_desktop_apply_css_recursive(), sp_repr_css_attr_new(), sp_repr_css_attr_unref(), sp_repr_css_merge(), sp_repr_css_property_is_unset(), and sp_repr_css_unset_property().

◆ sp_desktop_set_style() [2/2]

void sp_desktop_set_style ( SPDesktop desktop,
SPCSSAttr css,
bool  change = true,
bool  write_current = true,
bool  switch_style = false 
)

Apply style on selection on desktop.

Definition at line 173 of file desktop-style.cpp.

References css, desktop, SPDesktop::getSelection(), and sp_desktop_set_style().

Referenced by Inkscape::UI::Tools::EraserTool::_handleStrokeStyle(), Inkscape::UI::Widget::SelectedStyle::_on_paste_callback(), Inkscape::UI::Dialog::TextEdit::apply_changes(), Inkscape::UI::Widget::StrokeStyle::buttonToggledCB(), Inkscape::UI::Widget::RotateableSwatch::color_adjust(), Inkscape::UI::Toolbar::TextToolbar::fontstyle_value_changed(), Inkscape::UI::Toolbar::TextToolbar::lineheight_unit_changed(), Inkscape::UI::Toolbar::TextToolbar::lineheight_value_changed(), Inkscape::UI::Toolbar::TextToolbar::mergeDefaultStyle(), Inkscape::UI::Dialog::ColorItem::on_click(), Inkscape::UI::Widget::SelectedStyle::on_fill_black(), Inkscape::UI::Widget::SelectedStyle::on_fill_invert(), Inkscape::UI::Widget::SelectedStyle::on_fill_lastselected(), Inkscape::UI::Widget::SelectedStyle::on_fill_lastused(), Inkscape::UI::Widget::SelectedStyle::on_fill_opaque(), Inkscape::UI::Widget::SelectedStyle::on_fill_remove(), Inkscape::UI::Widget::SelectedStyle::on_fill_unset(), Inkscape::UI::Widget::SelectedStyle::on_fill_white(), Inkscape::UI::Widget::SelectedStyle::on_opacity_changed(), Inkscape::UI::Widget::SelectedStyle::on_opacity_click(), Inkscape::UI::Widget::SelectedStyle::on_popup_preset(), Inkscape::UI::Widget::SelectedStyle::on_stroke_black(), Inkscape::UI::Widget::SelectedStyle::on_stroke_invert(), Inkscape::UI::Widget::SelectedStyle::on_stroke_lastselected(), Inkscape::UI::Widget::SelectedStyle::on_stroke_lastused(), Inkscape::UI::Widget::SelectedStyle::on_stroke_opaque(), Inkscape::UI::Widget::SelectedStyle::on_stroke_remove(), Inkscape::UI::Widget::SelectedStyle::on_stroke_unset(), Inkscape::UI::Widget::SelectedStyle::on_stroke_white(), Inkscape::ObjectSet::removeFilter(), Inkscape::UI::Toolbar::TextToolbar::script_changed(), Inkscape::UI::Widget::SelectedStyle::SelectedStyle(), Inkscape::UI::Widget::StyleSubject::Selection::setCSS(), Inkscape::UI::Widget::FillNStroke::setFillrule(), Inkscape::UI::Widget::StrokeStyle::setStrokeDash(), Inkscape::UI::Widget::StrokeStyle::setStrokeMiter(), Inkscape::UI::Widget::StrokeStyle::setStrokeWidth(), sp_desktop_set_color(), sp_desktop_set_style(), Inkscape::ObjectSet::swapFillStroke(), Inkscape::UI::Toolbar::TextToolbar::text_outer_set_style(), Inkscape::UI::Widget::StrokeStyle::unitChangedCB(), Inkscape::UI::Widget::FillNStroke::updateFromPaint(), and Inkscape::UI::Widget::RotateableStrokeWidth::value_adjust().

◆ stroke_average_width()

gdouble stroke_average_width ( const std::vector< SPItem * > &  objects)

Determine average stroke width, simple method.

Definition at line 421 of file desktop-style.cpp.

References Geom::Affine::descrim(), SPItem::i2dt_affine(), Geom::infinity(), item, SPStyle::stroke, SPStyle::stroke_width, SPObject::style, and width.

Referenced by Inkscape::SelTrans::_updateVolatileState().