diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index fadfcaa2eb..a96ffcf529 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -177,6 +177,7 @@ OBJECTS := \ $(OBJDIR)/juce_MultiDocumentPanel_50e05aac.o \ $(OBJDIR)/juce_ResizableBorderComponent_7f4f2182.o \ $(OBJDIR)/juce_ResizableCornerComponent_1cac2df9.o \ + $(OBJDIR)/juce_ResizableEdgeComponent_b9c9291.o \ $(OBJDIR)/juce_ScrollBar_89666ad4.o \ $(OBJDIR)/juce_StretchableLayoutManager_6bf5d800.o \ $(OBJDIR)/juce_StretchableLayoutResizerBar_a720084c.o \ @@ -1071,6 +1072,11 @@ $(OBJDIR)/juce_ResizableCornerComponent_1cac2df9.o: ../../src/gui/components/lay @echo "Compiling juce_ResizableCornerComponent.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" +$(OBJDIR)/juce_ResizableEdgeComponent_b9c9291.o: ../../src/gui/components/layout/juce_ResizableEdgeComponent.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_ResizableEdgeComponent.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + $(OBJDIR)/juce_ScrollBar_89666ad4.o: ../../src/gui/components/layout/juce_ScrollBar.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_ScrollBar.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index c4a5b64040..8c98c3d888 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -146,6 +146,7 @@ F5F3F25D9F377128DC74D95B = { isa = PBXBuildFile; fileRef = FF046140CCF1EDB0DFF80178; }; C64A2BF05224582134872415 = { isa = PBXBuildFile; fileRef = A95F42C5CB0C2E5052B31568; }; 0A9C9486A6B31F21B1472D2B = { isa = PBXBuildFile; fileRef = A31221E2A50CCE9DF06B5F4B; }; + ED9F9A6CB4F8BB7FEA5384B7 = { isa = PBXBuildFile; fileRef = 3D8B0E86C98E2EE49AE868C8; }; DE0BAD16BD5A6568EB4D228B = { isa = PBXBuildFile; fileRef = B116FEC4D544DB8E38CB571E; }; AF6FEC311B9FDA112CEEBE03 = { isa = PBXBuildFile; fileRef = F1F65C9E7394E04E073A57A4; }; 3795ECCE9D98F872F5BCAE64 = { isa = PBXBuildFile; fileRef = 993C90B10202DA78FA31CC58; }; @@ -691,6 +692,8 @@ 600B2FDBBBE812784CB49A69 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ResizableBorderComponent.h; path = ../../src/gui/components/layout/juce_ResizableBorderComponent.h; sourceTree = SOURCE_ROOT; }; A31221E2A50CCE9DF06B5F4B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ResizableCornerComponent.cpp; path = ../../src/gui/components/layout/juce_ResizableCornerComponent.cpp; sourceTree = SOURCE_ROOT; }; CB54AC3D311C44A1F3B463A5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ResizableCornerComponent.h; path = ../../src/gui/components/layout/juce_ResizableCornerComponent.h; sourceTree = SOURCE_ROOT; }; + 3D8B0E86C98E2EE49AE868C8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ResizableEdgeComponent.cpp; path = ../../src/gui/components/layout/juce_ResizableEdgeComponent.cpp; sourceTree = SOURCE_ROOT; }; + 238965266F88730956D776DB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ResizableEdgeComponent.h; path = ../../src/gui/components/layout/juce_ResizableEdgeComponent.h; sourceTree = SOURCE_ROOT; }; B116FEC4D544DB8E38CB571E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ScrollBar.cpp; path = ../../src/gui/components/layout/juce_ScrollBar.cpp; sourceTree = SOURCE_ROOT; }; 797C94BB7F42CBBAACCFFB87 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ScrollBar.h; path = ../../src/gui/components/layout/juce_ScrollBar.h; sourceTree = SOURCE_ROOT; }; F1F65C9E7394E04E073A57A4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_StretchableLayoutManager.cpp; path = ../../src/gui/components/layout/juce_StretchableLayoutManager.cpp; sourceTree = SOURCE_ROOT; }; @@ -933,6 +936,7 @@ 341631A7E86BF1C0E49093C6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Memory.h; path = ../../src/memory/juce_Memory.h; sourceTree = SOURCE_ROOT; }; AD655AA04981173716022D8D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MemoryBlock.cpp; path = ../../src/memory/juce_MemoryBlock.cpp; sourceTree = SOURCE_ROOT; }; F1D085B5F12E814BF1D5C395 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MemoryBlock.h; path = ../../src/memory/juce_MemoryBlock.h; sourceTree = SOURCE_ROOT; }; + 58654C2630387C4A336A5BFB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_OptionalScopedPointer.h; path = ../../src/memory/juce_OptionalScopedPointer.h; sourceTree = SOURCE_ROOT; }; 524A70C9F23954F8F2A3F99B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ReferenceCountedObject.h; path = ../../src/memory/juce_ReferenceCountedObject.h; sourceTree = SOURCE_ROOT; }; E05812E3CC31875A202D6B30 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ScopedPointer.h; path = ../../src/memory/juce_ScopedPointer.h; sourceTree = SOURCE_ROOT; }; 224C989BF83B6EA867814BFF = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_WeakReference.h; path = ../../src/memory/juce_WeakReference.h; sourceTree = SOURCE_ROOT; }; @@ -1448,6 +1452,8 @@ 600B2FDBBBE812784CB49A69, A31221E2A50CCE9DF06B5F4B, CB54AC3D311C44A1F3B463A5, + 3D8B0E86C98E2EE49AE868C8, + 238965266F88730956D776DB, B116FEC4D544DB8E38CB571E, 797C94BB7F42CBBAACCFFB87, F1F65C9E7394E04E073A57A4, @@ -1748,6 +1754,7 @@ 341631A7E86BF1C0E49093C6, AD655AA04981173716022D8D, F1D085B5F12E814BF1D5C395, + 58654C2630387C4A336A5BFB, 524A70C9F23954F8F2A3F99B, E05812E3CC31875A202D6B30, 224C989BF83B6EA867814BFF ); name = memory; sourceTree = ""; }; @@ -2156,6 +2163,7 @@ F5F3F25D9F377128DC74D95B, C64A2BF05224582134872415, 0A9C9486A6B31F21B1472D2B, + ED9F9A6CB4F8BB7FEA5384B7, DE0BAD16BD5A6568EB4D228B, AF6FEC311B9FDA112CEEBE03, 3795ECCE9D98F872F5BCAE64, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index 9250f1d033..75ad9e3c2a 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -555,6 +555,8 @@ + + diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index fb5098a8a1..f974da83d7 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -555,6 +555,8 @@ + + diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index ee12f37b63..2c959be427 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -557,6 +557,8 @@ + + diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index 7c69cf0228..ec40acb4b3 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -260,6 +260,7 @@ + @@ -629,6 +630,7 @@ + diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index bdc0457f2e..dd4283a72a 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -640,6 +640,9 @@ Juce\Source\gui\components\layout + + Juce\Source\gui\components\layout + Juce\Source\gui\components\layout @@ -1821,6 +1824,9 @@ Juce\Source\gui\components\layout + + Juce\Source\gui\components\layout + Juce\Source\gui\components\layout diff --git a/Builds/iOS/Juce.xcodeproj/project.pbxproj b/Builds/iOS/Juce.xcodeproj/project.pbxproj index 3d1aefc0c0..c4b2be049e 100644 --- a/Builds/iOS/Juce.xcodeproj/project.pbxproj +++ b/Builds/iOS/Juce.xcodeproj/project.pbxproj @@ -146,6 +146,7 @@ F5F3F25D9F377128DC74D95B = { isa = PBXBuildFile; fileRef = FF046140CCF1EDB0DFF80178; }; C64A2BF05224582134872415 = { isa = PBXBuildFile; fileRef = A95F42C5CB0C2E5052B31568; }; 0A9C9486A6B31F21B1472D2B = { isa = PBXBuildFile; fileRef = A31221E2A50CCE9DF06B5F4B; }; + ED9F9A6CB4F8BB7FEA5384B7 = { isa = PBXBuildFile; fileRef = 3D8B0E86C98E2EE49AE868C8; }; DE0BAD16BD5A6568EB4D228B = { isa = PBXBuildFile; fileRef = B116FEC4D544DB8E38CB571E; }; AF6FEC311B9FDA112CEEBE03 = { isa = PBXBuildFile; fileRef = F1F65C9E7394E04E073A57A4; }; 3795ECCE9D98F872F5BCAE64 = { isa = PBXBuildFile; fileRef = 993C90B10202DA78FA31CC58; }; @@ -691,6 +692,8 @@ 600B2FDBBBE812784CB49A69 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ResizableBorderComponent.h; path = ../../src/gui/components/layout/juce_ResizableBorderComponent.h; sourceTree = SOURCE_ROOT; }; A31221E2A50CCE9DF06B5F4B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ResizableCornerComponent.cpp; path = ../../src/gui/components/layout/juce_ResizableCornerComponent.cpp; sourceTree = SOURCE_ROOT; }; CB54AC3D311C44A1F3B463A5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ResizableCornerComponent.h; path = ../../src/gui/components/layout/juce_ResizableCornerComponent.h; sourceTree = SOURCE_ROOT; }; + 3D8B0E86C98E2EE49AE868C8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ResizableEdgeComponent.cpp; path = ../../src/gui/components/layout/juce_ResizableEdgeComponent.cpp; sourceTree = SOURCE_ROOT; }; + 238965266F88730956D776DB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ResizableEdgeComponent.h; path = ../../src/gui/components/layout/juce_ResizableEdgeComponent.h; sourceTree = SOURCE_ROOT; }; B116FEC4D544DB8E38CB571E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ScrollBar.cpp; path = ../../src/gui/components/layout/juce_ScrollBar.cpp; sourceTree = SOURCE_ROOT; }; 797C94BB7F42CBBAACCFFB87 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ScrollBar.h; path = ../../src/gui/components/layout/juce_ScrollBar.h; sourceTree = SOURCE_ROOT; }; F1F65C9E7394E04E073A57A4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_StretchableLayoutManager.cpp; path = ../../src/gui/components/layout/juce_StretchableLayoutManager.cpp; sourceTree = SOURCE_ROOT; }; @@ -933,6 +936,7 @@ 341631A7E86BF1C0E49093C6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Memory.h; path = ../../src/memory/juce_Memory.h; sourceTree = SOURCE_ROOT; }; AD655AA04981173716022D8D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MemoryBlock.cpp; path = ../../src/memory/juce_MemoryBlock.cpp; sourceTree = SOURCE_ROOT; }; F1D085B5F12E814BF1D5C395 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MemoryBlock.h; path = ../../src/memory/juce_MemoryBlock.h; sourceTree = SOURCE_ROOT; }; + 58654C2630387C4A336A5BFB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_OptionalScopedPointer.h; path = ../../src/memory/juce_OptionalScopedPointer.h; sourceTree = SOURCE_ROOT; }; 524A70C9F23954F8F2A3F99B = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ReferenceCountedObject.h; path = ../../src/memory/juce_ReferenceCountedObject.h; sourceTree = SOURCE_ROOT; }; E05812E3CC31875A202D6B30 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ScopedPointer.h; path = ../../src/memory/juce_ScopedPointer.h; sourceTree = SOURCE_ROOT; }; 224C989BF83B6EA867814BFF = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_WeakReference.h; path = ../../src/memory/juce_WeakReference.h; sourceTree = SOURCE_ROOT; }; @@ -1448,6 +1452,8 @@ 600B2FDBBBE812784CB49A69, A31221E2A50CCE9DF06B5F4B, CB54AC3D311C44A1F3B463A5, + 3D8B0E86C98E2EE49AE868C8, + 238965266F88730956D776DB, B116FEC4D544DB8E38CB571E, 797C94BB7F42CBBAACCFFB87, F1F65C9E7394E04E073A57A4, @@ -1748,6 +1754,7 @@ 341631A7E86BF1C0E49093C6, AD655AA04981173716022D8D, F1D085B5F12E814BF1D5C395, + 58654C2630387C4A336A5BFB, 524A70C9F23954F8F2A3F99B, E05812E3CC31875A202D6B30, 224C989BF83B6EA867814BFF ); name = memory; sourceTree = ""; }; @@ -2160,6 +2167,7 @@ F5F3F25D9F377128DC74D95B, C64A2BF05224582134872415, 0A9C9486A6B31F21B1472D2B, + ED9F9A6CB4F8BB7FEA5384B7, DE0BAD16BD5A6568EB4D228B, AF6FEC311B9FDA112CEEBE03, 3795ECCE9D98F872F5BCAE64, diff --git a/Juce.jucer b/Juce.jucer index 70492273e0..c336ec50cb 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -742,6 +742,10 @@ resource="0" file="src/gui/components/layout/juce_ResizableCornerComponent.cpp"/> + + removeChangeListener (this); - if (projectTree != 0) - projectTree->deleteRootItem(); - - projectTree = 0; contentView = 0; resizerBar = 0; + if (projectTree != 0) + { + StoredSettings::getInstance()->getProps().setValue ("projectTreeviewWidth", projectTree->getWidth()); + projectTree->deleteRootItem(); + projectTree = 0; + } + project = newProject; if (project != 0) { addAndMakeVisible (projectTree = new TreeView()); + projectTree->setComponentID ("tree"); projectTree->setRootItemVisible (true); projectTree->setMultiSelectEnabled (true); projectTree->setDefaultOpenness (true); projectTree->setColour (TreeView::backgroundColourId, Colour::greyLevel (0.93f)); projectTree->setIndentSize (14); - addAndMakeVisible (resizerBar = new StretchableLayoutResizerBar (this, 1, true)); - - resized(); - projectTree->setRootItem (new GroupTreeViewItem (project->getMainGroup())); projectTree->getRootItem()->setOpen (true); + String lastTreeWidth (StoredSettings::getInstance()->getProps().getValue ("projectTreeviewWidth")); + if (lastTreeWidth.getIntValue() < 150) + lastTreeWidth = "250"; + + projectTree->setBounds (RelativeRectangle ("0, 0, left + " + lastTreeWidth + ", parent.height")); + + addAndMakeVisible (resizerBar = new ResizableEdgeComponent (projectTree, &treeSizeConstrainer, + ResizableEdgeComponent::rightEdge)); + resizerBar->setComponentID ("resizer"); + resizerBar->setBounds (RelativeRectangle ("tree.right, 0, tree.right + 4, parent.height")); + project->addChangeListener (this); if (currentDocument == 0) @@ -161,7 +160,8 @@ bool ProjectContentComponent::setEditorComponent (Component* editor, OpenDocumen contentView = editor; currentDocument = doc; addAndMakeVisible (editor); - resized(); + editor->setBounds (RelativeRectangle ("resizer.right, 0, parent.right, parent.height")); + updateMainWindowTitle(); commandManager->commandStatusChanged(); diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.h index 81f56d4e0a..7680dc9384 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.h @@ -35,8 +35,7 @@ */ class ProjectContentComponent : public Component, public ApplicationCommandTarget, - public ChangeListener, - public StretchableLayoutManager + public ChangeListener { public: //============================================================================== @@ -44,7 +43,6 @@ public: ~ProjectContentComponent(); void paint (Graphics& g); - void resized(); void setProject (Project* project); @@ -56,7 +54,6 @@ public: void updateMissingFileStatuses(); void changeListenerCallback (ChangeBroadcaster*); - void hasBeenMoved(); //============================================================================== ApplicationCommandTarget* getNextCommandTarget(); @@ -66,12 +63,14 @@ public: bool perform (const InvocationInfo& info); private: - ScopedPointer projectTree; Project* project; - ScopedPointer contentView; OpenDocumentManager::Document* currentDocument; - ScopedPointer resizerBar; + ScopedPointer projectTree; + ScopedPointer resizerBar; + ScopedPointer contentView; + + ComponentBoundsConstrainer treeSizeConstrainer; void updateMainWindowTitle(); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index ccc798d24e..bf23df53c0 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -61843,7 +61843,12 @@ void ComponentBoundsConstrainer::checkComponentBounds (Component* component) void ComponentBoundsConstrainer::applyBoundsToComponent (Component* component, const Rectangle& bounds) { - component->setBounds (bounds); + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (bounds); + else + component->setBounds (bounds); } void ComponentBoundsConstrainer::resizeStart() @@ -62803,13 +62808,22 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) const Rectangle bounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); if (constrainer != 0) + { constrainer->setBoundsForComponent (component, bounds, mouseZone.isDraggingTopEdge(), mouseZone.isDraggingLeftEdge(), mouseZone.isDraggingBottomEdge(), mouseZone.isDraggingRightEdge()); + } else - component->setBounds (bounds); + { + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (bounds); + else + component->setBounds (bounds); + } } void ResizableBorderComponent::mouseUp (const MouseEvent&) @@ -62905,9 +62919,18 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) originalBounds.getHeight() + e.getDistanceFromDragStartY())); if (constrainer != 0) + { constrainer->setBoundsForComponent (component, r, false, false, true, true); + } else - component->setBounds (r); + { + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (r); + else + component->setBounds (r); + } } void ResizableCornerComponent::mouseUp (const MouseEvent&) @@ -62930,6 +62953,98 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_ResizableCornerComponent.cpp ***/ +/*** Start of inlined file: juce_ResizableEdgeComponent.cpp ***/ +BEGIN_JUCE_NAMESPACE + +ResizableEdgeComponent::ResizableEdgeComponent (Component* const componentToResize, + ComponentBoundsConstrainer* const constrainer_, + Edge edge_) + : component (componentToResize), + constrainer (constrainer_), + edge (edge_) +{ + setRepaintsOnMouseActivity (true); + setMouseCursor (MouseCursor (isVertical() ? MouseCursor::LeftRightResizeCursor + : MouseCursor::UpDownResizeCursor)); +} + +ResizableEdgeComponent::~ResizableEdgeComponent() +{ +} + +bool ResizableEdgeComponent::isVertical() const throw() +{ + return edge == leftEdge || edge == rightEdge; +} + +void ResizableEdgeComponent::paint (Graphics& g) +{ + getLookAndFeel().drawStretchableLayoutResizerBar (g, getWidth(), getHeight(), isVertical(), + isMouseOver(), isMouseButtonDown()); +} + +void ResizableEdgeComponent::mouseDown (const MouseEvent& e) +{ + if (component == 0) + { + jassertfalse; // You've deleted the component that this resizer was supposed to be using! + return; + } + + originalBounds = component->getBounds(); + + if (constrainer != 0) + constrainer->resizeStart(); +} + +void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) +{ + if (component == 0) + { + jassertfalse; // You've deleted the component that this resizer was supposed to be using! + return; + } + + Rectangle bounds (originalBounds); + + switch (edge) + { + case leftEdge: bounds.setLeft (bounds.getX() + e.getDistanceFromDragStartX()); break; + case rightEdge: bounds.setWidth (bounds.getWidth() + e.getDistanceFromDragStartX()); break; + case topEdge: bounds.setTop (bounds.getY() + e.getDistanceFromDragStartY()); break; + case bottomEdge: bounds.setHeight (bounds.getHeight() + e.getDistanceFromDragStartY()); break; + default: jassertfalse; break; + } + + if (constrainer != 0) + { + constrainer->setBoundsForComponent (component, bounds, + edge == topEdge, + edge == leftEdge, + edge == bottomEdge, + edge == rightEdge); + } + else + { + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (bounds); + else + component->setBounds (bounds); + } +} + +void ResizableEdgeComponent::mouseUp (const MouseEvent&) +{ + if (constrainer != 0) + constrainer->resizeEnd(); +} + +END_JUCE_NAMESPACE +/*** End of inlined file: juce_ResizableEdgeComponent.cpp ***/ + + /*** Start of inlined file: juce_ScrollBar.cpp ***/ BEGIN_JUCE_NAMESPACE @@ -79954,8 +80069,19 @@ public: jassertfalse; // must be a recursive reference! } + void applyNewBounds (const Rectangle& newBounds) + { + if (newBounds != getComponent().getBounds()) + { + ComponentScope scope (getComponent()); + rectangle.moveToAbsolute (newBounds.toFloat(), &scope); + + applyToComponentBounds(); + } + } + private: - const RelativeRectangle rectangle; + RelativeRectangle rectangle; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeRectangleComponentPositioner); }; @@ -86515,6 +86641,11 @@ public: owner.repaint(); } + void applyNewBounds (const Rectangle& newBounds) + { + jassertfalse; // drawables can't be resized directly! + } + private: DrawableShape& owner; const DrawableShape::RelativeFillType fill; @@ -87570,6 +87701,11 @@ public: owner.applyRelativePath (*owner.relativePath, &scope); } + void applyNewBounds (const Rectangle& newBounds) + { + jassertfalse; // drawables can't be resized directly! + } + private: DrawablePath& owner; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 442643cb92..1cdf6cb1ce 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 32 +#define JUCE_BUILDNUMBER 33 /** Current Juce version number. @@ -31755,6 +31755,13 @@ public: /** Returns the component that this positioner controls. */ Component& getComponent() const throw() { return component; } + /** Attempts to set the component's position to the given rectangle. + Unlike simply calling Component::setBounds(), this may involve the positioner + being smart enough to adjust itself to fit the new bounds, e.g. a RelativeRectangle's + positioner may try to reverse the expressions used to make them fit these new coordinates. + */ + virtual void applyNewBounds (const Rectangle& newBounds) = 0; + private: Component& component; @@ -49126,6 +49133,11 @@ protected: owner.recalculateCoordinates (&scope); } + void applyNewBounds (const Rectangle&) + { + jassertfalse; // drawables can't be resized directly! + } + private: DrawableType& owner; @@ -55072,7 +55084,7 @@ private: #define __JUCE_RESIZABLEBORDERCOMPONENT_JUCEHEADER__ /** - A component that resizes its parent window when dragged. + A component that resizes its parent component when dragged. This component forms a frame around the edge of a component, allowing it to be dragged by the edges or corners to resize it - like the way windows are @@ -55240,7 +55252,7 @@ private: #ifndef __JUCE_RESIZABLECORNERCOMPONENT_JUCEHEADER__ #define __JUCE_RESIZABLECORNERCOMPONENT_JUCEHEADER__ -/** A component that resizes a parent window when dragged. +/** A component that resizes a parent component when dragged. This is the small triangular stripey resizer component you get in the bottom-right of windows (more commonly on the Mac than Windows). Put one in the corner of @@ -58785,6 +58797,85 @@ private: #endif #ifndef __JUCE_RESIZABLECORNERCOMPONENT_JUCEHEADER__ +#endif +#ifndef __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ + +/*** Start of inlined file: juce_ResizableEdgeComponent.h ***/ +#ifndef __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ +#define __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ + +/** + A component that resizes its parent component when dragged. + + This component forms a bar along one edge of a component, allowing it to + be dragged by that edges to resize it. + + To use it, just add it to your component, positioning it along the appropriate + edge. Make sure you reposition the resizer component each time the parent's size + changes, to keep it in the correct position. + + @see ResizbleBorderComponent, ResizableCornerComponent +*/ +class JUCE_API ResizableEdgeComponent : public Component +{ +public: + + enum Edge + { + leftEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's left-hand edge. */ + rightEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's right-hand edge. */ + topEdge, /**< Indicates a horizontal bar that can be dragged up/down to move the top of the component. */ + bottomEdge /**< Indicates a horizontal bar that can be dragged up/down to move the bottom of the component. */ + }; + + /** Creates a resizer bar. + + Pass in the target component which you want to be resized when this one is + dragged. The target component will usually be this component's parent, but this + isn't mandatory. + + Remember that when the target component is resized, it'll need to move and + resize this component to keep it in place, as this won't happen automatically. + + If the constrainer parameter is non-zero, then this object will be used to enforce + limits on the size and position that the component can be stretched to. Make sure + that the constrainer isn't deleted while still in use by this object. + + @see ComponentBoundsConstrainer + */ + ResizableEdgeComponent (Component* componentToResize, + ComponentBoundsConstrainer* constrainer, + Edge edgeToResize); + + /** Destructor. */ + ~ResizableEdgeComponent(); + + bool isVertical() const throw(); + +protected: + + /** @internal */ + void paint (Graphics& g); + /** @internal */ + void mouseDown (const MouseEvent& e); + /** @internal */ + void mouseDrag (const MouseEvent& e); + /** @internal */ + void mouseUp (const MouseEvent& e); + +private: + WeakReference component; + ComponentBoundsConstrainer* constrainer; + Rectangle originalBounds; + const Edge edge; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent); +}; + +#endif // __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ +/*** End of inlined file: juce_ResizableEdgeComponent.h ***/ + + #endif #ifndef __JUCE_SCROLLBAR_JUCEHEADER__ diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 88c19777e5..b54540011b 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 32 +#define JUCE_BUILDNUMBER 33 /** Current Juce version number. diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 15c46a14a7..68a9eb48c3 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -2183,6 +2183,13 @@ public: /** Returns the component that this positioner controls. */ Component& getComponent() const throw() { return component; } + /** Attempts to set the component's position to the given rectangle. + Unlike simply calling Component::setBounds(), this may involve the positioner + being smart enough to adjust itself to fit the new bounds, e.g. a RelativeRectangle's + positioner may try to reverse the expressions used to make them fit these new coordinates. + */ + virtual void applyNewBounds (const Rectangle& newBounds) = 0; + private: Component& component; diff --git a/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp b/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp index 3e0912dc72..821d088b30 100644 --- a/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp +++ b/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp @@ -182,7 +182,12 @@ void ComponentBoundsConstrainer::checkComponentBounds (Component* component) void ComponentBoundsConstrainer::applyBoundsToComponent (Component* component, const Rectangle& bounds) { - component->setBounds (bounds); + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (bounds); + else + component->setBounds (bounds); } //============================================================================== diff --git a/src/gui/components/layout/juce_ResizableBorderComponent.cpp b/src/gui/components/layout/juce_ResizableBorderComponent.cpp index 21a85f0c9c..5fa041893a 100644 --- a/src/gui/components/layout/juce_ResizableBorderComponent.cpp +++ b/src/gui/components/layout/juce_ResizableBorderComponent.cpp @@ -28,7 +28,6 @@ BEGIN_JUCE_NAMESPACE #include "juce_ResizableBorderComponent.h" -#include "../juce_Desktop.h" #include "../../graphics/geometry/juce_RectangleList.h" #include "../../graphics/geometry/juce_Line.h" #include "../lookandfeel/juce_LookAndFeel.h" @@ -154,13 +153,22 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) const Rectangle bounds (mouseZone.resizeRectangleBy (originalBounds, e.getOffsetFromDragStart())); if (constrainer != 0) + { constrainer->setBoundsForComponent (component, bounds, mouseZone.isDraggingTopEdge(), mouseZone.isDraggingLeftEdge(), mouseZone.isDraggingBottomEdge(), mouseZone.isDraggingRightEdge()); + } else - component->setBounds (bounds); + { + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (bounds); + else + component->setBounds (bounds); + } } void ResizableBorderComponent::mouseUp (const MouseEvent&) diff --git a/src/gui/components/layout/juce_ResizableBorderComponent.h b/src/gui/components/layout/juce_ResizableBorderComponent.h index 849b726033..8bbf14ab4e 100644 --- a/src/gui/components/layout/juce_ResizableBorderComponent.h +++ b/src/gui/components/layout/juce_ResizableBorderComponent.h @@ -31,7 +31,7 @@ //============================================================================== /** - A component that resizes its parent window when dragged. + A component that resizes its parent component when dragged. This component forms a frame around the edge of a component, allowing it to be dragged by the edges or corners to resize it - like the way windows are diff --git a/src/gui/components/layout/juce_ResizableCornerComponent.cpp b/src/gui/components/layout/juce_ResizableCornerComponent.cpp index 2d15cf8306..367c9c325f 100644 --- a/src/gui/components/layout/juce_ResizableCornerComponent.cpp +++ b/src/gui/components/layout/juce_ResizableCornerComponent.cpp @@ -82,9 +82,18 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) originalBounds.getHeight() + e.getDistanceFromDragStartY())); if (constrainer != 0) + { constrainer->setBoundsForComponent (component, r, false, false, true, true); + } else - component->setBounds (r); + { + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (r); + else + component->setBounds (r); + } } void ResizableCornerComponent::mouseUp (const MouseEvent&) diff --git a/src/gui/components/layout/juce_ResizableCornerComponent.h b/src/gui/components/layout/juce_ResizableCornerComponent.h index 462d566387..a9302152cb 100644 --- a/src/gui/components/layout/juce_ResizableCornerComponent.h +++ b/src/gui/components/layout/juce_ResizableCornerComponent.h @@ -30,7 +30,7 @@ //============================================================================== -/** A component that resizes a parent window when dragged. +/** A component that resizes a parent component when dragged. This is the small triangular stripey resizer component you get in the bottom-right of windows (more commonly on the Mac than Windows). Put one in the corner of diff --git a/src/gui/components/layout/juce_ResizableEdgeComponent.cpp b/src/gui/components/layout/juce_ResizableEdgeComponent.cpp new file mode 100644 index 0000000000..a75fa73c54 --- /dev/null +++ b/src/gui/components/layout/juce_ResizableEdgeComponent.cpp @@ -0,0 +1,121 @@ +/* + ============================================================================== + + 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. + + ============================================================================== +*/ + +#include "../../../core/juce_StandardHeader.h" + +BEGIN_JUCE_NAMESPACE + +#include "juce_ResizableEdgeComponent.h" +#include "../lookandfeel/juce_LookAndFeel.h" + + +//============================================================================== +ResizableEdgeComponent::ResizableEdgeComponent (Component* const componentToResize, + ComponentBoundsConstrainer* const constrainer_, + Edge edge_) + : component (componentToResize), + constrainer (constrainer_), + edge (edge_) +{ + setRepaintsOnMouseActivity (true); + setMouseCursor (MouseCursor (isVertical() ? MouseCursor::LeftRightResizeCursor + : MouseCursor::UpDownResizeCursor)); +} + +ResizableEdgeComponent::~ResizableEdgeComponent() +{ +} + +//============================================================================== +bool ResizableEdgeComponent::isVertical() const throw() +{ + return edge == leftEdge || edge == rightEdge; +} + +void ResizableEdgeComponent::paint (Graphics& g) +{ + getLookAndFeel().drawStretchableLayoutResizerBar (g, getWidth(), getHeight(), isVertical(), + isMouseOver(), isMouseButtonDown()); +} + +void ResizableEdgeComponent::mouseDown (const MouseEvent& e) +{ + if (component == 0) + { + jassertfalse; // You've deleted the component that this resizer was supposed to be using! + return; + } + + originalBounds = component->getBounds(); + + if (constrainer != 0) + constrainer->resizeStart(); +} + +void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) +{ + if (component == 0) + { + jassertfalse; // You've deleted the component that this resizer was supposed to be using! + return; + } + + Rectangle bounds (originalBounds); + + switch (edge) + { + case leftEdge: bounds.setLeft (bounds.getX() + e.getDistanceFromDragStartX()); break; + case rightEdge: bounds.setWidth (bounds.getWidth() + e.getDistanceFromDragStartX()); break; + case topEdge: bounds.setTop (bounds.getY() + e.getDistanceFromDragStartY()); break; + case bottomEdge: bounds.setHeight (bounds.getHeight() + e.getDistanceFromDragStartY()); break; + default: jassertfalse; break; + } + + if (constrainer != 0) + { + constrainer->setBoundsForComponent (component, bounds, + edge == topEdge, + edge == leftEdge, + edge == bottomEdge, + edge == rightEdge); + } + else + { + Component::Positioner* const positioner = component->getPositioner(); + + if (positioner != 0) + positioner->applyNewBounds (bounds); + else + component->setBounds (bounds); + } +} + +void ResizableEdgeComponent::mouseUp (const MouseEvent&) +{ + if (constrainer != 0) + constrainer->resizeEnd(); +} + +END_JUCE_NAMESPACE diff --git a/src/gui/components/layout/juce_ResizableEdgeComponent.h b/src/gui/components/layout/juce_ResizableEdgeComponent.h new file mode 100644 index 0000000000..c1ed314ca3 --- /dev/null +++ b/src/gui/components/layout/juce_ResizableEdgeComponent.h @@ -0,0 +1,102 @@ +/* + ============================================================================== + + 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_RESIZABLEEDGECOMPONENT_JUCEHEADER__ +#define __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ + +#include "juce_ComponentBoundsConstrainer.h" + + +//============================================================================== +/** + A component that resizes its parent component when dragged. + + This component forms a bar along one edge of a component, allowing it to + be dragged by that edges to resize it. + + To use it, just add it to your component, positioning it along the appropriate + edge. Make sure you reposition the resizer component each time the parent's size + changes, to keep it in the correct position. + + @see ResizbleBorderComponent, ResizableCornerComponent +*/ +class JUCE_API ResizableEdgeComponent : public Component +{ +public: + //============================================================================== + enum Edge + { + leftEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's left-hand edge. */ + rightEdge, /**< Indicates a vertical bar that can be dragged left/right to move the component's right-hand edge. */ + topEdge, /**< Indicates a horizontal bar that can be dragged up/down to move the top of the component. */ + bottomEdge /**< Indicates a horizontal bar that can be dragged up/down to move the bottom of the component. */ + }; + + /** Creates a resizer bar. + + Pass in the target component which you want to be resized when this one is + dragged. The target component will usually be this component's parent, but this + isn't mandatory. + + Remember that when the target component is resized, it'll need to move and + resize this component to keep it in place, as this won't happen automatically. + + If the constrainer parameter is non-zero, then this object will be used to enforce + limits on the size and position that the component can be stretched to. Make sure + that the constrainer isn't deleted while still in use by this object. + + @see ComponentBoundsConstrainer + */ + ResizableEdgeComponent (Component* componentToResize, + ComponentBoundsConstrainer* constrainer, + Edge edgeToResize); + + /** Destructor. */ + ~ResizableEdgeComponent(); + + bool isVertical() const throw(); + +protected: + //============================================================================== + /** @internal */ + void paint (Graphics& g); + /** @internal */ + void mouseDown (const MouseEvent& e); + /** @internal */ + void mouseDrag (const MouseEvent& e); + /** @internal */ + void mouseUp (const MouseEvent& e); + +private: + WeakReference component; + ComponentBoundsConstrainer* constrainer; + Rectangle originalBounds; + const Edge edge; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableEdgeComponent); +}; + + +#endif // __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ diff --git a/src/gui/components/layout/juce_StretchableLayoutResizerBar.h b/src/gui/components/layout/juce_StretchableLayoutResizerBar.h index d455f89ae1..c58df66f48 100644 --- a/src/gui/components/layout/juce_StretchableLayoutResizerBar.h +++ b/src/gui/components/layout/juce_StretchableLayoutResizerBar.h @@ -95,5 +95,4 @@ private: }; - #endif // __JUCE_STRETCHABLELAYOUTRESIZERBAR_JUCEHEADER__ diff --git a/src/gui/components/positioning/juce_RelativeRectangle.cpp b/src/gui/components/positioning/juce_RelativeRectangle.cpp index 4b3f7c26e8..895c295898 100644 --- a/src/gui/components/positioning/juce_RelativeRectangle.cpp +++ b/src/gui/components/positioning/juce_RelativeRectangle.cpp @@ -232,8 +232,19 @@ public: jassertfalse; // must be a recursive reference! } + void applyNewBounds (const Rectangle& newBounds) + { + if (newBounds != getComponent().getBounds()) + { + ComponentScope scope (getComponent()); + rectangle.moveToAbsolute (newBounds.toFloat(), &scope); + + applyToComponentBounds(); + } + } + private: - const RelativeRectangle rectangle; + RelativeRectangle rectangle; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeRectangleComponentPositioner); }; diff --git a/src/gui/graphics/drawables/juce_Drawable.h b/src/gui/graphics/drawables/juce_Drawable.h index 00644e28eb..0c12a11ac4 100644 --- a/src/gui/graphics/drawables/juce_Drawable.h +++ b/src/gui/graphics/drawables/juce_Drawable.h @@ -234,6 +234,11 @@ protected: owner.recalculateCoordinates (&scope); } + void applyNewBounds (const Rectangle&) + { + jassertfalse; // drawables can't be resized directly! + } + private: DrawableType& owner; diff --git a/src/gui/graphics/drawables/juce_DrawablePath.cpp b/src/gui/graphics/drawables/juce_DrawablePath.cpp index ac803e2351..1a9f4b2a51 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.cpp +++ b/src/gui/graphics/drawables/juce_DrawablePath.cpp @@ -123,6 +123,11 @@ public: owner.applyRelativePath (*owner.relativePath, &scope); } + void applyNewBounds (const Rectangle& newBounds) + { + jassertfalse; // drawables can't be resized directly! + } + private: DrawablePath& owner; diff --git a/src/gui/graphics/drawables/juce_DrawableShape.cpp b/src/gui/graphics/drawables/juce_DrawableShape.cpp index 32ae271f12..37ac5add7d 100644 --- a/src/gui/graphics/drawables/juce_DrawableShape.cpp +++ b/src/gui/graphics/drawables/juce_DrawableShape.cpp @@ -77,6 +77,11 @@ public: owner.repaint(); } + void applyNewBounds (const Rectangle& newBounds) + { + jassertfalse; // drawables can't be resized directly! + } + private: DrawableShape& owner; const DrawableShape::RelativeFillType fill; diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index fd18f13381..7db011e2f3 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -446,6 +446,9 @@ #ifndef __JUCE_RESIZABLECORNERCOMPONENT_JUCEHEADER__ #include "gui/components/layout/juce_ResizableCornerComponent.h" #endif +#ifndef __JUCE_RESIZABLEEDGECOMPONENT_JUCEHEADER__ + #include "gui/components/layout/juce_ResizableEdgeComponent.h" +#endif #ifndef __JUCE_SCROLLBAR_JUCEHEADER__ #include "gui/components/layout/juce_ScrollBar.h" #endif