Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / Introjucer / Source / Project / jucer_GroupInformationComponent.cpp
blob0b09ee0004affffb1a655e3059afa4cc1c91264a
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-10 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "jucer_GroupInformationComponent.h"
29 //==============================================================================
30 GroupInformationComponent::GroupInformationComponent (const Project::Item& item_)
31 : item (item_)
33 list.setModel (this);
34 addAndMakeVisible (&list);
35 list.updateContent();
36 list.setRowHeight (20);
37 item.getNode().addListener (this);
40 GroupInformationComponent::~GroupInformationComponent()
42 item.getNode().removeListener (this);
45 void GroupInformationComponent::resized()
47 list.setSize (getWidth(), getHeight());
50 int GroupInformationComponent::getNumRows()
52 return item.getNumChildren();
55 void GroupInformationComponent::paintListBoxItem (int rowNumber, Graphics& g, int width, int height, bool rowIsSelected)
59 //==============================================================================
60 void GroupInformationComponent::valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, const Identifier& property)
62 list.updateContent();
65 void GroupInformationComponent::valueTreeChildAdded (ValueTree&, ValueTree&)
67 list.updateContent();
70 void GroupInformationComponent::valueTreeChildRemoved (ValueTree&, ValueTree&)
72 list.updateContent();
75 void GroupInformationComponent::valueTreeChildOrderChanged (ValueTree&)
77 list.updateContent();
80 void GroupInformationComponent::valueTreeParentChanged (ValueTree&)
82 list.updateContent();
85 //==============================================================================
86 class FileOptionComponent : public Component
88 public:
89 FileOptionComponent (const Project::Item& item_)
90 : item (item_),
91 compileButton ("Compile"),
92 resourceButton ("Add to Binary Resources")
94 if (item.isFile())
96 addAndMakeVisible (&compileButton);
97 compileButton.getToggleStateValue().referTo (item.getShouldCompileValue());
99 addAndMakeVisible (&resourceButton);
100 resourceButton.getToggleStateValue().referTo (item.getShouldAddToResourceValue());
104 void paint (Graphics& g)
106 int x = getHeight() + 6;
108 item.getIcon()->drawWithin (g, Rectangle<float> (2.0f, 2.0f, x - 4.0f, getHeight() - 4.0f),
109 RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
111 g.setColour (Colours::black);
112 g.setFont (getHeight() * 0.6f);
114 const int x2 = compileButton.isVisible() ? compileButton.getX() - 4
115 : getWidth() - 4;
117 g.drawText (item.getName().toString(), x, 0, x2 - x, getHeight(), Justification::centredLeft, true);
119 g.setColour (Colours::lightgrey);
120 g.fillRect (0, getHeight() - 1, getWidth(), 1);
123 void resized()
125 int w = 180;
126 resourceButton.setBounds (getWidth() - w, 1, w, getHeight() - 2);
127 w = 100;
128 compileButton.setBounds (resourceButton.getX() - w, 1, w, getHeight() - 2);
131 Project::Item item;
133 private:
134 ToggleButton compileButton, resourceButton;
137 Component* GroupInformationComponent::refreshComponentForRow (int rowNumber, bool isRowSelected, Component* existingComponentToUpdate)
139 if (rowNumber < getNumRows())
141 Project::Item child (item.getChild (rowNumber));
143 if (existingComponentToUpdate == nullptr
144 || dynamic_cast <FileOptionComponent*> (existingComponentToUpdate)->item != child)
146 delete existingComponentToUpdate;
147 existingComponentToUpdate = new FileOptionComponent (child);
150 else
152 deleteAndZero (existingComponentToUpdate);
155 return existingComponentToUpdate;