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

Added a colour ID TreeView::selectedItemBackgroundColourId, and changed the TreeView to fill selected items with this. (The colour is set to transparent by default so this won't affect existing code).

Updated the LookAndFeel::drawTreeviewPlusMinusBox and TreeViewItem::paintOpenCloseButton methods to provide more flexibility.
This commit is contained in:
jules 2013-10-27 12:49:17 +00:00
parent 020f138d20
commit 56ec1d1400
10 changed files with 71 additions and 57 deletions

View file

@ -107,6 +107,7 @@ LookAndFeel::LookAndFeel()
TreeView::linesColourId, 0x4c000000,
TreeView::backgroundColourId, 0x00000000,
TreeView::dragAndDropIndicatorColourId, 0x80ff0000,
TreeView::selectedItemBackgroundColourId, 0x00000000,
PopupMenu::backgroundColourId, 0xffffffff,
PopupMenu::textColourId, 0xff000000,
@ -913,14 +914,15 @@ Path LookAndFeel::getCrossShape (const float height)
}
//==============================================================================
void LookAndFeel::drawTreeviewPlusMinusBox (Graphics& g, int x, int y, int w, int h, bool isPlus, bool /*isMouseOver*/)
void LookAndFeel::drawTreeviewPlusMinusBox (Graphics& g, const Rectangle<float>& area,
Colour /*backgroundColour*/, bool isOpen, bool /*isMouseOver*/)
{
const int boxSize = ((jmin (16, w, h) << 1) / 3) | 1;
const int boxSize = roundToInt (jmin (16.0f, area.getWidth(), area.getHeight()) * 0.7f) | 1;
x += (w - boxSize) >> 1;
y += (h - boxSize) >> 1;
w = boxSize;
h = boxSize;
const int x = ((int) area.getWidth() - boxSize) / 2 + (int) area.getX();
const int y = ((int) area.getHeight() - boxSize) / 2 + (int) area.getY();
const int w = boxSize;
const int h = boxSize;
g.setColour (Colour (0xe5ffffff));
g.fillRect (x, y, w, h);
@ -933,7 +935,7 @@ void LookAndFeel::drawTreeviewPlusMinusBox (Graphics& g, int x, int y, int w, in
g.fillRect (x + (w - size) * 0.5f, y + centre, size, 1.0f);
if (isPlus)
if (! isOpen)
g.fillRect (x + centre, y + (h - size) * 0.5f, 1.0f, size);
}
@ -2472,7 +2474,7 @@ void LookAndFeel::drawPropertyPanelSectionHeader (Graphics& g, const String& nam
const int buttonSize = (height * 3) / 4;
const int buttonIndent = (height - buttonSize) / 2;
drawTreeviewPlusMinusBox (g, buttonIndent, buttonIndent, buttonSize, buttonSize, ! isOpen, false);
drawTreeviewPlusMinusBox (g, buttonIndent, buttonIndent, buttonSize, buttonSize, isOpen, false);
const int textX = buttonIndent * 2 + buttonSize + 2;

View file

@ -270,7 +270,8 @@ public:
//==============================================================================
/** Draws the + or - box in a treeview. */
virtual void drawTreeviewPlusMinusBox (Graphics&, int x, int y, int w, int h, bool isPlus, bool isMouseOver);
virtual void drawTreeviewPlusMinusBox (Graphics&, const Rectangle<float>& area,
Colour backgroundColour, bool isOpen, bool isMouseOver);
//==============================================================================
virtual void fillTextEditorBackground (Graphics&, int width, int height, TextEditor& textEditor);
@ -657,6 +658,7 @@ private:
virtual int drawBubble (Graphics&, float, float, float, float, float, float) { return 0; }
virtual int getFontForTextButton (TextButton&) { return 0; }
virtual int createFileChooserHeaderText (const String&, const String&, GlyphArrangement&, int) { return 0; }
virtual int drawTreeviewPlusMinusBox (Graphics&, int, int, int, int, bool, bool) { return 0; }
#endif
class GlassWindowButton;