Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
color-preview.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Lauris Kaplinski <lauris@kaplinski.com>
5 * Ralf Stephan <ralf@ark.in-berlin.de>
6 * Michael Kowalski
7 *
8 * Copyright (C) 2001-2005 Authors
9 * Copyright (C) 2001 Ximian, Inc.
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SEEN_COLOR_PREVIEW_H
15#define SEEN_COLOR_PREVIEW_H
16
17#include <cairomm/pattern.h>
18#include <cstdint>
19#include <cairomm/refptr.h>
20#include <gtkmm/drawingarea.h>
21
22namespace Cairo {
23class Context;
24} // namespace Cairo
25
26namespace Inkscape::UI::Widget {
27
43class ColorPreview final : public Gtk::DrawingArea {
44public:
45 ColorPreview(std::uint32_t rgba);
46 // set preview color RGBA with opacity (alpha)
47 void setRgba32(std::uint32_t rgba);
48 // set arbitrary pattern-based preview
49 void setPattern(Cairo::RefPtr<Cairo::Pattern> pattern);
50 // simple color patch vs outlined color patch
52 void setStyle(Style style);
53 // add indicator on top of the preview: swatch or spot color
55 void setIndicator(Indicator indicator);
56private:
57 std::uint32_t _rgba; // requested RGBA color, used if there is no pattern given
58 Cairo::RefPtr<Cairo::Pattern> _pattern; // pattern to show, if provided
61 void draw_func(Cairo::RefPtr<Cairo::Context> const &cr, int width, int height);
62};
63
64} // namespace Inkscape::UI::Widget
65
66#endif // SEEN_COLOR_PREVIEW_H
67
68/*
69 Local Variables:
70 mode:c++
71 c-file-style:"stroustrup"
72 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
73 indent-tabs-mode:nil
74 fill-column:99
75 End:
76*/
77// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
A color preview widget, used within a picker button and style indicator.
Cairo::RefPtr< Cairo::Pattern > _pattern
void draw_func(Cairo::RefPtr< Cairo::Context > const &cr, int width, int height)
void setIndicator(Indicator indicator)
void setRgba32(std::uint32_t rgba)
void setPattern(Cairo::RefPtr< Cairo::Pattern > pattern)
Control handle rendering/caching.
Custom widgets.
Definition desktop.h:126
static constexpr int height
double width