Browse Source

LookAndFeel_V3 tweaks.

tags/2021-05-28
jules 11 years ago
parent
commit
e9598bb5c5
3 changed files with 99 additions and 10 deletions
  1. +93
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp
  2. +2
    -0
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h
  3. +4
    -7
      modules/juce_gui_basics/windows/juce_DocumentWindow.cpp

+ 93
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp View File

@@ -380,10 +380,13 @@ void LookAndFeel_V3::drawLinearSlider (Graphics& g, int x, int y, int width, int
else
p.addRectangle ((float) x, (float) y, (sliderPos - x), (float) height);
drawButtonShape (g, p, slider.findColour (Slider::thumbColourId)
Colour baseColour (slider.findColour (Slider::thumbColourId)
.withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f)
.withMultipliedAlpha (0.8f),
(float) height);
.withMultipliedAlpha (0.8f));
g.setGradientFill (ColourGradient (baseColour.brighter (0.1f), 0.0f, 0.0f,
baseColour.darker (0.1f), 0.0f, (float) height, false));
g.fillPath (p);
}
else
{
@@ -496,3 +499,90 @@ void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height,
g.drawRect (0, 0, width, height);
}
}
class LookAndFeel_V3_DocumentWindowButton : public Button
{
public:
LookAndFeel_V3_DocumentWindowButton (const String& name, Colour c, const Path& normal, const Path& toggled)
: Button (name), colour (c), normalShape (normal), toggledShape (toggled)
{
}
void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown) override
{
Colour background (Colours::grey);
if (ResizableWindow* rw = findParentComponentOfClass<ResizableWindow>())
background = rw->getBackgroundColour();
const float cx = getWidth() * 0.5f, cy = getHeight() * 0.5f;
const float diam = jmin (cx, cy) * (isButtonDown ? 0.60f : 0.65f);
g.setColour (background);
g.fillEllipse (cx - diam, cy - diam, diam * 2.0f, diam * 2.0f);
Colour c (background.contrasting (colour, 0.6f));
if (! isEnabled())
c = c.withAlpha (0.6f);
else if (isMouseOverButton)
c = c.brighter();
g.setColour (c);
g.drawEllipse (cx - diam, cy - diam, diam * 2.0f, diam * 2.0f, diam * 0.2f);
Path& p = getToggleState() ? toggledShape : normalShape;
float scale = 0.55f;
g.fillPath (p, p.getTransformToScaleToFit (cx - diam * scale, cy - diam * scale,
diam * 2.0f * scale, diam * 2.0f * scale, true));
}
private:
Colour colour;
Path normalShape, toggledShape;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LookAndFeel_V3_DocumentWindowButton)
};
Button* LookAndFeel_V3::createDocumentWindowButton (int buttonType)
{
Path shape;
const float crossThickness = 0.25f;
if (buttonType == DocumentWindow::closeButton)
{
shape.addLineSegment (Line<float> (0.0f, 0.0f, 1.0f, 1.0f), crossThickness * 1.4f);
shape.addLineSegment (Line<float> (1.0f, 0.0f, 0.0f, 1.0f), crossThickness * 1.4f);
return new LookAndFeel_V3_DocumentWindowButton ("close", Colour (0xffdd1100), shape, shape);
}
if (buttonType == DocumentWindow::minimiseButton)
{
shape.addLineSegment (Line<float> (0.0f, 0.5f, 1.0f, 0.5f), crossThickness);
return new LookAndFeel_V3_DocumentWindowButton ("minimise", Colour (0xffaa8811), shape, shape);
}
if (buttonType == DocumentWindow::maximiseButton)
{
shape.addLineSegment (Line<float> (0.5f, 0.0f, 0.5f, 1.0f), crossThickness);
shape.addLineSegment (Line<float> (0.0f, 0.5f, 1.0f, 0.5f), crossThickness);
Path fullscreenShape;
fullscreenShape.startNewSubPath (45.0f, 100.0f);
fullscreenShape.lineTo (0.0f, 100.0f);
fullscreenShape.lineTo (0.0f, 0.0f);
fullscreenShape.lineTo (100.0f, 0.0f);
fullscreenShape.lineTo (100.0f, 45.0f);
fullscreenShape.addRectangle (45.0f, 45.0f, 100.0f, 100.0f);
PathStrokeType (30.0f).createStrokedPath (fullscreenShape, fullscreenShape);
return new LookAndFeel_V3_DocumentWindowButton ("maximise", Colour (0xff119911), shape, fullscreenShape);
}
jassertfalse;
return nullptr;
}

+ 2
- 0
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h View File

@@ -47,6 +47,8 @@ public:
bool areLinesDrawnForTreeView (TreeView&) override;
int getTreeViewIndentSize (TreeView&) override;
Button* createDocumentWindowButton (int buttonType) override;
void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box) override;


+ 4
- 7
modules/juce_gui_basics/windows/juce_DocumentWindow.cpp View File

@@ -190,14 +190,11 @@ void DocumentWindow::paint (Graphics& g)
if (resizableBorder == nullptr)
{
g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000)));
const BorderSize<int> border (getBorderThickness());
RectangleList<int> border (getLocalBounds());
border.subtract (getBorderThickness().subtractedFrom (getLocalBounds()));
g.fillRect (0, 0, getWidth(), border.getTop());
g.fillRect (0, border.getTop(), border.getLeft(), getHeight() - border.getTopAndBottom());
g.fillRect (getWidth() - border.getRight(), border.getTop(), border.getRight(), getHeight() - border.getTopAndBottom());
g.fillRect (0, getHeight() - border.getBottom(), getWidth(), border.getBottom());
g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000)));
g.fillRectList (border);
}
const Rectangle<int> titleBarArea (getTitleBarArea());


Loading…
Cancel
Save