From 7baa7fa209bf0d954743feb0cd1ffc548092abfc Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Sun, 18 Apr 2010 10:37:25 +0100 Subject: [PATCH] Fixed some VST includes on windows. Jucer development. --- .../Builds/Linux/Makefile | 6 + .../The Jucer.xcodeproj/project.pbxproj | 30 +- .../Builds/VisualStudio2005/The Jucer.vcproj | 14 +- .../Builds/VisualStudio2008/The Jucer.vcproj | 14 +- extras/Jucer (experimental)/Jucer.jucer | 28 +- .../model/Component Types/jucer_ComboBox.h | 56 ++ .../jucer_ComponentTypeManager.cpp | 336 ++++++++++++ .../jucer_ComponentTypeManager.h | 127 +++++ .../Component Types/jucer_ComponentTypes.h | 36 ++ .../Component Types/jucer_GenericComponent.h | 75 +++ .../Component Types/jucer_GroupComponent.h | 56 ++ .../Component Types/jucer_JucerComponent.h | 74 +++ .../model/Component Types/jucer_Label.h | 60 +++ .../model/Component Types/jucer_Slider.h | 56 ++ .../Component Types/jucer_TabbedComponent.h | 56 ++ .../model/Component Types/jucer_TextButton.h | 27 +- .../model/Component Types/jucer_TextEditor.h | 60 +++ .../Component Types/jucer_ToggleButton.h | 24 +- .../model/Component Types/jucer_Viewport.h | 56 ++ .../Source/model/jucer_ComponentDocument.cpp | 340 +----------- .../Source/model/jucer_ComponentDocument.h | 31 +- .../jucer_ComponentEditor.cpp | 510 +++++++++++------- juce_amalgamated.cpp | 6 +- .../formats/juce_AudioUnitPluginFormat.mm | 3 +- .../plugins/formats/juce_VSTPluginFormat.cpp | 5 +- 25 files changed, 1482 insertions(+), 604 deletions(-) create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_ComboBox.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.cpp create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypes.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_GenericComponent.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_GroupComponent.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_JucerComponent.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_Label.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_Slider.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_TabbedComponent.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_TextEditor.h create mode 100644 extras/Jucer (experimental)/Source/model/Component Types/jucer_Viewport.h diff --git a/extras/Jucer (experimental)/Builds/Linux/Makefile b/extras/Jucer (experimental)/Builds/Linux/Makefile index 1e17ee19c8..d37c763f10 100644 --- a/extras/Jucer (experimental)/Builds/Linux/Makefile +++ b/extras/Jucer (experimental)/Builds/Linux/Makefile @@ -43,6 +43,7 @@ ifeq ($(CONFIG),Release) endif OBJECTS := \ + $(OBJDIR)/jucer_ComponentTypeManager.o \ $(OBJDIR)/jucer_ComponentDocument.o \ $(OBJDIR)/jucer_Coordinate.o \ $(OBJDIR)/jucer_DrawableDocument.o \ @@ -88,6 +89,11 @@ clean: -@rm -rf $(OBJDIR)/* -@rm -rf $(OBJDIR) +$(OBJDIR)/jucer_ComponentTypeManager.o: ../../Source/model/Component\ Types/jucer_ComponentTypeManager.cpp + -@mkdir -p $(OBJDIR) + @echo $(notdir $<) + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + $(OBJDIR)/jucer_ComponentDocument.o: ../../Source/model/jucer_ComponentDocument.cpp -@mkdir -p $(OBJDIR) @echo $(notdir $<) diff --git a/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj b/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj index 7ad9077590..bf05c190b2 100644 --- a/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj +++ b/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ DBE3CE9482B19CF1AE700805 = { isa = PBXBuildFile; fileRef = 23CF69B4C644D1E6E61E5C82; }; 93C9F3F27602A33DDC9C2250 = { isa = PBXBuildFile; fileRef = 2767E1D082874D301D5D5F43; }; 2E6836738CE7EB452FDC7E9A = { isa = PBXBuildFile; fileRef = D9FB1A5365FEEB854A0FF7BF; }; + 52D75B8B0F52DD4F37A4B1C0 = { isa = PBXBuildFile; fileRef = 82A1EC47692975C7031B3973; }; CD4226951C3F7FE19CF8A7CE = { isa = PBXBuildFile; fileRef = 2D6D6985B452EA0B67A18914; }; 1DF9688E29753A0459E6C32A = { isa = PBXBuildFile; fileRef = 45C80436FD5A8438D0E6BE17; }; 1174D3512AF8207950094C56 = { isa = PBXBuildFile; fileRef = FF625CB50FB5C3536BA40604; }; @@ -59,8 +60,20 @@ D9FB1A5365FEEB854A0FF7BF = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = System/Library/Frameworks/QuickTime.framework; sourceTree = SDKROOT; }; 12E1601866B3489844AFD645 = { isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Jucer.app; sourceTree = BUILT_PRODUCTS_DIR; }; F4C5CF1AA7EB9298043D89D3 = { isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Info.plist; sourceTree = SOURCE_ROOT; }; - A6FAA90B494DCD7CA5911196 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ToggleButton.h; path = "../../Source/model/Component Types/jucer_ToggleButton.h"; sourceTree = SOURCE_ROOT; }; + 82A1EC47692975C7031B3973 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentTypeManager.cpp; path = "../../Source/model/Component Types/jucer_ComponentTypeManager.cpp"; sourceTree = SOURCE_ROOT; }; + 4F23FF649E7BA3A0F737E3BE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentTypeManager.h; path = "../../Source/model/Component Types/jucer_ComponentTypeManager.h"; sourceTree = SOURCE_ROOT; }; + 6FD54B7E8992FD692BAA0DC6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentTypes.h; path = "../../Source/model/Component Types/jucer_ComponentTypes.h"; sourceTree = SOURCE_ROOT; }; + 926FC04F4EAF24C7C4671207 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComboBox.h; path = "../../Source/model/Component Types/jucer_ComboBox.h"; sourceTree = SOURCE_ROOT; }; + C6263909812DBE995167932B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_GenericComponent.h; path = "../../Source/model/Component Types/jucer_GenericComponent.h"; sourceTree = SOURCE_ROOT; }; + 6B5504F7274B11DFAD3B2E26 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_GroupComponent.h; path = "../../Source/model/Component Types/jucer_GroupComponent.h"; sourceTree = SOURCE_ROOT; }; + 133385B65A02DF50291B222F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_JucerComponent.h; path = "../../Source/model/Component Types/jucer_JucerComponent.h"; sourceTree = SOURCE_ROOT; }; + C64A89EA5C3F0A701F9EBA79 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_Label.h; path = "../../Source/model/Component Types/jucer_Label.h"; sourceTree = SOURCE_ROOT; }; + 40716207B98461E05DC46F14 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_Slider.h; path = "../../Source/model/Component Types/jucer_Slider.h"; sourceTree = SOURCE_ROOT; }; + 4A22DE9DF590115F174CA70E = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_TabbedComponent.h; path = "../../Source/model/Component Types/jucer_TabbedComponent.h"; sourceTree = SOURCE_ROOT; }; E18C99BDD4EF3DFD767F3770 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_TextButton.h; path = "../../Source/model/Component Types/jucer_TextButton.h"; sourceTree = SOURCE_ROOT; }; + 1BBF86F1D833DAD4A1503C82 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_TextEditor.h; path = "../../Source/model/Component Types/jucer_TextEditor.h"; sourceTree = SOURCE_ROOT; }; + A6FAA90B494DCD7CA5911196 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ToggleButton.h; path = "../../Source/model/Component Types/jucer_ToggleButton.h"; sourceTree = SOURCE_ROOT; }; + 03AD2BF6C80C6AF47BBDB7E9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_Viewport.h; path = "../../Source/model/Component Types/jucer_Viewport.h"; sourceTree = SOURCE_ROOT; }; 2D6D6985B452EA0B67A18914 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentDocument.cpp; path = ../../Source/model/jucer_ComponentDocument.cpp; sourceTree = SOURCE_ROOT; }; E6CC3A04349F6B227FDAB26F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentDocument.h; path = ../../Source/model/jucer_ComponentDocument.h; sourceTree = SOURCE_ROOT; }; 45C80436FD5A8438D0E6BE17 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_Coordinate.cpp; path = ../../Source/model/jucer_Coordinate.cpp; sourceTree = SOURCE_ROOT; }; @@ -141,8 +154,20 @@ 268B4FFB1C675B679138545F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = JuceLibraryCode3.mm; path = ../../JuceLibraryCode/JuceLibraryCode3.mm; sourceTree = SOURCE_ROOT; }; 60A217F62952DE8A752BD79F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = JuceLibraryCode4.mm; path = ../../JuceLibraryCode/JuceLibraryCode4.mm; sourceTree = SOURCE_ROOT; }; D3D6EC2C17524688F2E803EB = { isa = PBXGroup; children = ( + 82A1EC47692975C7031B3973, + 4F23FF649E7BA3A0F737E3BE, + 6FD54B7E8992FD692BAA0DC6, + 926FC04F4EAF24C7C4671207, + C6263909812DBE995167932B, + 6B5504F7274B11DFAD3B2E26, + 133385B65A02DF50291B222F, + C64A89EA5C3F0A701F9EBA79, + 40716207B98461E05DC46F14, + 4A22DE9DF590115F174CA70E, + E18C99BDD4EF3DFD767F3770, + 1BBF86F1D833DAD4A1503C82, A6FAA90B494DCD7CA5911196, - E18C99BDD4EF3DFD767F3770 ); name = "Component Types"; sourceTree = ""; }; + 03AD2BF6C80C6AF47BBDB7E9 ); name = "Component Types"; sourceTree = ""; }; BF6238C9155879B9A9C47213 = { isa = PBXGroup; children = ( D3D6EC2C17524688F2E803EB, 2D6D6985B452EA0B67A18914, @@ -323,6 +348,7 @@ 673FACB8969ADED17ACEFF7C ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; 87CCE4CB1FAB40B6F21DEACE = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; 5362E03ADF975A126C1F2F7B = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 52D75B8B0F52DD4F37A4B1C0, CD4226951C3F7FE19CF8A7CE, 1DF9688E29753A0459E6C32A, 1174D3512AF8207950094C56, diff --git a/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj b/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj index f9c87c4459..8f9c6650ae 100644 --- a/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj +++ b/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj @@ -134,8 +134,20 @@ - + + + + + + + + + + + + + diff --git a/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj b/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj index 42ebc2f4ca..b90d01f837 100644 --- a/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj +++ b/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj @@ -134,8 +134,20 @@ - + + + + + + + + + + + + + diff --git a/extras/Jucer (experimental)/Jucer.jucer b/extras/Jucer (experimental)/Jucer.jucer index 9dc62a9a97..f8d1ffeb51 100644 --- a/extras/Jucer (experimental)/Jucer.jucer +++ b/extras/Jucer (experimental)/Jucer.jucer @@ -28,10 +28,34 @@ - + + + + + + + + + + + + + diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComboBox.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComboBox.h new file mode 100644 index 0000000000..f9e937e27b --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComboBox.h @@ -0,0 +1,56 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#ifdef ADD_TO_LIST + ADD_TO_LIST (ComboBoxHandler); +#else + +#include "../jucer_ComponentDocument.h" + + +//============================================================================== +class ComboBoxHandler : public ComponentTypeHelper +{ +public: + ComboBoxHandler() : ComponentTypeHelper ("ComboBox", "COMBOBOX", "comboBox") {} + ~ComboBoxHandler() {} + + Component* createComponent() { return new ComboBox (String::empty); } + const Rectangle getDefaultSize() { return Rectangle (0, 0, 180, 24); } + + void update (ComponentDocument& document, ComboBox* comp, const ValueTree& state) + { + } + + void initialiseNew (ComponentDocument& document, ValueTree& state) + { + } + + void createProperties (ComponentDocument& document, ValueTree& state, Array & props) + { + } +}; + +#endif diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.cpp b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.cpp new file mode 100644 index 0000000000..0f814ea0bc --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.cpp @@ -0,0 +1,336 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#include "jucer_ComponentTypeManager.h" +#include "jucer_ComponentTypes.h" + +//============================================================================== +class ComponentBoundsEditor : public PropertyComponent, + public ButtonListener, + public Value::Listener +{ +public: + enum Type + { + left, top, right, bottom + }; + + //============================================================================== + ComponentBoundsEditor (ComponentDocument& document_, const String& name, Type type_, + const ValueTree& compState_, const Value& boundsValue_) + : PropertyComponent (name, 40), document (document_), type (type_), + compState (compState_), boundsValue (boundsValue_) + { + addAndMakeVisible (label = new Label (String::empty, String::empty)); + + label->setEditable (true, true, false); + label->setColour (Label::backgroundColourId, Colours::white); + label->setColour (Label::outlineColourId, findColour (ComboBox::outlineColourId)); + label->getTextValue().referTo (Value (new BoundsCoordValueSource (boundsValue, type))); + + addAndMakeVisible (proportionButton = new TextButton ("%")); + proportionButton->addButtonListener (this); + + addAndMakeVisible (anchorButton1 = new TextButton (String::empty)); + anchorButton1->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnTop | Button::ConnectedOnRight | Button::ConnectedOnBottom); + anchorButton1->setTriggeredOnMouseDown (true); + anchorButton1->addButtonListener (this); + + addAndMakeVisible (anchorButton2 = new TextButton (String::empty)); + anchorButton2->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnTop | Button::ConnectedOnRight | Button::ConnectedOnBottom); + anchorButton2->setTriggeredOnMouseDown (true); + anchorButton2->addButtonListener (this); + + boundsValue.addListener (this); + valueChanged (boundsValue); + } + + ~ComponentBoundsEditor() + { + boundsValue.removeListener (this); + deleteAllChildren(); + } + + void resized() + { + const Rectangle r (getLookAndFeel().getPropertyComponentContentPosition (*this)); + + label->setBounds (r.getX(), r.getY(), r.getWidth() / 2, r.getHeight() / 2); + proportionButton->setBounds (r.getX() + r.getWidth() / 2, r.getY(), + r.getWidth() / 2, r.getHeight() / 2); + + if (anchorButton2->isVisible()) + { + anchorButton1->setBounds (r.getX(), r.getY() + r.getHeight() / 2, r.getWidth() / 2, r.getHeight() / 2); + anchorButton2->setBounds (r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2, r.getWidth() / 2, r.getHeight() / 2); + } + else + { + anchorButton1->setBounds (r.getX(), r.getY() + r.getHeight() / 2, r.getWidth(), r.getHeight() / 2); + } + } + + void refresh() + { + } + + void buttonClicked (Button* button) + { + RectangleCoordinates r (boundsValue.toString()); + Coordinate& coord = getCoord (r); + ScopedPointer markers (document.createMarkerResolver (compState)); + + if (button == proportionButton) + { + coord.toggleProportionality (*markers); + boundsValue = r.toString(); + } + else if (button == anchorButton1) + { + const String marker (pickMarker (anchorButton1, coord.getAnchor1())); + + if (marker.isNotEmpty()) + { + coord.changeAnchor1 (marker, *markers); + boundsValue = r.toString(); + } + } + else if (button == anchorButton2) + { + const String marker (pickMarker (anchorButton2, coord.getAnchor2())); + + if (marker.isNotEmpty()) + { + coord.changeAnchor2 (marker, *markers); + boundsValue = r.toString(); + } + } + } + + void valueChanged (Value&) + { + RectangleCoordinates r (boundsValue.toString()); + Coordinate& coord = getCoord (r); + + anchorButton1->setButtonText (coord.getAnchor1()); + + anchorButton2->setVisible (coord.isProportional()); + anchorButton2->setButtonText (coord.getAnchor2()); + resized(); + } + + //============================================================================== + class BoundsCoordValueSource : public Value::ValueSource, + public Value::Listener + { + public: + BoundsCoordValueSource (const Value& sourceValue_, Type type_) + : sourceValue (sourceValue_), type (type_) + { + sourceValue.addListener (this); + } + + ~BoundsCoordValueSource() {} + + const var getValue() const + { + RectangleCoordinates r (sourceValue.toString()); + Coordinate& coord = getCoord (r); + + if (coord.isProportional()) + return String (coord.getEditableValue()) + "%"; + + return coord.getEditableValue(); + } + + void setValue (const var& newValue) + { + RectangleCoordinates r (sourceValue.toString()); + Coordinate& coord = getCoord (r); + + coord.setEditableValue ((double) newValue); + + const String newVal (r.toString()); + if (sourceValue != newVal) + sourceValue = newVal; + } + + void valueChanged (Value&) + { + sendChangeMessage (true); + } + + //============================================================================== + juce_UseDebuggingNewOperator + + protected: + Value sourceValue; + Type type; + + Coordinate& getCoord (RectangleCoordinates& r) const + { + return getCoordForType (type, r); + } + + BoundsCoordValueSource (const BoundsCoordValueSource&); + const BoundsCoordValueSource& operator= (const BoundsCoordValueSource&); + }; + + static Coordinate& getCoordForType (const Type type, RectangleCoordinates& r) + { + switch (type) + { + case left: return r.left; + case right: return r.right; + case top: return r.top; + case bottom: return r.bottom; + default: jassertfalse; break; + } + + return r.left; + } + + const String pickMarker (Component* button, const String& currentMarker) + { + const StringArray markers (document.getComponentMarkers (type == left || type == right)); + + PopupMenu m; + for (int i = 0; i < markers.size(); ++i) + m.addItem (i + 1, markers[i], true, currentMarker == markers[i]); + + const int r = m.showAt (button); + + if (r > 0) + return markers [r - 1]; + + return String::empty; + } + +private: + ComponentDocument& document; + Type type; + ValueTree compState; + Value boundsValue; + Label* label; + TextButton* proportionButton; + TextButton* anchorButton1; + TextButton* anchorButton2; + + Coordinate& getCoord (RectangleCoordinates& r) + { + return getCoordForType (type, r); + } +}; + + +//============================================================================== +ComponentTypeHandler::ComponentTypeHandler (const String& name_, const String& xmlTag_, + const String& memberNameRoot_) + : name (name_), xmlTag (xmlTag_), + memberNameRoot (memberNameRoot_) +{ +} + +ComponentTypeHandler::~ComponentTypeHandler() +{ +} + +Value ComponentTypeHandler::getValue (const var::identifier& name, ValueTree& state, ComponentDocument& document) const +{ + return state.getPropertyAsValue (name, document.getUndoManager()); +} + +void ComponentTypeHandler::updateComponent (ComponentDocument& document, Component* comp, const ValueTree& state) +{ + RectangleCoordinates pos (state [ComponentDocument::compBoundsProperty].toString()); + ScopedPointer markers (document.createMarkerResolver (state)); + comp->setBounds (pos.resolve (*markers)); + + comp->setName (state [ComponentDocument::compNameProperty]); +} + +void ComponentTypeHandler::initialiseNewItem (ComponentDocument& document, ValueTree& state) +{ + state.setProperty (ComponentDocument::compNameProperty, String::empty, 0); + state.setProperty (ComponentDocument::memberNameProperty, document.getNonExistentMemberName (getMemberNameRoot()), 0); + + const Rectangle bounds (getDefaultSize().withPosition (Point (Random::getSystemRandom().nextInt (100) + 100, + Random::getSystemRandom().nextInt (100) + 100))); + + state.setProperty (ComponentDocument::compBoundsProperty, RectangleCoordinates (bounds).toString(), 0); +} + +void ComponentTypeHandler::createPropertyEditors (ComponentDocument& document, ValueTree& state, Array & props) +{ + props.add (new ComponentBoundsEditor (document, "Left", ComponentBoundsEditor::left, state, getValue (ComponentDocument::compBoundsProperty, state, document))); + props.add (new ComponentBoundsEditor (document, "Right", ComponentBoundsEditor::right, state, getValue (ComponentDocument::compBoundsProperty, state, document))); + props.add (new ComponentBoundsEditor (document, "Top", ComponentBoundsEditor::top, state, getValue (ComponentDocument::compBoundsProperty, state, document))); + props.add (new ComponentBoundsEditor (document, "Bottom", ComponentBoundsEditor::bottom, state, getValue (ComponentDocument::compBoundsProperty, state, document))); +} + +//============================================================================== +ComponentTypeManager::ComponentTypeManager() +{ + #define ADD_TO_LIST(HandlerType) handlers.add (new HandlerType()); + #include "jucer_ComponentTypes.h" + #undef ADD_TO_LIST +} + +ComponentTypeManager::~ComponentTypeManager() +{ +} + +Component* ComponentTypeManager::createFromStoredType (ComponentDocument& document, const ValueTree& value) +{ + ComponentTypeHandler* handler = getHandlerFor (value.getType()); + if (handler == 0) + return 0; + + Component* c = handler->createComponent(); + if (c != 0) + handler->updateComponent (document, c, value); + + return c; +} + +ComponentTypeHandler* ComponentTypeManager::getHandlerFor (const String& type) +{ + for (int i = handlers.size(); --i >= 0;) + if (handlers.getUnchecked(i)->getXmlTag() == type) + return handlers.getUnchecked(i); + + return 0; +} + +const StringArray ComponentTypeManager::getTypeNames() const +{ + StringArray s; + for (int i = 0; i < handlers.size(); ++i) + s.add (handlers.getUnchecked(i)->getName()); + + return s; +} + +juce_ImplementSingleton_SingleThreaded (ComponentTypeManager); diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.h new file mode 100644 index 0000000000..f0967312e1 --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypeManager.h @@ -0,0 +1,127 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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_COMPONENTTYPEMANAGER_H_734EBF1__ +#define __JUCER_COMPONENTTYPEMANAGER_H_734EBF1__ + +#include "../../jucer_Headers.h" +#include "../jucer_ComponentDocument.h" + + +//============================================================================== +class ComponentTypeHandler +{ +public: + //============================================================================== + ComponentTypeHandler (const String& name_, const String& xmlTag_, const String& memberNameRoot_); + virtual ~ComponentTypeHandler(); + + const String& getName() const { return name; } + const String& getXmlTag() const { return xmlTag; } + const String& getMemberNameRoot() const { return memberNameRoot; } + + virtual Component* createComponent() = 0; + virtual const Rectangle getDefaultSize() = 0; + + virtual void updateComponent (ComponentDocument& document, Component* comp, const ValueTree& state); + virtual void initialiseNewItem (ComponentDocument& document, ValueTree& state); + virtual void createPropertyEditors (ComponentDocument& document, ValueTree& state, Array & props); + + Value getValue (const var::identifier& name, ValueTree& state, ComponentDocument& document) const; + + //============================================================================== +protected: + const String name, xmlTag, memberNameRoot; +}; + + +//============================================================================== +class ComponentTypeManager : public DeletedAtShutdown +{ +public: + //============================================================================== + ComponentTypeManager(); + ~ComponentTypeManager(); + + juce_DeclareSingleton_SingleThreaded_Minimal (ComponentTypeManager); + + //============================================================================== + Component* createFromStoredType (ComponentDocument& document, const ValueTree& value); + + int getNumHandlers() const { return handlers.size(); } + ComponentTypeHandler* getHandler (const int index) const { return handlers[index]; } + + ComponentTypeHandler* getHandlerFor (const String& type); + const StringArray getTypeNames() const; + + +private: + //============================================================================== + OwnedArray handlers; +}; + + +//============================================================================== +template +class ComponentTypeHelper : public ComponentTypeHandler +{ +public: + ComponentTypeHelper (const String& name_, const String& xmlTag_, const String& memberNameRoot_) + : ComponentTypeHandler (name_, xmlTag_, memberNameRoot_) + { + } + + virtual void update (ComponentDocument& document, ComponentClass* comp, const ValueTree& state) = 0; + + void updateComponent (ComponentDocument& document, Component* comp, const ValueTree& state) + { + ComponentTypeHandler::updateComponent (document, comp, state); + + ComponentClass* const c = dynamic_cast (comp); + jassert (c != 0); + update (document, c, state); + } + + virtual void initialiseNew (ComponentDocument& document, ValueTree& state) = 0; + + void initialiseNewItem (ComponentDocument& document, ValueTree& state) + { + ComponentTypeHandler::initialiseNewItem (document, state); + initialiseNew (document, state); + } + + virtual void createProperties (ComponentDocument& document, ValueTree& state, Array & props) = 0; + + void createPropertyEditors (ComponentDocument& document, ValueTree& state, Array & props) + { + ComponentTypeHandler::createPropertyEditors (document, state, props); + createProperties (document, state, props); + } +}; + + + + +#endif // __JUCER_COMPONENTTYPEMANAGER_H_734EBF1__ diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypes.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypes.h new file mode 100644 index 0000000000..5baf6ef52f --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_ComponentTypes.h @@ -0,0 +1,36 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#include "jucer_TextButton.h" +#include "jucer_ToggleButton.h" +#include "jucer_TextEditor.h" +#include "jucer_Viewport.h" +#include "jucer_ComboBox.h" +#include "jucer_GroupComponent.h" +#include "jucer_JucerComponent.h" +#include "jucer_GenericComponent.h" +#include "jucer_Label.h" +#include "jucer_Slider.h" +#include "jucer_TabbedComponent.h" diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_GenericComponent.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_GenericComponent.h new file mode 100644 index 0000000000..1d715be157 --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_GenericComponent.h @@ -0,0 +1,75 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#ifdef ADD_TO_LIST + ADD_TO_LIST (GenericComponentHandler); +#else + +#include "../jucer_ComponentDocument.h" + + +//============================================================================== +class GenericComponentHandler : public ComponentTypeHelper +{ +public: + GenericComponentHandler() : ComponentTypeHelper ("Generic Component", "COMPONENT", "component") {} + ~GenericComponentHandler() {} + + //============================================================================== + class PlaceholderComp : public Component + { + public: + PlaceholderComp() + { + } + + void paint (Graphics& g) + { + g.setColour (Colours::grey); + g.drawRect (getLocalBounds()); + + g.drawLine (0.5f, 0.5f, getWidth() - 0.5f, getHeight() - 0.5f); + g.drawLine (0.5f, getHeight() - 0.5f, getWidth() - 0.5f, 0.5f); + } + }; + + //============================================================================== + Component* createComponent() { return new PlaceholderComp(); } + const Rectangle getDefaultSize() { return Rectangle (0, 0, 180, 24); } + + void update (ComponentDocument& document, Component* comp, const ValueTree& state) + { + } + + void initialiseNew (ComponentDocument& document, ValueTree& state) + { + } + + void createProperties (ComponentDocument& document, ValueTree& state, Array & props) + { + } +}; + +#endif diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_GroupComponent.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_GroupComponent.h new file mode 100644 index 0000000000..e4e7231ac8 --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_GroupComponent.h @@ -0,0 +1,56 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#ifdef ADD_TO_LIST + ADD_TO_LIST (GroupComponentHandler); +#else + +#include "../jucer_ComponentDocument.h" + + +//============================================================================== +class GroupComponentHandler : public ComponentTypeHelper +{ +public: + GroupComponentHandler() : ComponentTypeHelper ("GroupComponent", "GROUPCOMPONENT", "group") {} + ~GroupComponentHandler() {} + + Component* createComponent() { return new GroupComponent (String::empty, String::empty); } + const Rectangle getDefaultSize() { return Rectangle (0, 0, 200, 200); } + + void update (ComponentDocument& document, GroupComponent* comp, const ValueTree& state) + { + } + + void initialiseNew (ComponentDocument& document, ValueTree& state) + { + } + + void createProperties (ComponentDocument& document, ValueTree& state, Array & props) + { + } +}; + +#endif diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_JucerComponent.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_JucerComponent.h new file mode 100644 index 0000000000..9886a2a0b2 --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_JucerComponent.h @@ -0,0 +1,74 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#ifdef ADD_TO_LIST + ADD_TO_LIST (JucerComponentHandler); +#else + +#include "../jucer_ComponentDocument.h" + +//============================================================================== +class JucerComponent : public Component +{ +public: + JucerComponent() + { + } + + void paint (Graphics& g) + { + g.setColour (Colours::grey); + g.drawRect (getLocalBounds()); + + g.drawLine (0.5f, 0.5f, getWidth() - 0.5f, getHeight() - 0.5f); + g.drawLine (0.5f, getHeight() - 0.5f, getWidth() - 0.5f, 0.5f); + } +}; + +//============================================================================== +class JucerComponentHandler : public ComponentTypeHelper +{ +public: + JucerComponentHandler() : ComponentTypeHelper ("Jucer Component", "JUCERCOMPONENT", "jucerComp") {} + ~JucerComponentHandler() {} + + //============================================================================== + Component* createComponent() { return new JucerComponent(); } + const Rectangle getDefaultSize() { return Rectangle (0, 0, 150, 150); } + + void update (ComponentDocument& document, JucerComponent* comp, const ValueTree& state) + { + } + + void initialiseNew (ComponentDocument& document, ValueTree& state) + { + } + + void createProperties (ComponentDocument& document, ValueTree& state, Array & props) + { + } +}; + +#endif diff --git a/extras/Jucer (experimental)/Source/model/Component Types/jucer_Label.h b/extras/Jucer (experimental)/Source/model/Component Types/jucer_Label.h new file mode 100644 index 0000000000..bf78bd693c --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/Component Types/jucer_Label.h @@ -0,0 +1,60 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 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. + + ============================================================================== +*/ + +#ifdef ADD_TO_LIST + ADD_TO_LIST (LabelHandler); +#else + +#include "../jucer_ComponentDocument.h" + + +//============================================================================== +class LabelHandler : public ComponentTypeHelper