From 7ed446b5fd81dc3dbd0cc3b6b63071145aa13a7d Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Fri, 30 Apr 2010 11:00:38 +0100 Subject: [PATCH] Tweak to TextInputTarget. Code clean-ups. Jucer development. --- .../Builds/Linux/Makefile | 6 +- .../The Jucer.xcodeproj/project.pbxproj | 18 +- .../Builds/VisualStudio2005/The Jucer.vcproj | 7 +- .../Builds/VisualStudio2008/The Jucer.vcproj | 7 +- extras/Jucer (experimental)/Jucer.jucer | 14 +- .../jucer_ComponentEditor.cpp | 522 +----------------- .../jucer_ComponentEditorCanvas.cpp | 8 +- .../jucer_ComponentEditorCanvas.h | 4 +- .../jucer_ComponentEditorCodeView.h | 217 ++++++++ .../jucer_ComponentEditorToolbar.h | 94 ++++ .../jucer_ComponentEditorTreeView.h | 309 +++++++++++ juce.h | 4 +- juce_amalgamated.cpp | 314 +++++------ juce_amalgamated.h | 39 +- .../juce_AudioFormatManager.cpp | 2 +- .../juce_QuickTimeAudioFormat.cpp | 7 +- src/audio/midi/juce_MidiMessage.cpp | 16 +- .../plugins/formats/juce_VSTPluginFormat.cpp | 4 +- .../plugins/juce_AudioPluginFormatManager.cpp | 2 +- src/audio/processors/juce_AudioProcessor.cpp | 6 +- src/audio/processors/juce_AudioProcessor.h | 2 +- src/containers/juce_Array.h | 9 + src/containers/juce_OwnedArray.h | 9 + src/core/juce_Memory.h | 2 +- src/core/juce_PlatformDefs.h | 4 +- src/core/juce_SystemStats.cpp | 4 +- src/events/juce_Timer.cpp | 16 +- .../code_editor/juce_CodeEditorComponent.cpp | 5 + .../code_editor/juce_CodeEditorComponent.h | 2 + .../components/controls/juce_TextEditor.cpp | 5 + src/gui/components/controls/juce_TextEditor.h | 2 + src/gui/components/controls/juce_Toolbar.cpp | 2 +- src/gui/components/juce_Component.cpp | 6 +- src/gui/components/juce_Component.h | 2 +- .../keyboard/juce_TextInputTarget.h | 5 + .../components/windows/juce_ComponentPeer.cpp | 6 +- .../windows/juce_ResizableWindow.cpp | 10 +- .../components/windows/juce_ResizableWindow.h | 4 +- .../graphics/colour/juce_ColourGradient.cpp | 4 +- ...uce_LowLevelGraphicsPostScriptRenderer.cpp | 2 +- src/io/files/juce_ZipFile.cpp | 12 +- src/io/files/juce_ZipFile.h | 2 +- src/native/linux/juce_linux_Audio.cpp | 79 ++- src/native/linux/juce_linux_Clipboard.cpp | 2 +- src/native/linux/juce_linux_Fonts.cpp | 2 +- src/native/linux/juce_linux_Messaging.cpp | 8 +- src/native/linux/juce_linux_Windowing.cpp | 12 +- .../windows/juce_win32_AudioCDReader.cpp | 13 +- src/native/windows/juce_win32_DirectSound.cpp | 59 +- src/native/windows/juce_win32_Network.cpp | 22 +- src/native/windows/juce_win32_SystemStats.cpp | 4 +- src/native/windows/juce_win32_Threads.cpp | 8 +- src/text/juce_XmlElement.cpp | 4 +- 53 files changed, 1019 insertions(+), 909 deletions(-) create mode 100644 extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCodeView.h create mode 100644 extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorToolbar.h create mode 100644 extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorTreeView.h diff --git a/extras/Jucer (experimental)/Builds/Linux/Makefile b/extras/Jucer (experimental)/Builds/Linux/Makefile index 0955bbd1da..9225b64cc4 100644 --- a/extras/Jucer (experimental)/Builds/Linux/Makefile +++ b/extras/Jucer (experimental)/Builds/Linux/Makefile @@ -53,8 +53,8 @@ OBJECTS := \ $(OBJDIR)/jucer_ProjectExporter.o \ $(OBJDIR)/jucer_ProjectWizard.o \ $(OBJDIR)/jucer_ResourceFile.o \ - $(OBJDIR)/jucer_ComponentEditorCanvas.o \ $(OBJDIR)/jucer_ComponentEditor.o \ + $(OBJDIR)/jucer_ComponentEditorCanvas.o \ $(OBJDIR)/jucer_DrawableEditor.o \ $(OBJDIR)/jucer_DocumentEditorComponent.o \ $(OBJDIR)/jucer_GroupInformationComponent.o \ @@ -141,12 +141,12 @@ $(OBJDIR)/jucer_ResourceFile.o: ../../Source/model/jucer_ResourceFile.cpp @echo $(notdir $<) @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/jucer_ComponentEditorCanvas.o: ../../Source/ui/Component\ Editor/jucer_ComponentEditorCanvas.cpp +$(OBJDIR)/jucer_ComponentEditor.o: ../../Source/ui/Component\ Editor/jucer_ComponentEditor.cpp -@mkdir -p $(OBJDIR) @echo $(notdir $<) @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/jucer_ComponentEditor.o: ../../Source/ui/Component\ Editor/jucer_ComponentEditor.cpp +$(OBJDIR)/jucer_ComponentEditorCanvas.o: ../../Source/ui/Component\ Editor/jucer_ComponentEditorCanvas.cpp -@mkdir -p $(OBJDIR) @echo $(notdir $<) @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" 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 77cbb223d0..18985299b1 100644 --- a/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj +++ b/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj @@ -27,8 +27,8 @@ 60CDC1358E84801B6526E434 = { isa = PBXBuildFile; fileRef = FE9A53032395E717F54AE85B; }; EEC6FC8E546C88C825411DB2 = { isa = PBXBuildFile; fileRef = 0AD266A3E698D40DCD88A432; }; B2B821DE12F1679A3ADA597A = { isa = PBXBuildFile; fileRef = DBE9A3BB502125C5D3433AE7; }; - CDB5102BEFD7C18BD28709F3 = { isa = PBXBuildFile; fileRef = 81D9A078702EFE0A32C037A1; }; D706C3B5016318D85FE452C2 = { isa = PBXBuildFile; fileRef = 3263F4099F45D6FACD28F08D; }; + CDB5102BEFD7C18BD28709F3 = { isa = PBXBuildFile; fileRef = 81D9A078702EFE0A32C037A1; }; E43D00B370F289420379B759 = { isa = PBXBuildFile; fileRef = 82F91CF84A296665177CB79A; }; 944CE0EADAD951F48EC77071 = { isa = PBXBuildFile; fileRef = 3B2C45064E85B3B631D4F921; }; 4E8860E0F8680956A6F5B493 = { isa = PBXBuildFile; fileRef = 8F731296532276CBF2B6190D; }; @@ -99,10 +99,13 @@ DBE9A3BB502125C5D3433AE7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ResourceFile.cpp; path = ../../Source/model/jucer_ResourceFile.cpp; sourceTree = SOURCE_ROOT; }; 2DEE6D9FE17874DAB301648C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ResourceFile.h; path = ../../Source/model/jucer_ResourceFile.h; sourceTree = SOURCE_ROOT; }; BAA4B3ECAA1344B0B4052542 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentDragOperation.h; path = "../../Source/ui/Component Editor/jucer_ComponentDragOperation.h"; sourceTree = SOURCE_ROOT; }; - 81D9A078702EFE0A32C037A1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentEditorCanvas.cpp; path = "../../Source/ui/Component Editor/jucer_ComponentEditorCanvas.cpp"; sourceTree = SOURCE_ROOT; }; - 3B77C7A8D9A2386088D75CFE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentEditorCanvas.h; path = "../../Source/ui/Component Editor/jucer_ComponentEditorCanvas.h"; sourceTree = SOURCE_ROOT; }; 3263F4099F45D6FACD28F08D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentEditor.cpp; path = "../../Source/ui/Component Editor/jucer_ComponentEditor.cpp"; sourceTree = SOURCE_ROOT; }; 16328135EAE8536A5E2AB454 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentEditor.h; path = "../../Source/ui/Component Editor/jucer_ComponentEditor.h"; sourceTree = SOURCE_ROOT; }; + 81D9A078702EFE0A32C037A1 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentEditorCanvas.cpp; path = "../../Source/ui/Component Editor/jucer_ComponentEditorCanvas.cpp"; sourceTree = SOURCE_ROOT; }; + 3B77C7A8D9A2386088D75CFE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentEditorCanvas.h; path = "../../Source/ui/Component Editor/jucer_ComponentEditorCanvas.h"; sourceTree = SOURCE_ROOT; }; + 7CB154C3682F8C786134A6F3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentEditorCodeView.h; path = "../../Source/ui/Component Editor/jucer_ComponentEditorCodeView.h"; sourceTree = SOURCE_ROOT; }; + B5F5AD9FC53F60610C71367C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentEditorToolbar.h; path = "../../Source/ui/Component Editor/jucer_ComponentEditorToolbar.h"; sourceTree = SOURCE_ROOT; }; + 8CB73D6F1D0FFC4B379D1240 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentEditorTreeView.h; path = "../../Source/ui/Component Editor/jucer_ComponentEditorTreeView.h"; sourceTree = SOURCE_ROOT; }; 82F91CF84A296665177CB79A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_DrawableEditor.cpp; path = "../../Source/ui/Drawable Editor/jucer_DrawableEditor.cpp"; sourceTree = SOURCE_ROOT; }; D1776C5F3E6BB7E8C698BAD6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_DrawableEditor.h; path = "../../Source/ui/Drawable Editor/jucer_DrawableEditor.h"; sourceTree = SOURCE_ROOT; }; F9EAFD5BC3E676BC59B326E0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_DrawableObjectComponent.h; path = "../../Source/ui/Drawable Editor/jucer_DrawableObjectComponent.h"; sourceTree = SOURCE_ROOT; }; @@ -204,10 +207,13 @@ 2DEE6D9FE17874DAB301648C ); name = Model; sourceTree = ""; }; 3A0BE83502CB509D623C2C07 = { isa = PBXGroup; children = ( BAA4B3ECAA1344B0B4052542, + 3263F4099F45D6FACD28F08D, + 16328135EAE8536A5E2AB454, 81D9A078702EFE0A32C037A1, 3B77C7A8D9A2386088D75CFE, - 3263F4099F45D6FACD28F08D, - 16328135EAE8536A5E2AB454 ); name = "Component Editor"; sourceTree = ""; }; + 7CB154C3682F8C786134A6F3, + B5F5AD9FC53F60610C71367C, + 8CB73D6F1D0FFC4B379D1240 ); name = "Component Editor"; sourceTree = ""; }; E6053BD673F80E900DDA3593 = { isa = PBXGroup; children = ( 82F91CF84A296665177CB79A, D1776C5F3E6BB7E8C698BAD6, @@ -376,8 +382,8 @@ 60CDC1358E84801B6526E434, EEC6FC8E546C88C825411DB2, B2B821DE12F1679A3ADA597A, - CDB5102BEFD7C18BD28709F3, D706C3B5016318D85FE452C2, + CDB5102BEFD7C18BD28709F3, E43D00B370F289420379B759, 944CE0EADAD951F48EC77071, 4E8860E0F8680956A6F5B493, diff --git a/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj b/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj index d7771a24fe..1b72eb525f 100644 --- a/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj +++ b/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj @@ -175,10 +175,13 @@ - - + + + + + diff --git a/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj b/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj index 0886514e0e..8f0977be80 100644 --- a/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj +++ b/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj @@ -175,10 +175,13 @@ - - + + + + + diff --git a/extras/Jucer (experimental)/Jucer.jucer b/extras/Jucer (experimental)/Jucer.jucer index ed7e42a242..1218345e5d 100644 --- a/extras/Jucer (experimental)/Jucer.jucer +++ b/extras/Jucer (experimental)/Jucer.jucer @@ -106,14 +106,20 @@ - - + + + + + getSelection().addChangeListener (this); - } - - ~Base() - { - editor.getCanvas()->getSelection().removeChangeListener (this); - } - - //============================================================================== - void valueTreePropertyChanged (ValueTree& tree, const var::identifier& property) {} - void valueTreeParentChanged (ValueTree& tree) {} - void valueTreeChildrenChanged (ValueTree& tree) {} - - const String getUniqueName() const - { - jassert (getItemId().isNotEmpty()); - return getItemId(); - } - - //============================================================================== - void itemOpennessChanged (bool isNowOpen) - { - if (isNowOpen) - refreshSubItems(); - } - - virtual void refreshSubItems() = 0; - virtual const String getItemId() const = 0; - - void setName (const String& newName) {} - - void itemClicked (const MouseEvent& e) {} - void itemDoubleClicked (const MouseEvent& e) {} - - void itemSelectionChanged (bool isNowSelected) - { - if (isNowSelected) - editor.getCanvas()->getSelection().addToSelection (getItemId()); - else - editor.getCanvas()->getSelection().deselect (getItemId()); - } - - void changeListenerCallback (void*) { updateSelectionState(); } - - void updateSelectionState() - { - setSelected (editor.getCanvas()->getSelection().isSelected (getItemId()), false); - } - - bool isMissing() { return false; } - const String getTooltip() { return String::empty; } - - protected: - //============================================================================== - ComponentEditor& editor; - }; - - - //============================================================================== - class ComponentItem : public Base - { - public: - ComponentItem (ComponentEditor& editor_, const ValueTree& componentState_) - : Base (editor_), componentState (componentState_) - { - componentState.addListener (this); - updateSelectionState(); - } - - ~ComponentItem() - { - componentState.removeListener (this); - } - - //============================================================================== - const String getItemId() const { return componentState [ComponentDocument::idProperty]; } - - bool mightContainSubItems() { return false; } - void refreshSubItems() {} - - const String getDisplayName() const { return getRenamingName(); } - const String getRenamingName() const { return componentState [ComponentDocument::memberNameProperty]; } - - Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); } - - const String getDragSourceDescription() { return componentItemDragType; } - - void valueTreePropertyChanged (ValueTree& tree, const var::identifier& property) - { - if (property == ComponentDocument::memberNameProperty) - repaintItem(); - } - - private: - //============================================================================== - ValueTree componentState; - }; - - //============================================================================== - class ComponentList : public Base - { - public: - ComponentList (ComponentEditor& editor_) - : Base (editor_), componentTree (editor.getDocument().getComponentGroup()) - { - componentTree.addListener (this); - } - - ~ComponentList() - { - componentTree.removeListener (this); - } - - //============================================================================== - const String getItemId() const { return "components"; } - bool mightContainSubItems() { return true; } - - void valueTreeChildrenChanged (ValueTree& tree) - { - if (tree == componentTree) - refreshSubItems(); - } - - void refreshSubItems() - { - ScopedPointer openness (getOpennessState()); - clearSubItems(); - - ComponentDocument& doc = editor.getDocument(); - - const int num = doc.getNumComponents(); - for (int i = 0; i < num; ++i) - addSubItem (new ComponentItem (editor, doc.getComponent (i))); - - if (openness != 0) - restoreOpennessState (*openness); - } - - const String getDisplayName() const { return getRenamingName(); } - const String getRenamingName() const { return "Components"; } - Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } - const String getDragSourceDescription() { return String::empty; } - - private: - ValueTree componentTree; - }; - - - //============================================================================== - class MarkerItem : public Base - { - public: - MarkerItem (ComponentEditor& editor_, const ValueTree& markerState_) - : Base (editor_), markerState (markerState_) - { - markerState.addListener (this); - updateSelectionState(); - } - - ~MarkerItem() - { - markerState.removeListener (this); - } - - //============================================================================== - const String getItemId() const { return markerState [ComponentDocument::idProperty]; } - - bool mightContainSubItems() { return false; } - void refreshSubItems() {} - - const String getDisplayName() const { return getRenamingName(); } - const String getRenamingName() const { return markerState [ComponentDocument::markerNameProperty]; } - - Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); } - - const String getDragSourceDescription() { return componentItemDragType; } - - void valueTreePropertyChanged (ValueTree& tree, const var::identifier& property) - { - if (property == ComponentDocument::markerNameProperty) - repaintItem(); - } - - private: - //============================================================================== - ValueTree markerState; - }; - - //============================================================================== - class MarkerList : public Base - { - public: - MarkerList (ComponentEditor& editor_, bool isX_) - : Base (editor_), markerList (editor_.getDocument().getMarkerList (isX_).getGroup()), isX (isX_) - { - markerList.addListener (this); - } - - ~MarkerList() - { - markerList.removeListener (this); - } - - //============================================================================== - const String getItemId() const { return isX ? "markersX" : "markersY"; } - bool mightContainSubItems() { return true; } - - void valueTreeChildrenChanged (ValueTree& tree) - { - refreshSubItems(); - } - - void refreshSubItems() - { - ScopedPointer openness (getOpennessState()); - clearSubItems(); - - ComponentDocument::MarkerList& markers = editor.getDocument().getMarkerList (isX); - - const int num = markers.size(); - for (int i = 0; i < num; ++i) - addSubItem (new MarkerItem (editor, markers.getMarker (i))); - - if (openness != 0) - restoreOpennessState (*openness); - } - - const String getDisplayName() const { return getRenamingName(); } - const String getRenamingName() const { return isX ? "Markers (X-axis)" : "Markers (Y-axis)"; } - Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } - const String getDragSourceDescription() { return String::empty; } - - private: - ValueTree markerList; - bool isX; - }; - - //============================================================================== - class Root : public Base - { - public: - Root (ComponentEditor& editor_) : Base (editor_) {} - ~Root() {} - - //============================================================================== - const String getItemId() const { return "root"; } - bool mightContainSubItems() { return true; } - - void refreshSubItems() - { - ScopedPointer openness (getOpennessState()); - clearSubItems(); - - addSubItem (new ComponentList (editor)); - addSubItem (new MarkerList (editor, true)); - addSubItem (new MarkerList (editor, false)); - - if (openness != 0) - restoreOpennessState (*openness); - } - - const String getDisplayName() const { return getRenamingName(); } - const String getRenamingName() const { return editor.getDocument().getClassName().toString(); } - Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } - const String getDragSourceDescription() { return String::empty; } - }; -} - //============================================================================== class ComponentEditor::ClassInfoHolder : public Component { @@ -339,15 +61,14 @@ private: //============================================================================== -class ComponentEditor::LayoutEditorHolder : public Component, - public ToolbarItemFactory +class ComponentEditor::LayoutEditorHolder : public Component { public: LayoutEditorHolder (ComponentEditor& editor_) - : editor (editor_), infoPanel (0), tree (0) + : toolbarFactory (editor_), editor (editor_), infoPanel (0), tree (0) { addAndMakeVisible (toolbar = new Toolbar()); - toolbar->addDefaultItems (*this); + toolbar->addDefaultItems (toolbarFactory); toolbar->setStyle (Toolbar::textOnly); addAndMakeVisible (viewport = new Viewport()); @@ -371,7 +92,7 @@ public: { viewport->setViewedComponent (new ComponentEditorCanvas (editor)); addAndMakeVisible (infoPanel = new InfoPanel (editor)); - tree->setRootItem (new ComponentTree::Root (editor)); + tree->setRootItem (new ComponentEditorTreeView::Root (editor)); resized(); } @@ -412,51 +133,6 @@ public: Viewport* getViewport() const { return viewport; } - //============================================================================== - enum DemoToolbarItemIds - { - createComponent = 1, - showInfo = 2, - showComponentTree = 3, - }; - - void getAllToolbarItemIds (Array & ids) - { - ids.add (createComponent); - ids.add (showInfo); - ids.add (showComponentTree); - - ids.add (separatorBarId); - ids.add (spacerId); - ids.add (flexibleSpacerId); - } - - void getDefaultItemSet (Array & ids) - { - ids.add (createComponent); - ids.add (flexibleSpacerId); - ids.add (showInfo); - ids.add (showComponentTree); - } - - ToolbarItemComponent* createItem (int itemId) - { - String name; - int commandId = 0; - - switch (itemId) - { - case createComponent: name = "new"; break; - case showInfo: name = "info"; commandId = CommandIDs::showOrHideProperties; break; - case showComponentTree: name = "tree"; commandId = CommandIDs::showOrHideTree; break; - default: jassertfalse; return 0; - } - - ToolbarButton* b = new ToolbarButton (itemId, name, new DrawablePath(), 0); - b->setCommandToTrigger (commandManager, commandId, true); - return b; - } - private: //============================================================================== class InfoPanel : public Component, @@ -506,6 +182,7 @@ private: }; Toolbar* toolbar; + ComponentEditorToolbarFactory toolbarFactory; ComponentEditor& editor; Viewport* viewport; InfoPanel* infoPanel; @@ -529,189 +206,6 @@ private: ComponentEditor& editor; }; -//============================================================================== -class ComponentEditor::CodeEditorHolder : public Component, - public ButtonListener -{ -public: - CodeEditorHolder (ComponentEditor& editor_) - : editor (editor_), switchFileButton (String::empty), showingHeader (true) - { - addAndMakeVisible (&viewport); - viewport.setScrollBarsShown (true, false); - - addAndMakeVisible (&switchFileButton); - - buttonClicked (0); - switchFileButton.addButtonListener (this); - } - - ~CodeEditorHolder() - { - } - - void resized() - { - viewport.setBounds (getLocalBounds()); - - int visWidth = viewport.getMaximumVisibleWidth(); - dynamic_cast (viewport.getViewedComponent())->updateSize (visWidth); - - if (viewport.getMaximumVisibleWidth() != visWidth) - dynamic_cast (viewport.getViewedComponent())->updateSize (viewport.getMaximumVisibleWidth()); - - switchFileButton.setBounds (getWidth() - 150, 4, 120, 20); - } - - void buttonClicked (Button*) - { - showingHeader = ! showingHeader; - viewport.setViewedComponent (new ContentHolder (editor.getDocument(), showingHeader)); - resized(); - switchFileButton.setButtonText (showingHeader ? "Show CPP file" : "Show header file"); - } - -private: - enum { updateCommandId = 0x23427fa1 }; - - //============================================================================== - class EditorHolder : public Component, - public CodeDocument::Listener - { - public: - EditorHolder (const CodeGenerator::CustomCodeList::CodeDocumentRef::Ptr doc, - const String& textBefore, const String& textAfter) - : document (doc), cppTokeniser(), codeEditor (doc->getDocument(), &cppTokeniser) - { - linesBefore.addLines (textBefore); - linesAfter.addLines (textAfter); - - addAndMakeVisible (&codeEditor); - doc->getDocument().addListener (this); - } - - ~EditorHolder() - { - document->getDocument().removeListener (this); - } - - void paint (Graphics& g) - { - g.setFont (codeEditor.getFont()); - g.setColour (Colours::darkgrey); - - const int fontHeight = codeEditor.getLineHeight(); - const int fontAscent = (int) codeEditor.getFont().getAscent(); - const int textX = 5; - - int i; - for (i = 0; i < linesBefore.size(); ++i) - g.drawSingleLineText (linesBefore[i], textX, i * fontHeight + fontAscent); - - for (i = 0; i < linesAfter.size(); ++i) - g.drawSingleLineText (linesAfter[i], textX, codeEditor.getBottom() + i * fontHeight + fontAscent); - } - - void updateSize (int width) - { - const int fontHeight = codeEditor.getLineHeight(); - - codeEditor.setBounds (0, fontHeight * linesBefore.size() + 1, - width, 2 + codeEditor.getScrollbarThickness() - + fontHeight * jlimit (1, 50, document->getDocument().getNumLines())); - - setSize (width, (linesBefore.size() + linesAfter.size()) * fontHeight + codeEditor.getHeight()); - } - - void codeDocumentChanged (const CodeDocument::Position&, const CodeDocument::Position&) - { - int oldHeight = getHeight(); - updateSize (getWidth()); - if (getHeight() != oldHeight) - getParentComponent()->handleCommandMessage (updateCommandId); - } - - private: - const CodeGenerator::CustomCodeList::CodeDocumentRef::Ptr document; - CPlusPlusCodeTokeniser cppTokeniser; - CodeEditorComponent codeEditor; - StringArray linesBefore, linesAfter; - }; - - //============================================================================== - class ContentHolder : public Component, - public ChangeListener - { - public: - ContentHolder (ComponentDocument& document_, bool isHeader_) - : document (document_), isHeader (isHeader_) - { - setOpaque (true); - document.getCustomCodeList().addChangeListener (this); - changeListenerCallback (0); - } - - ~ContentHolder() - { - document.getCustomCodeList().removeChangeListener (this); - } - - void paint (Graphics& g) - { - g.fillAll (Colours::lightgrey); - } - - void updateSize (int width) - { - int y = 2; - for (int i = 0; i < editors.size(); ++i) - { - EditorHolder* const ed = editors.getUnchecked(i); - ed->updateSize (width - 8); - ed->setTopLeftPosition (4, y + 1); - y = ed->getBottom() + 1; - } - - setSize (width, y + 2); - } - - void changeListenerCallback (void*) - { - editors.clear(); - - CodeGenerator::CustomCodeList::Iterator iter (isHeader ? document.getHeaderContent() - : document.getCppContent(), - document.getCustomCodeList()); - - while (iter.next()) - { - EditorHolder* ed = new EditorHolder (iter.codeDocument, iter.textBefore, iter.textAfter); - editors.add (ed); - addAndMakeVisible (ed); - } - - updateSize (getWidth()); - } - - void handleCommandMessage (int commandId) - { - if (commandId == updateCommandId) - updateSize (getWidth()); - else - Component::handleCommandMessage (commandId); - } - - private: - OwnedArray editors; - ComponentDocument& document; - bool isHeader; - }; - - ComponentEditor& editor; - Viewport viewport; - TextButton switchFileButton; - bool showingHeader; -}; //============================================================================== ComponentEditor::ComponentEditor (OpenDocumentManager::Document* document, diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.cpp b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.cpp index 59f1322361..142a841f6c 100644 --- a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.cpp +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.cpp @@ -675,15 +675,15 @@ private: }; //============================================================================== -class ComponentEditorCanvas::WholeComponentResizer : public Component +class ComponentEditorCanvas::DocumentResizerFrame : public Component { public: - WholeComponentResizer (ComponentEditorCanvas& canvas_) + DocumentResizerFrame (ComponentEditorCanvas& canvas_) : canvas (canvas_), dragStartWidth (0), dragStartHeight (0), resizerThickness (4) { } - ~WholeComponentResizer() + ~DocumentResizerFrame() { } @@ -770,7 +770,7 @@ ComponentEditorCanvas::ComponentEditorCanvas (ComponentEditor& editor_) setOpaque (true); addAndMakeVisible (componentHolder = new ComponentHolder()); addAndMakeVisible (overlay = new OverlayComponent (*this)); - overlay->addAndMakeVisible (resizeFrame = new WholeComponentResizer (*this)); + overlay->addAndMakeVisible (resizeFrame = new DocumentResizerFrame (*this)); setSize (500, 500); diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h index 4f8f42f1ca..c8a5eb1b7a 100644 --- a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCanvas.h @@ -121,13 +121,13 @@ private: friend class OverlayItemComponent; class ComponentResizeFrame; class MarkerComponent; - class WholeComponentResizer; + class DocumentResizerFrame; class OverlayComponent; //============================================================================== ComponentHolder* componentHolder; OverlayComponent* overlay; - WholeComponentResizer* resizeFrame; + DocumentResizerFrame* resizeFrame; SelectedItems selection; const Array getSelectedComps() const; diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCodeView.h b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCodeView.h new file mode 100644 index 0000000000..1d980a3ce2 --- /dev/null +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorCodeView.h @@ -0,0 +1,217 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-10 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_COMPONENTEDITORCODEVIEW_H_CA5124B0__ +#define __JUCER_COMPONENTEDITORCODEVIEW_H_CA5124B0__ + + +//============================================================================== +class ComponentEditor::CodeEditorHolder : public Component, + public ButtonListener +{ +public: + //============================================================================== + CodeEditorHolder (ComponentEditor& editor_) + : editor (editor_), switchFileButton (String::empty), showingHeader (true) + { + addAndMakeVisible (&viewport); + viewport.setScrollBarsShown (true, false); + + addAndMakeVisible (&switchFileButton); + + buttonClicked (0); + switchFileButton.addButtonListener (this); + } + + ~CodeEditorHolder() + { + } + + void resized() + { + viewport.setBounds (getLocalBounds()); + + int visWidth = viewport.getMaximumVisibleWidth(); + dynamic_cast (viewport.getViewedComponent())->updateSize (visWidth); + + if (viewport.getMaximumVisibleWidth() != visWidth) + dynamic_cast (viewport.getViewedComponent())->updateSize (viewport.getMaximumVisibleWidth()); + + switchFileButton.setBounds (getWidth() - 150, 4, 120, 20); + } + + void buttonClicked (Button*) + { + showingHeader = ! showingHeader; + viewport.setViewedComponent (new ContentHolder (editor.getDocument(), showingHeader)); + resized(); + switchFileButton.setButtonText (showingHeader ? "Show CPP file" : "Show header file"); + } + +private: + enum { updateCommandId = 0x23427fa1 }; + + //============================================================================== + class EditorHolder : public Component, + public CodeDocument::Listener + { + public: + EditorHolder (const CodeGenerator::CustomCodeList::CodeDocumentRef::Ptr doc, + const String& textBefore, const String& textAfter) + : document (doc), cppTokeniser(), codeEditor (doc->getDocument(), &cppTokeniser) + { + linesBefore.addLines (textBefore); + linesAfter.addLines (textAfter); + + addAndMakeVisible (&codeEditor); + doc->getDocument().addListener (this); + } + + ~EditorHolder() + { + document->getDocument().removeListener (this); + } + + void paint (Graphics& g) + { + g.setFont (codeEditor.getFont()); + g.setColour (Colours::darkgrey); + + const int fontHeight = codeEditor.getLineHeight(); + const int fontAscent = (int) codeEditor.getFont().getAscent(); + const int textX = 5; + + int i; + for (i = 0; i < linesBefore.size(); ++i) + g.drawSingleLineText (linesBefore[i], textX, i * fontHeight + fontAscent); + + for (i = 0; i < linesAfter.size(); ++i) + g.drawSingleLineText (linesAfter[i], textX, codeEditor.getBottom() + i * fontHeight + fontAscent); + } + + void updateSize (int width) + { + const int fontHeight = codeEditor.getLineHeight(); + + codeEditor.setBounds (0, fontHeight * linesBefore.size() + 1, + width, 2 + codeEditor.getScrollbarThickness() + + fontHeight * jlimit (1, 50, document->getDocument().getNumLines())); + + setSize (width, (linesBefore.size() + linesAfter.size()) * fontHeight + codeEditor.getHeight()); + } + + void codeDocumentChanged (const CodeDocument::Position&, const CodeDocument::Position&) + { + int oldHeight = getHeight(); + updateSize (getWidth()); + if (getHeight() != oldHeight) + getParentComponent()->handleCommandMessage (updateCommandId); + } + + private: + const CodeGenerator::CustomCodeList::CodeDocumentRef::Ptr document; + CPlusPlusCodeTokeniser cppTokeniser; + CodeEditorComponent codeEditor; + StringArray linesBefore, linesAfter; + }; + + //============================================================================== + class ContentHolder : public Component, + public ChangeListener + { + public: + ContentHolder (ComponentDocument& document_, bool isHeader_) + : document (document_), isHeader (isHeader_) + { + setOpaque (true); + document.getCustomCodeList().addChangeListener (this); + changeListenerCallback (0); + } + + ~ContentHolder() + { + document.getCustomCodeList().removeChangeListener (this); + } + + void paint (Graphics& g) + { + g.fillAll (Colours::lightgrey); + } + + void updateSize (int width) + { + int y = 2; + for (int i = 0; i < editors.size(); ++i) + { + EditorHolder* const ed = editors.getUnchecked(i); + ed->updateSize (width - 8); + ed->setTopLeftPosition (4, y + 1); + y = ed->getBottom() + 1; + } + + setSize (width, y + 2); + } + + void changeListenerCallback (void*) + { + editors.clear(); + + CodeGenerator::CustomCodeList::Iterator iter (isHeader ? document.getHeaderContent() + : document.getCppContent(), + document.getCustomCodeList()); + + while (iter.next()) + { + EditorHolder* ed = new EditorHolder (iter.codeDocument, iter.textBefore, iter.textAfter); + editors.add (ed); + addAndMakeVisible (ed); + } + + updateSize (getWidth()); + } + + void handleCommandMessage (int commandId) + { + if (commandId == updateCommandId) + updateSize (getWidth()); + else + Component::handleCommandMessage (commandId); + } + + private: + OwnedArray editors; + ComponentDocument& document; + bool isHeader; + }; + + //============================================================================== + ComponentEditor& editor; + Viewport viewport; + TextButton switchFileButton; + bool showingHeader; +}; + + +#endif // __JUCER_COMPONENTEDITORCODEVIEW_H_CA5124B0__ diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorToolbar.h b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorToolbar.h new file mode 100644 index 0000000000..d274a854c0 --- /dev/null +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorToolbar.h @@ -0,0 +1,94 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-10 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_COMPONENTEDITORTOOLBAR_H_6B5CA931__ +#define __JUCER_COMPONENTEDITORTOOLBAR_H_6B5CA931__ + + +class ComponentEditorToolbarFactory : public ToolbarItemFactory +{ +public: + ComponentEditorToolbarFactory (ComponentEditor& editor_) + : editor (editor_) + { + } + + ~ComponentEditorToolbarFactory() + { + } + + //============================================================================== + enum DemoToolbarItemIds + { + createComponent = 1, + showInfo = 2, + showComponentTree = 3, + }; + + void getAllToolbarItemIds (Array & ids) + { + ids.add (createComponent); + ids.add (showInfo); + ids.add (showComponentTree); + + ids.add (separatorBarId); + ids.add (spacerId); + ids.add (flexibleSpacerId); + } + + void getDefaultItemSet (Array & ids) + { + ids.add (spacerId); + ids.add (createComponent); + ids.add (flexibleSpacerId); + ids.add (showComponentTree); + ids.add (showInfo); + ids.add (spacerId); + } + + ToolbarItemComponent* createItem (int itemId) + { + String name; + int commandId = 0; + + switch (itemId) + { + case createComponent: name = "new"; break; + case showInfo: name = "info"; commandId = CommandIDs::showOrHideProperties; break; + case showComponentTree: name = "tree"; commandId = CommandIDs::showOrHideTree; break; + default: jassertfalse; return 0; + } + + ToolbarButton* b = new ToolbarButton (itemId, name, new DrawablePath(), 0); + b->setCommandToTrigger (commandManager, commandId, true); + return b; + } + +private: + ComponentEditor& editor; +}; + + +#endif // __JUCER_COMPONENTEDITORTOOLBAR_H_6B5CA931__ diff --git a/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorTreeView.h b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorTreeView.h new file mode 100644 index 0000000000..fb0b91122c --- /dev/null +++ b/extras/Jucer (experimental)/Source/ui/Component Editor/jucer_ComponentEditorTreeView.h @@ -0,0 +1,309 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-10 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 __JUCE_COMPONENTEDITORTREEVIEW_H_F3B95A41__ +#define __JUCE_COMPONENTEDITORTREEVIEW_H_F3B95A41__ + +#include "../jucer_JucerTreeViewBase.h" + + +//============================================================================== +namespace ComponentEditorTreeView +{ + //============================================================================== + class Base : public JucerTreeViewBase, + public ValueTree::Listener, + public ChangeListener + { + public: + Base (ComponentEditor& editor_) + : editor (editor_) + { + editor.getCanvas()->getSelection().addChangeListener (this); + } + + ~Base() + { + editor.getCanvas()->getSelection().removeChangeListener (this); + } + + //============================================================================== + void valueTreePropertyChanged (ValueTree& tree, const var::identifier& property) {} + void valueTreeParentChanged (ValueTree& tree) {} + void valueTreeChildrenChanged (ValueTree& tree) {} + + const String getUniqueName() const + { + jassert (getItemId().isNotEmpty()); + return getItemId(); + } + + //============================================================================== + void itemOpennessChanged (bool isNowOpen) + { + if (isNowOpen) + refreshSubItems(); + } + + virtual void refreshSubItems() = 0; + virtual const String getItemId() const = 0; + + void setName (const String& newName) {} + + void itemClicked (const MouseEvent& e) {} + void itemDoubleClicked (const MouseEvent& e) {} + + void itemSelectionChanged (bool isNowSelected) + { + if (isNowSelected) + editor.getCanvas()->getSelection().addToSelection (getItemId()); + else + editor.getCanvas()->getSelection().deselect (getItemId()); + } + + void changeListenerCallback (void*) { updateSelectionState(); } + + void updateSelectionState() + { + setSelected (editor.getCanvas()->getSelection().isSelected (getItemId()), false); + } + + bool isMissing() { return false; } + const String getTooltip() { return String::empty; } + + protected: + ComponentEditor& editor; + }; + + + //============================================================================== + class ComponentItem : public Base + { + public: + ComponentItem (ComponentEditor& editor_, const ValueTree& componentState_) + : Base (editor_), componentState (componentState_) + { + componentState.addListener (this); + updateSelectionState(); + } + + ~ComponentItem() + { + componentState.removeListener (this); + } + + //============================================================================== + const String getItemId() const { return componentState [ComponentDocument::idProperty]; } + + bool mightContainSubItems() { return false; } + void refreshSubItems() {} + + const String getDisplayName() const { return getRenamingName(); } + const String getRenamingName() const { return componentState [ComponentDocument::memberNameProperty]; } + + Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); } + + const String getDragSourceDescription() { return componentItemDragType; } + + void valueTreePropertyChanged (ValueTree& tree, const var::identifier& property) + { + if (property == ComponentDocument::memberNameProperty) + repaintItem(); + } + + private: + ValueTree componentState; + }; + + //============================================================================== + class ComponentList : public Base + { + public: + ComponentList (ComponentEditor& editor_) + : Base (editor_), componentTree (editor.getDocument().getComponentGroup()) + { + componentTree.addListener (this); + } + + ~ComponentList() + { + componentTree.removeListener (this); + } + + //============================================================================== + const String getItemId() const { return "components"; } + bool mightContainSubItems() { return true; } + + void valueTreeChildrenChanged (ValueTree& tree) + { + if (tree == componentTree) + refreshSubItems(); + } + + void refreshSubItems() + { + ScopedPointer openness (getOpennessState()); + clearSubItems(); + + ComponentDocument& doc = editor.getDocument(); + + const int num = doc.getNumComponents(); + for (int i = 0; i < num; ++i) + addSubItem (new ComponentItem (editor, doc.getComponent (i))); + + if (openness != 0) + restoreOpennessState (*openness); + } + + const String getDisplayName() const { return getRenamingName(); } + const String getRenamingName() const { return "Components"; } + Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } + const String getDragSourceDescription() { return String::empty; } + + private: + ValueTree componentTree; + }; + + + //============================================================================== + class MarkerItem : public Base + { + public: + MarkerItem (ComponentEditor& editor_, const ValueTree& markerState_) + : Base (editor_), markerState (markerState_) + { + markerState.addListener (this); + updateSelectionState(); + } + + ~MarkerItem() + { + markerState.removeListener (this); + } + + //============================================================================== + const String getItemId() const { return markerState [ComponentDocument::idProperty]; } + + bool mightContainSubItems() { return false; } + void refreshSubItems() {} + + const String getDisplayName() const { return getRenamingName(); } + const String getRenamingName() const { return markerState [ComponentDocument::markerNameProperty]; } + + Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); } + + const String getDragSourceDescription() { return componentItemDragType; } + + void valueTreePropertyChanged (ValueTree& tree, const var::identifier& property) + { + if (property == ComponentDocument::markerNameProperty) + repaintItem(); + } + + private: + ValueTree markerState; + }; + + //============================================================================== + class MarkerList : public Base + { + public: + MarkerList (ComponentEditor& editor_, bool isX_) + : Base (editor_), markerList (editor_.getDocument().getMarkerList (isX_).getGroup()), isX (isX_) + { + markerList.addListener (this); + } + + ~MarkerList() + { + markerList.removeListener (this); + } + + //============================================================================== + const String getItemId() const { return isX ? "markersX" : "markersY"; } + bool mightContainSubItems() { return true; } + + void valueTreeChildrenChanged (ValueTree& tree) + { + refreshSubItems(); + } + + void refreshSubItems() + { + ScopedPointer openness (getOpennessState()); + clearSubItems(); + + ComponentDocument::MarkerList& markers = editor.getDocument().getMarkerList (isX); + + const int num = markers.size(); + for (int i = 0; i < num; ++i) + addSubItem (new MarkerItem (editor, markers.getMarker (i))); + + if (openness != 0) + restoreOpennessState (*openness); + } + + const String getDisplayName() const { return getRenamingName(); } + const String getRenamingName() const { return isX ? "Markers (X-axis)" : "Markers (Y-axis)"; } + Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } + const String getDragSourceDescription() { return String::empty; } + + private: + ValueTree markerList; + bool isX; + }; + + //============================================================================== + class Root : public Base + { + public: + Root (ComponentEditor& editor_) : Base (editor_) {} + ~Root() {} + + //============================================================================== + const String getItemId() const { return "root"; } + bool mightContainSubItems() { return true; } + + void refreshSubItems() + { + ScopedPointer openness (getOpennessState()); + clearSubItems(); + + addSubItem (new ComponentList (editor)); + addSubItem (new MarkerList (editor, true)); + addSubItem (new MarkerList (editor, false)); + + if (openness != 0) + restoreOpennessState (*openness); + } + + const String getDisplayName() const { return getRenamingName(); } + const String getRenamingName() const { return editor.getDocument().getClassName().toString(); } + Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); } + const String getDragSourceDescription() { return String::empty; } + }; +} + +#endif // __JUCE_COMPONENTEDITORTREEVIEW_H_F3B95A41__ diff --git a/juce.h b/juce.h index 1f02a950b1..5fc461c247 100644 --- a/juce.h +++ b/juce.h @@ -115,13 +115,13 @@ END_JUCE_NAMESPACE including juce.h */ #ifdef JUCE_DLL - #ifdef JUCE_DEBUG + #if JUCE_DEBUG #define AUTOLINKEDLIB "JUCE_debug.lib" #else #define AUTOLINKEDLIB "JUCE.lib" #endif #else - #ifdef JUCE_DEBUG + #if JUCE_DEBUG #ifdef _WIN64 #define AUTOLINKEDLIB "jucelib_static_x64_debug.lib" #else diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 2c512efacb..aea1f01157 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -174,11 +174,11 @@ #endif #ifndef JUCE_ASIO - #define JUCE_ASIO 0 + #define JUCE_ASIO 1 #endif #ifndef JUCE_WASAPI - #define JUCE_WASAPI 0 + #define JUCE_WASAPI 1 #endif #ifndef JUCE_DIRECTSOUND @@ -190,11 +190,11 @@ #endif #ifndef JUCE_JACK - #define JUCE_JACK 0 + #define JUCE_JACK 1 #endif #if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IPHONE || (JUCE_WINDOWS && ! JUCE_MSVC)) - #define JUCE_QUICKTIME 0 + #define JUCE_QUICKTIME 1 #endif #if (JUCE_IPHONE || JUCE_LINUX) && JUCE_QUICKTIME @@ -214,15 +214,15 @@ #endif #if (! defined (JUCE_USE_CDBURNER)) && ! (JUCE_WINDOWS && ! JUCE_MSVC) - #define JUCE_USE_CDBURNER 0 + #define JUCE_USE_CDBURNER 1 #endif #ifndef JUCE_USE_CDREADER - #define JUCE_USE_CDREADER 0 + #define JUCE_USE_CDREADER 1 #endif #if (JUCE_QUICKTIME || JUCE_WINDOWS) && ! defined (JUCE_USE_CAMERA) - #define JUCE_USE_CAMERA 0 + #define JUCE_USE_CAMERA 1 #endif #ifndef JUCE_ENABLE_REPAINT_DEBUGGING @@ -1452,7 +1452,7 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI() const ScopedAutoReleasePool pool; #endif -#ifdef JUCE_DEBUG +#if JUCE_DEBUG { // Some simple test code to keep an eye on things and make sure these functions // work ok on all platforms. Let me know if any of these assertions fail! @@ -1578,7 +1578,7 @@ void juce_Free (void* const block) free (block); } -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS void* juce_DebugMalloc (const int size, const char* file, const int line) { @@ -8683,7 +8683,7 @@ public: } else { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG file_.numOpenStreams++; #endif } @@ -8702,7 +8702,7 @@ public: ~ZipInputStream() throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG if (inputStream != 0 && inputStream == file.inputStream) file.numOpenStreams--; #endif @@ -8775,7 +8775,7 @@ private: ZipFile::ZipFile (InputStream* const source_, const bool deleteStreamWhenDestroyed) throw() : inputStream (source_) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , numOpenStreams (0) #endif { @@ -8787,7 +8787,7 @@ ZipFile::ZipFile (InputStream* const source_, ZipFile::ZipFile (const File& file) : inputStream (0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , numOpenStreams (0) #endif { @@ -8798,7 +8798,7 @@ ZipFile::ZipFile (const File& file) ZipFile::ZipFile (InputSource* const inputSource_) : inputStream (0), inputSource (inputSource_) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , numOpenStreams (0) #endif { @@ -8807,7 +8807,7 @@ ZipFile::ZipFile (InputSource* const inputSource_) ZipFile::~ZipFile() throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG entries.clear(); // If you hit this assertion, it means you've created a stream to read @@ -13870,7 +13870,7 @@ bool XmlElement::writeToFile (const File& file, bool XmlElement::hasTagName (const String& tagNameWanted) const throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // if debugging, check that the case is actually the same, because // valid xml is case-sensitive, and although this lets it pass, it's // better not to.. @@ -14071,7 +14071,7 @@ bool XmlElement::compareAttribute (const String& attributeName, void XmlElement::setAttribute (const String& attributeName, const String& value) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // check the identifier being passed in is legal.. const juce_wchar* t = attributeName; while (*t != 0) @@ -19974,7 +19974,7 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat, if (newFormat != 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG for (int i = getNumKnownFormats(); --i >= 0;) { if (getKnownFormat (i)->getFormatName() == newFormat->getFormatName()) @@ -20965,7 +20965,9 @@ public: bufferList->mNumberBuffers = 1; bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; bufferList->mBuffers[0].mDataByteSize = (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16; - bufferList->mBuffers[0].mData = malloc (bufferList->mBuffers[0].mDataByteSize); + + dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); + bufferList->mBuffers[0].mData = dataBuffer; sampleRate = inputStreamDesc.mSampleRate; bitsPerSample = 16; @@ -20989,8 +20991,6 @@ public: checkThreadIsAttached(); DisposeMovie (movie); - juce_free (bufferList->mBuffers[0].mData); - #if JUCE_MAC ExitMoviesOnThread (); #endif @@ -21075,6 +21075,7 @@ private: MovieAudioExtractionRef extractor; AudioStreamBasicDescription inputStreamDesc; HeapBlock bufferList; + HeapBlock dataBuffer; Handle dataHandle; void checkThreadIsAttached() @@ -27043,7 +27044,7 @@ MidiMessage::MidiMessage (const void* const d, const int dataSize, const double if (dataSize <= 4) data = static_cast (preallocatedData.asBytes); else - data = static_cast (juce_malloc (dataSize)); + data = new uint8 [dataSize]; memcpy (data, d, dataSize); @@ -27093,7 +27094,7 @@ MidiMessage::MidiMessage (const MidiMessage& other) { if (other.data != static_cast (other.preallocatedData.asBytes)) { - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; memcpy (data, other.data, size); } else @@ -27109,7 +27110,7 @@ MidiMessage::MidiMessage (const MidiMessage& other, const double newTimeStamp) { if (other.data != static_cast (other.preallocatedData.asBytes)) { - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; memcpy (data, other.data, size); } else @@ -27159,7 +27160,7 @@ MidiMessage::MidiMessage (const void* src_, int sz, int& numBytesUsed, const uin size = 1 + (int) (d - src); - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; *data = (uint8) byte; memcpy (data + 1, src, size - 1); } @@ -27169,7 +27170,7 @@ MidiMessage::MidiMessage (const void* src_, int sz, int& numBytesUsed, const uin const int bytesLeft = readVariableLengthVal (src + 1, n); size = jmin (sz + 1, n + 2 + bytesLeft); - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; *data = (uint8) byte; memcpy (data + 1, src, size - 1); } @@ -27205,11 +27206,11 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other) size = other.size; if (data != static_cast (preallocatedData.asBytes)) - juce_free (data); + delete[] data; if (other.data != static_cast (other.preallocatedData.asBytes)) { - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; memcpy (data, other.data, size); } else @@ -27225,7 +27226,7 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other) MidiMessage::~MidiMessage() { if (data != static_cast (preallocatedData.asBytes)) - juce_free (data); + delete[] data; } int MidiMessage::getChannel() const throw() @@ -28542,7 +28543,7 @@ juce_ImplementSingleton_SingleThreaded (AudioPluginFormatManager); void AudioPluginFormatManager::addDefaultFormats() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // you should only call this method once! for (int i = formats.size(); --i >= 0;) { @@ -31732,7 +31733,7 @@ public: if (cfmfp == 0) return 0; - UInt32* const mfp = (UInt32*) juce_malloc (sizeof (UInt32) * 6); + UInt32* const mfp = new UInt32[6]; mfp[0] = 0x3d800000 | ((UInt32) cfmfp >> 16); mfp[1] = 0x618c0000 | ((UInt32) cfmfp & 0xffff); @@ -31747,7 +31748,7 @@ public: static void disposeMachOFromCFM (void* ptr) { - juce_free (ptr); + delete[] static_cast (ptr); } void coerceAEffectFunctionCalls (AEffect* eff) @@ -34094,7 +34095,7 @@ AudioProcessor::~AudioProcessor() // that it refers to is deleted.. jassert (activeEditor == 0); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // This will fail if you've called beginParameterChangeGesture() for one // or more parameters without having made a corresponding call to endParameterChangeGesture... jassert (changingParams.countNumberOfSetBits() == 0); @@ -34172,7 +34173,7 @@ void AudioProcessor::beginParameterChangeGesture (int parameterIndex) { jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // This means you've called beginParameterChangeGesture twice in succession without a matching // call to endParameterChangeGesture. That might be fine in most hosts, but better to avoid doing it. jassert (! changingParams [parameterIndex]); @@ -34197,7 +34198,7 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex) { jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // This means you've called endParameterChangeGesture without having previously called // endParameterChangeGesture. That might be fine in most hosts, but better to keep the // calls matched correctly. @@ -37902,7 +37903,7 @@ private: void addTimer (Timer* const t) throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG Timer* tt = firstTimer; while (tt != 0) @@ -37947,7 +37948,7 @@ private: void removeTimer (Timer* const t) throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG Timer* tt = firstTimer; bool found = false; @@ -38013,7 +38014,7 @@ void juce_callAnyTimersSynchronously() InternalTimerThread::callAnyTimersSynchronously(); } -#ifdef JUCE_DEBUG +#if JUCE_DEBUG static SortedSet activeTimers; #endif @@ -38023,7 +38024,7 @@ Timer::Timer() throw() previous (0), next (0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG activeTimers.add (this); #endif } @@ -38034,7 +38035,7 @@ Timer::Timer (const Timer&) throw() previous (0), next (0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG activeTimers.add (this); #endif } @@ -38043,7 +38044,7 @@ Timer::~Timer() { stopTimer(); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG activeTimers.removeValue (this); #endif } @@ -38052,7 +38053,7 @@ void Timer::startTimer (const int interval) throw() { const ScopedLock sl (InternalTimerThread::lock); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // this isn't a valid object! Your timer might be a dangling pointer or something.. jassert (activeTimers.contains (this)); #endif @@ -38073,7 +38074,7 @@ void Timer::stopTimer() throw() { const ScopedLock sl (InternalTimerThread::lock); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // this isn't a valid object! Your timer might be a dangling pointer or something.. jassert (activeTimers.contains (this)); #endif @@ -38850,7 +38851,7 @@ void Component::setBounds (int x, int y, int w, int h) const bool wasResized = (getWidth() != w || getHeight() != h); const bool wasMoved = (getX() != x || getY() != y); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // It's a very bad idea to try to resize a window during its paint() method! jassert (! (flags.isInsidePaintCall && wasResized && isOnDesktop())); #endif @@ -39700,7 +39701,7 @@ void Component::paintEntireComponent (Graphics& g) { jassert (! g.isClipEmpty()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG flags.isInsidePaintCall = true; #endif @@ -39721,7 +39722,7 @@ void Component::paintEntireComponent (Graphics& g) renderComponent (g); } -#ifdef JUCE_DEBUG +#if JUCE_DEBUG flags.isInsidePaintCall = false; #endif } @@ -53428,7 +53429,7 @@ void Toolbar::addItemInternal (ToolbarItemFactory& factory, if (tc != 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG Array allowedIds; factory.getAllToolbarItemIds (allowedIds); @@ -76627,7 +76628,7 @@ ResizableWindow::ResizableWindow (const String& name, fullscreen (false), lastNonFullScreenPos (50, 50, 256, 256), constrainer (0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , hasBeenResized (false) #endif { @@ -76647,7 +76648,7 @@ ResizableWindow::ResizableWindow (const String& name, fullscreen (false), lastNonFullScreenPos (50, 50, 256, 256), constrainer (0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , hasBeenResized (false) #endif { @@ -76760,7 +76761,7 @@ void ResizableWindow::resized() updateLastPos(); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG hasBeenResized = true; #endif } @@ -76888,7 +76889,7 @@ void ResizableWindow::paint (Graphics& g) getBorderThickness(), *this); } -#ifdef JUCE_DEBUG +#if JUCE_DEBUG /* If this fails, then you've probably written a subclass with a resized() callback but forgotten to make it call its parent class's resized() method. @@ -77095,7 +77096,7 @@ void ResizableWindow::mouseDrag (const MouseEvent& e) dragger.dragComponent (this, e); } -#ifdef JUCE_DEBUG +#if JUCE_DEBUG void ResizableWindow::addChildComponent (Component* const child, int zOrder) { /* Agh! You shouldn't add components directly to a ResizableWindow - this class @@ -78289,7 +78290,7 @@ BEGIN_JUCE_NAMESPACE ColourGradient::ColourGradient() throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG x1 = 987654.0f; #endif } @@ -78391,7 +78392,7 @@ const Colour ColourGradient::getColourAtPosition (const float position) const th int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlock & lookupTable) const { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // trying to use the object without setting its co-ordinates? Have a careful read of // the comments for the constructors. jassert (x1 != 987654.0f); @@ -80299,7 +80300,7 @@ BEGIN_JUCE_NAMESPACE // possible in postscript #define WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS 0 -#if defined (JUCE_DEBUG) && WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS +#if JUCE_DEBUG && WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS #define notPossibleInPostscriptAssert jassertfalse #else #define notPossibleInPostscriptAssert @@ -210787,14 +210788,14 @@ void SystemStats::initialiseStats() throw() String s (SystemStats::getJUCEVersion()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG const MMRESULT res = timeBeginPeriod (1); jassert (res == TIMERR_NOERROR); #else timeBeginPeriod (1); #endif -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif } @@ -211126,7 +211127,7 @@ void juce_killThread (void* handle) { if (handle != 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG OutputDebugString (_T("** Warning - Forced thread termination **\n")); #endif TerminateThread (handle, 0); @@ -211135,7 +211136,7 @@ void juce_killThread (void* handle) void juce_setCurrentThreadName (const String& name) { -#if defined (JUCE_DEBUG) && JUCE_MSVC +#if JUCE_DEBUG && JUCE_MSVC struct { DWORD dwType; @@ -211199,7 +211200,7 @@ static HANDLE sleepEvent = 0; void juce_initialiseThreadEvents() { if (sleepEvent == 0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG sleepEvent = CreateEvent (0, 0, 0, _T("Juce Sleep Event")); #else sleepEvent = CreateEvent (0, 0, 0, 0); @@ -211282,7 +211283,7 @@ void Process::lowerPrivilege() void Process::terminate() { -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS _CrtDumpMemoryLeaks(); #endif @@ -212449,10 +212450,8 @@ int juce_seekInInternetFile (void* handle, int newPosition) const ConnectionAndRequestStruct* const crs = static_cast (handle); return InternetSetFilePointer (crs->request, newPosition, 0, FILE_BEGIN, 0); } - else - { - return -1; - } + + return -1; } int64 juce_getInternetFileContentLength (void* handle) @@ -212526,12 +212525,6 @@ static int getMACAddressViaGetAdaptersInfo (int64* addresses, int maxNum, const return numFound; } -struct ASTAT -{ - ADAPTER_STATUS adapt; - NAME_BUFFER NameBuff [30]; -}; - static int getMACAddressesViaNetBios (int64* addresses, int maxNum, const bool littleEndian) throw() { int numFound = 0; @@ -212544,6 +212537,12 @@ static int getMACAddressesViaNetBios (int64* addresses, int maxNum, const bool l NCB ncb; zerostruct (ncb); + struct ASTAT + { + ADAPTER_STATUS adapt; + NAME_BUFFER NameBuff [30]; + }; + ASTAT astat; zerostruct (astat); @@ -212600,8 +212599,6 @@ int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littl return numFound; } -typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); - bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, const String& emailSubject, const String& bodyText, @@ -212609,6 +212606,8 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd { HMODULE h = LoadLibraryA ("MAPI32.dll"); + typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); + MAPISendMailType mapiSendMail = (MAPISendMailType) GetProcAddress (h, "MAPISendMail"); bool ok = false; @@ -218765,8 +218764,8 @@ public: int numFrames; int dataStartOffset; int dataLength; - BYTE* buffer; int bufferSize; + HeapBlock buffer; int index; bool wantsIndex; @@ -218775,19 +218774,14 @@ public: numFrames (0), dataStartOffset (0), dataLength (0), + bufferSize (2352 * numberOfFrames), + buffer (bufferSize), index (0), wantsIndex (false) { - bufferSize = 2352 * numberOfFrames; - buffer = (BYTE*) juce_malloc (bufferSize); } - ~CDReadBuffer() - { - juce_free (buffer); - } - - bool isZero() const + bool isZero() const throw() { BYTE* p = buffer + dataStartOffset; @@ -224121,12 +224115,10 @@ public: isStarted (false), outputDeviceIndex (outputDeviceIndex_), inputDeviceIndex (inputDeviceIndex_), - numInputBuffers (0), - numOutputBuffers (0), totalSamplesOut (0), sampleRate (0.0), - inputBuffers (0), - outputBuffers (0), + inputBuffers (1, 1), + outputBuffers (1, 1), callback (0), bufferSizeSamples (0) { @@ -224323,12 +224315,13 @@ private: OwnedArray outChans; WaitableEvent startEvent; - int numInputBuffers, numOutputBuffers, bufferSizeSamples; + int bufferSizeSamples; int volatile totalSamplesOut; int64 volatile lastBlockTime; double sampleRate; BigInteger enabledInputs, enabledOutputs; - HeapBlock inputBuffers, outputBuffers; + + AudioSampleBuffer inputBuffers, outputBuffers; AudioIODeviceCallback* callback; CriticalSection startStopLock; @@ -224348,19 +224341,8 @@ private: inChans.clear(); outChans.clear(); - - int i; - for (i = 0; i < numInputBuffers; ++i) - juce_free (inputBuffers[i]); - - inputBuffers.free(); - numInputBuffers = 0; - - for (i = 0; i < numOutputBuffers; ++i) - juce_free (outputBuffers[i]); - - outputBuffers.free(); - numOutputBuffers = 0; + inputBuffers.setSize (1, 1); + outputBuffers.setSize (1, 1); } void resync() @@ -224467,10 +224449,10 @@ public: { JUCE_TRY { - callback->audioDeviceIOCallback (const_cast (inputBuffers.getData()), - numInputBuffers, - outputBuffers, - numOutputBuffers, + callback->audioDeviceIOCallback (const_cast (inputBuffers.getArrayOfChannels()), + inputBuffers.getNumChannels(), + outputBuffers.getArrayOfChannels(), + outputBuffers.getNumChannels(), bufferSizeSamples); } JUCE_CATCH_EXCEPTION @@ -224479,10 +224461,7 @@ public: } else { - for (i = 0; i < numOutputBuffers; ++i) - if (outputBuffers[i] != 0) - zeromem (outputBuffers[i], bufferSizeSamples * sizeof (float)); - + outputBuffers.clear(); totalSamplesOut = 0; sleep (1); } @@ -224672,20 +224651,18 @@ const String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, enabledInputs.getHighestBit() + 1 - inChannels.size(), false); - numInputBuffers = enabledInputs.countNumberOfSetBits(); - inputBuffers.calloc (numInputBuffers + 2); + inputBuffers.setSize (enabledInputs.countNumberOfSetBits(), bufferSizeSamples); int i, numIns = 0; for (i = 0; i <= enabledInputs.getHighestBit(); i += 2) { float* left = 0; - float* right = 0; - if (enabledInputs[i]) - left = inputBuffers[numIns++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + left = inputBuffers.getSampleData (numIns++); + float* right = 0; if (enabledInputs[i + 1]) - right = inputBuffers[numIns++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + right = inputBuffers.getSampleData (numIns++); if (left != 0 || right != 0) inChans.add (new DSoundInternalInChannel (dlh.inputDeviceNames [inputDeviceIndex], @@ -224699,20 +224676,18 @@ const String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, enabledOutputs.getHighestBit() + 1 - outChannels.size(), false); - numOutputBuffers = enabledOutputs.countNumberOfSetBits(); - outputBuffers.calloc (numOutputBuffers + 2); + outputBuffers.setSize (enabledOutputs.countNumberOfSetBits(), bufferSizeSamples); int numOuts = 0; for (i = 0; i <= enabledOutputs.getHighestBit(); i += 2) { float* left = 0; - float* right = 0; - if (enabledOutputs[i]) - left = outputBuffers[numOuts++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + left = outputBuffers.getSampleData (numOuts++); + float* right = 0; if (enabledOutputs[i + 1]) - right = outputBuffers[numOuts++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + right = outputBuffers.getSampleData (numOuts++); if (left != 0 || right != 0) outChans.add (new DSoundInternalOutChannel (dlh.outputDeviceNames[outputDeviceIndex], @@ -228692,7 +228667,7 @@ void* PlatformUtilities::getProcedureEntryPoint (void* libraryHandle, const Stri // compiled on its own). #if JUCE_INCLUDED_FILE -#ifdef JUCE_DEBUG +#if JUCE_DEBUG #define JUCE_DEBUG_XERRORS 1 #endif @@ -228924,14 +228899,14 @@ const String SystemClipboard::getTextFromClipboard() // compiled on its own). #if JUCE_INCLUDED_FILE -#ifdef JUCE_DEBUG +#if JUCE_DEBUG && ! defined (JUCE_DEBUG_XERRORS) #define JUCE_DEBUG_XERRORS 1 #endif Display* display = 0; // This is also referenced from WindowDriver.cpp Window juce_messageWindowHandle = None; -XContext improbableNumber; // This is referenced from Windowing.cpp +XContext windowHandleXContext; // This is referenced from Windowing.cpp extern void juce_windowMessageReceive (XEvent* event); // Defined in Windowing.cpp extern void juce_handleSelectionRequest (XSelectionRequestEvent &evt); // Defined in Clipboard.cpp @@ -229057,7 +229032,7 @@ static int ioErrorHandler (Display* display) // A protocol error has occurred static int errorHandler (Display* display, XErrorEvent* event) { -#ifdef JUCE_DEBUG_XERRORS +#if JUCE_DEBUG_XERRORS char errorStr[64] = { 0 }; char requestStr[64] = { 0 }; @@ -229171,7 +229146,7 @@ void MessageManager::doPlatformSpecificInitialisation() // Create a context to store user data associated with Windows we // create in WindowDriver - improbableNumber = XUniqueContext(); + windowHandleXContext = XUniqueContext(); // We're only interested in client messages for this window // which are always sent @@ -229826,7 +229801,7 @@ public: if (face == 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG String msg ("Failed to create typeface: "); msg << font.getTypefaceName() << " " << (font.isBold() ? 'B' : ' ') << (font.isItalic() ? 'I' : ' '); DBG (msg); @@ -229929,7 +229904,7 @@ void Font::getPlatformDefaultFontNames (String& defaultSans, String& defaultSeri // These are defined in juce_linux_Messaging.cpp extern Display* display; -extern XContext improbableNumber; +extern XContext windowHandleXContext; namespace Atoms { @@ -230609,7 +230584,7 @@ public: XPointer peer = 0; ScopedXLock xlock; - if (! XFindContext (display, (XID) windowHandle, improbableNumber, &peer)) + if (! XFindContext (display, (XID) windowHandle, windowHandleXContext, &peer)) { if (peer != 0 && ! ComponentPeer::isValidPeer ((LinuxComponentPeer*) peer)) peer = 0; @@ -232129,7 +232104,7 @@ private: GrabModeAsync, GrabModeAsync, None, None); // Set the window context to identify the window handle object - if (XSaveContext (display, (XID) wndH, improbableNumber, (XPointer) this)) + if (XSaveContext (display, (XID) wndH, windowHandleXContext, (XPointer) this)) { // Failed jassertfalse @@ -232222,8 +232197,8 @@ private: ScopedXLock xlock; XPointer handlePointer; - if (! XFindContext (display, (XID) windowH, improbableNumber, &handlePointer)) - XDeleteContext (display, (XID) windowH, improbableNumber); + if (! XFindContext (display, (XID) windowH, windowHandleXContext, &handlePointer)) + XDeleteContext (display, (XID) windowH, windowHandleXContext); XDestroyWindow (display, windowH); @@ -233116,7 +233091,7 @@ public: CWBorderPixel | CWColormap | CWEventMask, &swa); - XSaveContext (display, (XID) embeddedWindow, improbableNumber, (XPointer) peer); + XSaveContext (display, (XID) embeddedWindow, windowHandleXContext, (XPointer) peer); XMapWindow (display, embeddedWindow); XFreeColormap (display, colourMap); @@ -233548,8 +233523,11 @@ public: return true; } - bool write (float** const data, const int numSamples) + bool write (AudioSampleBuffer& outputChannels, const int numSamples) { + jassert (numChannelsRunning <= outputChannels.getNumChannels()); + float** const data = outputChannels.getArrayOfChannels(); + if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); @@ -233586,8 +233564,11 @@ public: return true; } - bool read (float** const data, const int numSamples) + bool read (AudioSampleBuffer& inputChannels, const int numSamples) { + jassert (numChannelsRunning <= inputChannels.getNumChannels()); + float** const data = inputChannels.getArrayOfChannels(); + if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); @@ -233661,14 +233642,9 @@ public: outputDevice (0), inputDevice (0), numCallbacks (0), - totalNumInputChannels (0), - totalNumOutputChannels (0) + inputChannels (1, 1), + outputChannels (1, 1) { - zeromem (outputChannelData, sizeof (outputChannelData)); - zeromem (outputChannelDataForCallback, sizeof (outputChannelDataForCallback)); - zeromem (inputChannelData, sizeof (inputChannelData)); - zeromem (inputChannelDataForCallback, sizeof (inputChannelDataForCallback)); - initialiseRatesAndChannels(); } @@ -233687,38 +233663,42 @@ public: error = String::empty; sampleRate = sampleRate_; bufferSize = bufferSize_; + + inputChannels.setSize (jmax ((int) minChansIn, inputChannels.getHighestBit()) + 1, bufferSize); + inputChannels.clear(); + inputChannelDataForCallback.clear(); currentInputChans.clear(); - currentOutputChans.clear(); if (inputChannels.getHighestBit() >= 0) { for (int i = 0; i <= jmax (inputChannels.getHighestBit(), (int) minChansIn); ++i) { - inputChannelData [i] = (float*) juce_calloc (sizeof (float) * bufferSize); - if (inputChannels[i]) { - inputChannelDataForCallback [totalNumInputChannels++] = inputChannelData [i]; + inputChannelDataForCallback.add (inputChannels.getSampleData (i)); currentInputChans.setBit (i); } } } + outputChannels.setSize (jmax ((int) minChansOut, outputChannels.getHighestBit()) + 1, bufferSize); + outputChannels.clear(); + outputChannelDataForCallback.clear(); + currentOutputChans.clear(); + if (outputChannels.getHighestBit() >= 0) { for (int i = 0; i <= jmax (outputChannels.getHighestBit(), (int) minChansOut); ++i) { - outputChannelData [i] = (float*) juce_calloc (sizeof (float) * bufferSize); - if (outputChannels[i]) { - outputChannelDataForCallback [totalNumOutputChannels++] = outputChannelData [i]; + outputChannelDataForCallback.add (outputChannels.getSampleData (i)); currentOutputChans.setBit (i); } } } - if (totalNumOutputChannels > 0 && outputId.isNotEmpty()) + if (outputChannelDataForCallback.size() > 0 && outputId.isNotEmpty()) { outputDevice = new ALSADevice (outputId, false); @@ -233741,7 +233721,7 @@ public: } } - if (totalNumInputChannels > 0 && inputId.isNotEmpty()) + if (inputChannelDataForCallback.size() > 0 && inputId.isNotEmpty()) { inputDevice = new ALSADevice (inputId, true); @@ -233804,18 +233784,8 @@ public: deleteAndZero (inputDevice); deleteAndZero (outputDevice); - for (int i = 0; i < maxNumChans; ++i) - { - juce_free (inputChannelData [i]); - juce_free (outputChannelData [i]); - } - - zeromem (outputChannelData, sizeof (outputChannelData)); - zeromem (outputChannelDataForCallback, sizeof (outputChannelDataForCallback)); - zeromem (inputChannelData, sizeof (inputChannelData)); - zeromem (inputChannelDataForCallback, sizeof (inputChannelDataForCallback)); - totalNumOutputChannels = 0; - totalNumInputChannels = 0; + inputChannels.setSize (1, 1); + outputChannels.setSize (1, 1); numCallbacks = 0; } @@ -233832,7 +233802,7 @@ public: { if (inputDevice != 0) { - if (! inputDevice->read (inputChannelData, bufferSize)) + if (! inputDevice->read (inputChannels, bufferSize)) { DBG ("ALSA: read failure"); break; @@ -233848,10 +233818,10 @@ public: if (callback != 0) { - callback->audioDeviceIOCallback ((const float**) inputChannelDataForCallback, - totalNumInputChannels, - outputChannelDataForCallback, - totalNumOutputChannels, + callback->audioDeviceIOCallback ((const float**) inputChannelDataForCallback.getRawDataPointer(), + inputChannelDataForCallback.size(), + outputChannelDataForCallback.getRawDataPointer(), + outputChannelDataForCallback.size(), bufferSize); } else @@ -233910,12 +233880,8 @@ private: CriticalSection callbackLock; - float* outputChannelData [maxNumChans]; - float* outputChannelDataForCallback [maxNumChans]; - int totalNumInputChannels; - float* inputChannelData [maxNumChans]; - float* inputChannelDataForCallback [maxNumChans]; - int totalNumOutputChannels; + AudioSampleBuffer inputChannels, outputChannels; + Array inputChannelDataForCallback, outputChannelDataForCallback; unsigned int minChansOut, maxChansOut; unsigned int minChansIn, maxChansIn; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index ff3249b03a..d6b1fe42f7 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -195,11 +195,11 @@ #endif #ifndef JUCE_ASIO - #define JUCE_ASIO 0 + #define JUCE_ASIO 1 #endif #ifndef JUCE_WASAPI - #define JUCE_WASAPI 0 + #define JUCE_WASAPI 1 #endif #ifndef JUCE_DIRECTSOUND @@ -211,11 +211,11 @@ #endif #ifndef JUCE_JACK - #define JUCE_JACK 0 + #define JUCE_JACK 1 #endif #if ! (defined (JUCE_QUICKTIME) || JUCE_LINUX || JUCE_IPHONE || (JUCE_WINDOWS && ! JUCE_MSVC)) - #define JUCE_QUICKTIME 0 + #define JUCE_QUICKTIME 1 #endif #if (JUCE_IPHONE || JUCE_LINUX) && JUCE_QUICKTIME @@ -235,15 +235,15 @@ #endif #if (! defined (JUCE_USE_CDBURNER)) && ! (JUCE_WINDOWS && ! JUCE_MSVC) - #define JUCE_USE_CDBURNER 0 + #define JUCE_USE_CDBURNER 1 #endif #ifndef JUCE_USE_CDREADER - #define JUCE_USE_CDREADER 0 + #define JUCE_USE_CDREADER 1 #endif #if (JUCE_QUICKTIME || JUCE_WINDOWS) && ! defined (JUCE_USE_CAMERA) - #define JUCE_USE_CAMERA 0 + #define JUCE_USE_CAMERA 1 #endif #ifndef JUCE_ENABLE_REPAINT_DEBUGGING @@ -367,13 +367,13 @@ // (For info about JUCE_LOG_ASSERTIONS, have a look in juce_Config.h) #if JUCE_LOG_ASSERTIONS #define juce_LogCurrentAssertion juce_LogAssertion (__FILE__, __LINE__); -#elif defined (JUCE_DEBUG) +#elif JUCE_DEBUG #define juce_LogCurrentAssertion std::cerr << "JUCE Assertion failure in " << __FILE__ << ", line " << __LINE__ << std::endl; #else #define juce_LogCurrentAssertion #endif -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // If debugging is enabled.. @@ -586,7 +586,7 @@ extern bool JUCE_PUBLIC_FUNCTION juce_isRunningUnderDebugger(); #ifndef __JUCE_MEMORY_JUCEHEADER__ #define __JUCE_MEMORY_JUCEHEADER__ -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS #ifndef JUCE_DLL // Win32 debug non-DLL versions.. @@ -2087,6 +2087,11 @@ public: : ElementType(); } + inline ElementType* getRawDataPointer() throw() + { + return data.elements; + } + int indexOf (ParameterType elementToLookFor) const { const ScopedLockType lock (getLock()); @@ -8119,7 +8124,7 @@ private: ScopedPointer streamToDelete; ScopedPointer inputSource; -#ifdef JUCE_DEBUG +#if JUCE_DEBUG int numOpenStreams; #endif @@ -13026,7 +13031,7 @@ private: bool currentlyModalFlag : 1; bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; -#ifdef JUCE_DEBUG +#if JUCE_DEBUG bool isInsidePaintCall : 1; #endif }; @@ -18124,7 +18129,7 @@ private: bool suspended, nonRealtime; CriticalSection callbackLock, listenerLock; -#ifdef JUCE_DEBUG +#if JUCE_DEBUG BigInteger changingParams; #endif @@ -23313,7 +23318,7 @@ protected: virtual const BorderSize getContentComponentBorder(); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG void addChildComponent (Component* child, int zOrder = -1); void addAndMakeVisible (Component* child, int zOrder = -1); @@ -23329,7 +23334,7 @@ private: Rectangle lastNonFullScreenPos; ComponentBoundsConstrainer defaultConstrainer; ComponentBoundsConstrainer* constrainer; - #ifdef JUCE_DEBUG + #if JUCE_DEBUG bool hasBeenResized; #endif @@ -28939,13 +28944,13 @@ END_JUCE_NAMESPACE #ifndef DONT_AUTOLINK_TO_JUCE_LIBRARY #ifdef JUCE_DLL - #ifdef JUCE_DEBUG + #if JUCE_DEBUG #define AUTOLINKEDLIB "JUCE_debug.lib" #else #define AUTOLINKEDLIB "JUCE.lib" #endif #else - #ifdef JUCE_DEBUG + #if JUCE_DEBUG #ifdef _WIN64 #define AUTOLINKEDLIB "jucelib_static_x64_debug.lib" #else diff --git a/src/audio/audio_file_formats/juce_AudioFormatManager.cpp b/src/audio/audio_file_formats/juce_AudioFormatManager.cpp index f346a5d4a6..7685343999 100644 --- a/src/audio/audio_file_formats/juce_AudioFormatManager.cpp +++ b/src/audio/audio_file_formats/juce_AudioFormatManager.cpp @@ -59,7 +59,7 @@ void AudioFormatManager::registerFormat (AudioFormat* newFormat, if (newFormat != 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG for (int i = getNumKnownFormats(); --i >= 0;) { if (getKnownFormat (i)->getFormatName() == newFormat->getFormatName()) diff --git a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp index d67618f6df..8bfbe82a25 100644 --- a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp @@ -197,7 +197,9 @@ public: bufferList->mNumberBuffers = 1; bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; bufferList->mBuffers[0].mDataByteSize = (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16; - bufferList->mBuffers[0].mData = malloc (bufferList->mBuffers[0].mDataByteSize); + + dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); + bufferList->mBuffers[0].mData = dataBuffer; sampleRate = inputStreamDesc.mSampleRate; bitsPerSample = 16; @@ -221,8 +223,6 @@ public: checkThreadIsAttached(); DisposeMovie (movie); - juce_free (bufferList->mBuffers[0].mData); - #if JUCE_MAC ExitMoviesOnThread (); #endif @@ -307,6 +307,7 @@ private: MovieAudioExtractionRef extractor; AudioStreamBasicDescription inputStreamDesc; HeapBlock bufferList; + HeapBlock dataBuffer; Handle dataHandle; //============================================================================== diff --git a/src/audio/midi/juce_MidiMessage.cpp b/src/audio/midi/juce_MidiMessage.cpp index bc14ae6e1c..d29d06a36e 100644 --- a/src/audio/midi/juce_MidiMessage.cpp +++ b/src/audio/midi/juce_MidiMessage.cpp @@ -85,7 +85,7 @@ MidiMessage::MidiMessage (const void* const d, const int dataSize, const double if (dataSize <= 4) data = static_cast (preallocatedData.asBytes); else - data = static_cast (juce_malloc (dataSize)); + data = new uint8 [dataSize]; memcpy (data, d, dataSize); @@ -135,7 +135,7 @@ MidiMessage::MidiMessage (const MidiMessage& other) { if (other.data != static_cast (other.preallocatedData.asBytes)) { - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; memcpy (data, other.data, size); } else @@ -151,7 +151,7 @@ MidiMessage::MidiMessage (const MidiMessage& other, const double newTimeStamp) { if (other.data != static_cast (other.preallocatedData.asBytes)) { - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; memcpy (data, other.data, size); } else @@ -201,7 +201,7 @@ MidiMessage::MidiMessage (const void* src_, int sz, int& numBytesUsed, const uin size = 1 + (int) (d - src); - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; *data = (uint8) byte; memcpy (data + 1, src, size - 1); } @@ -211,7 +211,7 @@ MidiMessage::MidiMessage (const void* src_, int sz, int& numBytesUsed, const uin const int bytesLeft = readVariableLengthVal (src + 1, n); size = jmin (sz + 1, n + 2 + bytesLeft); - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; *data = (uint8) byte; memcpy (data + 1, src, size - 1); } @@ -247,11 +247,11 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other) size = other.size; if (data != static_cast (preallocatedData.asBytes)) - juce_free (data); + delete[] data; if (other.data != static_cast (other.preallocatedData.asBytes)) { - data = static_cast (juce_malloc (size)); + data = new uint8 [size]; memcpy (data, other.data, size); } else @@ -267,7 +267,7 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other) MidiMessage::~MidiMessage() { if (data != static_cast (preallocatedData.asBytes)) - juce_free (data); + delete[] data; } int MidiMessage::getChannel() const throw() diff --git a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp index ac99ed734c..f674775faa 100644 --- a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp @@ -639,7 +639,7 @@ public: if (cfmfp == 0) return 0; - UInt32* const mfp = (UInt32*) juce_malloc (sizeof (UInt32) * 6); + UInt32* const mfp = new UInt32[6]; mfp[0] = 0x3d800000 | ((UInt32) cfmfp >> 16); mfp[1] = 0x618c0000 | ((UInt32) cfmfp & 0xffff); @@ -654,7 +654,7 @@ public: static void disposeMachOFromCFM (void* ptr) { - juce_free (ptr); + delete[] static_cast (ptr); } void coerceAEffectFunctionCalls (AEffect* eff) diff --git a/src/audio/plugins/juce_AudioPluginFormatManager.cpp b/src/audio/plugins/juce_AudioPluginFormatManager.cpp index bac9d48036..a441177d02 100644 --- a/src/audio/plugins/juce_AudioPluginFormatManager.cpp +++ b/src/audio/plugins/juce_AudioPluginFormatManager.cpp @@ -52,7 +52,7 @@ juce_ImplementSingleton_SingleThreaded (AudioPluginFormatManager); //============================================================================== void AudioPluginFormatManager::addDefaultFormats() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // you should only call this method once! for (int i = formats.size(); --i >= 0;) { diff --git a/src/audio/processors/juce_AudioProcessor.cpp b/src/audio/processors/juce_AudioProcessor.cpp index 996001b49d..8522aac67f 100644 --- a/src/audio/processors/juce_AudioProcessor.cpp +++ b/src/audio/processors/juce_AudioProcessor.cpp @@ -52,7 +52,7 @@ AudioProcessor::~AudioProcessor() // that it refers to is deleted.. jassert (activeEditor == 0); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // This will fail if you've called beginParameterChangeGesture() for one // or more parameters without having made a corresponding call to endParameterChangeGesture... jassert (changingParams.countNumberOfSetBits() == 0); @@ -130,7 +130,7 @@ void AudioProcessor::beginParameterChangeGesture (int parameterIndex) { jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // This means you've called beginParameterChangeGesture twice in succession without a matching // call to endParameterChangeGesture. That might be fine in most hosts, but better to avoid doing it. jassert (! changingParams [parameterIndex]); @@ -155,7 +155,7 @@ void AudioProcessor::endParameterChangeGesture (int parameterIndex) { jassert (((unsigned int) parameterIndex) < (unsigned int) getNumParameters()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // This means you've called endParameterChangeGesture without having previously called // endParameterChangeGesture. That might be fine in most hosts, but better to keep the // calls matched correctly. diff --git a/src/audio/processors/juce_AudioProcessor.h b/src/audio/processors/juce_AudioProcessor.h index 61d5763c8a..fe845dd7b8 100644 --- a/src/audio/processors/juce_AudioProcessor.h +++ b/src/audio/processors/juce_AudioProcessor.h @@ -578,7 +578,7 @@ private: bool suspended, nonRealtime; CriticalSection callbackLock, listenerLock; -#ifdef JUCE_DEBUG +#if JUCE_DEBUG BigInteger changingParams; #endif diff --git a/src/containers/juce_Array.h b/src/containers/juce_Array.h index 0732e46b09..ba994ebedf 100644 --- a/src/containers/juce_Array.h +++ b/src/containers/juce_Array.h @@ -277,6 +277,15 @@ public: : ElementType(); } + /** Returns a pointer to the actual array data. + This pointer will only be valid until the next time a non-const method + is called on the array. + */ + inline ElementType* getRawDataPointer() throw() + { + return data.elements; + } + //============================================================================== /** Finds the index of the first element which matches the value passed in. diff --git a/src/containers/juce_OwnedArray.h b/src/containers/juce_OwnedArray.h index 4eeaca22d8..47c4ff47f4 100644 --- a/src/containers/juce_OwnedArray.h +++ b/src/containers/juce_OwnedArray.h @@ -150,6 +150,15 @@ public: : static_cast (0); } + /** Returns a pointer to the actual array data. + This pointer will only be valid until the next time a non-const method + is called on the array. + */ + inline ObjectClass** getRawDataPointer() throw() + { + return data.elements; + } + //============================================================================== /** Finds the index of an object which might be in the array. diff --git a/src/core/juce_Memory.h b/src/core/juce_Memory.h index 37b084d0d1..a8f59cccc0 100644 --- a/src/core/juce_Memory.h +++ b/src/core/juce_Memory.h @@ -32,7 +32,7 @@ preference to the standard calls. */ -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS #ifndef JUCE_DLL //============================================================================== // Win32 debug non-DLL versions.. diff --git a/src/core/juce_PlatformDefs.h b/src/core/juce_PlatformDefs.h index a0d8e60d2e..4458137141 100644 --- a/src/core/juce_PlatformDefs.h +++ b/src/core/juce_PlatformDefs.h @@ -52,13 +52,13 @@ // (For info about JUCE_LOG_ASSERTIONS, have a look in juce_Config.h) #if JUCE_LOG_ASSERTIONS #define juce_LogCurrentAssertion juce_LogAssertion (__FILE__, __LINE__); -#elif defined (JUCE_DEBUG) +#elif JUCE_DEBUG #define juce_LogCurrentAssertion std::cerr << "JUCE Assertion failure in " << __FILE__ << ", line " << __LINE__ << std::endl; #else #define juce_LogCurrentAssertion #endif -#ifdef JUCE_DEBUG +#if JUCE_DEBUG //============================================================================== // If debugging is enabled.. diff --git a/src/core/juce_SystemStats.cpp b/src/core/juce_SystemStats.cpp index 78ba9537e7..f03088532c 100644 --- a/src/core/juce_SystemStats.cpp +++ b/src/core/juce_SystemStats.cpp @@ -78,7 +78,7 @@ void JUCE_PUBLIC_FUNCTION initialiseJuce_NonGUI() const ScopedAutoReleasePool pool; #endif -#ifdef JUCE_DEBUG +#if JUCE_DEBUG { // Some simple test code to keep an eye on things and make sure these functions // work ok on all platforms. Let me know if any of these assertions fail! @@ -205,7 +205,7 @@ void juce_Free (void* const block) free (block); } -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS void* juce_DebugMalloc (const int size, const char* file, const int line) { diff --git a/src/events/juce_Timer.cpp b/src/events/juce_Timer.cpp index 0426d627fd..7da04b1544 100644 --- a/src/events/juce_Timer.cpp +++ b/src/events/juce_Timer.cpp @@ -245,7 +245,7 @@ private: //============================================================================== void addTimer (Timer* const t) throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG Timer* tt = firstTimer; while (tt != 0) @@ -290,7 +290,7 @@ private: void removeTimer (Timer* const t) throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG Timer* tt = firstTimer; bool found = false; @@ -357,7 +357,7 @@ void juce_callAnyTimersSynchronously() } //============================================================================== -#ifdef JUCE_DEBUG +#if JUCE_DEBUG static SortedSet activeTimers; #endif @@ -367,7 +367,7 @@ Timer::Timer() throw() previous (0), next (0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG activeTimers.add (this); #endif } @@ -378,7 +378,7 @@ Timer::Timer (const Timer&) throw() previous (0), next (0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG activeTimers.add (this); #endif } @@ -387,7 +387,7 @@ Timer::~Timer() { stopTimer(); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG activeTimers.removeValue (this); #endif } @@ -396,7 +396,7 @@ void Timer::startTimer (const int interval) throw() { const ScopedLock sl (InternalTimerThread::lock); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // this isn't a valid object! Your timer might be a dangling pointer or something.. jassert (activeTimers.contains (this)); #endif @@ -417,7 +417,7 @@ void Timer::stopTimer() throw() { const ScopedLock sl (InternalTimerThread::lock); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // this isn't a valid object! Your timer might be a dangling pointer or something.. jassert (activeTimers.contains (this)); #endif diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp index b2abf7c1b4..20c4f7bb88 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.cpp +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.cpp @@ -348,6 +348,11 @@ void CodeEditorComponent::loadContent (const String& newContent) scrollToLine (0); } +bool CodeEditorComponent::isTextInputActive() const +{ + return true; +} + //============================================================================== void CodeEditorComponent::codeDocumentChanged (const CodeDocument::Position& affectedTextStart, const CodeDocument::Position& affectedTextEnd) diff --git a/src/gui/components/code_editor/juce_CodeEditorComponent.h b/src/gui/components/code_editor/juce_CodeEditorComponent.h index 5e680c048a..8453c7b91a 100644 --- a/src/gui/components/code_editor/juce_CodeEditorComponent.h +++ b/src/gui/components/code_editor/juce_CodeEditorComponent.h @@ -253,6 +253,8 @@ public: /** @internal */ void codeDocumentChanged (const CodeDocument::Position& affectedTextStart, const CodeDocument::Position& affectedTextEnd); + /** @internal */ + bool isTextInputActive() const; //============================================================================== juce_UseDebuggingNewOperator diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 3e6e3333ff..28b5fb986a 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -1072,6 +1072,11 @@ bool TextEditor::isReadOnly() const return readOnly || ! isEnabled(); } +bool TextEditor::isTextInputActive() const +{ + return ! isReadOnly(); +} + void TextEditor::setReturnKeyStartsNewLine (const bool shouldStartNewLine) { returnKeyStartsNewLine = shouldStartNewLine; diff --git a/src/gui/components/controls/juce_TextEditor.h b/src/gui/components/controls/juce_TextEditor.h index 16c172a8e2..6ea365b90f 100644 --- a/src/gui/components/controls/juce_TextEditor.h +++ b/src/gui/components/controls/juce_TextEditor.h @@ -535,6 +535,8 @@ public: void enablementChanged(); /** @internal */ void colourChanged(); + /** @internal */ + bool isTextInputActive() const; juce_UseDebuggingNewOperator diff --git a/src/gui/components/controls/juce_Toolbar.cpp b/src/gui/components/controls/juce_Toolbar.cpp index bfc2ce4140..4f96339b7d 100644 --- a/src/gui/components/controls/juce_Toolbar.cpp +++ b/src/gui/components/controls/juce_Toolbar.cpp @@ -329,7 +329,7 @@ void Toolbar::addItemInternal (ToolbarItemFactory& factory, if (tc != 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG Array allowedIds; factory.getAllToolbarItemIds (allowedIds); diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 975d8e5b2e..ed30b1ce2f 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -812,7 +812,7 @@ void Component::setBounds (int x, int y, int w, int h) const bool wasResized = (getWidth() != w || getHeight() != h); const bool wasMoved = (getX() != x || getY() != y); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // It's a very bad idea to try to resize a window during its paint() method! jassert (! (flags.isInsidePaintCall && wasResized && isOnDesktop())); #endif @@ -1673,7 +1673,7 @@ void Component::paintEntireComponent (Graphics& g) { jassert (! g.isClipEmpty()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG flags.isInsidePaintCall = true; #endif @@ -1694,7 +1694,7 @@ void Component::paintEntireComponent (Graphics& g) renderComponent (g); } -#ifdef JUCE_DEBUG +#if JUCE_DEBUG flags.isInsidePaintCall = false; #endif } diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 5dc745ca6d..1f8520b288 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -2026,7 +2026,7 @@ private: bool currentlyModalFlag : 1; bool isDisabledFlag : 1; bool childCompFocusedFlag : 1; -#ifdef JUCE_DEBUG +#if JUCE_DEBUG bool isInsidePaintCall : 1; #endif }; diff --git a/src/gui/components/keyboard/juce_TextInputTarget.h b/src/gui/components/keyboard/juce_TextInputTarget.h index 2383152279..df3bf9894d 100644 --- a/src/gui/components/keyboard/juce_TextInputTarget.h +++ b/src/gui/components/keyboard/juce_TextInputTarget.h @@ -47,6 +47,11 @@ public: /** Destructor. */ virtual ~TextInputTarget() {} + /** Returns true if this input target is currently accepting input. + For example, a text editor might return false if it's in read-only mode. + */ + virtual bool isTextInputActive() const = 0; + /** Returns the extents of the selected text region, or an empty range if nothing is selected, */ diff --git a/src/gui/components/windows/juce_ComponentPeer.cpp b/src/gui/components/windows/juce_ComponentPeer.cpp index e2a9696f50..8c087565c3 100644 --- a/src/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/gui/components/windows/juce_ComponentPeer.cpp @@ -270,7 +270,11 @@ TextInputTarget* ComponentPeer::findCurrentTextInputTarget() { Component* const c = Component::getCurrentlyFocusedComponent(); if (component->isParentOf (c)) - return dynamic_cast (c); + { + TextInputTarget* const ti = dynamic_cast (c); + if (ti != 0 && ti->isTextInputActive()) + return ti; + } return 0; } diff --git a/src/gui/components/windows/juce_ResizableWindow.cpp b/src/gui/components/windows/juce_ResizableWindow.cpp index 744dd48d28..c2238a049b 100644 --- a/src/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/gui/components/windows/juce_ResizableWindow.cpp @@ -43,7 +43,7 @@ ResizableWindow::ResizableWindow (const String& name, fullscreen (false), lastNonFullScreenPos (50, 50, 256, 256), constrainer (0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , hasBeenResized (false) #endif { @@ -63,7 +63,7 @@ ResizableWindow::ResizableWindow (const String& name, fullscreen (false), lastNonFullScreenPos (50, 50, 256, 256), constrainer (0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , hasBeenResized (false) #endif { @@ -177,7 +177,7 @@ void ResizableWindow::resized() updateLastPos(); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG hasBeenResized = true; #endif } @@ -309,7 +309,7 @@ void ResizableWindow::paint (Graphics& g) getBorderThickness(), *this); } -#ifdef JUCE_DEBUG +#if JUCE_DEBUG /* If this fails, then you've probably written a subclass with a resized() callback but forgotten to make it call its parent class's resized() method. @@ -520,7 +520,7 @@ void ResizableWindow::mouseDrag (const MouseEvent& e) } //============================================================================== -#ifdef JUCE_DEBUG +#if JUCE_DEBUG void ResizableWindow::addChildComponent (Component* const child, int zOrder) { /* Agh! You shouldn't add components directly to a ResizableWindow - this class diff --git a/src/gui/components/windows/juce_ResizableWindow.h b/src/gui/components/windows/juce_ResizableWindow.h index f14554afe7..dbbcf7e273 100644 --- a/src/gui/components/windows/juce_ResizableWindow.h +++ b/src/gui/components/windows/juce_ResizableWindow.h @@ -320,7 +320,7 @@ protected: */ virtual const BorderSize getContentComponentBorder(); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG /** Overridden to warn people about adding components directly to this component instead of using setContentComponent(). @@ -348,7 +348,7 @@ private: Rectangle lastNonFullScreenPos; ComponentBoundsConstrainer defaultConstrainer; ComponentBoundsConstrainer* constrainer; - #ifdef JUCE_DEBUG + #if JUCE_DEBUG bool hasBeenResized; #endif diff --git a/src/gui/graphics/colour/juce_ColourGradient.cpp b/src/gui/graphics/colour/juce_ColourGradient.cpp index b4ac4f77dc..cb985e3a13 100644 --- a/src/gui/graphics/colour/juce_ColourGradient.cpp +++ b/src/gui/graphics/colour/juce_ColourGradient.cpp @@ -33,7 +33,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== ColourGradient::ColourGradient() throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG x1 = 987654.0f; #endif } @@ -138,7 +138,7 @@ const Colour ColourGradient::getColourAtPosition (const float position) const th //============================================================================== int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlock & lookupTable) const { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // trying to use the object without setting its co-ordinates? Have a careful read of // the comments for the constructors. jassert (x1 != 987654.0f); diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp index 05ec24f56b..5c6c2d73ed 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.cpp @@ -40,7 +40,7 @@ BEGIN_JUCE_NAMESPACE //============================================================================== -#if defined (JUCE_DEBUG) && WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS +#if JUCE_DEBUG && WARN_ABOUT_NON_POSTSCRIPT_OPERATIONS #define notPossibleInPostscriptAssert jassertfalse #else #define notPossibleInPostscriptAssert diff --git a/src/io/files/juce_ZipFile.cpp b/src/io/files/juce_ZipFile.cpp index d26b3eb123..1901e03979 100644 --- a/src/io/files/juce_ZipFile.cpp +++ b/src/io/files/juce_ZipFile.cpp @@ -66,7 +66,7 @@ public: } else { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG file_.numOpenStreams++; #endif } @@ -85,7 +85,7 @@ public: ~ZipInputStream() throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG if (inputStream != 0 && inputStream == file.inputStream) file.numOpenStreams--; #endif @@ -161,7 +161,7 @@ private: ZipFile::ZipFile (InputStream* const source_, const bool deleteStreamWhenDestroyed) throw() : inputStream (source_) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , numOpenStreams (0) #endif { @@ -173,7 +173,7 @@ ZipFile::ZipFile (InputStream* const source_, ZipFile::ZipFile (const File& file) : inputStream (0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , numOpenStreams (0) #endif { @@ -184,7 +184,7 @@ ZipFile::ZipFile (const File& file) ZipFile::ZipFile (InputSource* const inputSource_) : inputStream (0), inputSource (inputSource_) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG , numOpenStreams (0) #endif { @@ -193,7 +193,7 @@ ZipFile::ZipFile (InputSource* const inputSource_) ZipFile::~ZipFile() throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG entries.clear(); // If you hit this assertion, it means you've created a stream to read diff --git a/src/io/files/juce_ZipFile.h b/src/io/files/juce_ZipFile.h index 765b38d723..a5d157c1c3 100644 --- a/src/io/files/juce_ZipFile.h +++ b/src/io/files/juce_ZipFile.h @@ -159,7 +159,7 @@ private: ScopedPointer streamToDelete; ScopedPointer inputSource; -#ifdef JUCE_DEBUG +#if JUCE_DEBUG int numOpenStreams; #endif diff --git a/src/native/linux/juce_linux_Audio.cpp b/src/native/linux/juce_linux_Audio.cpp index 21c8124fbe..911200f0e1 100644 --- a/src/native/linux/juce_linux_Audio.cpp +++ b/src/native/linux/juce_linux_Audio.cpp @@ -214,7 +214,7 @@ public: } /* -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // enable this to dump the config of the devices that get opened snd_output_t* out; snd_output_stdio_attach (&out, stderr, 0); @@ -229,8 +229,11 @@ public: } //============================================================================== - bool write (float** const data, const int numSamples) + bool write (AudioSampleBuffer& outputChannelBuffer, const int numSamples) { + jassert (numChannelsRunning <= outputChannelBuffer.getNumChannels()); + float** const data = outputChannelBuffer.getArrayOfChannels(); + if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); @@ -267,8 +270,11 @@ public: return true; } - bool read (float** const data, const int numSamples) + bool read (AudioSampleBuffer& inputChannelBuffer, const int numSamples) { + jassert (numChannelsRunning <= inputChannelBuffer.getNumChannels()); + float** const data = inputChannelBuffer.getArrayOfChannels(); + if (isInterleaved) { scratch.ensureSize (sizeof (float) * numSamples * numChannelsRunning, false); @@ -346,14 +352,9 @@ public: outputDevice (0), inputDevice (0), numCallbacks (0), - totalNumInputChannels (0), - totalNumOutputChannels (0) + inputChannelBuffer (1, 1), + outputChannelBuffer (1, 1) { - zeromem (outputChannelData, sizeof (outputChannelData)); - zeromem (outputChannelDataForCallback, sizeof (outputChannelDataForCallback)); - zeromem (inputChannelData, sizeof (inputChannelData)); - zeromem (inputChannelDataForCallback, sizeof (inputChannelDataForCallback)); - initialiseRatesAndChannels(); } @@ -372,38 +373,42 @@ public: error = String::empty; sampleRate = sampleRate_; bufferSize = bufferSize_; + + inputChannelBuffer.setSize (jmax ((int) minChansIn, inputChannels.getHighestBit()) + 1, bufferSize); + inputChannelBuffer.clear(); + inputChannelDataForCallback.clear(); currentInputChans.clear(); - currentOutputChans.clear(); if (inputChannels.getHighestBit() >= 0) { for (int i = 0; i <= jmax (inputChannels.getHighestBit(), (int) minChansIn); ++i) { - inputChannelData [i] = (float*) juce_calloc (sizeof (float) * bufferSize); - if (inputChannels[i]) { - inputChannelDataForCallback [totalNumInputChannels++] = inputChannelData [i]; + inputChannelDataForCallback.add (inputChannelBuffer.getSampleData (i)); currentInputChans.setBit (i); } } } + outputChannelBuffer.setSize (jmax ((int) minChansOut, outputChannels.getHighestBit()) + 1, bufferSize); + outputChannelBuffer.clear(); + outputChannelDataForCallback.clear(); + currentOutputChans.clear(); + if (outputChannels.getHighestBit() >= 0) { for (int i = 0; i <= jmax (outputChannels.getHighestBit(), (int) minChansOut); ++i) { - outputChannelData [i] = (float*) juce_calloc (sizeof (float) * bufferSize); - if (outputChannels[i]) { - outputChannelDataForCallback [totalNumOutputChannels++] = outputChannelData [i]; + outputChannelDataForCallback.add (outputChannelBuffer.getSampleData (i)); currentOutputChans.setBit (i); } } } - if (totalNumOutputChannels > 0 && outputId.isNotEmpty()) + if (outputChannelDataForCallback.size() > 0 && outputId.isNotEmpty()) { outputDevice = new ALSADevice (outputId, false); @@ -426,7 +431,7 @@ public: } } - if (totalNumInputChannels > 0 && inputId.isNotEmpty()) + if (inputChannelDataForCallback.size() > 0 && inputId.isNotEmpty()) { inputDevice = new ALSADevice (inputId, true); @@ -489,18 +494,8 @@ public: deleteAndZero (inputDevice); deleteAndZero (outputDevice); - for (int i = 0; i < maxNumChans; ++i) - { - juce_free (inputChannelData [i]); - juce_free (outputChannelData [i]); - } - - zeromem (outputChannelData, sizeof (outputChannelData)); - zeromem (outputChannelDataForCallback, sizeof (outputChannelDataForCallback)); - zeromem (inputChannelData, sizeof (inputChannelData)); - zeromem (inputChannelDataForCallback, sizeof (inputChannelDataForCallback)); - totalNumOutputChannels = 0; - totalNumInputChannels = 0; + inputChannelBuffer.setSize (1, 1); + outputChannelBuffer.setSize (1, 1); numCallbacks = 0; } @@ -517,7 +512,7 @@ public: { if (inputDevice != 0) { - if (! inputDevice->read (inputChannelData, bufferSize)) + if (! inputDevice->read (inputChannelBuffer, bufferSize)) { DBG ("ALSA: read failure"); break; @@ -533,15 +528,15 @@ public: if (callback != 0) { - callback->audioDeviceIOCallback ((const float**) inputChannelDataForCallback, - totalNumInputChannels, - outputChannelDataForCallback, - totalNumOutputChannels, + callback->audioDeviceIOCallback ((const float**) inputChannelDataForCallback.getRawDataPointer(), + inputChannelDataForCallback.size(), + outputChannelDataForCallback.getRawDataPointer(), + outputChannelDataForCallback.size(), bufferSize); } else { - for (int i = 0; i < totalNumOutputChannels; ++i) + for (int i = 0; i < outputChannelDataForCallback.size(); ++i) zeromem (outputChannelDataForCallback[i], sizeof (float) * bufferSize); } } @@ -555,7 +550,7 @@ public: failed (snd_pcm_avail_update (outputDevice->handle)); - if (! outputDevice->write (outputChannelData, bufferSize)) + if (! outputDevice->write (outputChannelBuffer, bufferSize)) { DBG ("ALSA: write failure"); break; @@ -596,12 +591,8 @@ private: CriticalSection callbackLock; - float* outputChannelData [maxNumChans]; - float* outputChannelDataForCallback [maxNumChans]; - int totalNumInputChannels; - float* inputChannelData [maxNumChans]; - float* inputChannelDataForCallback [maxNumChans]; - int totalNumOutputChannels; + AudioSampleBuffer inputChannelBuffer, outputChannelBuffer; + Array inputChannelDataForCallback, outputChannelDataForCallback; unsigned int minChansOut, maxChansOut; unsigned int minChansIn, maxChansIn; diff --git a/src/native/linux/juce_linux_Clipboard.cpp b/src/native/linux/juce_linux_Clipboard.cpp index 4a8c5ec151..2d7b978161 100644 --- a/src/native/linux/juce_linux_Clipboard.cpp +++ b/src/native/linux/juce_linux_Clipboard.cpp @@ -28,7 +28,7 @@ #if JUCE_INCLUDED_FILE //============================================================================== -#ifdef JUCE_DEBUG +#if JUCE_DEBUG #define JUCE_DEBUG_XERRORS 1 #endif diff --git a/src/native/linux/juce_linux_Fonts.cpp b/src/native/linux/juce_linux_Fonts.cpp index e077fc99d5..8e2d313d73 100644 --- a/src/native/linux/juce_linux_Fonts.cpp +++ b/src/native/linux/juce_linux_Fonts.cpp @@ -473,7 +473,7 @@ public: if (face == 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG String msg ("Failed to create typeface: "); msg << font.getTypefaceName() << " " << (font.isBold() ? 'B' : ' ') << (font.isItalic() ? 'I' : ' '); DBG (msg); diff --git a/src/native/linux/juce_linux_Messaging.cpp b/src/native/linux/juce_linux_Messaging.cpp index d053cc9b49..94298cd631 100644 --- a/src/native/linux/juce_linux_Messaging.cpp +++ b/src/native/linux/juce_linux_Messaging.cpp @@ -28,14 +28,14 @@ #if JUCE_INCLUDED_FILE //============================================================================== -#ifdef JUCE_DEBUG +#if JUCE_DEBUG && ! defined (JUCE_DEBUG_XERRORS) #define JUCE_DEBUG_XERRORS 1 #endif Display* display = 0; // This is also referenced from WindowDriver.cpp Window juce_messageWindowHandle = None; -XContext improbableNumber; // This is referenced from Windowing.cpp +XContext windowHandleXContext; // This is referenced from Windowing.cpp extern void juce_windowMessageReceive (XEvent* event); // Defined in Windowing.cpp extern void juce_handleSelectionRequest (XSelectionRequestEvent &evt); // Defined in Clipboard.cpp @@ -165,7 +165,7 @@ static int ioErrorHandler (Display* display) // A protocol error has occurred static int errorHandler (Display* display, XErrorEvent* event) { -#ifdef JUCE_DEBUG_XERRORS +#if JUCE_DEBUG_XERRORS char errorStr[64] = { 0 }; char requestStr[64] = { 0 }; @@ -280,7 +280,7 @@ void MessageManager::doPlatformSpecificInitialisation() // Create a context to store user data associated with Windows we // create in WindowDriver - improbableNumber = XUniqueContext(); + windowHandleXContext = XUniqueContext(); // We're only interested in client messages for this window // which are always sent diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index c748cc829c..8e1b19056e 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -30,7 +30,7 @@ //============================================================================== // These are defined in juce_linux_Messaging.cpp extern Display* display; -extern XContext improbableNumber; +extern XContext windowHandleXContext; //============================================================================== namespace Atoms @@ -721,7 +721,7 @@ public: XPointer peer = 0; ScopedXLock xlock; - if (! XFindContext (display, (XID) windowHandle, improbableNumber, &peer)) + if (! XFindContext (display, (XID) windowHandle, windowHandleXContext, &peer)) { if (peer != 0 && ! ComponentPeer::isValidPeer ((LinuxComponentPeer*) peer)) peer = 0; @@ -2245,7 +2245,7 @@ private: GrabModeAsync, GrabModeAsync, None, None); // Set the window context to identify the window handle object - if (XSaveContext (display, (XID) wndH, improbableNumber, (XPointer) this)) + if (XSaveContext (display, (XID) wndH, windowHandleXContext, (XPointer) this)) { // Failed jassertfalse @@ -2338,8 +2338,8 @@ private: ScopedXLock xlock; XPointer handlePointer; - if (! XFindContext (display, (XID) windowH, improbableNumber, &handlePointer)) - XDeleteContext (display, (XID) windowH, improbableNumber); + if (! XFindContext (display, (XID) windowH, windowHandleXContext, &handlePointer)) + XDeleteContext (display, (XID) windowH, windowHandleXContext); XDestroyWindow (display, windowH); @@ -3250,7 +3250,7 @@ public: CWBorderPixel | CWColormap | CWEventMask, &swa); - XSaveContext (display, (XID) embeddedWindow, improbableNumber, (XPointer) peer); + XSaveContext (display, (XID) embeddedWindow, windowHandleXContext, (XPointer) peer); XMapWindow (display, embeddedWindow); XFreeColormap (display, colourMap); diff --git a/src/native/windows/juce_win32_AudioCDReader.cpp b/src/native/windows/juce_win32_AudioCDReader.cpp index 78fd3748ee..9f8bc18b85 100644 --- a/src/native/windows/juce_win32_AudioCDReader.cpp +++ b/src/native/windows/juce_win32_AudioCDReader.cpp @@ -516,8 +516,8 @@ public: int numFrames; int dataStartOffset; int dataLength; - BYTE* buffer; int bufferSize; + HeapBlock buffer; int index; bool wantsIndex; @@ -527,19 +527,14 @@ public: numFrames (0), dataStartOffset (0), dataLength (0), + bufferSize (2352 * numberOfFrames), + buffer (bufferSize), index (0), wantsIndex (false) { - bufferSize = 2352 * numberOfFrames; - buffer = (BYTE*) juce_malloc (bufferSize); } - ~CDReadBuffer() - { - juce_free (buffer); - } - - bool isZero() const + bool isZero() const throw() { BYTE* p = buffer + dataStartOffset; diff --git a/src/native/windows/juce_win32_DirectSound.cpp b/src/native/windows/juce_win32_DirectSound.cpp index 2c461b5edc..545f2febfe 100644 --- a/src/native/windows/juce_win32_DirectSound.cpp +++ b/src/native/windows/juce_win32_DirectSound.cpp @@ -958,12 +958,10 @@ public: isStarted (false), outputDeviceIndex (outputDeviceIndex_), inputDeviceIndex (inputDeviceIndex_), - numInputBuffers (0), - numOutputBuffers (0), totalSamplesOut (0), sampleRate (0.0), - inputBuffers (0), - outputBuffers (0), + inputBuffers (1, 1), + outputBuffers (1, 1), callback (0), bufferSizeSamples (0) { @@ -1161,12 +1159,13 @@ private: OwnedArray outChans; WaitableEvent startEvent; - int numInputBuffers, numOutputBuffers, bufferSizeSamples; + int bufferSizeSamples; int volatile totalSamplesOut; int64 volatile lastBlockTime; double sampleRate; BigInteger enabledInputs, enabledOutputs; - HeapBlock inputBuffers, outputBuffers; + + AudioSampleBuffer inputBuffers, outputBuffers; AudioIODeviceCallback* callback; CriticalSection startStopLock; @@ -1186,19 +1185,8 @@ private: inChans.clear(); outChans.clear(); - - int i; - for (i = 0; i < numInputBuffers; ++i) - juce_free (inputBuffers[i]); - - inputBuffers.free(); - numInputBuffers = 0; - - for (i = 0; i < numOutputBuffers; ++i) - juce_free (outputBuffers[i]); - - outputBuffers.free(); - numOutputBuffers = 0; + inputBuffers.setSize (1, 1); + outputBuffers.setSize (1, 1); } void resync() @@ -1305,10 +1293,10 @@ public: { JUCE_TRY { - callback->audioDeviceIOCallback (const_cast (inputBuffers.getData()), - numInputBuffers, - outputBuffers, - numOutputBuffers, + callback->audioDeviceIOCallback (const_cast (inputBuffers.getArrayOfChannels()), + inputBuffers.getNumChannels(), + outputBuffers.getArrayOfChannels(), + outputBuffers.getNumChannels(), bufferSizeSamples); } JUCE_CATCH_EXCEPTION @@ -1317,10 +1305,7 @@ public: } else { - for (i = 0; i < numOutputBuffers; ++i) - if (outputBuffers[i] != 0) - zeromem (outputBuffers[i], bufferSizeSamples * sizeof (float)); - + outputBuffers.clear(); totalSamplesOut = 0; sleep (1); } @@ -1518,20 +1503,18 @@ const String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, enabledInputs.getHighestBit() + 1 - inChannels.size(), false); - numInputBuffers = enabledInputs.countNumberOfSetBits(); - inputBuffers.calloc (numInputBuffers + 2); + inputBuffers.setSize (enabledInputs.countNumberOfSetBits(), bufferSizeSamples); int i, numIns = 0; for (i = 0; i <= enabledInputs.getHighestBit(); i += 2) { float* left = 0; - float* right = 0; - if (enabledInputs[i]) - left = inputBuffers[numIns++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + left = inputBuffers.getSampleData (numIns++); + float* right = 0; if (enabledInputs[i + 1]) - right = inputBuffers[numIns++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + right = inputBuffers.getSampleData (numIns++); if (left != 0 || right != 0) inChans.add (new DSoundInternalInChannel (dlh.inputDeviceNames [inputDeviceIndex], @@ -1545,20 +1528,18 @@ const String DSoundAudioIODevice::openDevice (const BigInteger& inputChannels, enabledOutputs.getHighestBit() + 1 - outChannels.size(), false); - numOutputBuffers = enabledOutputs.countNumberOfSetBits(); - outputBuffers.calloc (numOutputBuffers + 2); + outputBuffers.setSize (enabledOutputs.countNumberOfSetBits(), bufferSizeSamples); int numOuts = 0; for (i = 0; i <= enabledOutputs.getHighestBit(); i += 2) { float* left = 0; - float* right = 0; - if (enabledOutputs[i]) - left = outputBuffers[numOuts++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + left = outputBuffers.getSampleData (numOuts++); + float* right = 0; if (enabledOutputs[i + 1]) - right = outputBuffers[numOuts++] = (float*) juce_calloc ((bufferSizeSamples + 16) * sizeof (float)); + right = outputBuffers.getSampleData (numOuts++); if (left != 0 || right != 0) outChans.add (new DSoundInternalOutChannel (dlh.outputDeviceNames[outputDeviceIndex], diff --git a/src/native/windows/juce_win32_Network.cpp b/src/native/windows/juce_win32_Network.cpp index c7ae272b0e..a0ecd89b3f 100644 --- a/src/native/windows/juce_win32_Network.cpp +++ b/src/native/windows/juce_win32_Network.cpp @@ -257,10 +257,8 @@ int juce_seekInInternetFile (void* handle, int newPosition) const ConnectionAndRequestStruct* const crs = static_cast (handle); return InternetSetFilePointer (crs->request, newPosition, 0, FILE_BEGIN, 0); } - else - { - return -1; - } + + return -1; } int64 juce_getInternetFileContentLength (void* handle) @@ -335,12 +333,6 @@ static int getMACAddressViaGetAdaptersInfo (int64* addresses, int maxNum, const return numFound; } -struct ASTAT -{ - ADAPTER_STATUS adapt; - NAME_BUFFER NameBuff [30]; -}; - static int getMACAddressesViaNetBios (int64* addresses, int maxNum, const bool littleEndian) throw() { int numFound = 0; @@ -353,6 +345,12 @@ static int getMACAddressesViaNetBios (int64* addresses, int maxNum, const bool l NCB ncb; zerostruct (ncb); + struct ASTAT + { + ADAPTER_STATUS adapt; + NAME_BUFFER NameBuff [30]; + }; + ASTAT astat; zerostruct (astat); @@ -410,8 +408,6 @@ int SystemStats::getMACAddresses (int64* addresses, int maxNum, const bool littl } //============================================================================== -typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); - bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAddress, const String& emailSubject, const String& bodyText, @@ -419,6 +415,8 @@ bool PlatformUtilities::launchEmailWithAttachments (const String& targetEmailAdd { HMODULE h = LoadLibraryA ("MAPI32.dll"); + typedef ULONG (WINAPI *MAPISendMailType) (LHANDLE, ULONG, lpMapiMessage, ::FLAGS, ULONG); + MAPISendMailType mapiSendMail = (MAPISendMailType) GetProcAddress (h, "MAPISendMail"); bool ok = false; diff --git a/src/native/windows/juce_win32_SystemStats.cpp b/src/native/windows/juce_win32_SystemStats.cpp index 9f11ae90af..f94fbe36db 100644 --- a/src/native/windows/juce_win32_SystemStats.cpp +++ b/src/native/windows/juce_win32_SystemStats.cpp @@ -163,14 +163,14 @@ void SystemStats::initialiseStats() throw() String s (SystemStats::getJUCEVersion()); -#ifdef JUCE_DEBUG +#if JUCE_DEBUG const MMRESULT res = timeBeginPeriod (1); jassert (res == TIMERR_NOERROR); #else timeBeginPeriod (1); #endif -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif } diff --git a/src/native/windows/juce_win32_Threads.cpp b/src/native/windows/juce_win32_Threads.cpp index 7fdb884eb2..d69373724e 100644 --- a/src/native/windows/juce_win32_Threads.cpp +++ b/src/native/windows/juce_win32_Threads.cpp @@ -135,7 +135,7 @@ void juce_killThread (void* handle) { if (handle != 0) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG OutputDebugString (_T("** Warning - Forced thread termination **\n")); #endif TerminateThread (handle, 0); @@ -144,7 +144,7 @@ void juce_killThread (void* handle) void juce_setCurrentThreadName (const String& name) { -#if defined (JUCE_DEBUG) && JUCE_MSVC +#if JUCE_DEBUG && JUCE_MSVC struct { DWORD dwType; @@ -208,7 +208,7 @@ static HANDLE sleepEvent = 0; void juce_initialiseThreadEvents() { if (sleepEvent == 0) -#ifdef JUCE_DEBUG +#if JUCE_DEBUG sleepEvent = CreateEvent (0, 0, 0, _T("Juce Sleep Event")); #else sleepEvent = CreateEvent (0, 0, 0, 0); @@ -294,7 +294,7 @@ void Process::lowerPrivilege() void Process::terminate() { -#if defined (JUCE_DEBUG) && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS +#if JUCE_DEBUG && JUCE_MSVC && JUCE_CHECK_MEMORY_LEAKS _CrtDumpMemoryLeaks(); #endif diff --git a/src/text/juce_XmlElement.cpp b/src/text/juce_XmlElement.cpp index 87bed1d850..4e07bdc134 100644 --- a/src/text/juce_XmlElement.cpp +++ b/src/text/juce_XmlElement.cpp @@ -435,7 +435,7 @@ bool XmlElement::writeToFile (const File& file, //============================================================================== bool XmlElement::hasTagName (const String& tagNameWanted) const throw() { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // if debugging, check that the case is actually the same, because // valid xml is case-sensitive, and although this lets it pass, it's // better not to.. @@ -639,7 +639,7 @@ bool XmlElement::compareAttribute (const String& attributeName, //============================================================================== void XmlElement::setAttribute (const String& attributeName, const String& value) { -#ifdef JUCE_DEBUG +#if JUCE_DEBUG // check the identifier being passed in is legal.. const juce_wchar* t = attributeName; while (*t != 0)