29LookAndFeel_V1::LookAndFeel_V1()
45 scrollbarShadow.
setShadowProperties (DropShadow (Colours::black.withAlpha (0.5f), 2, Point<int>()));
48LookAndFeel_V1::~LookAndFeel_V1()
53void LookAndFeel_V1::drawButtonBackground (Graphics& g, Button& button,
const Colour& backgroundColour,
56 const int width = button.getWidth();
57 const int height = button.getHeight();
59 const float indent = 2.0f;
64 p.addRoundedRectangle (indent, indent,
65 (
float) width - indent * 2.0f,
66 (
float) height - indent * 2.0f,
69 Colour
bc (backgroundColour.withMultipliedSaturation (0.3f));
75 else if (
bc.getBrightness() > 0.5f)
76 bc =
bc.darker (0.1f);
78 bc =
bc.brighter (0.1f);
88void LookAndFeel_V1::drawTickBox (Graphics& g, Component& ,
89 float x,
float y,
float w,
float h,
96 box.addRoundedRectangle (0.0f, 2.0f, 6.0f, 6.0f, 1.0f);
99 : Colours::lightgrey.withAlpha (0.1f));
103 g.fillPath (box,
trans);
105 g.setColour (Colours::black.withAlpha (0.6f));
106 g.strokePath (box, PathStrokeType (0.9f),
trans);
111 tick.startNewSubPath (1.5f, 3.0f);
112 tick.lineTo (3.0f, 6.0f);
113 tick.lineTo (6.0f, 0.0f);
115 g.setColour (isEnabled ? Colours::black : Colours::grey);
116 g.strokePath (
tick, PathStrokeType (2.5f),
trans);
122 if (button.hasKeyboardFocus (
true))
125 g.
drawRect (0, 0, button.getWidth(), button.getHeight());
130 drawTickBox (g, button, 4.0f, (
float) (button.getHeight() -
tickWidth) * 0.5f,
132 button.getToggleState(),
138 g.
setFont (
jmin (15.0f, (
float) button.getHeight() * 0.6f));
140 if (! button.isEnabled())
147 button.getWidth() -
textX - 2, button.getHeight() - 8,
152 int width,
int height,
174 g.
setFont ((
float) height * 0.6f);
194 const auto w = (
float) width;
195 const auto h = (
float) height;
217 g.
setColour (Colours::white.withAlpha (0.7f));
223 g.
setColour (Colours::black.withAlpha (0.5f));
228 int x,
int y,
int width,
int height,
235 .withAlpha ((isMouseOver ||
isMouseDown) ? 0.4f : 0.15f));
237 if ((
float) thumbSize > 0.0f)
248 width - 2, thumbSize);
257 thumbSize, height - 2);
261 .withAlpha ((isMouseOver ||
isMouseDown) ? 0.95f : 0.7f));
270 for (
int i = 3; --i >= 0;)
273 g.
setColour (Colours::black.withAlpha (0.15f));
278 g.
setColour (Colours::white.withAlpha (0.15f));
284 g.
setColour (Colours::white.withAlpha (0.15f));
294 return &scrollbarShadow;
303 g.
setColour (Colours::black.withAlpha (0.6f));
314void LookAndFeel_V1::drawTextEditorOutline (Graphics& g,
int width,
int height, TextEditor& textEditor)
316 if (textEditor.isEnabled())
319 g.drawRect (0, 0, width, height);
324void LookAndFeel_V1::drawComboBox (Graphics& g,
int width,
int height,
325 const bool isButtonDown,
332 : ComboBox::backgroundColourId));
336 g.drawRect (0, 0, width, height);
338 const float arrowX = 0.2f;
339 const float arrowH = 0.3f;
349 p.addTriangle (x + w * 0.5f, y + h * (0.45f -
arrowH),
350 x + w * (1.0f -
arrowX), y + h * 0.45f,
351 x + w *
arrowX, y + h * 0.45f);
353 p.addTriangle (x + w * 0.5f, y + h * (0.55f +
arrowH),
354 x + w * (1.0f -
arrowX), y + h * 0.55f,
355 x + w *
arrowX, y + h * 0.55f);
363Font LookAndFeel_V1::getComboBoxFont (ComboBox& box)
365 Font f (
jmin (15.0f, (
float) box.getHeight() * 0.85f));
366 f.setHorizontalScale (0.9f);
371static void drawTriangle (Graphics& g,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3, Colour fill, Colour outline)
374 p.addTriangle (x1, y1, x2, y2, x3, y3);
378 g.setColour (outline);
379 g.strokePath (p, PathStrokeType (0.3f));
382void LookAndFeel_V1::drawLinearSlider (Graphics& g,
383 int x,
int y,
int w,
int h,
393 g.fillRect (x, y, (
int)
sliderPos - x, h);
396 g.drawRect (x, y, (
int)
sliderPos - x, h);
401 .withMultipliedAlpha (slider.isEnabled() ? 1.0f : 0.3f));
403 if (slider.isHorizontal())
405 g.fillRect (x, y +
roundToInt ((
float) h * 0.6f),
410 g.fillRect (x +
roundToInt ((
float) w * 0.5f -
jmin (3.0f, (
float) w * 0.1f)), y,
416 if (slider.isEnabled())
417 alpha = slider.isMouseOverOrDragging() ? 1.0f : 0.7f;
420 const Colour outline (Colours::black.withAlpha (slider.isEnabled() ? 0.7f : 0.35f));
426 (
float) x + (
float) w * 0.5f -
jmin (8.0f, (
float) w * 0.4f),
minSliderPos - 7.0f,
433 (
float) x + (
float) w * 0.5f -
jmin (8.0f, (
float) w * 0.4f),
maxSliderPos + 7.0f,
455 sliderPos - 7.0f, (
float) y + (
float) h * 0.2f,
456 sliderPos + 7.0f, (
float) y + (
float) h * 0.2f,
462 (
float) x + (
float) w * 0.5f -
jmin (4.0f, (
float) w * 0.3f),
sliderPos,
463 (
float) x + (
float) w * 0.5f +
jmin (8.0f, (
float) w * 0.4f),
sliderPos - 7.0f,
464 (
float) x + (
float) w * 0.5f +
jmin (8.0f, (
float) w * 0.4f),
sliderPos + 7.0f,
470 drawLinearSliderOutline (g, x, y, w, h, style, slider);
473Button* LookAndFeel_V1::createSliderButton (Slider&,
const bool isIncrement)
476 return new ArrowButton (
"u", 0.75f, Colours::white.withAlpha (0.8f));
478 return new ArrowButton (
"d", 0.25f, Colours::white.withAlpha (0.8f));
481ImageEffectFilter* LookAndFeel_V1::getSliderEffect (Slider&)
483 return &scrollbarShadow;
486int LookAndFeel_V1::getSliderThumbRadius (Slider&)
492void LookAndFeel_V1::drawCornerResizer (Graphics& g,
int w,
int h,
bool isMouseOver,
bool isMouseDragging)
495 : Colours::darkgrey);
499 for (
float i = 0.0f; i < 1.0f; i += 0.3f)
501 g.drawLine ((
float) w * i,
510Button* LookAndFeel_V1::createDocumentWindowButton (
int buttonType)
514 if (
buttonType == DocumentWindow::closeButton)
516 shape.addLineSegment (
Line<float> (0.0f, 0.0f, 1.0f, 1.0f), 0.35f);
517 shape.addLineSegment (
Line<float> (1.0f, 0.0f, 0.0f, 1.0f), 0.35f);
519 ShapeButton*
const b =
new ShapeButton (
"close",
522 Colour (0xf7ff3333));
524 b->setShape (shape,
true,
true,
true);
527 else if (
buttonType == DocumentWindow::minimiseButton)
529 shape.addLineSegment (
Line<float> (0.0f, 0.5f, 1.0f, 0.5f), 0.25f);
534 dp.setFill (Colours::black.withAlpha (0.3f));
538 else if (
buttonType == DocumentWindow::maximiseButton)
540 shape.addLineSegment (
Line<float> (0.5f, 0.0f, 0.5f, 1.0f), 0.25f);
541 shape.addLineSegment (
Line<float> (0.0f, 0.5f, 1.0f, 0.5f), 0.25f);
546 dp.setFill (Colours::black.withAlpha (0.3f));
555void LookAndFeel_V1::positionDocumentWindowButtons (DocumentWindow&,
557 Button* minimiseButton,
558 Button* maximiseButton,
560 bool positionTitleBarButtonsOnLeft)
567 int x = positionTitleBarButtonsOnLeft ?
titleBarX + 4
570 if (closeButton !=
nullptr)
577 if (positionTitleBarButtonsOnLeft)
578 std::swap (minimiseButton, maximiseButton);
580 if (maximiseButton !=
nullptr)
586 if (minimiseButton !=
nullptr)
Represents a colour, also including a transparency value.
Colour contrasting(float amount=1.0f) const noexcept
Returns a colour that will be clearly visible against this colour.
@ outlineColourId
The colour for an outline around the box.
@ 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.
void setShadowProperties(const DropShadow &newShadow)
Sets up parameters affecting the shadow's appearance.
A graphics context, used for drawing a component or image.
void setOpacity(float newOpacity)
Changes the opacity to use with the current colour.
void drawText(const String &text, int x, int y, int width, int height, Justification justificationType, bool useEllipsesIfTooBig=true) const
Draws a line of text within a specified rectangle.
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 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 setColour(Colour newColour)
Changes the current drawing colour.
void drawLine(float startX, float startY, float endX, float endY) const
Draws a line between two points.
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.
A graphical effect filter that can be applied to components.
@ 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.
@ outlineColourId
An optional colour to use to draw a border around the list.
void drawPopupMenuBackground(Graphics &, int width, int height) override
Fills the background of a popup menu component.
void drawToggleButton(Graphics &, ToggleButton &, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Draws the contents of a standard ToggleButton.
void drawScrollbarButton(Graphics &, ScrollBar &, int width, int height, int buttonDirection, bool isScrollbarVertical, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
Draws one of the buttons on a scrollbar.
void drawProgressBar(Graphics &, ProgressBar &, int width, int height, double progress, const String &textToShow) override
Draws a progress bar.
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.
ImageEffectFilter * getScrollbarEffect() override
Returns the component effect to use for a scrollbar.
void drawProgressBar(Graphics &, ProgressBar &, int width, int height, double progress, const String &textToShow) override
Draws a progress bar.
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.
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.
void addTriangle(float x1, float y1, float x2, float y2, float x3, float y3)
Adds a triangle to the path.
A progress bar component.
@ backgroundColourId
The background colour, behind the bar.
@ foregroundColourId
The colour to use to draw the bar itself.
Manages a rectangle and allows geometric operations to be performed on it.
SliderStyle
The types of slider available.
@ ThreeValueHorizontal
A horizontal slider that has three thumbs instead of one, so it can show a minimum and maximum value,...
@ TwoValueHorizontal
A horizontal slider that has two thumbs instead of one, so it can show a minimum and maximum value.
@ LinearBar
A horizontal bar slider with the text label drawn on top of it.
@ LinearHorizontal
A traditional horizontal slider.
@ LinearVertical
A traditional vertical slider.
@ ThreeValueVertical
A vertical slider that has three thumbs instead of one, so it can show a minimum and maximum value,...
@ TwoValueVertical
A vertical slider that has two thumbs instead of one, so it can show a minimum and maximum value.
@ textBoxTextColourId
The colour for the text in the text-editor box used for editing the value.
@ textBoxOutlineColourId
The colour to use for a border around the text-editor box.
@ 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.
@ buttonColourId
The colour used to fill the button shape (when the button is toggled 'off').
@ 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...
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.