WE Core
Loading...
Searching...
No Matches
ComboBoxV2.h
Go to the documentation of this file.
1/*
2 * File: ComboBoxV2.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 ComboBoxV2 : public BASE {
39
40 public:
41 ComboBoxV2() = default;
42 virtual ~ComboBoxV2() = default;
43
45 inline virtual void drawComboBox(juce::Graphics& g,
46 int width,
47 int height,
48 const bool isButtonDown,
49 int buttonX,
50 int buttonY,
51 int buttonW,
52 int buttonH,
53 juce::ComboBox& box) override;
55 };
56
57 template <typename BASE>
58 void ComboBoxV2<BASE>::drawComboBox(juce::Graphics& g,
59 int /*width*/,
60 int /*height*/,
61 const bool /*isButtonDown*/,
62 int buttonX,
63 int buttonY,
64 int buttonW,
65 int buttonH,
66 juce::ComboBox& box) {
67
68 g.setColour(box.findColour(juce::ComboBox::arrowColourId));
69
70 juce::Path p;
71 constexpr float LINE_WIDTH {0.5};
72 const int arrowMarginX {buttonY / 4};
73 const int arrowMarginY {buttonH / 3};
74 const int arrowTipX {buttonX + (buttonW / 2)};
75 const int arrowTipY {buttonY + buttonH - arrowMarginY};
76
77 // Left side of arrow
78 p.addLineSegment(juce::Line<float>(buttonX + arrowMarginX,
79 buttonY + arrowMarginY,
80 arrowTipX,
81 arrowTipY),
82 LINE_WIDTH);
83
84 // Right side of arrow
85 p.addLineSegment(juce::Line<float>(buttonX + buttonW - arrowMarginX,
86 buttonY + arrowMarginY,
87 arrowTipX,
88 arrowTipY),
89 LINE_WIDTH);
90
91 g.strokePath(p, juce::PathStrokeType(1));
92 }
93}
virtual void drawComboBox(juce::Graphics &g, int width, int height, const bool isButtonDown, int buttonX, int buttonY, int buttonW, int buttonH, juce::ComboBox &box) override
Definition ComboBoxV2.h:58