Browse Source

Some tweaks to the new V3 look+feel.

tags/2021-05-28
jules 12 years ago
parent
commit
8d8848db64
3 changed files with 68 additions and 49 deletions
  1. +6
    -11
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  2. +56
    -35
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp
  3. +6
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h

+ 6
- 11
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp View File

@@ -1024,7 +1024,7 @@ int LookAndFeel_V2::getMenuWindowFlags()
}
void LookAndFeel_V2::drawMenuBarBackground (Graphics& g, int width, int height,
bool, MenuBarComponent& menuBar)
bool, MenuBarComponent& menuBar)
{
const Colour baseColour (LookAndFeelHelpers::createBaseColour (menuBar.findColour (PopupMenu::backgroundColourId), false, false, false));
@@ -1055,14 +1055,10 @@ int LookAndFeel_V2::getMenuBarItemWidth (MenuBarComponent& menuBar, int itemInde
.getStringWidth (itemText) + menuBar.getHeight();
}
void LookAndFeel_V2::drawMenuBarItem (Graphics& g,
int width, int height,
int itemIndex,
const String& itemText,
bool isMouseOverItem,
bool isMenuOpen,
bool /*isMouseOverBar*/,
MenuBarComponent& menuBar)
void LookAndFeel_V2::drawMenuBarItem (Graphics& g, int width, int height,
int itemIndex, const String& itemText,
bool isMouseOverItem, bool isMenuOpen,
bool /*isMouseOverBar*/, MenuBarComponent& menuBar)
{
if (! menuBar.isEnabled())
{
@@ -1084,8 +1080,7 @@ void LookAndFeel_V2::drawMenuBarItem (Graphics& g,
}
//==============================================================================
void LookAndFeel_V2::fillTextEditorBackground (Graphics& g, int /*width*/, int /*height*/,
TextEditor& textEditor)
void LookAndFeel_V2::fillTextEditorBackground (Graphics& g, int /*width*/, int /*height*/, TextEditor& textEditor)
{
g.fillAll (textEditor.findColour (TextEditor::backgroundColourId));
}


+ 56
- 35
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp View File

@@ -29,6 +29,7 @@ LookAndFeel_V3::LookAndFeel_V3()
const Colour textButtonColour (0xffeeeeff);
setColour (TextButton::buttonColourId, textButtonColour);
setColour (ComboBox::buttonColourId, textButtonColour);
setColour (TextEditor::outlineColourId, Colours::transparentBlack);
setColour (ScrollBar::thumbColourId, Colour::greyLevel (0.8f).contrasting().withAlpha (0.13f));
}
@@ -126,16 +127,20 @@ void LookAndFeel_V3::drawButtonBackground (Graphics& g, Button& button, const Co
const float width = button.getWidth() - 1.0f;
const float height = button.getHeight() - 1.0f;
const float cornerSize = 4.0f;
Path outline;
outline.addRoundedRectangle (0.5f, 0.5f, width, height, cornerSize, cornerSize,
! (flatOnLeft || flatOnTop),
! (flatOnRight || flatOnTop),
! (flatOnLeft || flatOnBottom),
! (flatOnRight || flatOnBottom));
if (width > 0 && height > 0)
{
const float cornerSize = 4.0f;
Path outline;
outline.addRoundedRectangle (0.5f, 0.5f, width, height, cornerSize, cornerSize,
! (flatOnLeft || flatOnTop),
! (flatOnRight || flatOnTop),
! (flatOnLeft || flatOnBottom),
! (flatOnRight || flatOnBottom));
drawButtonShape (g, outline, baseColour, height);
drawButtonShape (g, outline, baseColour, height);
}
}
void LookAndFeel_V3::drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header)
@@ -238,6 +243,23 @@ void LookAndFeel_V3::drawTabButton (TabBarButton& button, Graphics& g, bool isMo
textLayout.draw (g, Rectangle<float> (length, depth));
}
void LookAndFeel_V3::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor)
{
if (textEditor.isEnabled())
{
if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly())
{
g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId));
g.drawRect (0, 0, width, height, 2);
}
else
{
g.setColour (textEditor.findColour (TextEditor::outlineColourId));
g.drawRect (0, 0, width, height);
}
}
}
void LookAndFeel_V3::drawTreeviewPlusMinusBox (Graphics& g, const Rectangle<float>& area,
Colour backgroundColour, bool isOpen, bool isMouseOver)
{
@@ -276,36 +298,20 @@ void LookAndFeel_V3::drawComboBox (Graphics& g, int width, int height, const boo
g.drawRect (0, 0, width, height);
}
const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f;
Path buttonShape;
buttonShape.addRectangle (buttonX + outlineThickness,
buttonY + outlineThickness,
buttonW - outlineThickness * 2.0f,
buttonH - outlineThickness * 2.0f);
const float arrowX = 0.3f;
const float arrowH = 0.2f;
drawButtonShape (g, buttonShape,
buttonColour.withMultipliedSaturation (box.hasKeyboardFocus (true) ? 1.3f : 0.9f)
.withMultipliedAlpha (box.isEnabled() ? 0.9f : 0.5f),
(float) height);
if (box.isEnabled())
{
const float arrowX = 0.3f;
const float arrowH = 0.2f;
Path p;
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
Path p;
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f);
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH),
buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f,
buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f);
g.setColour (box.findColour (ComboBox::arrowColourId));
g.fillPath (p);
}
g.setColour (box.findColour (ComboBox::arrowColourId).withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.3f));
g.fillPath (p);
}
void LookAndFeel_V3::drawPopupMenuBackground (Graphics& g, int width, int height)
@@ -319,6 +325,21 @@ void LookAndFeel_V3::drawPopupMenuBackground (Graphics& g, int width, int height
#endif
}
void LookAndFeel_V3::drawMenuBarBackground (Graphics& g, int width, int height,
bool, MenuBarComponent& menuBar)
{
const Colour colour (menuBar.findColour (PopupMenu::backgroundColourId));
Rectangle<int> r (width, height);
g.setColour (colour.contrasting (0.15f));
g.fillRect (r.removeFromTop (1));
g.fillRect (r.removeFromBottom (1));
g.setGradientFill (ColourGradient (colour, 0, 0, colour.darker (0.08f), 0, height, false));
g.fillRect (r);
}
void LookAndFeel_V3::drawKeymapChangeButton (Graphics& g, int width, int height,
Button& button, const String& keyDescription)
{


+ 6
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.h View File

@@ -47,17 +47,20 @@ public:
bool areLinesDrawnForTreeView (TreeView&) override;
int getTreeViewIndentSize (TreeView&) override;
void drawComboBox (Graphics& g, int width, int height, bool isButtonDown,
void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
int buttonX, int buttonY, int buttonW, int buttonH, ComboBox& box) override;
void drawKeymapChangeButton (Graphics& g, int width, int height, Button& button, const String& keyDescription) override;
void drawKeymapChangeButton (Graphics&, int width, int height, Button& button, const String& keyDescription) override;
void drawPopupMenuBackground (Graphics& g, int width, int height) override;
void drawPopupMenuBackground (Graphics&, int width, int height) override;
void drawMenuBarBackground (Graphics&, int width, int height, bool, MenuBarComponent&) override;
int getTabButtonOverlap (int tabDepth) override;
int getTabButtonSpaceAroundImage() override;
void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override;
void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
void drawStretchableLayoutResizerBar (Graphics&, int w, int h, bool isVerticalBar, bool isMouseOver, bool isMouseDragging) override;
bool areScrollbarButtonsVisible() override;


Loading…
Cancel
Save