1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-13 00:04:19 +00:00
JUCE/extras/Introjucer/Source/Project/jucer_ConfigPage.h
2012-06-28 08:52:42 +01:00

163 lines
5.3 KiB
C++

/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
#ifndef __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__
#define __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__
#include "jucer_Project.h"
#include "../Utility/jucer_JucerTreeViewBase.h"
//==============================================================================
JucerTreeViewBase* createProjectConfigTreeViewRoot (Project& project);
//==============================================================================
class PropertyGroup : public Component
{
public:
PropertyGroup() {}
void setProperties (const PropertyListBuilder& newProps)
{
properties.clear();
properties.addArray (newProps.components);
for (int i = properties.size(); --i >= 0;)
addAndMakeVisible (properties.getUnchecked(i));
}
int updateSize (int x, int y, int width)
{
int height = 36;
for (int i = 0; i < properties.size(); ++i)
{
PropertyComponent* pp = properties.getUnchecked(i);
pp->setBounds (10, height, width - 20, pp->getPreferredHeight());
height += pp->getHeight();
}
height += 16;
setBounds (x, y, width, height);
return height;
}
void paint (Graphics& g)
{
g.setColour (Colours::white.withAlpha (0.3f));
g.fillRect (0, 28, getWidth(), getHeight() - 38);
g.setColour (Colours::black.withAlpha (0.4f));
g.drawRect (0, 28, getWidth(), getHeight() - 38);
g.setFont (Font (14.0f, Font::bold));
g.setColour (Colours::black);
g.drawFittedText (getName(), 12, 0, getWidth() - 16, 26, Justification::bottomLeft, 1);
}
OwnedArray<PropertyComponent> properties;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyGroup);
};
//==============================================================================
class PropertyPanelViewport : public Component
{
public:
PropertyPanelViewport (Component* content)
{
addAndMakeVisible (&viewport);
addAndMakeVisible (&rolloverHelp);
viewport.setViewedComponent (content, true);
}
void paint (Graphics& g)
{
g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png,
BinaryData::brushed_aluminium_pngSize),
0, 0, 1.0f);
g.fillAll();
drawRecessedShadows (g, getWidth(), getHeight(), 14);
}
void resized()
{
Rectangle<int> r (getLocalBounds());
rolloverHelp.setBounds (r.removeFromBottom (70).reduced (10, 0));
viewport.setBounds (r);
}
Viewport viewport;
RolloverHelpComp rolloverHelp;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PropertyPanelViewport);
};
//==============================================================================
class SettingsTreeViewItemBase : public JucerTreeViewBase,
public ValueTree::Listener
{
public:
SettingsTreeViewItemBase() {}
void showSettingsPage (Component* content);
void closeSettingsPage();
void deleteAllSelectedItems()
{
TreeView* const tree = getOwnerView();
jassert (tree->getNumSelectedItems() <= 1); // multi-select should be disabled
if (SettingsTreeViewItemBase* s = dynamic_cast <SettingsTreeViewItemBase*> (tree->getSelectedItem (0)))
s->deleteItem();
}
void itemOpennessChanged (bool isNowOpen)
{
if (isNowOpen)
refreshSubItems();
}
void valueTreePropertyChanged (ValueTree&, const Identifier&) {}
void valueTreeChildAdded (ValueTree&, ValueTree&) {}
void valueTreeChildRemoved (ValueTree&, ValueTree&) {}
void valueTreeChildOrderChanged (ValueTree&) {}
void valueTreeParentChanged (ValueTree&) {}
static void updateSize (Component& comp, PropertyGroup& group)
{
const int width = jmax (550, comp.getParentWidth() - 20);
int y = 0;
y += group.updateSize (12, y, width - 12);
comp.setSize (width, y);
}
};
#endif // __JUCER_PROJECTINFORMATIONCOMPONENT_H_30FFCD07__