summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/style-swatch.h
blob: 31165f51ac603a24a45ac8b9024c5a4897d52432 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
 * @brief Static style swatch (fill, stroke, opacity)
 */
/* Authors:
 *   buliabyak@gmail.com
 *   Krzysztof Kosiński <tweenk.pl@gmail.com>
 *
 * Copyright (C) 2005-2008 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef INKSCAPE_UI_CURRENT_STYLE_H
#define INKSCAPE_UI_CURRENT_STYLE_H

#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/enums.h>

#include "desktop.h"
#include "preferences.h"

constexpr int STYLE_SWATCH_WIDTH = 135;

class SPStyle;
class SPCSSAttr;

namespace Gtk {
class Grid;
}

namespace Inkscape {

namespace Util {
    class Unit;
}

namespace UI {
namespace Widget {

class StyleSwatch : public Gtk::Box
{
public:
    StyleSwatch (SPCSSAttr *attr, gchar const *main_tip);

    ~StyleSwatch() override;

    void setStyle(SPStyle *style);
    void setStyle(SPCSSAttr *attr);
    SPCSSAttr *getStyle();

    void setWatchedTool (const char *path, bool synthesize);
    void setToolName(const Glib::ustring& tool_name);
    void setDesktop(SPDesktop *desktop);
    bool on_click(GdkEventButton *event);

private:
    class ToolObserver;
    class StyleObserver;

    SPDesktop *_desktop;
    Glib::ustring _tool_name;
    SPCSSAttr *_css;
    ToolObserver *_tool_obs;
    StyleObserver *_style_obs;
    Glib::ustring _tool_path;

    Gtk::EventBox _swatch;

    Gtk::Grid *_table;

    Gtk::Label _label[2];
    Gtk::Box _empty_space;
    Gtk::EventBox _place[2];
    Gtk::EventBox _opacity_place;
    Gtk::Label _value[2];
    Gtk::Label _opacity_value;
    Gtk::Widget *_color_preview[2];
    Glib::ustring __color[2];
    Gtk::Box _stroke;
    Gtk::EventBox _stroke_width_place;
    Gtk::Label _stroke_width;

    Inkscape::Util::Unit *_sw_unit;

friend class ToolObserver;
};


} // namespace Widget
} // namespace UI
} // namespace Inkscape

#endif // INKSCAPE_UI_WIDGET_BUTTON_H

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :