Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
ui_components.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <pulp/view/view.hpp>
10#include <algorithm>
13#include <pulp/view/slider_core.hpp> // Notify, queue_async_notification
15#include <functional>
16#include <string>
17#include <string_view>
18#include <vector>
19#include <memory>
20
21namespace pulp::view {
22
23// Fit a label into `avail` px. Prefer SHRINKING the font from `base` toward
24// `min` to show the full text; only ellipsize (in-place, with "...") if it still
25// overflows at `min`. `width_at(s, f)` returns the rendered width of `s` at font
26// size `f` (e.g. a canvas set_font + measure_text). Returns the chosen font
27// size and rewrites `text` to the string to draw. Pure logic — unit-tested
28// independently of any canvas (a ComboBox box is often sized tight to a design's
29// own label, so truncating reads worse than a slightly smaller full label).
30float fit_combo_label(std::string& text, float avail, float base, float min,
31 const std::function<float(const std::string&, float)>& width_at);
32
33// ── ComboBox ─────────────────────────────────────────────────────────────
34
43class ComboBox : public View {
44public:
45 // A ComboBox is a dropdown, not a continuous range. It announced itself
46 // as AccessRole::slider until the role vocabulary grew `combo_box`, so
47 // VoiceOver / Narrator / Orca all told the user "slider" and offered
48 // increment/decrement instead of a list of choices.
50 set_focusable(true);
52 // Opening a dropdown IS this control's purpose, so a press on it while
53 // a different overlay is open means "switch menus": the dismissal
54 // policy lets that press through instead of spending it on the close.
56 }
57
58 // pulp #1818 — clear the popup slot if this dying ComboBox holds it.
59 // Without this, an unmounted React dropdown leaves a dangling pointer that
60 // the platform window host dereferences on the next mouseDown (PAC failure
61 // on the vtable load — exact crash signature in the issue). Clears BOTH the
62 // root-owned slot (S11, non-allocating) and the process-global shim mirror.
63 // Pattern matches `~View()` for `active_overlay_` / `focused_input_`.
64 ~ComboBox() override {
66 s->active_popup = nullptr;
67 if (active_popup_ == this) active_popup_ = nullptr;
68 }
69
74 void set_items(std::vector<std::string> items) {
75 items_ = std::move(items);
77 }
78 const std::vector<std::string>& items() const { return items_; }
79
80 int selected() const { return selected_; }
81 void set_selected(int index);
87 void set_selected(int index, Notify notify);
88 void set_selected_silent(int index);
89
90 const std::string& selected_text() const;
91
93 std::function<void(int index)> on_change;
94
95 void paint(canvas::Canvas& canvas) override;
96 void on_mouse_event(const MouseEvent& event) override;
97 void on_hover_move(Point local_pos) override; // track hovered dropdown row
98 bool on_key_event(const KeyEvent& event) override;
99 bool accepts_navigation_input() const override { return open_; }
100 void on_focus_changed(bool focused) override;
101 View* hit_test(Point local_point) override; // extend hit area over the open dropdown
102 bool wants_mouse_input() const override { return true; }
103
104 void on_text_input(const TextInputEvent& event) override;
105
106 bool is_open() const { return open_; }
109 void restore_open_state() { open_dropdown(); }
113 bool flips_up() const { return dropdown_local_top() < 0.0f; }
115 int hovered_index() const { return hover_index_; }
116 float dropdown_width_hint() const;
117
123 bool dropdown_window_rect(float& x, float& y, float& w, float& h) const;
124
126 static void close_active_popup();
128 static void close_active_popup(View& root);
131 static void abandon_active_popup(View& root) noexcept;
132
149
151 static void notify_global_click(View* target);
152
153private:
154 void set_selected_impl(int index, Notify notify);
155 void open_dropdown();
156 void close_dropdown();
157 // Top of the dropdown menu in this combo's LOCAL coords. Below the field normally;
158 // negative (above the field) when flipped up because it would spill past the window.
159 // Shared by paint, hit_test, and mouse hover so they always agree.
160 float dropdown_local_top() const;
161 // Flip/clamp/scroll-aware menu geometry in this combo's LOCAL coords, shared
162 // by paint, hit_test, hover and mouse so they always agree. `top_local` is the
163 // menu top relative to the field (negative = flipped above). `height` is the
164 // painted menu height (clamped so the menu never spills past the window).
165 // `first_row`/`visible_rows` select which items are drawn when the full list is
166 // taller than the available space (scrolling via dropdown_scroll_).
167 void dropdown_metrics(float& top_local, float& height,
168 int& first_row, int& visible_rows) const;
169 // On-screen (overlay-space) geometry of the field: top-left x/y and the
170 // height AND width of the nearest scroll viewport (root window when none).
171 // The dropdown overlay paints at the root canvas with NO scroll translation,
172 // so every ScrollView ancestor's scroll offset must be peeled off here —
173 // otherwise the menu renders at the unscrolled position once the page is
174 // scrolled, and the flip/clamp decisions compare against the wrong viewport.
175 void overlay_anchor_(float& out_x, float& out_y, float& out_viewport_h,
176 float& out_viewport_w) const;
177 void move_hover(int delta); // keyboard: move the highlighted row, skipping separators
178 void move_hover_to_edge(bool last);
179
180 std::vector<std::string> items_;
181 int selected_ = 0;
182 int hover_index_ = -1;
183 int dropdown_scroll_ = 0;
184 bool open_ = false;
185
186public:
188private:
189 static const std::string empty_string_;
190};
191
192// ── Tooltip ──────────────────────────────────────────────────────────────
193
196class Tooltip : public View {
197public:
198 explicit Tooltip(std::string text = {}) : text_(std::move(text)), opacity_(0.0f) {
199 set_visible(false);
200 }
201
202 void set_text(std::string text) { text_ = std::move(text); }
203 const std::string& text() const { return text_; }
204
207
209 void hide();
210
211 void paint(canvas::Canvas& canvas) override;
212
213 // Animation accessors for testing
214 float opacity() const { return opacity_.value(); }
215 void advance_animations(float dt) override;
216
217private:
218 std::string text_;
219 ValueAnimation opacity_;
220};
221
222// ── ThemeModeControl ──────────────────────────────────────────────────────
223
231class ThemeModeControl : public View {
232public:
234 void set_mode(ThemeMode m) { if (m != mode_) { mode_ = m; request_repaint(); } }
235 ThemeMode mode() const { return mode_; }
236 std::function<void(ThemeMode)> on_mode_change;
237 int hovered_segment() const { return hover_seg_; }
238 void paint(canvas::Canvas& canvas) override;
239 void on_mouse_down(Point pos) override;
240 void on_mouse_event(const MouseEvent& event) override; // hover tracking
241 bool wants_mouse_input() const override { return true; }
242 float intrinsic_height() const override { return 28.0f; }
243private:
244 int segment_at_(Point pos) const; // 0=system,1=light,2=dark, -1 outside
246 int hover_seg_ = -1;
247};
248
249// ── ProgressBar ──────────────────────────────────────────────────────────
250
259public:
261
263 void set_progress(float value) { progress_ = value; }
264 float progress() const { return progress_; }
265
268 bool is_indeterminate() const { return progress_ < 0.0f; }
269
270 // ── AccessibilityValueInterface ──────────────────────────────────────
271 double get_current_value() const override {
272 return is_indeterminate() ? 0.0
273 : static_cast<double>(std::clamp(progress_, 0.0f, 1.0f));
274 }
275
278 void set_current_value(double value) override {
279 set_progress(static_cast<float>(value));
280 }
281 double get_minimum_value() const override { return 0.0; }
282 double get_maximum_value() const override { return 1.0; }
283 std::string get_value_string() const override {
284 if (is_indeterminate()) return "indeterminate";
286 }
287
291 void set_label(std::string label) {
292 label_ = std::move(label);
294 }
295
296 void paint(canvas::Canvas& canvas) override;
297
298private:
299 float progress_ = 0.0f;
300 std::string label_;
301};
302
303// ── CallOutBox ───────────────────────────────────────────────────────────
304
313class CallOutBox : public View {
314public:
315 CallOutBox() = default;
316
317 void set_message(std::string msg) { message_ = std::move(msg); }
318 const std::string& message() const { return message_; }
319
321 std::function<void()> on_confirm;
323 std::function<void()> on_cancel;
324
327
329 static std::unique_ptr<CallOutBox> confirm(
330 const std::string& message,
331 std::function<void()> on_ok,
332 std::function<void()> on_cancel = {});
333
335 static std::unique_ptr<CallOutBox> notify(
336 const std::string& message,
337 float duration_seconds = 3.0f);
338
339 void paint(canvas::Canvas& canvas) override;
340 bool on_key_event(const KeyEvent& event) override;
341
342private:
343 std::string message_;
344};
345
346// ── TabPanel ─────────────────────────────────────────────────────────────
347
356class TabPanel : public View {
357public:
358 struct Tab {
359 std::string title;
360 std::unique_ptr<View> content;
361 };
362
370 enum class TabBarStyle { filled, underline };
371
372 // Reserve the tab-bar height as top padding so tab content flows BELOW the tab bar
373 // (instead of painting over it). Uses flex padding so child hit-testing stays correct.
374 // No AccessRole::tab_list here, deliberately. The tab strip is PAINTED;
375 // TabPanel's child Views are the tab CONTENT panels, not the tabs. A
376 // `tab_list` whose children are panels is worse than no role at all —
377 // VoiceOver's tab navigation would walk content instead of tabs. The role
378 // lands with per-tab `AccessRole::tab` elements (docs/guides/modules/view.md).
380 flex().padding_top = tab_height_;
381 }
382
383 void add_tab(std::string title, std::unique_ptr<View> content);
388 void set_active_tab(int index, Notify notify = Notify::sync);
389 int active_tab() const { return active_; }
390 int tab_count() const { return static_cast<int>(tabs_.size()); }
391 std::string_view tab_title(int index) const;
392 int find_tab(std::string_view title) const;
393 bool set_active_tab(std::string_view title, Notify notify = Notify::sync);
394
399 void set_show_tab_bar(bool show) {
400 show_tab_bar_ = show;
401 flex().padding_top = show ? tab_height_ : 0.0f;
402 }
403
406 void set_tab_bar_style(TabBarStyle style) { tab_bar_style_ = style; }
407 TabBarStyle tab_bar_style() const { return tab_bar_style_; }
408
410 std::function<void(int index)> on_tab_change;
411
412 void paint(canvas::Canvas& canvas) override;
413 void on_mouse_event(const MouseEvent& event) override;
414 bool wants_mouse_input() const override { return true; }
415
416private:
417 std::vector<Tab> tabs_;
418 int active_ = 0;
419 float tab_height_ = 32.0f;
420 bool show_tab_bar_ = true;
421 TabBarStyle tab_bar_style_ = TabBarStyle::filled;
422};
423
424// ── SegmentedControl ───────────────────────────────────────────────────────
425
443class SegmentedControl : public View {
444public:
449
450 void set_segments(std::vector<std::string> segments) {
451 segments_ = std::move(segments);
452 if (selected_ >= static_cast<int>(segments_.size())) selected_ = 0;
454 }
455 const std::vector<std::string>& segments() const { return segments_; }
456
457 int selected() const { return selected_; }
458 void set_selected(int index);
463 void set_selected(int index, Notify notify);
464 void set_selected_silent(int index);
465
467 std::function<void(int index)> on_change;
468
469 int hovered_segment() const { return hover_; }
472 void set_designed_overlay(bool enabled) { designed_overlay_ = enabled; request_repaint(); }
473 bool designed_overlay() const { return designed_overlay_; }
474
475 void paint(canvas::Canvas& canvas) override;
476 void on_mouse_event(const MouseEvent& event) override;
477 bool on_key_event(const KeyEvent& event) override;
478 bool wants_mouse_input() const override { return true; }
479 float intrinsic_height() const override { return 28.0f; }
480
481private:
482 int segment_at_(Point pos) const;
483
484 std::vector<std::string> segments_;
485 int selected_ = 0;
486 int hover_ = -1;
487 bool designed_overlay_ = false;
488};
489
490// ── ScrollView ───────────────────────────────────────────────────────────
491
494class ScrollView : public View {
495public:
498
499 void set_direction(Direction d) { direction_ = d; }
507 Size content_size() const { return content_size_; }
508 bool wants_wheel_scroll() const override;
509
510 float scroll_x() const { return smooth_scroll_x_.value(); }
511 float scroll_y() const { return smooth_scroll_y_.value(); }
512
513 // ScrollView is the richer widget over View's scrollable-overflow notion:
514 // it answers the same queries so one call site works for either, and
515 // reports its ANIMATED offset so the generic paint/hit-test pair and a
516 // bounds walk all read the position it is actually drawn at.
517 bool is_scroll_container() const override {
518 return true;
519 }
520 float scroll_offset_x() const override {
521 return smooth_scroll_x_.value();
522 }
523 float scroll_offset_y() const override {
524 return smooth_scroll_y_.value();
525 }
526 bool set_scroll_offset(float x, float y) override {
527 const float before_x = smooth_scroll_x_.value();
528 const float before_y = smooth_scroll_y_.value();
529 set_scroll(x, y);
530 return smooth_scroll_x_.value() != before_x || smooth_scroll_y_.value() != before_y;
531 }
532 bool scroll_animating() const {
533 return smooth_scroll_x_.animating() || smooth_scroll_y_.animating();
534 }
535 void set_scroll(float x, float y);
536
546 void scroll_by(float dx, float dy, bool animate = true);
547
548 void paint(canvas::Canvas& canvas) override;
550
555 bool applies_child_paint_offset() const override {
556 return scroll_x() != 0.0f || scroll_y() != 0.0f;
557 }
558
566 Point child_paint_offset(const View& child) const override {
567 if (child.position() == View::Position::sticky)
568 return Point{-scroll_x(), 0.0f};
569 return Point{-scroll_x(), -scroll_y()};
570 }
571
572 View* hit_test(Point local_point) override;
573 void on_mouse_enter() override;
574 void on_mouse_leave() override;
575
578 void layout_children() override;
579
580 // Scroll via mouse wheel, touch drag, or scrollbar drag
581 void on_mouse_event(const MouseEvent& event) override;
582 void on_mouse_drag(Point pos) override;
583 bool wants_mouse_input() const override { return true; }
584
585 // Animation accessors for testing
586 float bar_opacity() const { return bar_opacity_.value(); }
587 float bar_width() const { return bar_width_.value(); }
588 float target_scroll_y() const { return target_scroll_y_; }
589 void advance_animations(float dt) override;
590
591private:
592 static constexpr float kOverflowEpsilon = 1.0f;
593
594 void update_automatic_content_size();
595 void clamp_scroll_targets(bool clamp_current = false);
596 float max_scroll_x() const;
597 float max_scroll_y() const;
598
599 Direction direction_ = Direction::vertical;
600 Size content_size_{0, 0};
601 bool automatic_content_size_ = true;
602 float target_scroll_x_ = 0, target_scroll_y_ = 0;
603 ValueAnimation smooth_scroll_x_{0.0f}; // smoothly interpolated scroll position
604 ValueAnimation smooth_scroll_y_{0.0f};
605 ValueAnimation bar_opacity_{0.0f}; // fade in/out on hover
606 ValueAnimation bar_width_{4.0f}; // narrow when idle, wide on hover
607
608 // Scrollbar drag state
609 bool dragging_v_bar_ = false;
610 bool dragging_h_bar_ = false;
611 float drag_offset_ = 0; // offset from top of thumb where drag started
612};
613
624
627
628// ── ListBox ──────────────────────────────────────────────────────────────
629
637class ListBox : public View {
638public:
646
647 // No AccessRole::list here, deliberately — same reason as TableListBox:
648 // rows are painted, not child Views, so the role would export an empty
649 // AXList ("list, 0 items"). See docs/guides/modules/view.md.
651
652 void set_items(std::vector<std::string> items) { items_ = std::move(items); }
653 const std::vector<std::string>& items() const { return items_; }
654
658 void set_icons(std::vector<std::string> icons) { icons_ = std::move(icons); }
659
662 void set_selection_style(SelectionStyle s) { selection_style_ = s; }
663 SelectionStyle selection_style() const { return selection_style_; }
664
665 int selected() const { return selected_; }
670 void set_selected(int index, Notify notify = Notify::sync);
671
672 float row_height() const { return row_height_; }
673 void set_row_height(float h) { row_height_ = h; }
674
676 std::function<void(int index)> on_select;
678 std::function<void(int index)> on_activate;
679
680 void paint(canvas::Canvas& canvas) override;
681 void on_mouse_event(const MouseEvent& event) override;
682 bool on_key_event(const KeyEvent& event) override;
683 bool wants_mouse_input() const override { return true; }
684
686 void ensure_visible(int index);
687
688private:
689 std::vector<std::string> items_;
690 std::vector<std::string> icons_;
691 SelectionStyle selection_style_ = SelectionStyle::standard;
692 int selected_ = -1;
693 float row_height_ = 24.0f;
694 float scroll_offset_ = 0.0f;
695};
696
697} // namespace pulp::view
Definition canvas.hpp:240
Interface for accessible values (sliders, knobs, progress bars).
Definition accessibility.hpp:16
virtual std::string get_value_string() const
Value as a human-readable string (e.g., "50%" or "-6 dB").
void set_message(std::string msg)
Definition ui_components.hpp:317
std::function< void()> on_cancel
Called when the user cancels (Cancel/No) or presses Escape.
Definition ui_components.hpp:323
static std::unique_ptr< CallOutBox > notify(const std::string &message, float duration_seconds=3.0f)
Create a notification that auto-dismisses.
const std::string & message() const
Definition ui_components.hpp:318
float auto_dismiss_seconds
Auto-dismiss after N seconds (0 = no auto-dismiss).
Definition ui_components.hpp:326
void paint(canvas::Canvas &canvas) override
bool on_key_event(const KeyEvent &event) override
Key event with modifiers and up/down state.
std::function< void()> on_confirm
Called when the user confirms (OK/Yes).
Definition ui_components.hpp:321
static std::unique_ptr< CallOutBox > confirm(const std::string &message, std::function< void()> on_ok, std::function< void()> on_cancel={})
Create a confirmation dialog with OK/Cancel buttons.
void on_text_input(const TextInputEvent &event) override
Text input from keyboard/IME (separate from key events).
View * hit_test(Point local_point) override
static void notify_global_click(View *target)
Called by the root view on any mouse click — closes popup if click is outside.
std::function< void(int index)> on_change
Called when selection changes.
Definition ui_components.hpp:93
void set_items(std::vector< std::string > items)
Publishes the currently-selected item into access_value: the selected text IS a combo box's accessibl...
Definition ui_components.hpp:74
float dropdown_width_hint() const
static ComboBox * active_popup_
Definition ui_components.hpp:187
void restore_open_state()
Reopen after a retained subtree move when the dropdown was active.
Definition ui_components.hpp:109
bool dropdown_window_rect(float &x, float &y, float &w, float &h) const
On-screen rect (root/overlay space) of the open dropdown menu — already flip-aware,...
bool is_open() const
Definition ui_components.hpp:106
bool flips_up() const
True when the menu currently renders ABOVE the field (it would spill past the viewport bottom).
Definition ui_components.hpp:113
void on_hover_move(Point local_pos) override
Pointer moved over this view with no button held, reported in this view's LOCAL coordinates.
void on_mouse_event(const MouseEvent &event) override
Mouse down with full event context.
~ComboBox() override
Definition ui_components.hpp:64
void set_selected(int index, Notify notify)
Notifying overload.
bool accepts_navigation_input() const override
Does this widget temporarily need host-delivered navigation keys?
Definition ui_components.hpp:99
void set_selected_silent(int index)
void paint(canvas::Canvas &canvas) override
void on_focus_changed(bool focused) override
Called when this view gains or loses focus.
static void abandon_active_popup(View &root) noexcept
Clear popup routing without invoking dismissal/change callbacks.
bool wants_mouse_input() const override
True if this widget handles mouse down/drag through virtual methods even when it does not expose JS p...
Definition ui_components.hpp:102
int selected() const
Definition ui_components.hpp:80
ComboBox()
Definition ui_components.hpp:49
int hovered_index() const
Index of the row painted with the hover/keyboard highlight (-1 = none).
Definition ui_components.hpp:115
static ComboBox * active_popup_in(View &scope)
The open dropdown that belongs to scope's own tree, or nullptr.
const std::vector< std::string > & items() const
Definition ui_components.hpp:78
const std::string & selected_text() const
static void close_active_popup(View &root)
Close only the active ComboBox owned by root.
bool on_key_event(const KeyEvent &event) override
Key event with modifiers and up/down state.
static void close_active_popup()
Close the process-global active ComboBox shim.
void set_selected(int index)
std::function< void(int index)> on_select
Called when an item is selected.
Definition ui_components.hpp:676
bool wants_mouse_input() const override
True if this widget handles mouse down/drag through virtual methods even when it does not expose JS p...
Definition ui_components.hpp:683
void set_icons(std::vector< std::string > icons)
Optional per-row leading icon glyphs (parallel to items()).
Definition ui_components.hpp:658
ListBox()
Definition ui_components.hpp:650
SelectionStyle selection_style() const
Definition ui_components.hpp:663
std::function< void(int index)> on_activate
Called when an item is double-clicked.
Definition ui_components.hpp:678
int selected() const
Definition ui_components.hpp:665
void set_row_height(float h)
Definition ui_components.hpp:673
SelectionStyle
Selected-row treatment.
Definition ui_components.hpp:645
@ accent
Definition ui_components.hpp:645
@ standard
Definition ui_components.hpp:645
void paint(canvas::Canvas &canvas) override
void on_mouse_event(const MouseEvent &event) override
Mouse down with full event context.
void set_items(std::vector< std::string > items)
Definition ui_components.hpp:652
void set_selected(int index, Notify notify=Notify::sync)
notify controls whether the selection change reaches on_select: Notify::sync (default) fires it,...
void ensure_visible(int index)
Scroll to make the given item index visible in the viewport.
bool on_key_event(const KeyEvent &event) override
Key event with modifiers and up/down state.
const std::vector< std::string > & items() const
Definition ui_components.hpp:653
float row_height() const
Definition ui_components.hpp:672
void set_selection_style(SelectionStyle s)
Select the selected-row treatment (see SelectionStyle).
Definition ui_components.hpp:662
void set_label(std::string label)
Optional label shown inside the bar.
Definition ui_components.hpp:291
std::string get_value_string() const override
Value as a human-readable string (e.g., "50%" or "-6 dB").
Definition ui_components.hpp:283
double get_maximum_value() const override
Maximum value.
Definition ui_components.hpp:282
bool is_indeterminate() const
True while progress() < 0 — the bar is animating an unknown-duration task.
Definition ui_components.hpp:268
ProgressBar()
Definition ui_components.hpp:260
void set_progress(float value)
Set progress value (0.0 to 1.0). Values < 0 show indeterminate state.
Definition ui_components.hpp:263
void set_current_value(double value) override
A progress bar is read-only (it advertises RangeValue, not Value), but the interface is bidirectional...
Definition ui_components.hpp:278
float progress() const
Definition ui_components.hpp:264
double get_minimum_value() const override
Minimum value.
Definition ui_components.hpp:281
double get_current_value() const override
Current value as a number.
Definition ui_components.hpp:271
void paint(canvas::Canvas &canvas) override
Scrollable container that clips and scrolls its content.
Definition ui_components.hpp:494
void on_mouse_drag(Point pos) override
bool is_scroll_container() const override
True when this view scrolls its own content; ScrollView always does.
Definition ui_components.hpp:517
float scroll_offset_x() const override
Scroll offset in px, always within [0, max_scroll_offset_*].
Definition ui_components.hpp:520
Direction
Definition ui_components.hpp:497
@ horizontal
Definition ui_components.hpp:497
@ vertical
Definition ui_components.hpp:497
@ both
Definition ui_components.hpp:497
float bar_opacity() const
Definition ui_components.hpp:586
float scroll_y() const
Definition ui_components.hpp:511
bool wants_wheel_scroll() const override
True if this widget is itself a scroll container that should consume wheel input before an ancestor s...
bool applies_child_paint_offset() const override
paint_all() translates children by (-scroll_x, -scroll_y), so once scrolled the content no longer sit...
Definition ui_components.hpp:555
bool wants_mouse_input() const override
True if this widget handles mouse down/drag through virtual methods even when it does not expose JS p...
Definition ui_components.hpp:583
void paint(canvas::Canvas &canvas) override
void scroll_by(float dx, float dy, bool animate=true)
Scroll by a delta.
void advance_animations(float dt) override
Advance any per-widget non-CSS animation state (hover glows, thumb tweens, spinner phase) by dt secon...
Size content_size() const
Definition ui_components.hpp:507
ScrollView()
Definition ui_components.hpp:496
void use_automatic_content_size()
Restores child-derived sizing after a caller-owned extent and refreshes it immediately from the curre...
Point child_paint_offset(const View &child) const override
The per-child half of the above, so a bounds walk can recover a descendant's true painted position.
Definition ui_components.hpp:566
float scroll_x() const
Definition ui_components.hpp:510
void set_direction(Direction d)
Definition ui_components.hpp:499
bool scroll_animating() const
Definition ui_components.hpp:532
void paint_all(canvas::Canvas &canvas) override
View * hit_test(Point local_point) override
void set_scroll(float x, float y)
void set_content_size(Size size)
Sets a caller-owned content extent and disables automatic child-derived sizing.
bool set_scroll_offset(float x, float y) override
Set / advance the offset, clamped into [0, max_scroll_offset_*]: a container that fits stays at 0 and...
Definition ui_components.hpp:526
float bar_width() const
Definition ui_components.hpp:587
void layout_children() override
Layout children using content_size instead of view bounds.
void on_mouse_leave() override
void on_mouse_enter() override
void on_mouse_event(const MouseEvent &event) override
Mouse down with full event context.
float target_scroll_y() const
Definition ui_components.hpp:588
float scroll_offset_y() const override
Definition ui_components.hpp:523
bool designed_overlay() const
Definition ui_components.hpp:473
bool on_key_event(const KeyEvent &event) override
Key event with modifiers and up/down state.
void set_selected(int index, Notify notify)
Notifying overload.
void set_designed_overlay(bool enabled)
Marks a browser-captured control as a live replacement.
Definition ui_components.hpp:472
SegmentedControl()
Definition ui_components.hpp:445
const std::vector< std::string > & segments() const
Definition ui_components.hpp:455
void set_selected(int index)
clamps + notifies on_change
void set_segments(std::vector< std::string > segments)
Definition ui_components.hpp:450
void paint(canvas::Canvas &canvas) override
float intrinsic_height() const override
Definition ui_components.hpp:479
int selected() const
Definition ui_components.hpp:457
int hovered_segment() const
for tests; -1 = none
Definition ui_components.hpp:469
bool wants_mouse_input() const override
True if this widget handles mouse down/drag through virtual methods even when it does not expose JS p...
Definition ui_components.hpp:478
void on_mouse_event(const MouseEvent &event) override
Mouse down with full event context.
std::function< void(int index)> on_change
Called when the selected segment changes (user click or set_selected).
Definition ui_components.hpp:467
void set_selected_silent(int index)
clamps, no callback
void add_tab(std::string title, std::unique_ptr< View > content)
TabBarStyle
Visual treatment of the tab bar.
Definition ui_components.hpp:370
@ underline
Definition ui_components.hpp:370
@ filled
Definition ui_components.hpp:370
void on_mouse_event(const MouseEvent &event) override
Mouse down with full event context.
bool set_active_tab(std::string_view title, Notify notify=Notify::sync)
int active_tab() const
Definition ui_components.hpp:389
int find_tab(std::string_view title) const
TabPanel()
Definition ui_components.hpp:379
void set_show_tab_bar(bool show)
Hide the tab bar and use the panel purely as a navigable card stack (the active tab is shown; switch ...
Definition ui_components.hpp:399
void set_active_tab(int index, Notify notify=Notify::sync)
notify controls whether the switch reaches on_tab_change: Notify::sync (default) fires it,...
std::string_view tab_title(int index) const
void paint(canvas::Canvas &canvas) override
std::function< void(int index)> on_tab_change
Called when the active tab changes.
Definition ui_components.hpp:410
bool wants_mouse_input() const override
True if this widget handles mouse down/drag through virtual methods even when it does not expose JS p...
Definition ui_components.hpp:414
int tab_count() const
Definition ui_components.hpp:390
void set_tab_bar_style(TabBarStyle style)
Select the tab-bar visual treatment (see TabBarStyle).
Definition ui_components.hpp:406
TabBarStyle tab_bar_style() const
Definition ui_components.hpp:407
void on_mouse_event(const MouseEvent &event) override
Mouse down with full event context.
void paint(canvas::Canvas &canvas) override
ThemeMode mode() const
Definition ui_components.hpp:235
float intrinsic_height() const override
Definition ui_components.hpp:242
void set_mode(ThemeMode m)
Definition ui_components.hpp:234
int hovered_segment() const
for tests; -1 none
Definition ui_components.hpp:237
ThemeModeControl()
Definition ui_components.hpp:233
void on_mouse_down(Point pos) override
bool wants_mouse_input() const override
True if this widget handles mouse down/drag through virtual methods even when it does not expose JS p...
Definition ui_components.hpp:241
std::function< void(ThemeMode)> on_mode_change
Definition ui_components.hpp:236
void show_at(Point position)
Show the tooltip near a given position (with fade-in).
const std::string & text() const
Definition ui_components.hpp:203
float opacity() const
Definition ui_components.hpp:214
void paint(canvas::Canvas &canvas) override
void set_text(std::string text)
Definition ui_components.hpp:202
void hide()
Hide the tooltip (with fade-out).
void advance_animations(float dt) override
Advance any per-widget non-CSS animation state (hover glows, thumb tweens, spinner phase) by dt secon...
Tooltip(std::string text={})
Definition ui_components.hpp:198
Lightweight, embeddable value animator for widget members.
Definition animation.hpp:293
Definition view.hpp:73
void set_overlay_trigger(bool is_trigger)
Mark this view as a control that OPENS an overlay — a dropdown field, a menu button,...
Definition view.hpp:1701
Position position() const
Definition view.hpp:1767
void request_repaint()
Request that this view's host invalidate and schedule a repaint.
void set_visible(bool v)
Show or hide this view.
Definition view.hpp:343
RootInteractionState * existing_interaction()
Resolved interaction state WITHOUT lazily allocating — the root's slot if one exists,...
@ label
Definition view.hpp:989
@ group
Definition view.hpp:989
@ progress_bar
Definition view.hpp:992
@ combo_box
Definition view.hpp:990
void set_access_value(std::string value)
Definition view.hpp:1036
void set_derived_access_label(std::string label)
The CONTENT-DERIVED accessible name: a widget's visible text (Label::set_text, Knob/Fader/Toggleset_l...
Definition view.hpp:1020
void mark_runtime_view_kind(RuntimeViewKind kind)
Definition view.hpp:2379
int animate(std::function< void(float)> apply, float from, float to, float duration_s, std::function< float(float)> ease={}, std::function< void()> on_done={}, const std::string &tag={})
FlexStyle & flex()
Definition view.hpp:91
void set_access_role(AccessRole role)
Definition view.hpp:995
bool enabled() const
CSS :disabled equivalent — blocks input, reduces opacity.
Definition view.hpp:715
void set_focusable(bool f)
Definition view.hpp:669
@ sticky
Definition view.hpp:1753
Input event types with modifier keys and pointer IDs.
Definition affine_transform.hpp:24
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
@ text
Plain text (default color).
Definition code_editor_tokenizer.hpp:37
float fit_combo_label(std::string &text, float avail, float base, float min, const std::function< float(const std::string &, float)> &width_at)
ThemeMode
User-facing theme preference.
Definition appearance_tracker.hpp:17
@ system
Definition appearance_tracker.hpp:17
Notify
Whether a value write notifies listeners, and when.
Definition slider_core.hpp:60
@ sync
fire listeners before returning
Definition slider_core.hpp:62
@ value
the widget's primary value (Knob, Fader, RangeSlider, Toggle, ProgressBar)
Definition binding_diagnostics.hpp:19
@ scope
a block of samples for a SpectrumView / WaveformView
Definition binding_diagnostics.hpp:21
@ s
Definition input_events.hpp:41
@ h
Definition input_events.hpp:39
@ y
Definition input_events.hpp:42
@ m
Definition input_events.hpp:40
@ d
Definition input_events.hpp:39
@ x
Definition input_events.hpp:41
@ w
Definition input_events.hpp:41
View * find_wheel_scroll_view_at(View &root, Point root_point)
Find the deepest view that participates in native wheel scrolling.
@ scroll
Definition view.hpp:47
@ height
Definition css_animation.hpp:128
ScrollView * find_scroll_view_at(View &root, Point root_point)
Find the deepest ScrollView whose bounds contain root_point (a point in root's local coordinate space...
STL namespace.
The value engine shared by Pulp's continuous controls.
float padding_top
Per-side padding (-1 = use uniform padding).
Definition geometry.hpp:476
Rich key event with key code, modifiers, and repeat state.
Definition input_events.hpp:193
Rich mouse/pointer event with position, modifiers, button state, pointer ID, and stylus properties.
Definition input_events.hpp:104
Definition geometry.hpp:20
Definition geometry.hpp:28
Definition ui_components.hpp:358
std::string title
Definition ui_components.hpp:359
std::unique_ptr< View > content
Definition ui_components.hpp:360
Text input from IME or keyboard composition (separate from KeyEvent).
Definition input_events.hpp:210
ComboBox * active_popup
Definition view.hpp:1626