Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
widget_metrics.hpp
Go to the documentation of this file.
1#pragma once
2
44
45#include <string>
46
48
49namespace pulp::view {
50
51class View;
52
55struct FontSpec {
56 std::string family = "Inter";
57 float size = 13.0f;
58 int weight = 400;
59 float letter_spacing = 0.0f;
60};
61
63struct EdgeInsets {
64 float top = 0.0f, right = 0.0f, bottom = 0.0f, left = 0.0f;
65 float horizontal() const { return left + right; }
66 float vertical() const { return top + bottom; }
67};
68
71 std::string text;
72 bool separator = false;
73 bool header = false;
74 bool ticked = false;
75 bool has_submenu = false;
79 float standard_height = 0.0f;
80};
81
84struct BoxSize {
85 float width = 0.0f;
86 float height = 0.0f;
87};
88
92public:
93 virtual ~WidgetMetrics() = default;
94
95 // ── Menus ────────────────────────────────────────────────────────────
96 //
97 // A menu panel sizes itself from its rows: it asks for each row's natural
98 // size, takes the widest, stacks the heights, and adds the border. All
99 // three of those inputs are delegated, so a skin can make a menu wider,
100 // denser, or thicker-bordered without the menu widget knowing why.
101
102 virtual bool menu_item_size(const MenuItemMetricsQuery& query, BoxSize& out, View& source) {
103 (void)query; (void)out; (void)source;
104 return false;
105 }
106
108 virtual bool menu_border(float& out, View& source) {
109 (void)out; (void)source;
110 return false;
111 }
112
113 virtual bool menu_font(FontSpec& out, View& source) {
114 (void)out; (void)source;
115 return false;
116 }
117
118 // ── Text-bearing controls ────────────────────────────────────────────
119
120 virtual bool button_font(FontSpec& out, View& source) {
121 (void)out; (void)source;
122 return false;
123 }
124
125 virtual bool combo_box_font(FontSpec& out, View& source) {
126 (void)out; (void)source;
127 return false;
128 }
129
130 virtual bool text_field_font(FontSpec& out, View& source) {
131 (void)out; (void)source;
132 return false;
133 }
134
138 virtual bool text_field_insets(EdgeInsets& out, View& source) {
139 (void)out; (void)source;
140 return false;
141 }
142
145 virtual bool caret_width(float& out, View& source) {
146 (void)out; (void)source;
147 return false;
148 }
149};
150
151} // namespace pulp::view
Definition view.hpp:73
Install on a View to supply the SIZES of the controls in its subtree.
Definition widget_metrics.hpp:91
virtual bool caret_width(float &out, View &source)
Caret stroke width in pixels.
Definition widget_metrics.hpp:145
virtual bool combo_box_font(FontSpec &out, View &source)
Definition widget_metrics.hpp:125
virtual bool menu_border(float &out, View &source)
Padding between the panel edge and the rows, all four sides.
Definition widget_metrics.hpp:108
virtual ~WidgetMetrics()=default
virtual bool menu_item_size(const MenuItemMetricsQuery &query, BoxSize &out, View &source)
Definition widget_metrics.hpp:102
virtual bool button_font(FontSpec &out, View &source)
Definition widget_metrics.hpp:120
virtual bool text_field_font(FontSpec &out, View &source)
Definition widget_metrics.hpp:130
virtual bool text_field_insets(EdgeInsets &out, View &source)
The gap between a text field's frame and its text — the sum of whatever the skin thinks of as its fra...
Definition widget_metrics.hpp:138
virtual bool menu_font(FontSpec &out, View &source)
Definition widget_metrics.hpp:113
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
A control's natural size.
Definition widget_metrics.hpp:84
float height
Definition widget_metrics.hpp:86
float width
Definition widget_metrics.hpp:85
Per-side insets in pixels.
Definition widget_metrics.hpp:63
float bottom
Definition widget_metrics.hpp:64
float horizontal() const
Definition widget_metrics.hpp:65
float vertical() const
Definition widget_metrics.hpp:66
float top
Definition widget_metrics.hpp:64
float right
Definition widget_metrics.hpp:64
float left
Definition widget_metrics.hpp:64
A font request, as a delegate expresses it.
Definition widget_metrics.hpp:55
float size
Definition widget_metrics.hpp:57
int weight
100–900, 400 = regular
Definition widget_metrics.hpp:58
float letter_spacing
Definition widget_metrics.hpp:59
std::string family
Definition widget_metrics.hpp:56
What a menu row is, when the delegate is asked how big it should be.
Definition widget_metrics.hpp:70
bool header
Definition widget_metrics.hpp:73
bool separator
Definition widget_metrics.hpp:72
bool has_submenu
Definition widget_metrics.hpp:75
bool ticked
Definition widget_metrics.hpp:74
float standard_height
The height the widget would use if the delegate declines — passed so a delegate can honor a caller-re...
Definition widget_metrics.hpp:79
std::string text
Definition widget_metrics.hpp:71