From b24aadcc725dc2ef10669979b9b4c24e4cf36de3 Mon Sep 17 00:00:00 2001 From: tpoole Date: Mon, 3 Oct 2016 16:12:30 +0100 Subject: [PATCH] Added ColourIds to allow alternate colouring of TreeViewItems --- modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp | 2 ++ modules/juce_gui_basics/widgets/juce_TreeView.cpp | 3 +++ modules/juce_gui_basics/widgets/juce_TreeView.h | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 17c4c60400..2442ef9557 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -93,6 +93,8 @@ LookAndFeel_V2::LookAndFeel_V2() TreeView::backgroundColourId, 0x00000000, TreeView::dragAndDropIndicatorColourId, 0x80ff0000, TreeView::selectedItemBackgroundColourId, 0x00000000, + TreeView::oddItemsColourId, 0x00000000, + TreeView::evenItemsColourId, 0x00000000, PopupMenu::backgroundColourId, 0xffffffff, PopupMenu::textColourId, 0xff000000, diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index b4b3418785..ef31ea313d 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -1559,6 +1559,9 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) { if (isSelected()) g.fillAll (ownerView->findColour (TreeView::selectedItemBackgroundColourId)); + else + g.fillAll ((getRowNumberInTree() % 2 == 0) ? ownerView->findColour (TreeView::oddItemsColourId) + : ownerView->findColour (TreeView::evenItemsColourId)); paintItem (g, itemWidth < 0 ? width - indent : itemWidth, itemHeight); } diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index 78c064b4f4..75a9a9aaed 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -844,7 +844,9 @@ public: backgroundColourId = 0x1000500, /**< A background colour to fill the component with. */ linesColourId = 0x1000501, /**< The colour to draw the lines with.*/ dragAndDropIndicatorColourId = 0x1000502, /**< The colour to use for the drag-and-drop target position indicator. */ - selectedItemBackgroundColourId = 0x1000503 /**< The colour to use to fill the background of any selected items. */ + selectedItemBackgroundColourId = 0x1000503, /**< The colour to use to fill the background of any selected items. */ + oddItemsColourId = 0x1000504, /**< The colour to use to fill the backround of the odd numbered items. */ + evenItemsColourId = 0x1000505 /**< The colour to use to fill the backround of the even numbered items. */ }; //==============================================================================