MColorPicker
- Module
- Miri
- Header
#include "Miri/Widgets/MColorPicker.h"- Namespace
Miri
Properties
| Type | Name | Description |
|---|---|---|
MiriDelegate<void(const MiriColor&)> | OnColorChanged | |
MiriDelegate<void(bool)> | OnClosed | Enter -> OnClosed(true); Escape -> current color reverts to the original, then OnClosed(false). Hosts embed the picker and use this as the accept/cancel signal. |
Public functions
| Returns | Name | Description |
|---|---|---|
MIRI_WIDGET_ARGS | ||
MiriVec2 | ComputeDesiredSize | |
int32_t | OnPaint | |
CReply | OnMouseButtonDown | |
CReply | OnMouseButtonUp | |
CReply | OnMouseMove | |
EMiriCursorType | OnCursorQuery | |
void | OnMouseCaptureLost | |
CReply | OnKeyDown | |
CReply | OnKeyChar | |
bool | IsTextInput | While the hex field is being edited the picker is a text box: a typed "f" or "e" belongs to the hex value, not to Focus Selection or Rotate. |
void | OnFocusLost | |
MiriColor | GetColor | |
void | SetColor | |
void | SetOriginalColor | |
MiriColor | GetOriginalColor | |
void | SetShowAlpha | The alpha row is a whole slider's worth of height. |
bool | IsHexEditing | |
void | SetEyedropperSampler | In-window eyedropper: the host installs a sampler that resolves a window-space position to a color (the editor samples the rendered viewport). |
uint32_t | GetSavedColors | The saved swatches are ONE process-wide palette — every picker shares it, so a colour saved while editing a light is offered in the material editor a minute later. |
void | SetSavedColors | |
void | SetOnSavedColorsChanged | |
bool | IsSrgbDisplay | How the NUMBERS are shown and parsed — the stored colour never changes. |
void | SetSrgbDisplay | |
bool | CanCacheDesiredSize | A fixed card whose height only depends on whether the alpha row is shown; the colour being edited never resizes it. |
const char* | GetTypeName |
Function details
MIRI_WIDGET_ARGS
MIRI_WIDGET_ARGS(MColorPicker) MIRI_ATTR(MiriColor, InitialColor) MIRI_ARG(bool, ShowAlpha) MIRI_ARG(bool, DrawBackground) MIRI_WIDGET_ARGS_END() void Construct(const CArguments& args)ComputeDesiredSize
MiriVec2 ComputeDesiredSize(float scale) const overrideOnPaint
int32_t OnPaint(const CMiriPaintArgs& args, const CGeometry& geo, CMiriRenderer& renderer, int32_t layerId) const overrideOnMouseButtonDown
CReply OnMouseButtonDown(const CGeometry& geo, const CPointerEvent& event) overrideOnMouseButtonUp
CReply OnMouseButtonUp(const CGeometry& geo, const CPointerEvent& event) overrideOnMouseMove
CReply OnMouseMove(const CGeometry& geo, const CPointerEvent& event) overrideOnCursorQuery
EMiriCursorType OnCursorQuery(const CGeometry& geo, const CPointerEvent& event) const overrideOnMouseCaptureLost
void OnMouseCaptureLost() overrideOnKeyDown
CReply OnKeyDown(const CGeometry& geo, const CKeyEvent& event) overrideOnKeyChar
CReply OnKeyChar(const CGeometry& geo, const CCharacterEvent& event) overrideIsTextInput
bool IsTextInput() const overrideWhile the hex field is being edited the picker is a text box: a typed "f" or "e" belongs to the hex value, not to Focus Selection or Rotate.
OnFocusLost
void OnFocusLost(const CFocusEvent& event) overrideGetColor
MiriColor GetColor() constSetColor
void SetColor(const MiriColor& color)SetOriginalColor
void SetOriginalColor(const MiriColor& color)GetOriginalColor
MiriColor GetOriginalColor() constSetShowAlpha
void SetShowAlpha(bool show)The alpha row is a whole slider's worth of height.
IsHexEditing
bool IsHexEditing() constSetEyedropperSampler
static void SetEyedropperSampler(std::function<bool(const MiriVec2&, MiriColor&)> sampler)In-window eyedropper: the host installs a sampler that resolves a window-space position to a color (the editor samples the rendered viewport). Without a sampler the pipette button hides. While active the picker live-previews under the cursor; click commits, Escape restores the pre-activation color.
GetSavedColors
static uint32_t GetSavedColors(std::array<MiriColor, 8>& out)The saved swatches are ONE process-wide palette — every picker shares it, so a colour saved while editing a light is offered in the material editor a minute later. The host may persist it: Get/Set round-trip the palette and the callback fires after every user edit.
SetSavedColors
static void SetSavedColors(const MiriColor* colors, uint32_t count)SetOnSavedColorsChanged
static void SetOnSavedColorsChanged(std::function<void()> callback)IsSrgbDisplay
static bool IsSrgbDisplay()How the NUMBERS are shown and parsed — the stored colour never changes. Engine colours (light tint, base colour) are LINEAR, so their raw 0..255 reads much darker than the same colour in any other tool; sRGB mode gamma-encodes the hex and the R/G/B labels so a value can be copied in and out of one. Process-wide, like the saved palette: switching it in one picker switches it everywhere. Linear (raw) is the default — that is what every picker showed before the toggle existed.
SetSrgbDisplay
static void SetSrgbDisplay(bool srgb)CanCacheDesiredSize
bool CanCacheDesiredSize() const overrideA fixed card whose height only depends on whether the alpha row is shown; the colour being edited never resizes it.
GetTypeName
const char* GetTypeName() const override