mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
157 lines
4.8 KiB
C++
157 lines
4.8 KiB
C++
/*
|
|
==============================================================================
|
|
|
|
This file is part of the JUCE library.
|
|
Copyright (c) 2013 - Raw Material Software Ltd.
|
|
|
|
Permission is granted to use this software under the terms of either:
|
|
a) the GPL v2 (or any later version)
|
|
b) the Affero GPL v3
|
|
|
|
Details of these licenses can be found 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.juce.com for more information.
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
#ifndef __JUCER_CONFIGPAGE_JUCEHEADER__
|
|
#define __JUCER_CONFIGPAGE_JUCEHEADER__
|
|
|
|
#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 = 38;
|
|
|
|
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)
|
|
{
|
|
const Colour bkg (findColour (mainBackgroundColourId));
|
|
|
|
g.setColour (Colours::white.withAlpha (0.35f));
|
|
g.fillRect (0, 30, getWidth(), getHeight() - 38);
|
|
|
|
g.setFont (Font (15.0f, Font::bold));
|
|
g.setColour (bkg.contrasting (0.7f));
|
|
g.drawFittedText (getName(), 12, 0, getWidth() - 16, 25, 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)
|
|
{
|
|
IntrojucerLookAndFeel::fillWithBackgroundTexture (*this, g);
|
|
}
|
|
|
|
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_CONFIGPAGE_JUCEHEADER__
|