Vital
Loading...
Searching...
No Matches
tab_selector.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "JuceHeader.h"
8
16class TabSelector : public Slider {
17public:
19 static constexpr float kDefaultFontHeightPercent = 0.26f;
20
23 TabSelector(String name);
24
27 void paint(Graphics& g) override;
28
31 void mouseEvent(const MouseEvent& e);
32
35 void mouseDown(const MouseEvent& e) override;
36
39 void mouseDrag(const MouseEvent& e) override;
40
43 void mouseUp(const MouseEvent& e) override;
44
47 void setNames(std::vector<std::string> names) { names_ = names; }
48
51 void setFontHeightPercent(float percent) { font_height_percent_ = percent; }
52
55 float getFontHeightPercent() { return font_height_percent_; }
56
59 void setActive(bool active) { active_ = active; }
60
62 void valueChanged() override {
63 Slider::valueChanged();
64 redoImage();
65 }
66
69 OpenGlImageComponent* getImageComponent() { return &image_component_; }
70
72 void redoImage() { image_component_.redrawImage(true); }
73
74private:
78 int getTabX(int position);
79
80 OpenGlImageComponent image_component_;
81 float font_height_percent_;
82 bool active_;
83 std::vector<std::string> names_;
84
85 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TabSelector)
86};
A component that uses OpenGL to render a cached image of a JUCE component or custom drawing.
Definition open_gl_image_component.h:18
virtual void redrawImage(bool force)
Redraws the image if necessary, creating or updating the internal Image.
Definition open_gl_image_component.cpp:16
A slider-based UI component that displays selectable tabs.
Definition tab_selector.h:16
void redoImage()
Redraws the image component.
Definition tab_selector.h:72
void valueChanged() override
Called when the slider value changes, triggers a redraw of the image.
Definition tab_selector.h:62
TabSelector(String name)
Definition tab_selector.cpp:11
void setNames(std::vector< std::string > names)
Definition tab_selector.h:47
void paint(Graphics &g) override
Definition tab_selector.cpp:23
OpenGlImageComponent * getImageComponent()
Definition tab_selector.h:69
void mouseEvent(const MouseEvent &e)
Definition tab_selector.cpp:57
void mouseDrag(const MouseEvent &e) override
Definition tab_selector.cpp:71
static constexpr float kDefaultFontHeightPercent
Default percentage of the font height relative to the component height.
Definition tab_selector.h:19
void setFontHeightPercent(float percent)
Definition tab_selector.h:51
void mouseDown(const MouseEvent &e) override
Definition tab_selector.cpp:65
float getFontHeightPercent()
Definition tab_selector.h:55
void setActive(bool active)
Definition tab_selector.h:59
void mouseUp(const MouseEvent &e) override
Definition tab_selector.cpp:77