Vital
Loading...
Searching...
No Matches
wavetable_playhead_info.cpp
Go to the documentation of this file.
1/*
2Summary:
3
4WavetablePlayheadInfo is a component that displays the current integer position of a wavetable playhead as text. It implements the WavetablePlayhead::Listener interface, updating the displayed value whenever the playhead moves. The display is styled according to the current UI skin.
5 */
7#include "skin.h"
8
9void WavetablePlayheadInfo::paint(Graphics& g) {
10 // Fill background with the main body colour.
11 g.fillAll(findColour(Skin::kBody, true));
12
13 // Convert the current position to a string for display.
14 String position_text(playhead_position_);
15
16 // Draw the text in a colour that contrasts the background (e.g. body text).
17 g.setColour(findColour(Skin::kBodyText, true));
18 Rectangle<int> bounds = getLocalBounds();
19 // Adjust bounds to leave some space on the right side.
20 bounds.setWidth(bounds.getWidth() - bounds.getHeight() * 0.5f);
21
22 // Draw the current position text, right-aligned.
23 g.drawText(position_text, bounds, Justification::centredRight);
24}
25
27 // Ensures that if the size changes, we update the display region.
28 repaint();
29}
30
32 // Update the stored position and repaint to show the new value.
33 playhead_position_ = position;
34 repaint();
35}
@ kBodyText
Definition skin.h:133
@ kBody
Definition skin.h:129
void resized() override
Called when the component is resized.
Definition wavetable_playhead_info.cpp:26
void playheadMoved(int position) override
Called when the associated playhead moves to a new position.
Definition wavetable_playhead_info.cpp:31
void paint(Graphics &g) override
Paints the current playhead position text onto the component.
Definition wavetable_playhead_info.cpp:9
int playhead_position_
The current playhead position being displayed.
Definition wavetable_playhead_info.h:52