1
1
#include " Look.h"
2
2
3
+ Font Look::getFontInterRegular (float height)
4
+ {
5
+ static auto font = Font (Typeface::createSystemTypefaceFor (BinaryData::InterRegular_otf, BinaryData::InterRegular_otfSize));
6
+ return font.withHeight (height).withExtraKerningFactor (KERNING_FACTOR);
7
+ }
8
+
9
+ Font Look::getFontInterItalic (float height)
10
+ {
11
+ static auto font = Font (Typeface::createSystemTypefaceFor (BinaryData::InterItalic_otf, BinaryData::InterItalic_otfSize));
12
+ return font.withHeight (height).withExtraKerningFactor (KERNING_FACTOR);
13
+ }
14
+
15
+ Font Look::getFontInterBold (float height)
16
+ {
17
+ static auto font = Font (Typeface::createSystemTypefaceFor (BinaryData::InterBold_otf, BinaryData::InterBold_otfSize));
18
+ return font.withHeight (height).withExtraKerningFactor (KERNING_FACTOR);
19
+ }
20
+
21
+ Font Look::getFontInterBlack (float height)
22
+ {
23
+ static auto font = Font (Typeface::createSystemTypefaceFor (BinaryData::InterBlack_otf, BinaryData::InterBlack_otfSize));
24
+ return font.withHeight (height).withExtraKerningFactor (KERNING_FACTOR);
25
+ }
26
+
3
27
void Look::drawLinearSlider (Graphics &g, int x, int y, int width, int height, float sliderPos, float minSliderPos, float maxSliderPos, const Slider::SliderStyle slider_style, Slider &slider)
4
28
{
29
+ ignoreUnused (x, y, width, height, minSliderPos, maxSliderPos, slider_style);
30
+
5
31
// Background
6
32
g.fillAll (BEIGE);
7
33
8
- // Outline
9
- g.setColour (juce::Colours::black);
10
- g.drawRect (slider.getLocalBounds (), 2 );
11
-
12
34
// Indicator region
13
35
const auto bounds = slider.getLocalBounds ();
14
- g.setColour (GREY );
36
+ g.setColour (GREY_TRANSPARENT );
15
37
g.fillRect (bounds.getX (), bounds.getY (), (int )(sliderPos), bounds.getHeight ());
38
+
39
+ // Outline
40
+ g.setColour (juce::Colours::black);
41
+ g.drawRect (slider.getLocalBounds (), 2 );
16
42
}
17
43
18
44
void Look::drawRotarySlider (Graphics &g, int x, int y, int width, int height, float sliderPos, const float rotaryStartAngle, const float rotaryEndAngle, Slider &slider)
19
45
{
46
+ ignoreUnused (slider);
47
+
20
48
const auto centre_x = ((float )x + (float )width) / 2 .0f ;
21
- const auto centre_y = ((float )x + (float )height) / 2 .0f ;
49
+ const auto centre_y = ((float )y + (float )height) / 2 .0f ;
50
+
51
+ const auto half_outline = OUTLINE / 2 .0f ;
22
52
23
53
// Knob
24
54
25
55
const auto knob_radius = KNOB_DIM / 2 .0f ;
26
56
Path k;
27
- k.addEllipse (centre_x - knob_radius, centre_y - knob_radius, KNOB_DIM, KNOB_DIM);
57
+ k.addEllipse (centre_x - knob_radius, centre_y - knob_radius, KNOB_DIM - OUTLINE , KNOB_DIM - OUTLINE );
28
58
29
- g.setColour (Colours::white );
59
+ g.setColour (BEIGE );
30
60
g.fillPath (k);
31
- g.setColour (GREY );
61
+ g.setColour (GREY_TRANSPARENT );
32
62
g.fillPath (k);
33
63
34
64
g.setColour (Colours::black);
@@ -37,15 +67,15 @@ void Look::drawRotarySlider(Graphics &g, int x, int y, int width, int height, fl
37
67
// Pointer
38
68
39
69
const auto pointer_radius = POINTER_DIM / 2 .0f ;
40
- const auto knob_offset = (width - KNOB_DIM) / 2 .0f ;
70
+ const auto knob_offset = (( float ) width - ( float ) KNOB_DIM) / 2 .0f ;
41
71
Path p;
42
- p.addEllipse (x - pointer_radius, y - pointer_radius, POINTER_DIM, POINTER_DIM);
72
+ p.addEllipse (Rectangle< float >(- pointer_radius, - pointer_radius, POINTER_DIM, POINTER_DIM). reduced (OUTLINE) );
43
73
44
74
AffineTransform pointer_transform;
45
75
pointer_transform = pointer_transform
46
- .translated (0 .0f , -knob_radius + (pointer_radius + POINTER_OFFSET))
76
+ .translated (0 .0f , -( knob_radius + half_outline) + (pointer_radius + POINTER_OFFSET))
47
77
.rotated ((sliderPos - 0 .5f ) * (rotaryEndAngle - rotaryStartAngle))
48
- .translated (knob_radius + knob_offset, knob_radius + knob_offset);
78
+ .translated (knob_radius + knob_offset - half_outline , knob_radius + knob_offset - half_outline );
49
79
p.applyTransform (pointer_transform);
50
80
51
81
g.setColour (Colours::white);
@@ -62,17 +92,22 @@ void Look::drawTickBox(Graphics &g, Component &component,
62
92
const bool shouldDrawButtonAsHighlighted,
63
93
const bool shouldDrawButtonAsDown)
64
94
{
95
+ ignoreUnused (x, y, w, h, isEnabled, shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
96
+
97
+ auto bounds = component.getLocalBounds ();
98
+
65
99
// Background
66
100
g.fillAll (BEIGE);
67
101
68
102
// Outline
69
103
g.setColour (juce::Colours::black);
70
- g.drawRect (component. getLocalBounds (), 2 );
104
+ g.drawRect (bounds, ( int )OUTLINE );
71
105
72
106
if (ticked)
73
107
{
108
+ g.setColour (Colours::black);
74
109
g.setFont (Look::getFontInterBlack (FONT_SIZE));
75
- g.drawFittedText (" X" , component. getLocalBounds () , juce::Justification::centred, 1 , 1 .0f );
110
+ g.drawFittedText (" X" , bounds , juce::Justification::centred, 1 , 1 .0f );
76
111
}
77
112
}
78
113
@@ -96,32 +131,73 @@ void Look::drawLabel(Graphics &g, Label &label)
96
131
97
132
Font Look::getLabelFont (Label &label)
98
133
{
99
- if (( label.getProperties ()[" gui_class" ] == " label " ) || dynamic_cast <Slider *>(label. getParentComponent ()) )
134
+ if (label.getProperties ()[" gui_class" ] == " bold " )
100
135
{
101
- return getFontInterRegular (FONT_SIZE);
136
+ return getFontInterBold (FONT_SIZE);
102
137
}
103
- else if (label.getProperties ()[" gui_class" ] == " bold " )
138
+ if (label.getProperties ()[" gui_class" ] == " black " )
104
139
{
105
140
return getFontInterBlack (FONT_SIZE);
106
141
}
142
+ else if (label.getProperties ()[" gui_class" ] == " italic" )
143
+ {
144
+ return getFontInterItalic (FONT_SIZE);
145
+ }
107
146
else if (label.getProperties ()[" gui_class" ] == " title" )
108
147
{
109
148
return getFontInterBlack (FONT_SIZE_TITLE);
110
149
}
111
150
else
112
151
{
113
- return label. getFont ( );
152
+ return getFontInterRegular (FONT_SIZE );
114
153
}
115
154
}
116
155
117
- Font Look::getFontInterRegular ( float height)
156
+ void Look::drawComboBox (Graphics &g, int width, int height, bool , int , int , int , int , ComboBox &box )
118
157
{
119
- static auto font = Font (Typeface::createSystemTypefaceFor (BinaryData::InterRegular_otf, BinaryData::InterRegular_otfSize));
120
- return font.withHeight (height).withExtraKerningFactor (KERNING_FACTOR);
158
+ ignoreUnused (width, height);
159
+
160
+ auto bounds = box.getLocalBounds ();
161
+
162
+ g.setColour (BEIGE);
163
+ g.fillRect (bounds);
164
+
165
+ g.setColour (Colours::black);
166
+ g.drawRect (bounds, 2 .0f );
121
167
}
122
168
123
- Font Look::getFontInterBlack ( float height )
169
+ void Look::positionComboBoxText (ComboBox &box, Label &label )
124
170
{
125
- static auto font = Font (Typeface::createSystemTypefaceFor (BinaryData::InterBlack_otf, BinaryData::InterBlack_otfSize));
126
- return font.withHeight (height).withExtraKerningFactor (KERNING_FACTOR);
127
- }
171
+ label.setBounds (box.getLocalBounds ());
172
+ }
173
+
174
+ void Look::drawPopupMenuItem (Graphics &g, const Rectangle<int > &area,
175
+ const bool isSeparator, const bool isActive,
176
+ const bool isHighlighted, const bool isTicked,
177
+ const bool hasSubMenu, const String &text,
178
+ const String &shortcutKeyText,
179
+ const Drawable *icon, const Colour *const textColourToUse)
180
+ {
181
+ ignoreUnused (isSeparator, isActive, isTicked, hasSubMenu, shortcutKeyText, icon, textColourToUse);
182
+
183
+ g.setColour (BEIGE);
184
+ g.fillRect (area);
185
+ if (isHighlighted)
186
+ {
187
+ g.setColour (GREY_TRANSPARENT);
188
+ g.fillRect (area);
189
+ }
190
+ g.setColour (Colours::black);
191
+ g.drawRect (area, (int )OUTLINE);
192
+
193
+ auto font = Look::getFontInterRegular (FONT_SIZE);
194
+ g.setFont (font);
195
+ g.setColour (Colours::black);
196
+ g.drawFittedText (text, area, Justification::centred, 1 .0f );
197
+ }
198
+
199
+ void Look::drawPopupMenuBackground (Graphics &g, int width, int height)
200
+ {
201
+ ignoreUnused (width, height);
202
+ g.fillAll (Colours::black);
203
+ }
0 commit comments