Inkscape
Vector Graphics Editor
dash-selector.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/* Authors:
7 * Tavmjong Bah (Rewrite to use Gio::ListStore and Gtk::GridView).
8 *
9 * Original authors:
10 * Lauris Kaplinski <lauris@kaplinski.com>
11 * bulia byak <buliabyak@users.sf.net>
12 * Maximilian Albert <maximilian.albert@gmail.com> (gtkmm-ification)
13 *
14 * Copyright (C) 2002 Lauris Kaplinski
15 * Copyright (C) 2023 Tavmjong Bah
16 *
17 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
18 */
19
20#ifndef SEEN_DASH_SELECTOR_H
21#define SEEN_DASH_SELECTOR_H
22
23#include <glibmm/refptr.h>
24#include <gtkmm/box.h>
25
26namespace Gtk {
27class DrawingArea;
28class GridView;
29class ListItem;
30class Popover;
31class SingleSelection;
32} // namespace Gtk
33
34namespace Inkscape::UI::Widget {
35
36class DashSelector final : public Gtk::Box {
37
38public:
41
42 void set_dash_pattern(const std::vector<double>& dash, double offset);
43 const std::vector<double>& get_dash_pattern() { return dash_pattern; }
44 double get_offset() { return offset; }
45
46 sigc::signal<void ()> changed_signal;
47
48private:
49 // Functions
50 void update(int position);
51
52 void activate(Gtk::GridView* grid, unsigned int position);
53
54 void setup_listitem_cb(const Glib::RefPtr<Gtk::ListItem>& list_item);
55 void bind_listitem_cb( const Glib::RefPtr<Gtk::ListItem>& list_item);
56
57 void draw_pattern(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height,
58 const std::vector<double>& pattern);
59 void draw_text(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
60
61 // Variables
62 std::vector<double> dash_pattern; // The current pattern.
63 double offset = 0; // The current offset.
64
65 // Gtk
66 Glib::RefPtr<Gtk::SingleSelection> selection;
67 Gtk::DrawingArea* drawing_area = nullptr; // MenuButton
68 Gtk::Popover* popover = nullptr;
69 Glib::RefPtr<Gtk::Adjustment> adjustment; // Dash offset
70};
71
72} // namespace Inkscape::UI::Widget
73
74#endif // SEEN_DASH_SELECTOR_H
75
76/*
77 Local Variables:
78 mode:c++
79 c-file-style:"stroustrup"
80 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
81 indent-tabs-mode:nil
82 fill-column:99
83 End:
84*/
85// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
void setup_listitem_cb(const Glib::RefPtr< Gtk::ListItem > &list_item)
std::vector< double > dash_pattern
Definition: dash-selector.h:62
void set_dash_pattern(const std::vector< double > &dash, double offset)
void activate(Gtk::GridView *grid, unsigned int position)
const std::vector< double > & get_dash_pattern()
Definition: dash-selector.h:43
sigc::signal< void()> changed_signal
Definition: dash-selector.h:46
void draw_text(const Cairo::RefPtr< Cairo::Context > &cr, int width, int height)
Glib::RefPtr< Gtk::SingleSelection > selection
Definition: dash-selector.h:66
void draw_pattern(const Cairo::RefPtr< Cairo::Context > &cr, int width, int height, const std::vector< double > &pattern)
Glib::RefPtr< Gtk::Adjustment > adjustment
Definition: dash-selector.h:69
void bind_listitem_cb(const Glib::RefPtr< Gtk::ListItem > &list_item)
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127
static constexpr int height
STL namespace.
double width