JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_LookAndFeel_V3.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29LookAndFeel_V3::LookAndFeel_V3()
30{
32
33 const Colour textButtonColour (0xffeeeeff);
35 setColour (TextButton::buttonOnColourId, Colour (0xff888888));
38 setColour (TextEditor::outlineColourId, Colours::transparentBlack);
40 setColour (TabbedComponent::outlineColourId, Colour (0x66000000));
41 setColour (Slider::trackColourId, Colour (0xbbffffff));
42 setColour (Slider::thumbColourId, Colour (0xffddddff));
44 setColour (ScrollBar::thumbColourId, Colour::greyLevel (0.8f).contrasting().withAlpha (0.13f));
45 setColour (TableHeaderComponent::backgroundColourId, Colours::white.withAlpha (0.6f));
46 setColour (TableHeaderComponent::outlineColourId, Colours::black.withAlpha (0.5f));
47}
48
49LookAndFeel_V3::~LookAndFeel_V3() {}
50
51bool LookAndFeel_V3::areScrollbarButtonsVisible() { return false; }
52
53void LookAndFeel_V3::drawStretchableLayoutResizerBar (Graphics& g, int /*w*/, int /*h*/, bool /*isVerticalBar*/,
54 bool isMouseOver, bool isMouseDragging)
55{
56 if (isMouseOver || isMouseDragging)
57 g.fillAll (Colours::yellow.withAlpha (0.4f));
58}
59
60void LookAndFeel_V3::drawScrollbar (Graphics& g, ScrollBar& scrollbar, int x, int y, int width, int height,
61 bool isScrollbarVertical, int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown)
62{
64
65 if (thumbSize > 0)
66 {
67 const float thumbIndent = (float) (isScrollbarVertical ? width : height) * 0.25f;
68 const float thumbIndentx2 = thumbIndent * 2.0f;
69
72 (float) width - thumbIndentx2, (float) thumbSize - thumbIndentx2, ((float) width - thumbIndentx2) * 0.5f);
73 else
74 thumbPath.addRoundedRectangle ((float) thumbStartPosition + thumbIndent, (float) y + thumbIndent,
75 (float) thumbSize - thumbIndentx2, (float) height - thumbIndentx2, ((float) height - thumbIndentx2) * 0.5f);
76 }
77
79
80 if (isMouseOver || isMouseDown)
81 thumbCol = thumbCol.withMultipliedAlpha (2.0f);
82
85
86 g.setColour (thumbCol.contrasting ((isMouseOver || isMouseDown) ? 0.2f : 0.1f));
88}
89
90void LookAndFeel_V3::drawConcertinaPanelHeader (Graphics& g, const Rectangle<int>& area,
91 bool isMouseOver, bool /*isMouseDown*/,
93{
94 const Colour bkg (Colours::grey);
95
96 g.setGradientFill (ColourGradient::vertical (Colours::white.withAlpha (isMouseOver ? 0.4f : 0.2f), (float) area.getY(),
97 Colours::darkgrey.withAlpha (0.1f), (float) area.getBottom()));
98 g.fillAll();
99
100 g.setColour (bkg.contrasting().withAlpha (0.1f));
101 g.fillRect (area.withHeight (1));
102 g.fillRect (area.withTop (area.getBottom() - 1));
103
104 g.setColour (bkg.contrasting());
105 g.setFont (Font ((float) area.getHeight() * 0.6f).boldened());
106 g.drawFittedText (panel.getName(), 4, 0, area.getWidth() - 6, area.getHeight(), Justification::centredLeft, 1);
107}
108
109static void drawButtonShape (Graphics& g, const Path& outline, Colour baseColour, float height)
110{
111 const float mainBrightness = baseColour.getBrightness();
112 const float mainAlpha = baseColour.getFloatAlpha();
113
114 g.setGradientFill (ColourGradient::vertical (baseColour.brighter (0.2f), 0.0f,
115 baseColour.darker (0.25f), height));
116 g.fillPath (outline);
117
118 g.setColour (Colours::white.withAlpha (0.4f * mainAlpha * mainBrightness * mainBrightness));
119 g.strokePath (outline, PathStrokeType (1.0f), AffineTransform::translation (0.0f, 1.0f)
120 .scaled (1.0f, (height - 1.6f) / height));
121
122 g.setColour (Colours::black.withAlpha (0.4f * mainAlpha));
123 g.strokePath (outline, PathStrokeType (1.0f));
124}
125
126void LookAndFeel_V3::drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour,
128{
129 Colour baseColour (backgroundColour.withMultipliedSaturation (button.hasKeyboardFocus (true) ? 1.3f : 0.9f)
130 .withMultipliedAlpha (button.isEnabled() ? 0.9f : 0.5f));
131
133 baseColour = baseColour.contrasting (shouldDrawButtonAsDown ? 0.2f : 0.1f);
134
135 const bool flatOnLeft = button.isConnectedOnLeft();
136 const bool flatOnRight = button.isConnectedOnRight();
137 const bool flatOnTop = button.isConnectedOnTop();
138 const bool flatOnBottom = button.isConnectedOnBottom();
139
140 const float width = (float) button.getWidth() - 1.0f;
141 const float height = (float) button.getHeight() - 1.0f;
142
143 if (width > 0 && height > 0)
144 {
145 const float cornerSize = 4.0f;
146
147 Path outline;
148 outline.addRoundedRectangle (0.5f, 0.5f, width, height, cornerSize, cornerSize,
149 ! (flatOnLeft || flatOnTop),
150 ! (flatOnRight || flatOnTop),
153
154 drawButtonShape (g, outline, baseColour, height);
155 }
156}
157
158void LookAndFeel_V3::drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header)
159{
160 auto r = header.getLocalBounds();
161 auto outlineColour = header.findColour (TableHeaderComponent::outlineColourId);
162
163 g.setColour (outlineColour);
164 g.fillRect (r.removeFromBottom (1));
165
166 g.setColour (header.findColour (TableHeaderComponent::backgroundColourId));
167 g.fillRect (r);
168
169 g.setColour (outlineColour);
170
171 for (int i = header.getNumColumns (true); --i >= 0;)
172 g.fillRect (header.getColumnPosition (i).removeFromRight (1));
173}
174
175int LookAndFeel_V3::getTabButtonOverlap (int /*tabDepth*/) { return -1; }
176int LookAndFeel_V3::getTabButtonSpaceAroundImage() { return 0; }
177
178void LookAndFeel_V3::createTabTextLayout (const TabBarButton& button, float length, float depth,
179 Colour colour, TextLayout& textLayout)
180{
181 Font font (depth * 0.5f);
182 font.setUnderline (button.hasKeyboardFocus (false));
183
184 AttributedString s;
185 s.setJustification (Justification::centred);
186 s.append (button.getButtonText().trim(), font, colour);
187
188 textLayout.createLayout (s, length);
189}
190
191void LookAndFeel_V3::drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown)
192{
193 const Rectangle<int> activeArea (button.getActiveArea());
194
195 const TabbedButtonBar::Orientation o = button.getTabbedButtonBar().getOrientation();
196
197 const Colour bkg (button.getTabBackgroundColour());
198
199 if (button.getToggleState())
200 {
201 g.setColour (bkg);
202 }
203 else
204 {
205 Point<int> p1, p2;
206
207 switch (o)
208 {
209 case TabbedButtonBar::TabsAtBottom: p1 = activeArea.getBottomLeft(); p2 = activeArea.getTopLeft(); break;
210 case TabbedButtonBar::TabsAtTop: p1 = activeArea.getTopLeft(); p2 = activeArea.getBottomLeft(); break;
211 case TabbedButtonBar::TabsAtRight: p1 = activeArea.getTopRight(); p2 = activeArea.getTopLeft(); break;
212 case TabbedButtonBar::TabsAtLeft: p1 = activeArea.getTopLeft(); p2 = activeArea.getTopRight(); break;
213 default: jassertfalse; break;
214 }
215
216 g.setGradientFill (ColourGradient (bkg.brighter (0.2f), p1.toFloat(),
217 bkg.darker (0.1f), p2.toFloat(), false));
218 }
219
220 g.fillRect (activeArea);
221
222 g.setColour (button.findColour (TabbedButtonBar::tabOutlineColourId));
223
224 Rectangle<int> r (activeArea);
225
226 if (o != TabbedButtonBar::TabsAtBottom) g.fillRect (r.removeFromTop (1));
227 if (o != TabbedButtonBar::TabsAtTop) g.fillRect (r.removeFromBottom (1));
228 if (o != TabbedButtonBar::TabsAtRight) g.fillRect (r.removeFromLeft (1));
229 if (o != TabbedButtonBar::TabsAtLeft) g.fillRect (r.removeFromRight (1));
230
231 const float alpha = button.isEnabled() ? ((isMouseOver || isMouseDown) ? 1.0f : 0.8f) : 0.3f;
232
233 Colour col (bkg.contrasting().withMultipliedAlpha (alpha));
234
235 if (TabbedButtonBar* bar = button.findParentComponentOfClass<TabbedButtonBar>())
236 {
239
240 if (bar->isColourSpecified (colID))
241 col = bar->findColour (colID);
242 else if (isColourSpecified (colID))
243 col = findColour (colID);
244 }
245
246 const Rectangle<float> area (button.getTextArea().toFloat());
247
248 float length = area.getWidth();
249 float depth = area.getHeight();
250
251 if (button.getTabbedButtonBar().isVertical())
252 std::swap (length, depth);
253
254 TextLayout textLayout;
255 createTabTextLayout (button, length, depth, col, textLayout);
256
257 AffineTransform t;
258
259 switch (o)
260 {
261 case TabbedButtonBar::TabsAtLeft: t = t.rotated (MathConstants<float>::pi * -0.5f).translated (area.getX(), area.getBottom()); break;
262 case TabbedButtonBar::TabsAtRight: t = t.rotated (MathConstants<float>::pi * 0.5f).translated (area.getRight(), area.getY()); break;
263 case TabbedButtonBar::TabsAtTop:
264 case TabbedButtonBar::TabsAtBottom: t = t.translated (area.getX(), area.getY()); break;
265 default: jassertfalse; break;
266 }
267
268 g.addTransform (t);
269 textLayout.draw (g, Rectangle<float> (length, depth));
270}
271
272void LookAndFeel_V3::drawTabAreaBehindFrontButton (TabbedButtonBar& bar, Graphics& g, const int w, const int h)
273{
274 const float shadowSize = 0.15f;
275
276 Rectangle<int> shadowRect, line;
277 ColourGradient gradient (Colours::black.withAlpha (bar.isEnabled() ? 0.08f : 0.04f), 0, 0,
278 Colours::transparentBlack, 0, 0, false);
279
280 switch (bar.getOrientation())
281 {
282 case TabbedButtonBar::TabsAtLeft:
283 gradient.point1.x = (float) w;
284 gradient.point2.x = (float) w * (1.0f - shadowSize);
285 shadowRect.setBounds ((int) gradient.point2.x, 0, w - (int) gradient.point2.x, h);
286 line.setBounds (w - 1, 0, 1, h);
287 break;
288
289 case TabbedButtonBar::TabsAtRight:
290 gradient.point2.x = (float) w * shadowSize;
291 shadowRect.setBounds (0, 0, (int) gradient.point2.x, h);
292 line.setBounds (0, 0, 1, h);
293 break;
294
295 case TabbedButtonBar::TabsAtTop:
296 gradient.point1.y = (float) h;
297 gradient.point2.y = (float) h * (1.0f - shadowSize);
298 shadowRect.setBounds (0, (int) gradient.point2.y, w, h - (int) gradient.point2.y);
299 line.setBounds (0, h - 1, w, 1);
300 break;
301
302 case TabbedButtonBar::TabsAtBottom:
303 gradient.point2.y = (float) h * shadowSize;
304 shadowRect.setBounds (0, 0, w, (int) gradient.point2.y);
305 line.setBounds (0, 0, w, 1);
306 break;
307
308 default: break;
309 }
310
311 g.setGradientFill (gradient);
312 g.fillRect (shadowRect.expanded (2, 2));
313
314 g.setColour (bar.findColour (TabbedButtonBar::tabOutlineColourId));
315 g.fillRect (line);
316}
317
318void LookAndFeel_V3::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor)
319{
320 if (textEditor.isEnabled())
321 {
322 if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly())
323 {
324 g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId));
325 g.drawRect (0, 0, width, height, 2);
326 }
327 else
328 {
329 g.setColour (textEditor.findColour (TextEditor::outlineColourId));
330 g.drawRect (0, 0, width, height);
331 }
332 }
333}
334
335void LookAndFeel_V3::drawTreeviewPlusMinusBox (Graphics& g, const Rectangle<float>& area,
336 Colour backgroundColour, bool isOpen, bool isMouseOver)
337{
338 Path p;
339 p.addTriangle (0.0f, 0.0f, 1.0f, isOpen ? 0.0f : 0.5f, isOpen ? 0.5f : 0.0f, 1.0f);
340
341 g.setColour (backgroundColour.contrasting().withAlpha (isMouseOver ? 0.5f : 0.3f));
342 g.fillPath (p, p.getTransformToScaleToFit (area.reduced (2, area.getHeight() / 4), true));
343}
344
345bool LookAndFeel_V3::areLinesDrawnForTreeView (TreeView&)
346{
347 return false;
348}
349
350int LookAndFeel_V3::getTreeViewIndentSize (TreeView&)
351{
352 return 20;
353}
354
355void LookAndFeel_V3::drawComboBox (Graphics& g, int width, int height, const bool /*isMouseButtonDown*/,
356 int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box)
357{
358 g.fillAll (box.findColour (ComboBox::backgroundColourId));
359
360 if (box.isEnabled() && box.hasKeyboardFocus (false))
361 {
362 g.setColour (box.findColour (ComboBox::focusedOutlineColourId));
363 g.drawRect (0, 0, width, height, 2);
364 }
365 else
366 {
367 g.setColour (box.findColour (ComboBox::outlineColourId));
368 g.drawRect (0, 0, width, height);
369 }
370
371 const float arrowX = 0.3f;
372 const float arrowH = 0.2f;
373
374 const auto x = (float) buttonX;
375 const auto y = (float) buttonY;
376 const auto w = (float) buttonW;
377 const auto h = (float) buttonH;
378
379 Path p;
380 p.addTriangle (x + w * 0.5f, y + h * (0.45f - arrowH),
381 x + w * (1.0f - arrowX), y + h * 0.45f,
382 x + w * arrowX, y + h * 0.45f);
383
384 p.addTriangle (x + w * 0.5f, y + h * (0.55f + arrowH),
385 x + w * (1.0f - arrowX), y + h * 0.55f,
386 x + w * arrowX, y + h * 0.55f);
387
388 g.setColour (box.findColour (ComboBox::arrowColourId).withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.3f));
389 g.fillPath (p);
390}
391
392void LookAndFeel_V3::drawLinearSlider (Graphics& g, int x, int y, int width, int height,
393 float sliderPos, float minSliderPos, float maxSliderPos,
394 const Slider::SliderStyle style, Slider& slider)
395{
396 g.fillAll (slider.findColour (Slider::backgroundColourId));
397
398 if (style == Slider::LinearBar || style == Slider::LinearBarVertical)
399 {
400 const float fx = (float) x, fy = (float) y, fw = (float) width, fh = (float) height;
401
402 Path p;
403
404 if (style == Slider::LinearBarVertical)
405 p.addRectangle (fx, sliderPos, fw, 1.0f + fh - sliderPos);
406 else
407 p.addRectangle (fx, fy, sliderPos - fx, fh);
408
409 auto baseColour = slider.findColour (Slider::thumbColourId)
410 .withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f)
411 .withMultipliedAlpha (0.8f);
412
413 g.setGradientFill (ColourGradient::vertical (baseColour.brighter (0.08f), 0.0f,
414 baseColour.darker (0.08f), (float) height));
415 g.fillPath (p);
416
417 g.setColour (baseColour.darker (0.2f));
418
419 if (style == Slider::LinearBarVertical)
420 g.fillRect (fx, sliderPos, fw, 1.0f);
421 else
422 g.fillRect (sliderPos, fy, 1.0f, fh);
423
424 drawLinearSliderOutline (g, x, y, width, height, style, slider);
425 }
426 else
427 {
428 drawLinearSliderBackground (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
429 drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
430 }
431}
432
433void LookAndFeel_V3::drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height,
434 float /*sliderPos*/,
435 float /*minSliderPos*/,
436 float /*maxSliderPos*/,
437 const Slider::SliderStyle /*style*/, Slider& slider)
438{
439 const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2);
440
441 const Colour trackColour (slider.findColour (Slider::trackColourId));
442 const Colour gradCol1 (trackColour.overlaidWith (Colour (slider.isEnabled() ? 0x13000000 : 0x09000000)));
443 const Colour gradCol2 (trackColour.overlaidWith (Colour (0x06000000)));
444 Path indent;
445
446 if (slider.isHorizontal())
447 {
448 auto iy = (float) y + (float) height * 0.5f - sliderRadius * 0.5f;
449
450 g.setGradientFill (ColourGradient::vertical (gradCol1, iy, gradCol2, iy + sliderRadius));
451
452 indent.addRoundedRectangle ((float) x - sliderRadius * 0.5f, iy, (float) width + sliderRadius, sliderRadius, 5.0f);
453 }
454 else
455 {
456 auto ix = (float) x + (float) width * 0.5f - sliderRadius * 0.5f;
457
459
460 indent.addRoundedRectangle (ix, (float) y - sliderRadius * 0.5f, sliderRadius, (float) height + sliderRadius, 5.0f);
461 }
462
463 g.fillPath (indent);
464
465 g.setColour (trackColour.contrasting (0.5f));
466 g.strokePath (indent, PathStrokeType (0.5f));
467}
468
470{
472
473 #if ! JUCE_MAC
474 g.setColour (findColour (PopupMenu::textColourId).withAlpha (0.6f));
475 g.drawRect (0, 0, width, height);
476 #endif
477}
478
479void LookAndFeel_V3::drawMenuBarBackground (Graphics& g, int width, int height,
480 bool, MenuBarComponent& menuBar)
481{
482 auto colour = menuBar.findColour (PopupMenu::backgroundColourId);
483
484 Rectangle<int> r (width, height);
485
486 g.setColour (colour.contrasting (0.15f));
487 g.fillRect (r.removeFromTop (1));
488 g.fillRect (r.removeFromBottom (1));
489
490 g.setGradientFill (ColourGradient::vertical (colour, 0, colour.darker (0.08f), (float) height));
491 g.fillRect (r);
492}
493
494void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height,
495 Button& button, const String& keyDescription)
496{
497 const Colour textColour (button.findColour (0x100ad01 /*KeyMappingEditorComponent::textColourId*/, true));
498
499 if (keyDescription.isNotEmpty())
500 {
501 if (button.isEnabled())
502 {
503 g.setColour (textColour.withAlpha (button.isDown() ? 0.4f : (button.isOver() ? 0.2f : 0.1f)));
504 g.fillRoundedRectangle (button.getLocalBounds().toFloat(), 4.0f);
505 g.drawRoundedRectangle (button.getLocalBounds().toFloat(), 4.0f, 1.0f);
506 }
507
508 g.setColour (textColour);
509 g.setFont ((float) height * 0.6f);
510 g.drawFittedText (keyDescription, 4, 0, width - 8, height, Justification::centred, 1);
511 }
512 else
513 {
514 const float thickness = 7.0f;
515 const float indent = 22.0f;
516
517 Path p;
518 p.addEllipse (0.0f, 0.0f, 100.0f, 100.0f);
519 p.addRectangle (indent, 50.0f - thickness, 100.0f - indent * 2.0f, thickness * 2.0f);
520 p.addRectangle (50.0f - thickness, indent, thickness * 2.0f, 50.0f - indent - thickness);
521 p.addRectangle (50.0f - thickness, 50.0f + thickness, thickness * 2.0f, 50.0f - indent - thickness);
522 p.setUsingNonZeroWinding (false);
523
524 g.setColour (textColour.darker (0.1f).withAlpha (button.isDown() ? 0.7f : (button.isOver() ? 0.5f : 0.3f)));
525 g.fillPath (p, p.getTransformToScaleToFit (2.0f, 2.0f, (float) width - 4.0f, (float) height - 4.0f, true));
526 }
527
528 if (button.hasKeyboardFocus (false))
529 {
530 g.setColour (textColour.withAlpha (0.4f));
531 g.drawRect (0, 0, width, height);
532 }
533}
534
535
537{
538public:
539 LookAndFeel_V3_DocumentWindowButton (const String& name, Colour c, const Path& normal, const Path& toggled)
540 : Button (name), colour (c), normalShape (normal), toggledShape (toggled)
541 {
542 }
543
545 {
546 Colour background (Colours::grey);
547
549 background = rw->getBackgroundColour();
550
551 const float cx = (float) getWidth() * 0.5f, cy = (float) getHeight() * 0.5f;
552 const float diam = jmin (cx, cy) * (shouldDrawButtonAsDown ? 0.60f : 0.65f);
553
554 g.setColour (background);
555 g.fillEllipse (cx - diam, cy - diam, diam * 2.0f, diam * 2.0f);
556
557 Colour c (background.contrasting (colour, 0.6f));
558
559 if (! isEnabled())
560 c = c.withAlpha (0.6f);
562 c = c.brighter();
563
564 g.setColour (c);
565 g.drawEllipse (cx - diam, cy - diam, diam * 2.0f, diam * 2.0f, diam * 0.2f);
566
567 Path& p = getToggleState() ? toggledShape : normalShape;
568
569 float scale = 0.55f;
570 g.fillPath (p, p.getTransformToScaleToFit (cx - diam * scale, cy - diam * scale,
571 diam * 2.0f * scale, diam * 2.0f * scale, true));
572 }
573
574private:
575 Colour colour;
576 Path normalShape, toggledShape;
577
579};
580
581Button* LookAndFeel_V3::createDocumentWindowButton (int buttonType)
582{
583 Path shape;
584 const float crossThickness = 0.25f;
585
586 if (buttonType == DocumentWindow::closeButton)
587 {
588 shape.addLineSegment (Line<float> (0.0f, 0.0f, 1.0f, 1.0f), crossThickness * 1.4f);
589 shape.addLineSegment (Line<float> (1.0f, 0.0f, 0.0f, 1.0f), crossThickness * 1.4f);
590
591 return new LookAndFeel_V3_DocumentWindowButton ("close", Colour (0xffdd1100), shape, shape);
592 }
593
594 if (buttonType == DocumentWindow::minimiseButton)
595 {
596 shape.addLineSegment (Line<float> (0.0f, 0.5f, 1.0f, 0.5f), crossThickness);
597
598 return new LookAndFeel_V3_DocumentWindowButton ("minimise", Colour (0xffaa8811), shape, shape);
599 }
600
601 if (buttonType == DocumentWindow::maximiseButton)
602 {
603 shape.addLineSegment (Line<float> (0.5f, 0.0f, 0.5f, 1.0f), crossThickness);
604 shape.addLineSegment (Line<float> (0.0f, 0.5f, 1.0f, 0.5f), crossThickness);
605
606 Path fullscreenShape;
607 fullscreenShape.startNewSubPath (45.0f, 100.0f);
608 fullscreenShape.lineTo (0.0f, 100.0f);
609 fullscreenShape.lineTo (0.0f, 0.0f);
610 fullscreenShape.lineTo (100.0f, 0.0f);
611 fullscreenShape.lineTo (100.0f, 45.0f);
612 fullscreenShape.addRectangle (45.0f, 45.0f, 100.0f, 100.0f);
613 PathStrokeType (30.0f).createStrokedPath (fullscreenShape, fullscreenShape);
614
615 return new LookAndFeel_V3_DocumentWindowButton ("maximise", Colour (0xff119911), shape, fullscreenShape);
616 }
617
619 return nullptr;
620}
621
623{
624 static const unsigned char pathData[]
625 = { 110,109,32,210,202,64,126,183,148,64,108,39,244,247,64,245,76,124,64,108,178,131,27,65,246,76,252,64,108,175,242,4,65,246,76,252,
626 64,108,236,5,68,65,0,0,160,180,108,240,150,90,65,21,136,52,63,108,48,59,16,65,0,0,32,65,108,32,210,202,64,126,183,148,64, 99,101,0,0 };
627
628 Path p;
629 p.loadPathFromData (pathData, sizeof (pathData));
630 p.scaleToFit (0, 0, height * 2.0f, height, true);
631 return p;
632}
633
635{
636 static const unsigned char pathData[]
637 = { 110,109,88,57,198,65,29,90,171,65,108,63,53,154,65,8,172,126,65,108,76,55,198,65,215,163,38,65,108,141,151,175,65,82,184,242,64,108,117,147,131,65,90,100,81,65,108,184,30,47,65,82,184,242,64,108,59,223,1,65,215,163,38,65,108,84,227,89,65,8,172,126,65,
638 108,35,219,1,65,29,90,171,65,108,209,34,47,65,231,251,193,65,108,117,147,131,65,207,247,149,65,108,129,149,175,65,231,251,193,65,99,101,0,0 };
639
640 Path p;
641 p.loadPathFromData (pathData, sizeof (pathData));
642 p.scaleToFit (0, 0, height * 2.0f, height, true);
643 return p;
644}
645
646} // namespace juce
static AffineTransform translation(float deltaX, float deltaY) noexcept
Returns a new transform which is a translation.
@ backgroundColourId
A background colour to fill the bubble with.
A base class for buttons.
Definition juce_Button.h:43
bool getToggleState() const noexcept
Returns true if the button is 'on'.
static ColourGradient horizontal(Colour colour1, float x1, Colour colour2, float x2)
Creates a horizontal linear gradient between two X coordinates.
static ColourGradient vertical(Colour colour1, float y1, Colour colour2, float y2)
Creates a vertical linear gradient between two Y coordinates.
Represents a colour, also including a transparency value.
Definition juce_Colour.h:38
Colour withAlpha(uint8 newAlpha) const noexcept
Returns a colour that's the same colour as this one, but with a new alpha value.
Colour brighter(float amountBrighter=0.4f) const noexcept
Returns a brighter version of this colour.
static Colour greyLevel(float brightness) noexcept
Returns an opaque shade of grey.
Colour contrasting(float amount=1.0f) const noexcept
Returns a colour that will be clearly visible against this colour.
@ arrowColourId
The colour for the arrow shape that pops up the menu.
@ outlineColourId
The colour for an outline around the box.
@ focusedOutlineColourId
The colour that will be used to draw a box around the edge of the component when it has focus.
@ buttonColourId
The base colour for the button (a LookAndFeel class will probably use variations on this).
@ backgroundColourId
The background colour to fill the box with.
The base class for all JUCE user-interface objects.
int getHeight() const noexcept
Returns the component's height in pixels.
int getWidth() const noexcept
Returns the component's width in pixels.
bool isEnabled() const noexcept
Returns true if the component (and all its parents) are enabled.
A panel which holds a vertical stack of components which can be expanded and contracted.
Represents a particular font, including its size, style, etc.
Definition juce_Font.h:42
Font boldened() const
Returns a copy of this font with the bold attribute set.
A graphics context, used for drawing a component or image.
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void setGradientFill(const ColourGradient &gradient)
Sets the context to use a gradient for its fill pattern.
void drawRect(int x, int y, int width, int height, int lineThickness=1) const
Draws a rectangular outline, using the current colour or brush.
void fillRect(Rectangle< int > rectangle) const
Fills a rectangle with the current colour or brush.
void fillPath(const Path &path) const
Fills a path using the currently selected colour or brush.
void drawEllipse(float x, float y, float width, float height, float lineThickness) const
Draws an elliptical stroke using the current colour or brush.
void setColour(Colour newColour)
Changes the current drawing colour.
void strokePath(const Path &path, const PathStrokeType &strokeType, const AffineTransform &transform={}) const
Draws a path's outline using the currently selected colour or brush.
void fillAll() const
Fills the context's entire clip region with the current colour or brush.
void fillEllipse(float x, float y, float width, float height) const
Fills an ellipse with the current colour or brush.
@ centred
Indicates that the item should be centred vertically and horizontally.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
void paintButton(Graphics &g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Subclasses should override this to actually paint the button's contents.
void drawScrollbar(Graphics &, ScrollBar &, int x, int y, int width, int height, bool isScrollbarVertical, int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override
Draws the thumb area of a scrollbar.
Path getTickShape(float height) override
Returns a tick shape for use in yes/no boxes, etc.
void drawPopupMenuBackground(Graphics &, int width, int height) override
Fills the background of a popup menu component.
Path getCrossShape(float height) override
Returns a cross shape for use in yes/no boxes, etc.
bool isColourSpecified(int colourId) const noexcept
Returns true if the specified colour ID has been explicitly set using the setColour() method.
void setColour(int colourId, Colour colour) noexcept
Registers a colour to be used for a particular purpose.
Colour findColour(int colourId) const noexcept
Looks for a colour that has been registered with the given colour ID number.
A menu bar component.
Describes a type of stroke used to render a solid outline along a path.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
Definition juce_Path.h:65
void loadPathFromData(const void *data, size_t numberOfBytes)
Loads a stored path from a block of data.
void addRoundedRectangle(float x, float y, float width, float height, float cornerSize)
Adds a rectangle with rounded corners to the path.
AffineTransform getTransformToScaleToFit(float x, float y, float width, float height, bool preserveProportions, Justification justificationType=Justification::centred) const
Returns a transform that can be used to rescale the path to fit into a given space.
void scaleToFit(float x, float y, float width, float height, bool preserveProportions) noexcept
Rescales this path to make it fit neatly into a given space.
void addLineSegment(Line< float > line, float lineThickness)
Adds a line with a specified thickness.
@ backgroundColourId
The colour to fill the menu's background with.
@ textColourId
The colour for normal menu item text, (unless the colour is specified when the item is added).
Manages a rectangle and allows geometric operations to be performed on it.
ValueType getRight() const noexcept
Returns the x coordinate of the rectangle's right-hand-side.
Rectangle withHeight(ValueType newHeight) const noexcept
Returns a rectangle which has the same position and width as this one, but with a different height.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
ValueType getBottom() const noexcept
Returns the y coordinate of the rectangle's bottom edge.
ValueType getWidth() const noexcept
Returns the width of the rectangle.
ValueType getY() const noexcept
Returns the y coordinate of the rectangle's top edge.
Rectangle withTop(ValueType newTop) const noexcept
Returns a new rectangle with a different y position, but the same bottom edge as this one.
ValueType getHeight() const noexcept
Returns the height of the rectangle.
A base class for top-level windows that can be dragged around and resized.
A scrollbar component.
@ thumbColourId
A base colour to use for the thumb.
SliderStyle
The types of slider available.
Definition juce_Slider.h:62
@ LinearBarVertical
A vertical bar slider with the text label drawn on top of it.
Definition juce_Slider.h:66
@ LinearBar
A horizontal bar slider with the text label drawn on top of it.
Definition juce_Slider.h:65
@ trackColourId
The colour to draw the groove that the thumb moves along.
@ backgroundColourId
A colour to use to fill the slider's background.
@ thumbColourId
The colour to draw the thumb with.
The JUCE String class!
Definition juce_String.h:53
Orientation
The placement of the tab-bar.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the component.
@ tabOutlineColourId
The colour to use to draw an outline around the tabs.
@ frontTextColourId
The colour to use to draw the currently-selected tab name.
@ tabTextColourId
The colour to use to draw the tab names.
@ outlineColourId
The colour to use to draw an outline around the content.
@ backgroundColourId
The colour of the table header background.
@ outlineColourId
The colour of the table header's outline.
@ buttonColourId
The colour used to fill the button shape (when the button is toggled 'off').
@ buttonOnColourId
The colour used to fill the button shape (when the button is toggled 'on').
@ outlineColourId
If this is non-transparent, it will be used to draw a box around the edge of the component.
@ focusedOutlineColourId
If this is non-transparent, it will be used to draw a box around the edge of the component when it ha...
@ selectedItemBackgroundColourId
The colour to use to fill the background of any selected items.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define jassertfalse
This will always cause an assertion failure.
typedef int
typedef float
JUCE Namespace.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
static constexpr FloatType pi
A predefined value for Pi.
T swap(T... args)