@@ -29,24 +29,23 @@ String MainToolbarButton::getTooltip()
2929 return setTooltip;
3030}
3131
32-
3332void MainToolbarButton::paint (Graphics& g)
3433{
3534 bool const active = isOver () || isDown () || getToggleState ();
36-
35+
3736 auto constexpr cornerSize = Corners::defaultCornerRadius;
3837 auto const backgroundColour = active ? findColour (PlugDataColour::toolbarHoverColourId) : Colours::transparentBlack;
3938 auto bounds = getLocalBounds ().reduced (3 , 4 ).toFloat ();
40-
39+
4140 g.setColour (backgroundColour);
4241 g.fillRoundedRectangle (bounds, cornerSize);
43-
42+
4443 auto const textColour = findColour (PlugDataColour::toolbarTextColourId).withMultipliedAlpha (isEnabled () ? 1 .0f : 0 .5f );
45-
44+
4645#if JUCE_MAC
4746 bounds = bounds.withTrimmedBottom (2 );
4847#endif
49-
48+
5049 g.setFont (Fonts::getIconFont ().withHeight (getHeight () / 2.7 ));
5150 g.setColour (textColour);
5251 g.drawText (getButtonText (), bounds, Justification::centred);
@@ -88,28 +87,28 @@ void ToolbarRadioButton::paint(Graphics& g)
8887{
8988 bool const mouseOver = isOver ();
9089 bool const active = mouseOver || isDown () || getToggleState ();
91-
90+
9291 auto const flatOnLeft = isConnectedOnLeft ();
9392 auto const flatOnRight = isConnectedOnRight ();
9493 auto const flatOnTop = isConnectedOnTop ();
9594 auto const flatOnBottom = isConnectedOnBottom ();
96-
95+
9796 auto const backgroundColour = findColour (active ? PlugDataColour::toolbarHoverColourId : PlugDataColour::toolbarBackgroundColourId).contrasting (mouseOver && !getToggleState () ? 0 .0f : 0 .035f );
98-
97+
9998 auto bounds = getLocalBounds ().toFloat ();
10099 bounds = bounds.reduced (0 .0f , bounds.proportionOfHeight (0 .17f ));
101-
100+
102101 g.setColour (backgroundColour);
103102 Path p;
104103 p.addRoundedRectangle (bounds.getX (), bounds.getY (), bounds.getWidth (), bounds.getHeight (), Corners::defaultCornerRadius, Corners::defaultCornerRadius,
105- !(flatOnLeft || flatOnTop),
106- !(flatOnRight || flatOnTop),
107- !(flatOnLeft || flatOnBottom),
108- !(flatOnRight || flatOnBottom));
104+ !(flatOnLeft || flatOnTop),
105+ !(flatOnRight || flatOnTop),
106+ !(flatOnLeft || flatOnBottom),
107+ !(flatOnRight || flatOnBottom));
109108 g.fillPath (p);
110-
109+
111110 auto const textColour = findColour (PlugDataColour::toolbarTextColourId).withMultipliedAlpha (isEnabled () ? 1 .0f : 0 .5f );
112-
111+
113112 g.setFont (Fonts::getIconFont ().withHeight (getHeight () / 2.8 ));
114113 g.setColour (textColour);
115114 g.drawText (getButtonText (), getLocalBounds (), Justification::centred);
@@ -138,13 +137,11 @@ void ToolbarRadioButton::mouseExit(MouseEvent const& e)
138137}
139138#endif
140139
141-
142-
143140bool SmallIconButton::hitTest (int const x, int const y)
144141{
145142 if (getLocalBounds ().reduced (2 ).contains (x, y))
146143 return true ;
147-
144+
148145 return false ;
149146}
150147
@@ -161,22 +158,23 @@ void SmallIconButton::mouseExit(MouseEvent const& e)
161158void SmallIconButton::paint (Graphics& g)
162159{
163160 auto colour = findColour (PlugDataColour::toolbarTextColourId);
164-
161+
165162 if (!isEnabled ()) {
166163 colour = Colours::grey;
167164 } else if (getToggleState ()) {
168165 colour = findColour (PlugDataColour::toolbarActiveColourId);
169166 } else if (isMouseOver ()) {
170167 colour = findColour (PlugDataColour::toolbarTextColourId).brighter (0 .8f );
171168 }
172-
169+
173170 Fonts::drawIcon (g, getButtonText (), getLocalBounds (), colour, 12 );
174171}
175172
176-
177173WidePanelButton::WidePanelButton (String const & icon, int const iconSize)
178- : icon(icon)
179- , iconSize(iconSize) { }
174+ : icon(icon)
175+ , iconSize(iconSize)
176+ {
177+ }
180178
181179void WidePanelButton::mouseEnter (MouseEvent const & e)
182180{
@@ -194,31 +192,31 @@ void WidePanelButton::paint(Graphics& g)
194192 bool const flatOnRight = isConnectedOnRight ();
195193 bool const flatOnTop = isConnectedOnTop ();
196194 bool const flatOnBottom = isConnectedOnBottom ();
197-
195+
198196 float const width = getWidth () - 1 .0f ;
199197 float const height = getHeight () - 1 .0f ;
200-
198+
201199 constexpr float cornerSize = Corners::largeCornerRadius;
202200 Path outline;
203201 outline.addRoundedRectangle (0 .5f , 0 .5f , width, height, cornerSize, cornerSize,
204- !(flatOnLeft || flatOnTop),
205- !(flatOnRight || flatOnTop),
206- !(flatOnLeft || flatOnBottom),
207- !(flatOnRight || flatOnBottom));
208-
202+ !(flatOnLeft || flatOnTop),
203+ !(flatOnRight || flatOnTop),
204+ !(flatOnLeft || flatOnBottom),
205+ !(flatOnRight || flatOnBottom));
206+
209207 g.setColour (findColour (isMouseOver () ? PlugDataColour::panelActiveBackgroundColourId : PlugDataColour::panelForegroundColourId));
210208 g.fillPath (outline);
211-
209+
212210 g.setColour (findColour (PlugDataColour::outlineColourId));
213211 g.strokePath (outline, PathStrokeType (1 ));
214-
212+
215213 Fonts::drawText (g, getButtonText (), getLocalBounds ().reduced (12 , 2 ), findColour (PlugDataColour::panelTextColourId), 15 );
216214 Fonts::drawIcon (g, icon, getLocalBounds ().reduced (12 , 2 ).removeFromRight (24 ), findColour (PlugDataColour::panelTextColourId), iconSize);
217215}
218216
219217SettingsToolbarButton::SettingsToolbarButton (String iconToUse, String textToShow)
220- : icon(std::move(iconToUse))
221- , text(std::move(textToShow))
218+ : icon(std::move(iconToUse))
219+ , text(std::move(textToShow))
222220{
223221 setClickingTogglesState (true );
224222 setConnectedEdges (12 );
@@ -227,30 +225,29 @@ SettingsToolbarButton::SettingsToolbarButton(String iconToUse, String textToShow
227225void SettingsToolbarButton::paint (Graphics& g)
228226{
229227 auto const b = getLocalBounds ().reduced (2 .0f , 4 .0f );
230-
228+
231229 if (isMouseOver () || getToggleState ()) {
232230 auto background = findColour (PlugDataColour::toolbarHoverColourId);
233231 if (getToggleState ())
234232 background = background.darker (0 .025f );
235-
233+
236234 g.setColour (background);
237235 g.fillRoundedRectangle (b.toFloat (), Corners::defaultCornerRadius);
238236 }
239-
237+
240238 auto const textColour = findColour (PlugDataColour::toolbarTextColourId);
241239 auto const boldFont = Fonts::getBoldFont ().withHeight (13 .5f );
242240 auto const iconFont = Fonts::getIconFont ().withHeight (13 .5f );
243-
241+
244242 AttributedString attrStr;
245243 attrStr.setJustification (Justification::centred);
246244 attrStr.append (icon, iconFont, textColour);
247245 attrStr.append (" " + text, boldFont, textColour);
248246 attrStr.draw (g, b.toFloat ());
249247}
250248
251-
252249ReorderButton::ReorderButton ()
253- : SmallIconButton(Icons::Reorder)
250+ : SmallIconButton(Icons::Reorder)
254251{
255252 setSize (25 , 25 );
256253}
0 commit comments