Inkscape
Vector Graphics Editor
|
#include <color-set.h>
Public Member Functions | |
ColorSet (std::shared_ptr< Space::AnySpace > space={}, std::optional< bool > alpha={}) | |
Construct a new ColorSet object to contain a group of colors which will be modified collectively. | |
ColorSet (ColorSet const &obj)=delete | |
IdColors::const_iterator | begin () const |
IdColors::const_iterator | end () const |
IdColors::iterator | begin () |
IdColors::iterator | end () |
bool | isBlocked () const |
bool | isGrabbed () const |
void | grab () |
Set this color to being grabbed for a continuous set of changes. | |
void | release () |
Set the color as being released from continuous changes. | |
void | block () |
void | unblock () |
Space::Components const & | getComponents () const |
Get a list of components for the color space set to this color set. | |
std::shared_ptr< Space::AnySpace > const | getSpaceConstraint () const |
std::optional< bool > const | getAlphaConstraint () const |
bool | set (Color const &color) |
Remove any other colors and set to just this one color. | |
std::optional< Color > | get () const |
Get the color if there is only one color set with set(Color) | |
void | clear () |
Reset the color set and remove all colors from it. | |
std::optional< Color > | get (std::string const &id) const |
Return a single color by it's index. | |
bool | set (std::string id, Color const &color) |
Set a single color in the color set by its id. | |
unsigned | setAll (ColorSet const &other) |
Set each of the colors from the other color set by id. | |
unsigned | setAll (Color const &other) |
Overwrite all colors so they equal the the new color. | |
unsigned | setAll (Space::Component const &c, double value) |
Set this one component to this specific value for all colors. | |
std::vector< double > | getAll (Space::Component const &c) const |
Get a list of all normalized values for this one component. | |
void | setAverage (Space::Component const &c, double value) |
Set the average value in this component by taking the average finding the delta and moving all colors by the given delta. | |
double | getAverage (Space::Component const &c) const |
Get the average value for this component across all colors. | |
Color | getAverage () const |
Return the average color between this set of colors. | |
unsigned | size () const |
Return the number of items in the color set. | |
bool | isEmpty () const |
bool | isSame () const |
Returns true if all of the colors are the same color. | |
std::shared_ptr< Space::AnySpace > | getBestSpace () const |
Return the best color space from this collection of colors. | |
bool | isValid (const Space::Component &component) const |
Public Attributes | |
sigc::signal< void()> | signal_grabbed |
sigc::signal< void()> | signal_released |
sigc::signal< void()> | signal_changed |
sigc::signal< void()> | signal_cleared |
Private Member Functions | |
bool | _set (std::string id, Color const &color) |
void | colors_changed () |
Called when the colors change in some way. | |
void | colors_cleared () |
Called when the list of colors changes (add or clear) | |
Private Attributes | |
IdColors | _colors |
std::shared_ptr< Space::AnySpace > const | _space_constraint |
std::optional< bool > const | _alpha_constraint |
bool | _grabbed = false |
bool | _blocked = false |
Definition at line 29 of file color-set.h.
Inkscape::Colors::ColorSet::ColorSet | ( | std::shared_ptr< Space::AnySpace > | space = {} , |
std::optional< bool > | alpha = {} |
||
) |
Construct a new ColorSet object to contain a group of colors which will be modified collectively.
Definition at line 26 of file color-set.cpp.
|
delete |
|
private |
Definition at line 203 of file color-set.cpp.
References _alpha_constraint, _colors, and _space_constraint.
|
inline |
Definition at line 39 of file color-set.h.
References _colors.
|
inline |
Definition at line 37 of file color-set.h.
References _colors.
|
inline |
Definition at line 53 of file color-set.h.
References _blocked.
Referenced by colors_changed(), colors_cleared(), grab(), and release().
void Inkscape::Colors::ColorSet::clear | ( | ) |
Reset the color set and remove all colors from it.
Definition at line 44 of file color-set.cpp.
References _colors, and colors_cleared().
|
private |
Called when the colors change in some way.
Definition at line 81 of file color-set.cpp.
References _blocked, block(), signal_changed, and unblock().
Referenced by set(), setAll(), setAll(), setAll(), and setAverage().
|
private |
Called when the list of colors changes (add or clear)
Definition at line 94 of file color-set.cpp.
References _blocked, block(), signal_cleared, and unblock().
Referenced by clear().
|
inline |
Definition at line 40 of file color-set.h.
References _colors.
|
inline |
Definition at line 38 of file color-set.h.
References _colors.
std::optional< Color > Inkscape::Colors::ColorSet::get | ( | ) | const |
Get the color if there is only one color set with set(Color)
Definition at line 195 of file color-set.cpp.
References get().
Referenced by get().
std::optional< Color > Inkscape::Colors::ColorSet::get | ( | std::string const & | id | ) | const |
Return a single color by it's index.
The color will be normalized before returning a copy as some functions can modify colors out of bounds.
Definition at line 236 of file color-set.cpp.
References _colors.
std::vector< double > Inkscape::Colors::ColorSet::getAll | ( | Space::Component const & | c | ) | const |
Get a list of all normalized values for this one component.
Definition at line 318 of file color-set.cpp.
|
inline |
Definition at line 59 of file color-set.h.
References _alpha_constraint.
Color Inkscape::Colors::ColorSet::getAverage | ( | ) | const |
Return the average color between this set of colors.
If space is not constrained, it will return the average in the best color space. If alpha is not constrained, the average will always include an alpha channel
Definition at line 361 of file color-set.cpp.
References _alpha_constraint, _colors, getBestSpace(), and isEmpty().
Referenced by setAverage().
double Inkscape::Colors::ColorSet::getAverage | ( | Space::Component const & | c | ) | const |
Get the average value for this component across all colors.
Definition at line 300 of file color-set.cpp.
References _colors, c, and isValid().
Referenced by GrDrag::getColor().
std::shared_ptr< Space::AnySpace > Inkscape::Colors::ColorSet::getBestSpace | ( | ) | const |
Return the best color space from this collection of colors.
If the color space is constrained then the result will be that space. Otherwise picks the space with the most colors.
Definition at line 334 of file color-set.cpp.
References _colors, and _space_constraint.
Referenced by getAverage().
Space::Components const & Inkscape::Colors::ColorSet::getComponents | ( | ) | const |
Get a list of components for the color space set to this color set.
Definition at line 34 of file color-set.cpp.
References _alpha_constraint, and _space_constraint.
|
inline |
Definition at line 58 of file color-set.h.
References _space_constraint.
void Inkscape::Colors::ColorSet::grab | ( | ) |
Set this color to being grabbed for a continuous set of changes.
Definition at line 55 of file color-set.cpp.
References _blocked, _grabbed, block(), signal_grabbed, and unblock().
|
inline |
Definition at line 43 of file color-set.h.
References _blocked.
|
inline |
|
inline |
Definition at line 44 of file color-set.h.
References _grabbed.
bool Inkscape::Colors::ColorSet::isSame | ( | ) | const |
Returns true if all of the colors are the same color.
Definition at line 106 of file color-set.cpp.
References _colors.
bool Inkscape::Colors::ColorSet::isValid | ( | const Space::Component & | component | ) | const |
Definition at line 351 of file color-set.cpp.
References _space_constraint, and Inkscape::Colors::Space::Component::type.
Referenced by getAll(), getAverage(), and setAll().
void Inkscape::Colors::ColorSet::release | ( | ) |
Set the color as being released from continuous changes.
Definition at line 68 of file color-set.cpp.
References _blocked, _grabbed, block(), signal_released, and unblock().
bool Inkscape::Colors::ColorSet::set | ( | Color const & | other | ) |
Remove any other colors and set to just this one color.
Definition at line 182 of file color-set.cpp.
Referenced by Inkscape::UI::Dialog::collect_object_colors(), and GrDrag::getColor().
bool Inkscape::Colors::ColorSet::set | ( | std::string | id, |
Color const & | other | ||
) |
Set a single color in the color set by its id.
Definition at line 166 of file color-set.cpp.
References _set(), and colors_changed().
unsigned Inkscape::Colors::ColorSet::setAll | ( | Color const & | other | ) |
Overwrite all colors so they equal the the new color.
Definition at line 124 of file color-set.cpp.
References _colors, and colors_changed().
unsigned Inkscape::Colors::ColorSet::setAll | ( | ColorSet const & | other | ) |
Set each of the colors from the other color set by id.
Creating new entries where the id is not found.
Definition at line 146 of file color-set.cpp.
References _set(), and colors_changed().
unsigned Inkscape::Colors::ColorSet::setAll | ( | Space::Component const & | c, |
double | value | ||
) |
Set this one component to this specific value for all colors.
Definition at line 253 of file color-set.cpp.
References _colors, c, colors_changed(), and isValid().
void Inkscape::Colors::ColorSet::setAverage | ( | Space::Component const & | c, |
double | value | ||
) |
Set the average value in this component by taking the average finding the delta and moving all colors by the given delta.
This will not run normalization so out of bound changes can remember their values until the mutation period is finished and normalization is run on the returned colors. see ColorSet::get().
Definition at line 282 of file color-set.cpp.
References _colors, _space_constraint, c, colors_changed(), delta, and getAverage().
unsigned Inkscape::Colors::ColorSet::size | ( | ) | const |
Return the number of items in the color set.
Definition at line 392 of file color-set.cpp.
References _colors.
|
inline |
Definition at line 54 of file color-set.h.
References _blocked.
Referenced by colors_changed(), colors_cleared(), grab(), and release().
|
private |
Definition at line 98 of file color-set.h.
Referenced by _set(), getAlphaConstraint(), getAverage(), and getComponents().
|
private |
Definition at line 102 of file color-set.h.
Referenced by block(), colors_changed(), colors_cleared(), grab(), isBlocked(), release(), and unblock().
|
private |
Definition at line 94 of file color-set.h.
Referenced by _set(), begin(), begin(), clear(), end(), end(), get(), getAll(), getAverage(), getAverage(), getBestSpace(), isEmpty(), isSame(), set(), setAll(), setAll(), setAverage(), and size().
|
private |
Definition at line 101 of file color-set.h.
Referenced by grab(), isGrabbed(), and release().
|
private |
Definition at line 97 of file color-set.h.
Referenced by _set(), getBestSpace(), getComponents(), getSpaceConstraint(), isValid(), and setAverage().
sigc::signal<void()> Inkscape::Colors::ColorSet::signal_changed |
Definition at line 48 of file color-set.h.
Referenced by colors_changed().
sigc::signal<void()> Inkscape::Colors::ColorSet::signal_cleared |
Definition at line 49 of file color-set.h.
Referenced by colors_cleared().
sigc::signal<void()> Inkscape::Colors::ColorSet::signal_grabbed |
Definition at line 46 of file color-set.h.
Referenced by grab().
sigc::signal<void()> Inkscape::Colors::ColorSet::signal_released |
Definition at line 47 of file color-set.h.
Referenced by release().