Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::UI::Widget::ColorPreview Class Referencefinal

A color preview widget, used within a picker button and style indicator. More...

#include <color-preview.h>

Inheritance diagram for Inkscape::UI::Widget::ColorPreview:

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
 

Detailed Description

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.

Member Enumeration Documentation

◆ Indicator

Enumerator
None 
Swatch 
SpotColor 

Definition at line 54 of file color-preview.h.

◆ Style

Enumerator
Simple 
Outlined 

Definition at line 51 of file color-preview.h.

Constructor & Destructor Documentation

◆ ColorPreview()

Inkscape::UI::Widget::ColorPreview::ColorPreview ( std::uint32_t  rgba)

Definition at line 33 of file color-preview.cpp.

References _style, draw_func(), and setStyle().

Member Function Documentation

◆ draw_func()

◆ setIndicator()

void Inkscape::UI::Widget::ColorPreview::setIndicator ( Indicator  indicator)

Definition at line 231 of file color-preview.cpp.

References _indicator.

◆ setPattern()

void Inkscape::UI::Widget::ColorPreview::setPattern ( Cairo::RefPtr< Cairo::Pattern >  pattern)

Definition at line 49 of file color-preview.cpp.

References _pattern, and _rgba.

◆ setRgba32()

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().

◆ setStyle()

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().

Member Data Documentation

◆ _indicator

Indicator Inkscape::UI::Widget::ColorPreview::_indicator = None
private

Definition at line 60 of file color-preview.h.

Referenced by draw_func(), and setIndicator().

◆ _pattern

Cairo::RefPtr<Cairo::Pattern> Inkscape::UI::Widget::ColorPreview::_pattern
private

Definition at line 58 of file color-preview.h.

Referenced by draw_func(), setPattern(), and setRgba32().

◆ _rgba

std::uint32_t Inkscape::UI::Widget::ColorPreview::_rgba
private

Definition at line 57 of file color-preview.h.

Referenced by draw_func(), setPattern(), and setRgba32().

◆ _style

Style Inkscape::UI::Widget::ColorPreview::_style = Simple
private

Definition at line 59 of file color-preview.h.

Referenced by ColorPreview(), draw_func(), and setStyle().


The documentation for this class was generated from the following files: