Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
desktop-style.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_SP_DESKTOP_STYLE_H
3#define SEEN_SP_DESKTOP_STYLE_H
4
5/*
6 * Desktop style management
7 *
8 * Authors:
9 * bulia byak
10 * verbalshadow
11 *
12 * Copyright (C) 2004, 2006 authors
13 *
14 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 */
16
17#include <memory>
18#include <vector>
19#include <optional>
20
21#include <glib.h>
22
23class SPCSSAttr;
24class SPDesktop;
25class SPObject;
26class SPItem;
27class SPStyle;
28namespace Inkscape {
29class ObjectSet;
30namespace XML {
31class Node;
32}
33namespace Colors {
34class Color;
35class ColorSet;
36}
37}
38namespace Glib { class ustring; }
39
41
42enum { // what kind of a style the query is returning
43 QUERY_STYLE_NOTHING, // nothing was queried - e.g. no selection
44 QUERY_STYLE_SINGLE, // single object was queried
45 QUERY_STYLE_MULTIPLE_SAME, // multiple objects were queried, the results were the same
46 QUERY_STYLE_MULTIPLE_DIFFERENT, // multiple objects were queried, the results could NOT be meaningfully averaged
47 QUERY_STYLE_MULTIPLE_AVERAGED // multiple objects were queried, the results were meaningfully averaged
48};
49
50enum { // which property was queried (add when you need more)
52 QUERY_STYLE_PROPERTY_FILL, // fill, fill-opacity
53 QUERY_STYLE_PROPERTY_STROKE, // stroke, stroke-opacity
58 QUERY_STYLE_PROPERTY_STROKESTYLE, // markers, dasharray, miterlimit, stroke-width, stroke-cap, stroke-join
60 QUERY_STYLE_PROPERTY_FONT_SPECIFICATION, //-inkscape-font-specification
63 QUERY_STYLE_PROPERTY_FONTVARIANTS, // font variants (OpenType features)
64 QUERY_STYLE_PROPERTY_FONTFEATURESETTINGS, // font feature settings (OpenType features)
67 QUERY_STYLE_PROPERTY_WRITINGMODES, // writing-mode, text-orientation
72};
73
74void sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines);
75void sp_desktop_set_color(SPDesktop *desktop, Color const &color, bool is_relative, bool fill);
76void sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *css, bool change = true, bool write_current = true, bool switch_style = false);
77void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change = true, bool write_current = true, bool switch_style = false);
79double sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool* has_opacity = nullptr);
80double sp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill);
81std::optional<Color> sp_desktop_get_color (SPDesktop *desktop, bool is_fill);
82std::optional<Color> sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill);
84void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text);
85
86gdouble stroke_average_width (const std::vector<SPItem*> &objects);
87
88int objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill);
89int objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res);
90int objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res);
91int objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res);
92int objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_res);
93int objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res);
94int objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res);
95int objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res);
96int objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res);
97int objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res);
98
99int objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res);
100int objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res);
101
102int sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property);
103int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property);
104
105#endif // SEEN_SP_DESKTOP_STYLE_H
106
107
108/*
109 Local Variables:
110 mode:c++
111 c-file-style:"stroustrup"
112 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
113 indent-tabs-mode:nil
114 fill-column:99
115 End:
116*/
117// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Base class for visual SVG elements.
Definition sp-item.h:109
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
An SVG style object.
Definition style.h:45
std::shared_ptr< Css const > css
Colors::Color 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 des...
int objects_query_blend(const std::vector< SPItem * > &objects, SPStyle *style_res)
void sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *css, bool change=true, bool write_current=true, bool switch_style=false)
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_strokewidth(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the average stroke width of a list of objects.
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,...
std::optional< Color > sp_desktop_get_color(SPDesktop *desktop, bool is_fill)
Return the desktop's current color.
std::optional< Color > sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
double sp_desktop_get_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool is_fill)
int objects_query_opacity(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the average opacity of a list of objects.
@ QUERY_STYLE_PROPERTY_STROKE
@ QUERY_STYLE_PROPERTY_BLEND
@ QUERY_STYLE_PROPERTY_STROKEWIDTH
@ QUERY_STYLE_PROPERTY_FONTNUMBERS
@ QUERY_STYLE_PROPERTY_FONT_SPECIFICATION
@ QUERY_STYLE_PROPERTY_BASELINES
@ QUERY_STYLE_PROPERTY_FONTFEATURESETTINGS
@ QUERY_STYLE_PROPERTY_ISOLATION
@ QUERY_STYLE_PROPERTY_FONTSTYLE
@ QUERY_STYLE_PROPERTY_BLUR
@ QUERY_STYLE_PROPERTY_FONTFAMILY
@ QUERY_STYLE_PROPERTY_STROKEMITERLIMIT
@ QUERY_STYLE_PROPERTY_PAINTORDER
@ QUERY_STYLE_PROPERTY_EVERYTHING
@ QUERY_STYLE_PROPERTY_FILL
@ QUERY_STYLE_PROPERTY_STROKESTYLE
@ QUERY_STYLE_PROPERTY_FONTVARIANTS
@ QUERY_STYLE_PROPERTY_STROKEJOIN
@ QUERY_STYLE_PROPERTY_MASTEROPACITY
@ QUERY_STYLE_PROPERTY_STROKECAP
@ QUERY_STYLE_PROPERTY_WRITINGMODES
void sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
Apply style on object and children, recursively.
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_fontvariants(const std::vector< SPItem * > &objects, SPStyle *style_res)
gdouble stroke_average_width(const std::vector< SPItem * > &objects)
Determine average stroke width, simple method.
@ QUERY_STYLE_MULTIPLE_DIFFERENT
@ QUERY_STYLE_SINGLE
@ QUERY_STYLE_NOTHING
@ QUERY_STYLE_MULTIPLE_AVERAGED
@ QUERY_STYLE_MULTIPLE_SAME
double sp_desktop_get_master_opacity_tool(SPDesktop *desktop, Glib::ustring const &tool, bool *has_opacity=nullptr)
int objects_query_fontnumbers(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the average font size and spacing of objects.
SPCSSAttr * sp_desktop_get_style(SPDesktop *desktop, bool with_text)
Return the desktop's current style.
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_strokecap(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the stroke cap of a list of objects.
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,...
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_miterlimit(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the average miter limit of a list of objects.
void sp_desktop_set_color(SPDesktop *desktop, Color const &color, bool is_relative, bool fill)
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.
int objects_query_fontstyle(const std::vector< SPItem * > &objects, SPStyle *style_res)
Write to style_res the average font style of objects.
Helper class to stream background task notifications as a series of messages.
SPDesktop * desktop