1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

LookAndFeel_V3 tweaks.

This commit is contained in:
jules 2013-10-30 11:44:36 +00:00
parent cb29cbf4a5
commit 282078bf61
4 changed files with 128 additions and 145 deletions

View file

@ -42,146 +42,6 @@ LookAndFeel::LookAndFeel()
*/
jassert (Colours::white == Colour (0xffffffff));
// set up the standard set of colours..
const uint32 textButtonColour = 0xffbbbbff;
const uint32 textHighlightColour = 0x401111ee;
const uint32 standardOutlineColour = 0xb2808080;
static const uint32 standardColours[] =
{
TextButton::buttonColourId, textButtonColour,
TextButton::buttonOnColourId, 0xff4444ff,
TextButton::textColourOnId, 0xff000000,
TextButton::textColourOffId, 0xff000000,
ToggleButton::textColourId, 0xff000000,
TextEditor::backgroundColourId, 0xffffffff,
TextEditor::textColourId, 0xff000000,
TextEditor::highlightColourId, textHighlightColour,
TextEditor::highlightedTextColourId, 0xff000000,
TextEditor::outlineColourId, 0x00000000,
TextEditor::focusedOutlineColourId, textButtonColour,
TextEditor::shadowColourId, 0x38000000,
CaretComponent::caretColourId, 0xff000000,
Label::backgroundColourId, 0x00000000,
Label::textColourId, 0xff000000,
Label::outlineColourId, 0x00000000,
ScrollBar::backgroundColourId, 0x00000000,
ScrollBar::thumbColourId, 0xffffffff,
TreeView::linesColourId, 0x4c000000,
TreeView::backgroundColourId, 0x00000000,
TreeView::dragAndDropIndicatorColourId, 0x80ff0000,
TreeView::selectedItemBackgroundColourId, 0x00000000,
PopupMenu::backgroundColourId, 0xffffffff,
PopupMenu::textColourId, 0xff000000,
PopupMenu::headerTextColourId, 0xff000000,
PopupMenu::highlightedTextColourId, 0xffffffff,
PopupMenu::highlightedBackgroundColourId, 0x991111aa,
ComboBox::buttonColourId, 0xffbbbbff,
ComboBox::outlineColourId, standardOutlineColour,
ComboBox::textColourId, 0xff000000,
ComboBox::backgroundColourId, 0xffffffff,
ComboBox::arrowColourId, 0x99000000,
TextPropertyComponent::backgroundColourId, 0xffffffff,
TextPropertyComponent::textColourId, 0xff000000,
TextPropertyComponent::outlineColourId, standardOutlineColour,
ListBox::backgroundColourId, 0xffffffff,
ListBox::outlineColourId, standardOutlineColour,
ListBox::textColourId, 0xff000000,
Slider::backgroundColourId, 0x00000000,
Slider::thumbColourId, textButtonColour,
Slider::trackColourId, 0x7fffffff,
Slider::rotarySliderFillColourId, 0x7f0000ff,
Slider::rotarySliderOutlineColourId, 0x66000000,
Slider::textBoxTextColourId, 0xff000000,
Slider::textBoxBackgroundColourId, 0xffffffff,
Slider::textBoxHighlightColourId, textHighlightColour,
Slider::textBoxOutlineColourId, standardOutlineColour,
ResizableWindow::backgroundColourId, 0xff777777,
//DocumentWindow::textColourId, 0xff000000, // (this is deliberately not set)
AlertWindow::backgroundColourId, 0xffededed,
AlertWindow::textColourId, 0xff000000,
AlertWindow::outlineColourId, 0xff666666,
ProgressBar::backgroundColourId, 0xffeeeeee,
ProgressBar::foregroundColourId, 0xffaaaaee,
TooltipWindow::backgroundColourId, 0xffeeeebb,
TooltipWindow::textColourId, 0xff000000,
TooltipWindow::outlineColourId, 0x4c000000,
TabbedComponent::backgroundColourId, 0x00000000,
TabbedComponent::outlineColourId, 0xff777777,
TabbedButtonBar::tabOutlineColourId, 0x80000000,
TabbedButtonBar::frontOutlineColourId, 0x90000000,
Toolbar::backgroundColourId, 0xfff6f8f9,
Toolbar::separatorColourId, 0x4c000000,
Toolbar::buttonMouseOverBackgroundColourId, 0x4c0000ff,
Toolbar::buttonMouseDownBackgroundColourId, 0x800000ff,
Toolbar::labelTextColourId, 0xff000000,
Toolbar::editingModeOutlineColourId, 0xffff0000,
DrawableButton::textColourId, 0xff000000,
DrawableButton::textColourOnId, 0xff000000,
DrawableButton::backgroundColourId, 0x00000000,
DrawableButton::backgroundOnColourId, 0xaabbbbff,
HyperlinkButton::textColourId, 0xcc1111ee,
GroupComponent::outlineColourId, 0x66000000,
GroupComponent::textColourId, 0xff000000,
BubbleComponent::backgroundColourId, 0xeeeeeebb,
BubbleComponent::outlineColourId, 0x77000000,
DirectoryContentsDisplayComponent::highlightColourId, textHighlightColour,
DirectoryContentsDisplayComponent::textColourId, 0xff000000,
0x1000440, /*LassoComponent::lassoFillColourId*/ 0x66dddddd,
0x1000441, /*LassoComponent::lassoOutlineColourId*/ 0x99111111,
0x1005000, /*MidiKeyboardComponent::whiteNoteColourId*/ 0xffffffff,
0x1005001, /*MidiKeyboardComponent::blackNoteColourId*/ 0xff000000,
0x1005002, /*MidiKeyboardComponent::keySeparatorLineColourId*/ 0x66000000,
0x1005003, /*MidiKeyboardComponent::mouseOverKeyOverlayColourId*/ 0x80ffff00,
0x1005004, /*MidiKeyboardComponent::keyDownOverlayColourId*/ 0xffb6b600,
0x1005005, /*MidiKeyboardComponent::textLabelColourId*/ 0xff000000,
0x1005006, /*MidiKeyboardComponent::upDownButtonBackgroundColourId*/ 0xffd3d3d3,
0x1005007, /*MidiKeyboardComponent::upDownButtonArrowColourId*/ 0xff000000,
0x1004500, /*CodeEditorComponent::backgroundColourId*/ 0xffffffff,
0x1004502, /*CodeEditorComponent::highlightColourId*/ textHighlightColour,
0x1004503, /*CodeEditorComponent::defaultTextColourId*/ 0xff000000,
0x1004504, /*CodeEditorComponent::lineNumberBackgroundId*/ 0x44999999,
0x1004505, /*CodeEditorComponent::lineNumberTextId*/ 0x44000000,
0x1007000, /*ColourSelector::backgroundColourId*/ 0xffe5e5e5,
0x1007001, /*ColourSelector::labelTextColourId*/ 0xff000000,
0x100ad00, /*KeyMappingEditorComponent::backgroundColourId*/ 0x00000000,
0x100ad01, /*KeyMappingEditorComponent::textColourId*/ 0xff000000,
FileSearchPathListComponent::backgroundColourId, 0xffffffff,
FileChooserDialogBox::titleTextColourId, 0xff000000,
};
for (int i = 0; i < numElementsInArray (standardColours); i += 2)
setColour ((int) standardColours [i], Colour ((uint32) standardColours [i + 1]));
juce_getTypefaceForFont = getTypefaceForFontFromLookAndFeel;
}

