Code

Removed redundant refresh button, ui cleanup, added frames, etc. for bug #171376.
[inkscape.git] / src / ui / dialog / color-item.h
1 /** @file
2  * @brief Inkscape color swatch UI item.
3  */
4 /* Authors:
5  *   Jon A. Cruz
6  *
7  * Copyright (C) 2010 Jon A. Cruz
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #ifndef SEEN_DIALOGS_COLOR_ITEM_H
13 #define SEEN_DIALOGS_COLOR_ITEM_H
15 #include <gtkmm/tooltips.h>
17 #include "widgets/ege-paint-def.h"
18 #include "ui/previewable.h"
20 class SPGradient;
22 namespace Inkscape {
23 namespace UI {
24 namespace Dialogs {
26 class ColorItem;
28 class SwatchPage
29 {
30 public:
31     SwatchPage();
32     ~SwatchPage();
34     Glib::ustring _name;
35     int _prefWidth;
36     std::vector<ColorItem*> _colors;
37 };
40 /**
41  * The color swatch you see on screen as a clickable box.
42  */
43 class ColorItem : public Inkscape::UI::Previewable
44 {
45     friend void _loadPaletteFile( gchar const *filename );
46 public:
47     ColorItem( ege::PaintDef::ColorType type );
48     ColorItem( unsigned int r, unsigned int g, unsigned int b,
49                Glib::ustring& name );
50     virtual ~ColorItem();
51     ColorItem(ColorItem const &other);
52     virtual ColorItem &operator=(ColorItem const &other);
53     virtual Gtk::Widget* getPreview(PreviewStyle style,
54                                     ViewType view,
55                                     ::PreviewSize size,
56                                     guint ratio);
57     void buttonClicked(bool secondary = false);
59     void setGradient(SPGradient *grad);
60     SPGradient * getGradient() const { return _grad; }
62     void setPixData(guchar* px, int width, int height);
64     void setState( bool fill, bool stroke );
65     bool isFill() { return _isFill; }
66     bool isStroke() { return _isStroke; }
68     ege::PaintDef def;
70 private:
72     static void _dropDataIn( GtkWidget *widget,
73                              GdkDragContext *drag_context,
74                              gint x, gint y,
75                              GtkSelectionData *data,
76                              guint info,
77                              guint event_time,
78                              gpointer user_data);
80     static void _dragGetColorData( GtkWidget *widget,
81                                    GdkDragContext *drag_context,
82                                    GtkSelectionData *data,
83                                    guint info,
84                                    guint time,
85                                    gpointer user_data);
87     static void _wireMagicColors( SwatchPage *colorSet );
88     static void _colorDefChanged(void* data);
90     void _updatePreviews();
91     void _regenPreview(EekPreview * preview);
93     void _linkTint( ColorItem& other, int percent );
94     void _linkTone( ColorItem& other, int percent, int grayLevel );
96     Gtk::Tooltips tips;
97     std::vector<Gtk::Widget*> _previews;
99     bool _isFill;
100     bool _isStroke;
101     bool _isLive;
102     bool _linkIsTone;
103     int _linkPercent;
104     int _linkGray;
105     ColorItem* _linkSrc;
106     SPGradient* _grad;
107     guchar *_pixData;
108     int _pixWidth;
109     int _pixHeight;
110     std::vector<ColorItem*> _listeners;
111 };
113 } // namespace Dialogs
114 } // namespace UI
115 } // namespace Inkscape
117 #endif // SEEN_DIALOGS_COLOR_ITEM_H
119 /*
120   Local Variables:
121   mode:c++
122   c-file-style:"stroustrup"
123   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
124   indent-tabs-mode:nil
125   fill-column:99
126   End:
127 */
128 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :