|
KiCad PCB EDA Suite
|
A simple color swatch of the kind used to set layer colors. More...
#include <color_swatch.h>
Public Member Functions | |
| COLOR_SWATCH (wxWindow *aParent, const KIGFX::COLOR4D &aColor, int aID, const KIGFX::COLOR4D &aBackground, const KIGFX::COLOR4D &aDefault, SWATCH_SIZE aSwatchType, bool aTriggerWithSingleClick=false) | |
| Construct a COLOR_SWATCH. | |
| COLOR_SWATCH (wxWindow *aParent, wxWindowID aId, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0) | |
| Constructor for wxFormBuilder. | |
| void | SetSwatchColor (const KIGFX::COLOR4D &aColor, bool aSendEvent) |
| Set the current swatch color directly. | |
| void | SetDefaultColor (const KIGFX::COLOR4D &aColor) |
| Sets the color that will be chosen with the "Reset to Default" button in the chooser. | |
| void | SetSwatchBackground (const KIGFX::COLOR4D &aBackground) |
| Set the swatch background color. | |
| KIGFX::COLOR4D | GetSwatchColor () const |
| void | SetWindowID (wxWindowID aId) |
| Update the window ID of this control and its children. | |
| void | GetNewSwatchColor () |
| Prompt for a new colour, using the colour picker dialog. | |
| void | SetReadOnly (bool aReadOnly=true) |
| bool | IsReadOnly () const |
| void | SetSupportsOpacity (bool aSupportsOpacity) |
| void | SetReadOnlyCallback (std::function< void()> aCallback) |
| Register a handler for when the user tries to interact with a read-only swatch. | |
| void | OnDarkModeToggle () |
| Respond to a change in the OS's DarkMode setting. | |
Static Public Member Functions | |
| static wxBitmap | MakeBitmap (const KIGFX::COLOR4D &aColor, const KIGFX::COLOR4D &aBackground, const wxSize &aSize, const wxSize &aCheckerboardSize, const KIGFX::COLOR4D &aCheckerboardBackground, const std::vector< int > &aMargins={ 0, 0, 0, 0 }) |
| static void | RenderToDC (wxDC *aDC, const KIGFX::COLOR4D &aColor, const KIGFX::COLOR4D &aBackground, const wxRect &aRect, const wxSize &aCheckerboardSize, const KIGFX::COLOR4D &aCheckerboardBackground, const std::vector< int > &aMargins={ 0, 0, 0, 0 }) |
Private Member Functions | |
| void | setupEvents (bool aTriggerWithSingleClick) |
| wxBitmap | makeBitmap () |
| void | rePostEvent (wxEvent &aEvent) |
| Pass unwanted events on to listeners of this object. | |
| void | onMouseEvent (wxEvent &aEvent) |
| Handle mouse events on the swatch, and trigger the color picker dialog if appropriate. | |
Private Attributes | |
| KIGFX::COLOR4D | m_color |
| KIGFX::COLOR4D | m_background |
| KIGFX::COLOR4D | m_default |
| CUSTOM_COLORS_LIST * | m_userColors |
| 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. | |
| std::function< void()> | m_readOnlyCallback |
| bool | m_supportsOpacity |
| If opacity is not supported the color chooser dialog will be displayed without it. | |
A simple color swatch of the kind used to set layer colors.
Definition at line 55 of file color_swatch.h.
| COLOR_SWATCH::COLOR_SWATCH | ( | wxWindow * | aParent, |
| const KIGFX::COLOR4D & | aColor, | ||
| int | aID, | ||
| const KIGFX::COLOR4D & | aBackground, | ||
| const KIGFX::COLOR4D & | aDefault, | ||
| SWATCH_SIZE | aSwatchType, | ||
| bool | aTriggerWithSingleClick = false ) |
Construct a COLOR_SWATCH.
| aParent | parent window. |
| aColor | initial swatch color. |
| aID | id to use when sending swatch events. |
Definition at line 150 of file color_swatch.cpp.
References CHECKERBOARD_SIZE_DU(), m_background, m_checkerboardBg, m_checkerboardSize, m_color, m_default, m_readOnly, m_size, m_supportsOpacity, m_swatch, m_userColors, 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 185 of file color_swatch.cpp.
References CHECKERBOARD_SIZE_DU(), m_checkerboardBg, m_checkerboardSize, m_readOnly, m_size, m_supportsOpacity, m_swatch, m_userColors, 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 300 of file color_swatch.cpp.
References DIALOG_COLOR_PICKER::GetColor(), m_color, m_default, m_readOnly, m_readOnlyCallback, m_supportsOpacity, m_swatch, m_userColors, makeBitmap(), sendSwatchChangeEvent(), DIALOG_SHIM::ShowModal(), and COLOR4D::UNSPECIFIED.
Referenced by onMouseEvent(), APPEARANCE_CONTROLS::onNetclassContextMenu(), LAYER_WIDGET::OnRightDownLayer(), and LAYER_WIDGET::OnRightDownRender().
| COLOR4D COLOR_SWATCH::GetSwatchColor | ( | ) | const |
Definition at line 294 of file color_swatch.cpp.
References m_color.
Referenced by PANEL_COLOR_SETTINGS::OnColorChanged(), APPEARANCE_CONTROLS::OnColorSwatchChanged(), APPEARANCE_CONTROLS_3D::onColorSwatchChanged(), LAYER_WIDGET::OnLayerSwatchChanged(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), and LAYER_WIDGET::OnRenderSwatchChanged().
|
inline |
Definition at line 115 of file color_swatch.h.
References m_readOnly.
|
static |
Definition at line 37 of file color_swatch.cpp.
References RenderToDC().
Referenced by GRID_CELL_COLOR_RENDERER::Draw(), DIALOG_COLOR_PICKER::initDefinedColors(), makeBitmap(), ZONE_SETTINGS::SetupLayersList(), DIALOG_COLOR_PICKER::updatePreview(), and ZONE_PREVIEW_NOTEBOOK::ZONE_PREVIEW_NOTEBOOK().
|
private |
Definition at line 52 of file color_swatch.cpp.
References m_background, m_checkerboardBg, m_checkerboardSize, m_color, m_size, and MakeBitmap().
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), GetNewSwatchColor(), OnDarkModeToggle(), SetSwatchBackground(), and SetSwatchColor().
| void COLOR_SWATCH::OnDarkModeToggle | ( | ) |
Respond to a change in the OS's DarkMode setting.
Definition at line 328 of file color_swatch.cpp.
References m_checkerboardBg, m_swatch, and makeBitmap().
|
private |
Handle mouse events on the swatch, and trigger the color picker dialog if appropriate.
Binds to the event sink so it is properly freed when the swatch is destroyed.
Definition at line 251 of file color_swatch.cpp.
References GetNewSwatchColor().
Referenced by setupEvents().
|
static |
Definition at line 62 of file color_swatch.cpp.
References COLOR4D::BLACK, KIGFX::COLOR4D::Brightened(), KIGFX::COLOR4D::Darkened(), KIGFX::COLOR4D::GetBrightness(), KIGFX::COLOR4D::m_text, KIGFX::COLOR4D::ToColour(), COLOR4D::UNSPECIFIED, and COLOR4D::WHITE.
Referenced by MakeBitmap(), and PG_CELL_RENDERER::Render().
|
private |
Pass unwanted events on to listeners of this object.
Definition at line 245 of file color_swatch.cpp.
Referenced by setupEvents().
| void COLOR_SWATCH::SetDefaultColor | ( | const KIGFX::COLOR4D & | aColor | ) |
Sets the color that will be chosen with the "Reset to Default" button in the chooser.
Definition at line 280 of file color_swatch.cpp.
References m_default.
|
inline |
Definition at line 114 of file color_swatch.h.
References m_readOnly.
Referenced by APPEARANCE_CONTROLS::rebuildLayers().
|
inline |
Register a handler for when the user tries to interact with a read-only swatch.
Definition at line 120 of file color_swatch.h.
References m_readOnlyCallback.
Referenced by APPEARANCE_CONTROLS::rebuildLayers(), APPEARANCE_CONTROLS_3D::rebuildLayers(), and APPEARANCE_CONTROLS::rebuildObjects().
|
inline |
Definition at line 117 of file color_swatch.h.
References m_supportsOpacity.
| void COLOR_SWATCH::SetSwatchBackground | ( | const KIGFX::COLOR4D & | aBackground | ) |
Set the swatch background color.
Definition at line 286 of file color_swatch.cpp.
References m_background, m_swatch, and makeBitmap().
Referenced by LAYER_WIDGET::OnRenderSwatchChanged().
| void COLOR_SWATCH::SetSwatchColor | ( | const KIGFX::COLOR4D & | aColor, |
| bool | aSendEvent ) |
Set the current swatch color directly.
Definition at line 269 of file color_swatch.cpp.
References m_color, m_swatch, makeBitmap(), and sendSwatchChangeEvent().
Referenced by APPEARANCE_CONTROLS_3D::onColorSwatchChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), and PANEL_COLOR_SETTINGS::ResetPanel().
|
private |
Definition at line 219 of file color_swatch.cpp.
References m_swatch, onMouseEvent(), and rePostEvent().
Referenced by COLOR_SWATCH(), and COLOR_SWATCH().
|
inline |
Update the window ID of this control and its children.
| aId | new Window ID to set. |
Definition at line 101 of file color_swatch.h.
References m_swatch.
|
private |
Definition at line 152 of file color_swatch.h.
Referenced by COLOR_SWATCH(), makeBitmap(), and SetSwatchBackground().
|
private |
Definition at line 160 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), makeBitmap(), and OnDarkModeToggle().
|
private |
Definition at line 159 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), and makeBitmap().
|
private |
Definition at line 151 of file color_swatch.h.
Referenced by COLOR_SWATCH(), GetNewSwatchColor(), GetSwatchColor(), makeBitmap(), and SetSwatchColor().
|
private |
Definition at line 153 of file color_swatch.h.
Referenced by COLOR_SWATCH(), GetNewSwatchColor(), and SetDefaultColor().
|
private |
A read-only swatch won't show the color chooser dialog but otherwise works normally.
Definition at line 163 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), GetNewSwatchColor(), IsReadOnly(), and SetReadOnly().
|
private |
Definition at line 164 of file color_swatch.h.
Referenced by GetNewSwatchColor(), and SetReadOnlyCallback().
|
private |
Definition at line 158 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), and makeBitmap().
|
private |
If opacity is not supported the color chooser dialog will be displayed without it.
Definition at line 167 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), GetNewSwatchColor(), and SetSupportsOpacity().
|
private |
Definition at line 156 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), GetNewSwatchColor(), OnDarkModeToggle(), SetSwatchBackground(), SetSwatchColor(), setupEvents(), and SetWindowID().
|
private |
Definition at line 154 of file color_swatch.h.
Referenced by COLOR_SWATCH(), COLOR_SWATCH(), and GetNewSwatchColor().