Inkscape
Vector Graphics Editor
|
A color preview widget, used within a picker button and style indicator. More...
#include <color-preview.h>
Public Types | |
enum | Style { Simple , Outlined } |
enum | Indicator { None , Swatch , SpotColor } |
Public Member Functions | |
ColorPreview (std::uint32_t rgba) | |
void | setRgba32 (std::uint32_t rgba) |
void | setPattern (Cairo::RefPtr< Cairo::Pattern > pattern) |
void | setStyle (Style style) |
void | setIndicator (Indicator indicator) |
Private Member Functions | |
void | draw_func (Cairo::RefPtr< Cairo::Context > const &cr, int width, int height) |
Private Attributes | |
std::uint32_t | _rgba |
Cairo::RefPtr< Cairo::Pattern > | _pattern |
Style | _style = Simple |
Indicator | _indicator = None |
A color preview widget, used within a picker button and style indicator.
It can show RGBA color or Cairo pattern.
RGBA colors are split in half to show solid color and transparency, if any. RGBA colors are also manipulated to reduce intensity if color preview is disabled.
Patterns are shown "as is" on top of the checkerboard. There's no separate "disabled" look for patterns.
Outlined style can be used to surround color patch with a contrasting border. Border is dark-theme-aware.
Indicators can be used to distinguish ad-hoc colors from swatches and spot colors.
Definition at line 43 of file color-preview.h.
Enumerator | |
---|---|
None | |
Swatch | |
SpotColor |
Definition at line 54 of file color-preview.h.
Enumerator | |
---|---|
Simple | |
Outlined |
Definition at line 51 of file color-preview.h.
Inkscape::UI::Widget::ColorPreview::ColorPreview | ( | std::uint32_t | rgba | ) |
Definition at line 33 of file color-preview.cpp.
References _style, draw_func(), and setStyle().
|
private |
Definition at line 76 of file color-preview.cpp.
References _indicator, _pattern, _rgba, _style, cairo_line_to(), Inkscape::UI::Widget::create_checkerboard_pattern(), get_luminance(), Inkscape::UI::Widget::height, Inkscape::Colors::Space::HSLUV, ink_cairo_set_source_rgba32(), Inkscape::Colors::lightness(), None, Outlined, Inkscape::Colors::Space::RGB, rgb, Inkscape::UI::Widget::round_rect(), Simple, SpotColor, Swatch, and width.
Referenced by ColorPreview().
void Inkscape::UI::Widget::ColorPreview::setIndicator | ( | Indicator | indicator | ) |
Definition at line 231 of file color-preview.cpp.
References _indicator.
void Inkscape::UI::Widget::ColorPreview::setPattern | ( | Cairo::RefPtr< Cairo::Pattern > | pattern | ) |
Definition at line 49 of file color-preview.cpp.
void Inkscape::UI::Widget::ColorPreview::setRgba32 | ( | std::uint32_t | rgba | ) |
Definition at line 41 of file color-preview.cpp.
References _pattern, and _rgba.
Referenced by Inkscape::UI::Widget::ColorPicker::set_preview().
void Inkscape::UI::Widget::ColorPreview::setStyle | ( | Style | style | ) |
Definition at line 220 of file color-preview.cpp.
References _style, and Simple.
Referenced by Inkscape::UI::Widget::ColorPicker::_construct(), and ColorPreview().
Definition at line 60 of file color-preview.h.
Referenced by draw_func(), and setIndicator().
|
private |
Definition at line 58 of file color-preview.h.
Referenced by draw_func(), setPattern(), and setRgba32().
|
private |
Definition at line 57 of file color-preview.h.
Referenced by draw_func(), setPattern(), and setRgba32().
Definition at line 59 of file color-preview.h.
Referenced by ColorPreview(), draw_func(), and setStyle().