Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
tracing_badge.hpp
Go to the documentation of this file.
1#pragma once
2
3// Tracing badge — the always-visible "◉ TRACING" reminder the root View paints
4// on every frame when the binary is built with PULP_TRACING=ON, so a developer
5// can never forget that Perfetto tracing is compiled in while looking at the
6// plugin UI. It complements the ship-guard, the `pulp status` line, and the
7// startup log. The paint site (in View::paint_all) is behind
8// `if constexpr (pulp::runtime::kTracingEnabled)`, so the default OFF build
9// carries no branch, no draw, and no per-frame cost.
10
11namespace pulp::view {
12
13// True only when tracing is compiled in AND the badge has not been suppressed.
14// Always defined (returns false in an OFF build) so callers and tests can query
15// it in either build configuration.
17
18// Suppress or re-enable the badge at runtime. Default is visible-when-compiled-in
19// (the whole point is that you can't miss it). Golden visual-regression harnesses
20// call set_tracing_badge_visible(false) so an ON build's badge never pollutes a
21// reference screenshot. No effect in an OFF build.
23
24// The badge's label, for an application that hides the root badge and draws
25// the reminder in its own chrome instead.
26inline constexpr const char* kTracingBadgeLabel = "\u25C9 TRACING";
27
28// Where the root badge sits, in the root View's coordinates. The default is the
29// top-right corner the badge has always used; an application whose header has
30// a line of controls can move the pill onto that line (set `top` and `height`
31// to the row's) instead of hiding it.
33 float right = 8.0f;
34 float top = 8.0f;
35 float height = 0.0f;
36 float font_px = 11.0f;
37};
38
39// Replace or read the process-wide placement. Safe to call from the UI thread
40// while frames are painting; the next frame uses the new placement.
43
44// The pill and label geometry for a root `root_width` wide, given the label's
45// measured advance and its face's ascent and descent. Pure, so a test or an
46// application can compute exactly where the root badge paints. The label is
47// centred on its ink: equal space above the ascent and below the descent.
49 float pill_x = 0.0f, pill_y = 0.0f, pill_width = 0.0f, pill_height = 0.0f;
50 float text_x = 0.0f;
51 float baseline_y = 0.0f;
52};
53TracingBadgeLayout tracing_badge_layout(float root_width, float text_width,
54 float ascent, float descent,
55 const TracingBadgePlacement& placement);
56
57} // namespace pulp::view
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
void set_tracing_badge_placement(const TracingBadgePlacement &placement)
TracingBadgePlacement tracing_badge_placement()
bool tracing_badge_should_paint()
@ visible
Content renders beyond bounds (default for views).
Definition geometry.hpp:384
constexpr const char * kTracingBadgeLabel
Definition tracing_badge.hpp:26
TracingBadgeLayout tracing_badge_layout(float root_width, float text_width, float ascent, float descent, const TracingBadgePlacement &placement)
void set_tracing_badge_visible(bool visible)
Definition tracing_badge.hpp:48
float pill_height
Definition tracing_badge.hpp:49
float text_x
Definition tracing_badge.hpp:50
float baseline_y
Definition tracing_badge.hpp:51
float pill_y
Definition tracing_badge.hpp:49
float pill_width
Definition tracing_badge.hpp:49
float pill_x
Definition tracing_badge.hpp:49
Definition tracing_badge.hpp:32
float height
Pill height; 0 sizes it to the font plus padding.
Definition tracing_badge.hpp:35
float font_px
Label font size.
Definition tracing_badge.hpp:36
float top
Pill top.
Definition tracing_badge.hpp:34
float right
Gap between the pill and the root's right edge.
Definition tracing_badge.hpp:33