View file

@ -1196,10 +1196,10 @@ void LookAndFeel_V2::drawLabel (Graphics& g, Label& label)
//==============================================================================
void LookAndFeel_V2::drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height,
float /*sliderPos*/,
float /*minSliderPos*/,
float /*maxSliderPos*/,
const Slider::SliderStyle /*style*/, Slider& slider)
float /*sliderPos*/,
float /*minSliderPos*/,
float /*maxSliderPos*/,
const Slider::SliderStyle /*style*/, Slider& slider)
{
const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2);

View file

@ -30,7 +30,10 @@ LookAndFeel_V3::LookAndFeel_V3()
setColour (TextButton::buttonColourId, textButtonColour);
setColour (ComboBox::buttonColourId, textButtonColour);
setColour (TextEditor::outlineColourId, Colours::transparentBlack);
setColour (TabbedButtonBar::tabOutlineColourId, Colour (0x50000000));
setColour (TabbedButtonBar::tabOutlineColourId, Colour (0xff999999));
setColour (TabbedComponent::outlineColourId, Colour (0xff999999));
setColour (Slider::trackColourId, Colour (0xbbffffff));
setColour (Slider::thumbColourId, Colour (0xffddddff));
setColour (ScrollBar::thumbColourId, Colour::greyLevel (0.8f).contrasting().withAlpha (0.13f));
}
@ -245,6 +248,52 @@ void LookAndFeel_V3::drawTabButton (TabBarButton& button, Graphics& g, bool isMo
textLayout.draw (g, Rectangle<float> (length, depth));
}
void LookAndFeel_V3::drawTabAreaBehindFrontButton (TabbedButtonBar& bar, Graphics& g, const int w, const int h)
{
const float shadowSize = 0.15f;
Rectangle<int> shadowRect, line;
ColourGradient gradient (Colours::black.withAlpha (bar.isEnabled() ? 0.08f : 0.04f), 0, 0,
Colours::transparentBlack, 0, 0, false);
switch (bar.getOrientation())
{
case TabbedButtonBar::TabsAtLeft:
gradient.point1.x = (float) w;
gradient.point2.x = w * (1.0f - shadowSize);
shadowRect.setBounds ((int) gradient.point2.x, 0, w - (int) gradient.point2.x, h);
line.setBounds (w - 1, 0, 1, h);
break;
case TabbedButtonBar::TabsAtRight:
gradient.point2.x = w * shadowSize;
shadowRect.setBounds (0, 0, (int) gradient.point2.x, h);
line.setBounds (0, 0, 1, h);
break;
case TabbedButtonBar::TabsAtTop:
gradient.point1.y = (float) h;
gradient.point2.y = h * (1.0f - shadowSize);
shadowRect.setBounds (0, (int) gradient.point2.y, w, h - (int) gradient.point2.y);
line.setBounds (0, h - 1, w, 1);
break;
case TabbedButtonBar::TabsAtBottom:
gradient.point2.y = h * shadowSize;
shadowRect.setBounds (0, 0, w, (int) gradient.point2.y);
line.setBounds (0, 0, w, 1);
break;
default: break;
}
g.setGradientFill (gradient);
g.fillRect (shadowRect.expanded (2, 2));
g.setColour (bar.findColour (TabbedButtonBar::tabOutlineColourId));
g.fillRect (line);
}
void LookAndFeel_V3::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor)
{
if (textEditor.isEnabled())
@ -316,6 +365,71 @@ void LookAndFeel_V3::drawComboBox (Graphics& g, int width, int height, const boo
g.fillPath (p);
}
void LookAndFeel_V3::drawLinearSlider (Graphics& g, int x, int y, int width, int height,
float sliderPos, float minSliderPos, float maxSliderPos,
const Slider::SliderStyle style, Slider& slider)
{
g.fillAll (slider.findColour (Slider::backgroundColourId));
if (style == Slider::LinearBar || style == Slider::LinearBarVertical)
{
Path p;
if (style == Slider::LinearBarVertical)
p.addRectangle ((float) x, sliderPos, (float) width, (height - sliderPos));
else
p.addRectangle ((float) x, (float) y, (sliderPos - x), (float) height);
drawButtonShape (g, p, slider.findColour (Slider::thumbColourId)
.withMultipliedSaturation (slider.isEnabled() ? 1.0f : 0.5f)
.withMultipliedAlpha (0.8f),
height);
}
else
{
drawLinearSliderBackground (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
drawLinearSliderThumb (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, style, slider);
}
}
void LookAndFeel_V3::drawLinearSliderBackground (Graphics& g, int x, int y, int width, int height,
float /*sliderPos*/,
float /*minSliderPos*/,
float /*maxSliderPos*/,
const Slider::SliderStyle /*style*/, Slider& slider)
{
const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2);
const Colour trackColour (slider.findColour (Slider::trackColourId));
const Colour gradCol1 (trackColour.overlaidWith (Colour (slider.isEnabled() ? 0x13000000 : 0x09000000)));
const Colour gradCol2 (trackColour.overlaidWith (Colour (0x06000000)));
Path indent;
if (slider.isHorizontal())
{
const float iy = y + height * 0.5f - sliderRadius * 0.5f;
g.setGradientFill (ColourGradient (gradCol1, 0.0f, iy,
gradCol2, 0.0f, iy + sliderRadius, false));
indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, width + sliderRadius, sliderRadius, 5.0f);
}
else
{
const float ix = x + width * 0.5f - sliderRadius * 0.5f;
g.setGradientFill (ColourGradient (gradCol1, ix, 0.0f,
gradCol2, ix + sliderRadius, 0.0f, false));
indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, sliderRadius, height + sliderRadius, 5.0f);
}
g.fillPath (indent);
g.setColour (trackColour.contrasting (0.5f));
g.strokePath (indent, PathStrokeType (0.5f));
}
void LookAndFeel_V3::drawPopupMenuBackground (Graphics& g, int width, int height)
{
g.fillAll (findColour (PopupMenu::backgroundColourId));

View file

@ -58,6 +58,7 @@ public:
int getTabButtonOverlap (int tabDepth) override;
int getTabButtonSpaceAroundImage() override;
void drawTabButton (TabBarButton&, Graphics&, bool isMouseOver, bool isMouseDown) override;
void drawTabAreaBehindFrontButton (TabbedButtonBar& bar, Graphics& g, int w, int h) override;
void drawTextEditorOutline (Graphics&, int width, int height, TextEditor&) override;
@ -68,6 +69,14 @@ public:
void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical,
int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override;
void drawLinearSlider (Graphics&, int x, int y, int width, int height,
float sliderPos, float minSliderPos, float maxSliderPos,
const Slider::SliderStyle, Slider&) override;
void drawLinearSliderBackground (Graphics&, int x, int y, int width, int height,
float sliderPos, float minSliderPos, float maxSliderPos,
const Slider::SliderStyle, Slider&) override;
void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area, bool isMouseOver, bool isMouseDown,
ConcertinaPanel&, Component&) override;