WE Core
Loading...
Searching...
No Matches
GroupComponentV2.h
Go to the documentation of this file.
1/*
2 * File: GroupComponentV2.h
3 *
4 * Version: 1.0.0
5 *
6 * Created: 19/03/2019
7 *
8 * This file is part of WECore.
9 *
10 * WECore is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * WECore is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with WECore. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#pragma once
26
27#include "../JuceLibraryCode/JuceHeader.h"
28
30
37 template <typename BASE>
38 class GroupComponentV2 : public BASE {
39
40 public:
41 GroupComponentV2() : _groupFontName("Courier New") {}
42 virtual ~GroupComponentV2() = default;
43
45 inline virtual void drawGroupComponentOutline(juce::Graphics& g,
46 int width,
47 int height,
48 const juce::String& text,
49 const juce::Justification& justification,
50 juce::GroupComponent& group) override;
51
54 void setGroupFontName(const char* fontName) { _groupFontName = fontName; }
55
56 private:
57 const char* _groupFontName;
58 };
59
60 template <typename BASE>
62 int width,
63 int height,
64 const juce::String& text,
65 const juce::Justification& /*justification*/,
66 juce::GroupComponent& group) {
67
68 constexpr int MARGIN {2};
69
70 g.setColour(group.findColour(juce::GroupComponent::textColourId));
71
72 juce::Font font;
73 font.setTypefaceName(_groupFontName);
74 g.setFont(font);
75
76 g.drawText(text,
77 MARGIN,
78 MARGIN,
79 width,
80 height,
81 juce::Justification::topLeft,
82 true);
83 }
84
85}
virtual void drawGroupComponentOutline(juce::Graphics &g, int width, int height, const juce::String &text, const juce::Justification &justification, juce::GroupComponent &group) override