![]() |
KiCad PCB EDA Suite
|
Class representing a simple color swatch, of the kind used to set layer colors. More...
#include <color_swatch.h>
Public Member Functions | |
COLOR_SWATCH (wxWindow *aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground, const KIGFX::COLOR4D aDefault, SWATCH_SIZE aSwatchType) | |
Construct a COLOR_SWATCH. More... | |
COLOR_SWATCH (wxWindow *aParent, wxWindowID aId, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0) | |
constructor for wxFormBuilder More... | |
void | SetSwatchColor (KIGFX::COLOR4D aColor, bool aSendEvent) |
Set the current swatch color directly. More... | |
void | SetDefaultColor (KIGFX::COLOR4D aColor) |
Sets the color that will be chosen with the "Reset to Default" button in the chooser. More... | |
void | SetSwatchBackground (KIGFX::COLOR4D aBackground) |
Set the swatch background color. More... | |
KIGFX::COLOR4D | GetSwatchColor () const |
void | GetNewSwatchColor () |
Prompt for a new colour, using the colour picker dialog. More... | |
void | SetReadOnly (bool aReadOnly=true) |
bool | IsReadOnly () const |
void | SetReadOnlyCallback (std::function< void()> aCallback) |
Registers a handler for when the user tries to interact with a read-only swatch. More... | |
Static Public Member Functions | |
static wxBitmap | MakeBitmap (KIGFX::COLOR4D aColor, KIGFX::COLOR4D aBackground, wxSize aSize, wxSize aCheckerboardSize, KIGFX::COLOR4D aCheckerboardBackground) |
Make a simple color swatch bitmap. More... | |
Private Member Functions | |
void | setupEvents () |
void | rePostEvent (wxEvent &aEvent) |
Pass unwanted events on to listeners of this object. More... | |
Private Attributes | |
KIGFX::COLOR4D | m_color |
KIGFX::COLOR4D | m_background |
KIGFX::COLOR4D | m_default |
wxStaticBitmap * | m_swatch |
wxSize | m_size |
wxSize | m_checkerboardSize |
KIGFX::COLOR4D | m_checkerboardBg |
bool | m_readOnly |
A read-only swatch won't show the color chooser dialog but otherwise works normally. More... | |
std::function< void()> | m_readOnlyCallback |
Class representing a simple color swatch, of the kind used to set layer colors.
Definition at line 57 of file color_swatch.h.
COLOR_SWATCH::COLOR_SWATCH | ( | wxWindow * | aParent, |
KIGFX::COLOR4D | aColor, | ||
int | aID, | ||
KIGFX::COLOR4D | aBackground, | ||
const KIGFX::COLOR4D | aDefault, | ||
SWATCH_SIZE | aSwatchType | ||
) |
Construct a COLOR_SWATCH.
aParent | parent window |
aColor | initial swatch color |
aID | id to use when sending swatch events |
Definition at line 116 of file color_swatch.cpp.
References CHECKERBOARD_SIZE_DU(), m_checkerboardBg, m_checkerboardSize, m_size, m_swatch, MakeBitmap(), setupEvents(), SWATCH_EXPAND, SWATCH_LARGE, SWATCH_MEDIUM, SWATCH_SIZE_LARGE_DU(), SWATCH_SIZE_MEDIUM_DU(), SWATCH_SIZE_SMALL_DU(), and SWATCH_SMALL.
COLOR_SWATCH::COLOR_SWATCH | ( | wxWindow * | aParent, |
wxWindowID | aId, | ||
const wxPoint & | aPos = wxDefaultPosition , |
||
const wxSize & | aSize = wxDefaultSize , |
||
long | aStyle = 0 |
||
) |
constructor for wxFormBuilder
Definition at line 150 of file color_swatch.cpp.
References CHECKERBOARD_SIZE_DU(), m_checkerboardBg, m_checkerboardSize, m_size, m_swatch, MakeBitmap(), setupEvents(), and SWATCH_SIZE_MEDIUM_DU().
void COLOR_SWATCH::GetNewSwatchColor | ( | ) |
Prompt for a new colour, using the colour picker dialog.
A colour change event will be sent if it's set.
Definition at line 266 of file color_swatch.cpp.
References DIALOG_COLOR_PICKER::GetColor(), m_background, m_checkerboardBg, m_checkerboardSize, m_color, m_default, m_readOnly, m_readOnlyCallback, m_size, m_swatch, MakeBitmap(), and sendSwatchChangeEvent().
Referenced by APPEARANCE_CONTROLS::onNetclassContextMenu(), LAYER_WIDGET::OnRightDownLayer(), LAYER_WIDGET::OnRightDownRender(), and setupEvents().
COLOR4D COLOR_SWATCH::GetSwatchColor | ( | ) | const |
Definition at line 260 of file color_swatch.cpp.
References m_color.
Referenced by PANEL_COLOR_SETTINGS::OnColorChanged(), APPEARANCE_CONTROLS::OnColorSwatchChanged(), LAYER_WIDGET::OnLayerSwatchChanged(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow(), DIALOG_EDIT_LINE_STYLE::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().
|
inline |
Definition at line 105 of file color_swatch.h.
References m_readOnly.
|
static |
Make a simple color swatch bitmap.
aWindow | - window used as context for device-independent size |
Definition at line 44 of file color_swatch.cpp.
References BLACK, KIGFX::COLOR4D::Brightened(), color, KIGFX::COLOR4D::Darkened(), KIGFX::COLOR4D::GetBrightness(), WHITE, and KIGFX::COLOR4D::WithAlpha().
Referenced by COLOR_SWATCH(), GRID_CELL_COLOR_RENDERER::Draw(), GetNewSwatchColor(), DIALOG_COLOR_PICKER::initDefinedColors(), SetSwatchBackground(), SetSwatchColor(), ZONE_SETTINGS::SetupLayersList(), and DIALOG_COLOR_PICKER::updatePreview().
|
private |
Pass unwanted events on to listeners of this object.
Definition at line 216 of file color_swatch.cpp.
Referenced by setupEvents().
void COLOR_SWATCH::SetDefaultColor | ( | KIGFX::COLOR4D | aColor | ) |
Sets the color that will be chosen with the "Reset to Default" button in the chooser.
Definition at line 246 of file color_swatch.cpp.
References m_default.
Referenced by DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS(), DIALOG_JUNCTION_PROPS::DIALOG_JUNCTION_PROPS(), PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS(), and DIALOG_SHEET_PROPERTIES::TransferDataToWindow().
|
inline |
Definition at line 104 of file color_swatch.h.
References m_readOnly.
Referenced by APPEARANCE_CONTROLS::rebuildLayers().
|
inline |
Registers a handler for when the user tries to interact with a read-only swatch.
Definition at line 108 of file color_swatch.h.
References m_readOnlyCallback.
Referenced by APPEARANCE_CONTROLS::rebuildLayers(), and APPEARANCE_CONTROLS::rebuildObjects().
void COLOR_SWATCH::SetSwatchBackground | ( | KIGFX::COLOR4D | aBackground | ) |
Set the swatch background color.
Definition at line 252 of file color_swatch.cpp.
References m_background, m_checkerboardBg, m_checkerboardSize, m_color, m_size, m_swatch, and MakeBitmap().
Referenced by LAYER_WIDGET::OnRenderSwatchChanged(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow(), and DIALOG_SHEET_PROPERTIES::TransferDataToWindow().
void COLOR_SWATCH::SetSwatchColor | ( | KIGFX::COLOR4D | aColor, |
bool | aSendEvent | ||
) |
Set the current swatch color directly.
Definition at line 234 of file color_swatch.cpp.
References m_background, m_checkerboardBg, m_checkerboardSize, m_color, m_size, m_swatch, MakeBitmap(), and sendSwatchChangeEvent().
Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS(), DIALOG_JUNCTION_PROPS::resetDefaults(), DIALOG_EDIT_LINE_STYLE::resetDefaults(), PANEL_COLOR_SETTINGS::ResetPanel(), DIALOG_JUNCTION_PROPS::TransferDataToWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow(), DIALOG_EDIT_LINE_STYLE::TransferDataToWindow(), and DIALOG_SHEET_PROPERTIES::TransferDataToWindow().
|
private |
Definition at line 178 of file color_swatch.cpp.
References GetNewSwatchColor(), m_swatch, and rePostEvent().
Referenced by COLOR_SWATCH().
|
private |
Definition at line 122 of file color_swatch.h.
Referenced by GetNewSwatchColor(), SetSwatchBackground(), and SetSwatchColor().
|
private |
Definition at line 129 of file color_swatch.h.
Referenced by COLOR_SWATCH(), GetNewSwatchColor(), SetSwatchBackground(), and SetSwatchColor().
|
private |
Definition at line 128 of file color_swatch.h.
Referenced by COLOR_SWATCH(), GetNewSwatchColor(), SetSwatchBackground(), and SetSwatchColor().
|
private |
Definition at line 121 of file color_swatch.h.
Referenced by GetNewSwatchColor(), GetSwatchColor(), SetSwatchBackground(), and SetSwatchColor().
|
private |
Definition at line 123 of file color_swatch.h.
Referenced by GetNewSwatchColor(), and SetDefaultColor().
|
private |
A read-only swatch won't show the color chooser dialog but otherwise works normally.
Definition at line 132 of file color_swatch.h.
Referenced by GetNewSwatchColor(), IsReadOnly(), and SetReadOnly().
|
private |
Definition at line 133 of file color_swatch.h.
Referenced by GetNewSwatchColor(), and SetReadOnlyCallback().
|
private |
Definition at line 127 of file color_swatch.h.
Referenced by COLOR_SWATCH(), GetNewSwatchColor(), SetSwatchBackground(), and SetSwatchColor().
|
private |
Definition at line 125 of file color_swatch.h.
Referenced by COLOR_SWATCH(), GetNewSwatchColor(), SetSwatchBackground(), SetSwatchColor(), and setupEvents().