3#include "structure/design_pattern/spk_observable_value.hpp"
4#include "structure/graphics/painter/spk_color_painter.hpp"
5#include "structure/graphics/spk_color.hpp"
6#include "structure/math/spk_vector2.hpp"
7#include "structure/system/event/spk_update_event.hpp"
8#include "structure/widget/spk_frame.hpp"
9#include "structure/widget/spk_grid_layout.hpp"
10#include "structure/widget/spk_linear_layout.hpp"
11#include "structure/widget/spk_slider.hpp"
12#include "structure/widget/spk_text_edit.hpp"
13#include "structure/widget/spk_widget.hpp"
41 spk::Vector2UInt _minimalSize{};
50 ColorPreview(
const std::wstring &p_name,
spk::Widget *p_parent);
55 void setMinimalSize(
const spk::Vector2UInt &p_minimalSize);
56 const spk::Vector2UInt &minimalSize()
const;
64 spk::Vector2UInt _textEditMinimalSize{};
65 uint32_t _sliderMinimalWidth = 0;
68 ComponentLine(
const std::wstring &p_name,
spk::Widget *p_parent);
76 void configureTextEditMinimalSize();
77 const spk::Vector2UInt &textEditMinimalSize()
const;
79 void setSliderMinimalWidth(uint32_t p_width);
80 uint32_t sliderMinimalWidth()
const;
83 spk::HorizontalLayout _mainLayout;
87 ColorPreview _colorPreview;
88 ComponentLine _redLine;
89 ComponentLine _greenLine;
90 ComponentLine _blueLine;
91 ComponentLine _alphaLine;
93 std::array<spk::ObservableValue<float>::Contract, 4> _sliderContracts;
96 spk::Vector2UInt _colorOutputMinimalSize{32, 32};
97 uint32_t _sliderMinimalWidth{120};
98 spk::Vector2UInt _componentTextEditMinimalSize{};
99 bool _isSyncing =
false;
101 static int _componentValueFromRatio(
float p_value);
102 static float _ratioFromComponentValue(
int p_value);
103 static bool _parseComponentText(
const std::wstring &p_text,
int &p_value);
104 static std::wstring _trimmed(
const std::wstring &p_text);
106 static int _componentValue(
const spk::Color &p_color,
size_t p_index);
107 void _setComponentValue(
size_t p_index,
int p_value);
108 ComponentLine &_line(
size_t p_index);
109 const ComponentLine &_line(
size_t p_index)
const;
111 void _syncComponentLine(
size_t p_index);
112 void _syncAllComponentLines();
113 void _handleSliderChange(
size_t p_index);
114 void _ensureComponentTextEditSizes();
115 spk::Vector2UInt _computeComponentTextEditMinimalSize(
const spk::TextEdit &p_edit)
const;
116 spk::Vector2UInt _colorFrameMinimalSize()
const;
117 void _refreshColorFrameSize();
118 void _refreshLayoutSizeHints();
Helper used to build ColorMesh instances from primitives.
Definition spk_color_painter.hpp:63
Mesh specialization for colored vertices.
Definition spk_color_painter.hpp:41
Painter that renders ColorMesh instances.
Definition spk_color_painter.hpp:169
const spk::Color & color() const
Returns the current color.
Definition spk_color_picker.cpp:220
ColorPicker(const std::wstring &p_name, spk::Widget *p_parent)
Builds a color picker widget.
Definition spk_color_picker.cpp:154
void setColor(const spk::Color &p_color)
Sets the current color.
Definition spk_color_picker.cpp:209
const spk::Vector2UInt & colorOutputMinimalSize() const
Returns the minimal size of the color preview output.
Definition spk_color_picker.cpp:239
void _onGeometryChange() override
Updates layout and geometry when the widget size changes.
Definition spk_color_picker.cpp:492
void _onUpdateEvent(spk::UpdateEvent &p_event) override
Handles periodic updates for syncing UI state.
Definition spk_color_picker.cpp:500
void setColorOutputMinimalSize(const spk::Vector2UInt &p_minimalSize)
Sets the minimal size of the color preview output.
Definition spk_color_picker.cpp:225
void setComponentSliderMinimalWidth(uint32_t p_width)
Sets the minimal width for component sliders.
Definition spk_color_picker.cpp:244
uint32_t componentSliderMinimalWidth() const
Returns the minimal width for component sliders.
Definition spk_color_picker.cpp:259
Widget frame rendered using a nine-slice background.
Definition spk_frame.hpp:19
Layout arranging elements in a grid by cell position.
Definition spk_grid_layout.hpp:27
Slider widget for selecting a ratio within [0,1].
Definition spk_slider.hpp:25
Editable text field with validation and cursor handling.
Definition spk_text_edit.hpp:29
RGBA color utility storing normalized floating components.
Definition spk_color.hpp:18
Event emitted when a drawable region needs repainting.
Definition spk_paint_event.hpp:19
Carries per-frame update timing and input state snapshot.
Definition spk_update_event.hpp:15