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_
)
34 addAndMakeVisible (&list
);
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
)
65 void GroupInformationComponent::valueTreeChildAdded (ValueTree
&, ValueTree
&)
70 void GroupInformationComponent::valueTreeChildRemoved (ValueTree
&, ValueTree
&)
75 void GroupInformationComponent::valueTreeChildOrderChanged (ValueTree
&)
80 void GroupInformationComponent::valueTreeParentChanged (ValueTree
&)
85 //==============================================================================
86 class FileOptionComponent
: public Component
89 FileOptionComponent (const Project::Item
& item_
)
91 compileButton ("Compile"),
92 resourceButton ("Add to Binary Resources")
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
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);
126 resourceButton
.setBounds (getWidth() - w
, 1, w
, getHeight() - 2);
128 compileButton
.setBounds (resourceButton
.getX() - w
, 1, w
, getHeight() - 2);
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
);
152 deleteAndZero (existingComponentToUpdate
);
155 return existingComponentToUpdate
;