Inkscape
Vector Graphics Editor
stroke-style.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/* Author:
7 * Lauris Kaplinski <lauris@ximian.com>
8 * Jon A. Cruz <jon@joncruz.org>
9 *
10 * Copyright (C) 2010 Jon A. Cruz
11 * Copyright (C) 2001 Ximian, Inc.
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#ifndef SEEN_DIALOGS_STROKE_STYLE_H
17#define SEEN_DIALOGS_STROKE_STYLE_H
18
19#include <vector>
20#include <glibmm/refptr.h>
21#include <gtkmm/box.h>
22#include <gtkmm/togglebutton.h>
23
24#include "style.h"
26
27namespace Gtk {
28class Adjustment;
29class Entry;
30class Grid;
31class Label;
32} // namespace Gtk
33
34class SPDocument;
35class SPObject;
36SPObject *getMarkerObj(gchar const *n, SPDocument *doc);
37
38namespace Inkscape {
39
40namespace Util {
41class Unit;
42} // namespace Util
43
44namespace UI::Widget {
45
46class DashSelector;
47class MarkerComboBox;
48class UnitMenu;
49
50class StrokeStyleButton;
51
52class StrokeStyle : public Gtk::Box
53{
54public:
56 ~StrokeStyle() override;
58 void updateLine();
59 void selectionModifiedCB(guint flags);
60 void selectionChangedCB();
61private:
67 };
68
73 class StrokeStyleButton : public Gtk::ToggleButton {
74 public:
75 StrokeStyleButton(Gtk::ToggleButton *&grp,
76 char const *icon,
78 gchar const *stroke_style);
79
82
84 inline gchar const * get_stroke_style() {return stroke_style;}
85
86 private:
88 gchar const *stroke_style;
89 };
90
91 std::vector<double> getDashFromStyle(SPStyle *style, double &offset);
92
93 void updateAllMarkers(std::vector<SPItem*> const &objects, bool skip_undo = false);
95 void setJoinType (unsigned const jointype);
96 void setCapType (unsigned const captype);
97 void setPaintOrder (gchar const *paint_order);
98 void setJoinButtons(Gtk::ToggleButton *active);
99 void setCapButtons(Gtk::ToggleButton *active);
100 void setPaintOrderButtons(Gtk::ToggleButton *active);
101 void setStrokeWidth();
102 void setStrokeDash();
103 void setStrokeMiter();
104 void setScaledDash(SPCSSAttr *css, int ndash, const double *dash, double offset, double scale);
105 bool isHairlineSelected() const;
106
107 StrokeStyleButton * makeRadioButton(Gtk::ToggleButton *&grp,
108 char const *icon,
109 Gtk::Box *hb,
110 StrokeStyleButtonType button_type,
111 gchar const *stroke_style);
112
113 // Callback functions
114 void unitChangedCB();
116 void markerSelectCB(MarkerComboBox *marker_combo, SPMarkerLoc const which);
117 static void buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw);
118
119
123 Gtk::Grid *table;
124 Glib::RefPtr<Gtk::Adjustment> widthAdj;
125 Glib::RefPtr<Gtk::Adjustment> miterLimitAdj;
129 //Gtk::ToggleButton *hairline;
143 Gtk::Entry* _pattern_entry = nullptr;
144 Gtk::Label* _pattern_label = nullptr;
145 void update_dash_entry(const std::vector<double> &dash_pattern);
147
148 gboolean update;
149 double _last_width = 0.0;
151 sigc::connection startMarkerConn;
152 sigc::connection midMarkerConn;
153 sigc::connection endMarkerConn;
154
156
158 void enterEditMarkerMode(SPMarkerLoc editMarkerMode);
160};
161
162} // namespace UI::Widget
163
164} // namespace Inkscape
165
166#endif // SEEN_DIALOGS_STROKE_STYLE_H
167
168/*
169 Local Variables:
170 mode:c++
171 c-file-style:"stroustrup"
172 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
173 indent-tabs-mode:nil
174 fill-column:99
175 End:
176*/
177// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
double scale
Definition: aa.cpp:228
ComboBox-like class for selecting stroke markers.
SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMen...
Definition: spinbutton.h:49
A custom radio check-button for setting the stroke style.
Definition: stroke-style.h:73
StrokeStyleButtonType get_button_type()
Get the type (line/cap) of the stroke-style button.
Definition: stroke-style.h:81
gchar const * stroke_style
The stroke style associated with the button.
Definition: stroke-style.h:88
gchar const * get_stroke_style()
Get the stroke style attribute associated with the button.
Definition: stroke-style.h:84
StrokeStyleButtonType button_type
The type (line/cap) of the button.
Definition: stroke-style.h:87
StrokeStyleButton(Gtk::ToggleButton *&grp, char const *icon, StrokeStyleButtonType button_type, gchar const *stroke_style)
Construct a stroke-style radio button with a given icon.
void update_dash_entry(const std::vector< double > &dash_pattern)
Inkscape::Util::Unit const * _old_unit
Definition: stroke-style.h:155
StrokeStyleButton * paintOrderFMS
Definition: stroke-style.h:138
StrokeStyleButton * paintOrderMFS
Definition: stroke-style.h:139
void setCapType(unsigned const captype)
Sets the cap type for a line, and updates the stroke style widget's buttons.
StrokeStyleButton * paintOrderSMF
Definition: stroke-style.h:140
void enterEditMarkerMode(SPMarkerLoc editMarkerMode)
void markerSelectCB(MarkerComboBox *marker_combo, SPMarkerLoc const which)
Handles when user selects one of the markers from the marker combobox.
void setStrokeWidth()
Set the stroke width and adjust the dash pattern if needed.
void setJoinType(unsigned const jointype)
Sets the join type for a line, and updates the stroke style widget's buttons.
static void buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw)
This routine handles toggle events for buttons in the stroke style dialog.
StrokeStyleButton * paintOrderMSF
Definition: stroke-style.h:141
void setStrokeDash()
Apply the stroke dash pattern to objects, scale to the existing width if needed.
void setStrokeMiter()
Set the Miter Limit value only.
StrokeStyleButton * makeRadioButton(Gtk::ToggleButton *&grp, char const *icon, Gtk::Box *hb, StrokeStyleButtonType button_type, gchar const *stroke_style)
Helper function for creating stroke-style radio buttons.
void setPaintOrderButtons(Gtk::ToggleButton *active)
Updates the paint order style toggle buttons.
void selectionModifiedCB(guint flags)
Callback for when stroke style widget is modified.
void setDesktop(SPDesktop *desktop)
void updateAllMarkers(std::vector< SPItem * > const &objects, bool skip_undo=false)
Updates the marker combobox to highlight the appropriate marker and scroll to that marker.
void setPaintOrder(gchar const *paint_order)
Sets the cap type for a line, and updates the stroke style widget's buttons.
void setJoinButtons(Gtk::ToggleButton *active)
Updates the join style toggle buttons.
StrokeStyleButton * paintOrderFSM
Definition: stroke-style.h:136
void unitChangedCB()
Callback for when UnitMenu widget is modified.
sigc::connection _document_replaced_connection
Definition: stroke-style.h:159
void updateLine()
Callback for when stroke style widget is updated, including markers, cap type, join type,...
void setScaledDash(SPCSSAttr *css, int ndash, const double *dash, double offset, double scale)
Sets a line's dash properties in a CSS style object.
std::vector< double > getDashFromStyle(SPStyle *style, double &offset)
Get a dash array and offset from the style.
bool isHairlineSelected() const
Returns whether the currently selected stroke width is "hairline".
void selectionChangedCB()
Callback for when stroke style widget is changed.
Glib::RefPtr< Gtk::Adjustment > widthAdj
Definition: stroke-style.h:124
StrokeStyleButtonType
List of valid types for the stroke-style radio check-button widget.
Definition: stroke-style.h:63
@ STROKE_STYLE_BUTTON_ORDER
A button to set the paint-order style.
Definition: stroke-style.h:66
@ STROKE_STYLE_BUTTON_JOIN
A button to set the line-join style.
Definition: stroke-style.h:64
@ STROKE_STYLE_BUTTON_CAP
A button to set the line-cap style.
Definition: stroke-style.h:65
void setCapButtons(Gtk::ToggleButton *active)
Updates the cap style toggle buttons.
void setDashSelectorFromStyle(DashSelector *dsel, SPStyle *style)
Sets selector widgets' dash style from an SPStyle object.
StrokeStyleButton * paintOrderSFM
Definition: stroke-style.h:137
Glib::RefPtr< Gtk::Adjustment > miterLimitAdj
Definition: stroke-style.h:125
void _handleDocumentReplaced(SPDesktop *, SPDocument *)
A drop down menu for choosing unit types.
Definition: unit-menu.h:31
To do: update description of desktop.
Definition: desktop.h:150
Typed SVG document implementation.
Definition: document.h:106
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition: sp-object.h:146
An SVG style object.
Definition: style.h:45
std::shared_ptr< Css const > css
std::vector< double > dash_pattern
double offset
Definition: desktop.h:51
Miscellaneous supporting code.
Definition: color-conv.cpp:9
CMYK to sRGB conversion routines.
int n
Definition: spiro.cpp:66
SPMarkerLoc
These enums are to allow us to have 4-element arrays that represent a set of marker locations (all,...
Definition: sp-marker-loc.h:20
SPObject * getMarkerObj(gchar const *n, SPDocument *doc)
Extract the actual name of the link e.g.
SPStyle - a style object for SPItem objects.