Inkscape
Vector Graphics Editor
shapeicon.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Martin Owens
5 *
6 * Copyright (C) 2020 Authors
7 *
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10
11#ifndef SEEN_INKSCAPE_UI_DIALOG_SHAPEICON_H
12#define SEEN_INKSCAPE_UI_DIALOG_SHAPEICON_H
13
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <typeinfo>
18#include <glibmm/property.h>
19#include <glibmm/propertyproxy.h>
20#include <gtkmm/cellrendererpixbuf.h>
21#include <sigc++/functors/mem_fun.h>
22
23namespace Inkscape::UI::Widget {
24
25// Object overlay states usually modify the icon and indicate
26// That there may be non-item children under this item (e.g. clip)
27using OverlayState = int;
29 OVERLAY_NONE = 0, // Nothing special about the object.
30 OVERLAY_CLIP = 1, // Object has a clip
31 OVERLAY_MASK = 2, // Object has a mask
32 OVERLAY_BOTH = 3, // Object has both clip and mask
33};
34
36class CellRendererItemIcon : public Gtk::CellRendererPixbuf {
37public:
39 Glib::ObjectBase{typeid(*this)},
40 Gtk::CellRendererPixbuf{},
41 _property_shape_type(*this, "shape_type", "unknown"),
42 _property_color(*this, "color", 0),
43 _property_clipmask(*this, "clipmask", 0)
44 {
45 property_mode() = Gtk::CellRendererMode::ACTIVATABLE;
46 property_icon_size().set_value(Gtk::IconSize::NORMAL); // Previously ICON_SIZE_MENU
47
49 auto const set = sigc::mem_fun(*this, &CellRendererItemIcon::set_icon_name);
50 property_shape_type().signal_changed().connect(set);
51 property_color ().signal_changed().connect(set);
52 }
53
54 Glib::PropertyProxy<std::string> property_shape_type() {
55 return _property_shape_type.get_proxy();
56 }
57 Glib::PropertyProxy<unsigned int> property_color() {
58 return _property_color.get_proxy();
59 }
60 Glib::PropertyProxy<unsigned int> property_clipmask() {
61 return _property_clipmask.get_proxy();
62 }
63
64 typedef sigc::signal<void (Glib::ustring)> type_signal_activated;
65
67 return _signal_activated;
68 }
69
70private:
71 void set_icon_name();
72 void snapshot_vfunc(Glib::RefPtr<Gtk::Snapshot> const &snapshot,
73 Gtk::Widget &widget,
74 const Gdk::Rectangle &background_area,
75 const Gdk::Rectangle &cell_area,
76 Gtk::CellRendererState flags) override;
77
78 bool activate_vfunc(Glib::RefPtr<Gdk::Event const> const &event,
79 Gtk::Widget &widget,
80 const Glib::ustring &path,
81 const Gdk::Rectangle &background_area,
82 const Gdk::Rectangle &cell_area,
83 Gtk::CellRendererState flags) override;
84
86 Glib::Property<std::string> _property_shape_type;
87 Glib::Property<unsigned int> _property_color;
88 Glib::Property<unsigned int> _property_clipmask;
89
90 Glib::ustring _color_class;
91 std::optional<std::uint32_t> _widget_color;
92};
93
94} // namespace Inkscape::UI::Widget
95
96#endif // SEEN_INKSCAPE_UI_DIALOG_SHAPEICON_H
97
98/*
99 Local Variables:
100 mode:c++
101 c-file-style:"stroustrup"
102 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103 indent-tabs-mode:nil
104 fill-column:99
105 End:
106*/
107// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Custom cell renderer for shapes of items in Objects dialog, w/ optional clip/mask icon overlaid.
Definition: shapeicon.h:36
type_signal_activated _signal_activated
Definition: shapeicon.h:85
Glib::Property< unsigned int > _property_clipmask
Definition: shapeicon.h:88
Glib::PropertyProxy< std::string > property_shape_type()
Definition: shapeicon.h:54
type_signal_activated signal_activated()
Definition: shapeicon.h:66
Glib::PropertyProxy< unsigned int > property_color()
Definition: shapeicon.h:57
Glib::PropertyProxy< unsigned int > property_clipmask()
Definition: shapeicon.h:60
sigc::signal< void(Glib::ustring)> type_signal_activated
Definition: shapeicon.h:64
Glib::Property< std::string > _property_shape_type
Definition: shapeicon.h:86
Glib::Property< unsigned int > _property_color
Definition: shapeicon.h:87
bool activate_vfunc(Glib::RefPtr< Gdk::Event const > const &event, Gtk::Widget &widget, const Glib::ustring &path, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) override
Definition: shapeicon.cpp:84
void snapshot_vfunc(Glib::RefPtr< Gtk::Snapshot > const &snapshot, Gtk::Widget &widget, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area, Gtk::CellRendererState flags) override
Definition: shapeicon.cpp:45
std::optional< std::uint32_t > _widget_color
Definition: shapeicon.h:91
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127