8#include <portals/cell_buffer.hpp>
9#include <portals/glyph_profile.hpp>
10#include <portals/scrollbar_skin.hpp>
17inline constexpr std::size_t SCROLLBAR_AXIS_LITERAL_GLYPH_COUNT = 10;
18inline constexpr std::size_t SCROLLBAR_LITERAL_THUMB_SEGMENTS = 6;
19inline constexpr std::size_t SCROLLBAR_LITERAL_CORNER = 2 * SCROLLBAR_AXIS_LITERAL_GLYPH_COUNT;
20inline constexpr std::size_t SCROLLBAR_LITERAL_GLYPH_COUNT = SCROLLBAR_LITERAL_CORNER + 1;
23struct ScrollbarGlyphLiteral {
25 std::shared_ptr<const std::string> source;
27 std::size_t column{1};
29 bool operator==(
const ScrollbarGlyphLiteral &other)
const noexcept {
30 return text == other.text;
34using ScrollbarGlyphRefs = std::array<std::shared_ptr<const ScrollbarGlyphLiteral>, SCROLLBAR_LITERAL_GLYPH_COUNT>;
35using ScrollbarGlyphStates = std::array<ScrollbarGlyphRefs, 6>;
37static_assert(std::is_nothrow_default_constructible_v<ScrollbarGlyphStates>);
38static_assert(std::is_nothrow_copy_constructible_v<ScrollbarGlyphStates>);
39static_assert(std::is_nothrow_move_constructible_v<ScrollbarGlyphStates>);
43struct ScrollbarGlyphStorage : std::optional<ScrollbarGlyphStates> {
44 using Base = std::optional<ScrollbarGlyphStates>;
46 using Base::operator=;
48 ScrollbarGlyphStorage() =
default;
49 ScrollbarGlyphStorage(ScrollbarGlyphStorage &&) =
default;
50 ScrollbarGlyphStorage &operator=(ScrollbarGlyphStorage &&) =
default;
52 ScrollbarGlyphStorage(
const ScrollbarGlyphStorage &other)
noexcept {
58 ScrollbarGlyphStorage &operator=(
const ScrollbarGlyphStorage &other)
noexcept {
71static_assert(
sizeof(ScrollbarGlyphStorage) ==
sizeof(std::optional<ScrollbarGlyphStates>));
73bool equalScrollbarGlyphs(
const ScrollbarGlyphRefs &left,
const ScrollbarGlyphRefs &right)
noexcept;
74bool equalScrollbarGlyphs(
const ScrollbarGlyphStates &left,
const ScrollbarGlyphStates &right)
noexcept;
80 std::optional<CellStyle>
line{};
81 std::optional<CellStyle>
title{};
82 std::optional<CellStyle>
ends{};
92 std::optional<CellStyle>
track{};
93 std::optional<CellStyle>
thumb{};
94 std::optional<CellStyle>
ends{};
177 std::array<FrameAppearance, 6>
frame{};
191 detail::ScrollbarGlyphStorage scrollbarGlyphs{};
202struct StyleGlyphBlock {
203 std::array<GlyphAppearance, 6> values{};
204 std::shared_ptr<const ScrollbarGlyphStates> literals;
205 std::shared_ptr<const StyleSizing> sizing;
206 std::shared_ptr<const std::array<SliderAppearance, 6>> sliderParts;
208 bool operator==(
const StyleGlyphBlock &other)
const noexcept;
211struct StyleSnapshotBlocks {
212 std::shared_ptr<const std::array<FrameAppearance, 6>> frame;
213 std::shared_ptr<const std::array<ScrollbarAppearance, 6>> scrollbar;
214 std::shared_ptr<const std::array<ScrollbarThumbAppearance, 6>> thumb;
215 std::shared_ptr<const StyleGlyphBlock> glyphs;
218std::size_t styleBlockHash(
const std::array<FrameAppearance, 6> &value)
noexcept;
219std::size_t styleBlockHash(
const std::array<ScrollbarAppearance, 6> &value)
noexcept;
220std::size_t styleBlockHash(
const std::array<ScrollbarThumbAppearance, 6> &value)
noexcept;
221std::size_t styleBlockHash(
const std::array<GlyphAppearance, 6> &value)
noexcept;
222std::size_t styleBlockHash(
const StyleGlyphBlock &value)
noexcept;
233 friend class StyleEngine;
235 PreparedTag() =
default;
238 PreparedTag(
const PreparedTag &) =
default;
259 const std::array<FrameAppearance, 6> &
frame() const noexcept;
269 const detail::ScrollbarGlyphStates *scrollbarGlyphs() const noexcept;
293 friend class StyleEngine;
294 detail::StyleSnapshotBlocks blocks_;
300struct ComputedStyleView {
308 const std::array<FrameAppearance, 6> &
frame;
309 const std::array<ScrollbarAppearance, 6> &
scrollbar;
311 const std::array<SliderAppearance, 6> *
sliderParts;
312 const std::array<GlyphAppearance, 6> &
glyphs;
313 const ScrollbarGlyphStates *scrollbarGlyphs;
321 sliderParts(value.sliderParts ? &*value.sliderParts :
nullptr),
glyphs(value.glyphs),
322 scrollbarGlyphs(value.scrollbarGlyphs ? &*value.scrollbarGlyphs :
nullptr),
323 sizing(value.sizing ? &*value.sizing :
nullptr) {
330 sliderParts(value.sliderParts()),
glyphs(value.glyphs()), scrollbarGlyphs(value.scrollbarGlyphs()),
bool hasGlyphs() const noexcept
const std::array< ScrollbarThumbAppearance, 6 > * scrollbarThumbSegments() const noexcept
CellStyle disabled
Disabled control text and fill.
Definition style_types.hpp:244
CellStyle header
Fixed table heading.
Definition style_types.hpp:246
const std::array< FrameAppearance, 6 > & frame() const noexcept
const std::array< GlyphAppearance, 6 > & glyphs() const noexcept
bool hasScrollbar() const noexcept
const StyleSizing * sizing() const noexcept
ComputedStyle flatten() const noexcept
const std::array< ScrollbarAppearance, 6 > & scrollbar() const noexcept
CellStyle normal
Ordinary text and fill.
Definition style_types.hpp:242
const std::array< SliderAppearance, 6 > * sliderParts() const noexcept
CellStyle caret
Editor software caret.
Definition style_types.hpp:247
bool hasFrame() const noexcept
bool hasThumbSegments() const noexcept
CellStyle selected
Selected row or editor range.
Definition style_types.hpp:245
CellStyle focused
Focused control text and fill.
Definition style_types.hpp:243
StyleSnapshot(const ComputedStyle &value)
Prepare the complete immutable value; may throw std::bad_alloc.
std::size_t contentHash() const noexcept
std::int32_t minWidth
Nonnegative hard column minimum.
Definition style_types.hpp:248
Public Portals API.
Definition action.hpp:8
ui::ValueText text(std::format_string< const ui::detail::TextArgumentValue< Args > &... > pattern, Args &&...args)
Declare live formatted text over explicit scalar roots, fields or value properties.
Definition ui_value_text.hpp:567
StyleSizeMode
State-independent style request for one allocation axis.
Definition style_types.hpp:139
@ AUTOMATIC
Use the ordinary preferred/intrinsic allocation.
Definition style_types.hpp:140
@ AUTOMATIC
Use the preferred/intrinsic extent; shrink towards minimum when space is scarce.
Definition layout.hpp:13
@ CONTENT
Prefer intrinsic size, shrink towards minimum, and never grow to consume spare cells.
Definition layout.hpp:16
@ FIXED
Keep the bounded preferred/intrinsic extent even when it overflows the available space.
Definition layout.hpp:14
@ FLEX
Share spare main-axis cells by weight; allow shrinking towards minimum.
Definition layout.hpp:15
Small owning paint value, independent of themes and text metrics.
Definition cell_buffer.hpp:35
Owning resolved presentation; no actions or model state are encoded.
Definition style_types.hpp:169
CellStyle normal
Ordinary text and fill.
Definition style_types.hpp:170
std::optional< StyleSizing > sizing
Inline scratch constraints; resolution and copying never allocate.
Definition style_types.hpp:193
bool operator==(const ComputedStyle &other) const noexcept
std::optional< std::array< ScrollbarThumbAppearance, 6 > > scrollbarThumbSegments
Optional complete segment values in normal/focused/disabled/selected/header/caret order....
Definition style_types.hpp:183
CellStyle disabled
Disabled control text and fill.
Definition style_types.hpp:172
std::array< GlyphAppearance, 6 > glyphs
Definition style_types.hpp:189
CellStyle caret
Editor software caret.
Definition style_types.hpp:175
CellStyle header
Fixed table heading.
Definition style_types.hpp:174
std::array< ScrollbarAppearance, 6 > scrollbar
Parts in normal/focused/disabled/selected/header/caret order.
Definition style_types.hpp:178
std::int32_t minWidth
Nonnegative hard column minimum; zero adds no style constraint.
Definition style_types.hpp:176
CellStyle selected
Selected list/table row or editor range.
Definition style_types.hpp:173
std::array< FrameAppearance, 6 > frame
Parts in normal/focused/disabled/selected/header/caret order.
Definition style_types.hpp:177
CellStyle focused
Focused control text and fill.
Definition style_types.hpp:171
std::optional< std::array< SliderAppearance, 6 > > sliderParts
Complete Slider paints in normal/focused/disabled/selected/header/caret order. Engaged only for match...
Definition style_types.hpp:188
Resolved frame parts; absent parts inherit the ordinary control state.
Definition style_types.hpp:79
bool operator==(const FrameAppearance &other) const =default
std::optional< CellStyle > ends
Prefix/suffix appearance, including their spacing.
Definition style_types.hpp:82
std::optional< CellStyle > title
Title text appearance.
Definition style_types.hpp:81
std::optional< CellStyle > line
Perimeter glyph appearance.
Definition style_types.hpp:80
Logical glyph overrides; absent values retain the control's owning manual map.
Definition style_types.hpp:130
std::optional< GlyphFallback > fallback
Explicit admission fallback.
Definition style_types.hpp:132
std::optional< GlyphProfile > profile
Explicit base map, independent of colors.
Definition style_types.hpp:131
constexpr bool operator==(const GlyphAppearance &other) const =default
Complete resolved Slider part paints, inheriting the ordinary control state.
Definition style_types.hpp:120
bool operator==(const SliderAppearance &other) const =default
CellStyle thumb
Movable position indicator.
Definition style_types.hpp:123
CellStyle track
Unfilled rail cells.
Definition style_types.hpp:121
CellStyle fill
Filled rail prefix.
Definition style_types.hpp:122
One tagged style mode; changing mode leaves no former exact-size constraint.
Definition style_types.hpp:147
StyleSizeMode mode
Allocation request.
Definition style_types.hpp:148
std::uint32_t weight
Positive FLEX weight.
Definition style_types.hpp:150
constexpr bool operator==(const StyleAxisSize &other) const =default
std::int32_t extent
Nonnegative cells for FIXED; otherwise zero.
Definition style_types.hpp:149
Sparse style sizing; legacy min-width remains solely in minWidth.
Definition style_types.hpp:157
constexpr bool operator==(const StyleSizing &other) const =default
std::optional< StyleAxisSize > width
Horizontal mode request.
Definition style_types.hpp:158
std::optional< std::int32_t > maxHeight
Inclusive nonnegative row cap.
Definition style_types.hpp:162
std::optional< std::int32_t > maxWidth
Inclusive nonnegative column cap.
Definition style_types.hpp:160
std::optional< std::int32_t > minHeight
Nonnegative hard row minimum.
Definition style_types.hpp:161
std::optional< StyleAxisSize > height
Vertical mode request.
Definition style_types.hpp:159