diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index 2772f3045b..77ae1db196 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -253,11 +253,9 @@ OBJECTS := \ $(OBJDIR)/juce_TextLayout_d18f700e.o \ $(OBJDIR)/juce_Typeface_34b3026e.o \ $(OBJDIR)/juce_AffineTransform_4a320188.o \ - $(OBJDIR)/juce_BorderSize_bf140c3c.o \ $(OBJDIR)/juce_Path_dcdd4594.o \ $(OBJDIR)/juce_PathIterator_4e116c22.o \ $(OBJDIR)/juce_PathStrokeType_506dcb86.o \ - $(OBJDIR)/juce_PositionedRectangle_1b6e8982.o \ $(OBJDIR)/juce_RectangleList_b6ae7ee8.o \ $(OBJDIR)/juce_GIFLoader_61887b90.o \ $(OBJDIR)/juce_JPEGLoader_412d2ccc.o \ @@ -1437,11 +1435,6 @@ $(OBJDIR)/juce_AffineTransform_4a320188.o: ../../src/gui/graphics/geometry/juce_ @echo "Compiling juce_AffineTransform.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_BorderSize_bf140c3c.o: ../../src/gui/graphics/geometry/juce_BorderSize.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling juce_BorderSize.cpp" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - $(OBJDIR)/juce_Path_dcdd4594.o: ../../src/gui/graphics/geometry/juce_Path.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_Path.cpp" @@ -1457,11 +1450,6 @@ $(OBJDIR)/juce_PathStrokeType_506dcb86.o: ../../src/gui/graphics/geometry/juce_P @echo "Compiling juce_PathStrokeType.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_PositionedRectangle_1b6e8982.o: ../../src/gui/graphics/geometry/juce_PositionedRectangle.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling juce_PositionedRectangle.cpp" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - $(OBJDIR)/juce_RectangleList_b6ae7ee8.o: ../../src/gui/graphics/geometry/juce_RectangleList.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_RectangleList.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index 5ee14e4ba4..fe5a21bf61 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -222,11 +222,9 @@ 803FFCA3DAC0C004A80143B4 = { isa = PBXBuildFile; fileRef = 91CB423DBC5F3CBEDD9CF2EF; }; F0556B3AD9D388177E26B90D = { isa = PBXBuildFile; fileRef = AF66A9951377E2D04C54CADD; }; 0558FFF11AED944C6B3E5FB5 = { isa = PBXBuildFile; fileRef = 2ED8CC539A9D9BE611F67A9A; }; - 11109DE27B3E3E3863360113 = { isa = PBXBuildFile; fileRef = 4B550E0887AA76BBAF8BA5BF; }; CF73FAC91E319C464F07C966 = { isa = PBXBuildFile; fileRef = 29BC53FEE9BC27F44534C909; }; B6D3EDA0F2E3516F3922F23F = { isa = PBXBuildFile; fileRef = 312F208B501E0D7764C6B613; }; E7C9FAA5F8A4AEDAD8A8CC1D = { isa = PBXBuildFile; fileRef = 9D3F1BAB1D48DDECB9F35916; }; - DC4BB8AFC054ECD4141B47CC = { isa = PBXBuildFile; fileRef = 11D8021D49B895410A836486; }; 084C9F2D4F78134CB1EFE676 = { isa = PBXBuildFile; fileRef = 1B170F70AF8AA0A39074F671; }; 4DAD08CD3A688747C9CA237B = { isa = PBXBuildFile; fileRef = 0F1C5770B363EF7DF64A876A; }; 60FE8BFA252E3EF2D60B77AD = { isa = PBXBuildFile; fileRef = 6619D27E74F623B1E8CE8F71; }; @@ -839,7 +837,6 @@ 932024E0F2A2CC22B7657691 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Typeface.h; path = ../../src/gui/graphics/fonts/juce_Typeface.h; sourceTree = SOURCE_ROOT; }; 2ED8CC539A9D9BE611F67A9A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_AffineTransform.cpp; path = ../../src/gui/graphics/geometry/juce_AffineTransform.cpp; sourceTree = SOURCE_ROOT; }; 5CD42FFF9F1A509D117BD0CB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_AffineTransform.h; path = ../../src/gui/graphics/geometry/juce_AffineTransform.h; sourceTree = SOURCE_ROOT; }; - 4B550E0887AA76BBAF8BA5BF = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_BorderSize.cpp; path = ../../src/gui/graphics/geometry/juce_BorderSize.cpp; sourceTree = SOURCE_ROOT; }; C18F342C087F69D141B3FAF5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_BorderSize.h; path = ../../src/gui/graphics/geometry/juce_BorderSize.h; sourceTree = SOURCE_ROOT; }; 4011751B9EFCA7B9345D7D7C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Line.h; path = ../../src/gui/graphics/geometry/juce_Line.h; sourceTree = SOURCE_ROOT; }; 29BC53FEE9BC27F44534C909 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Path.cpp; path = ../../src/gui/graphics/geometry/juce_Path.cpp; sourceTree = SOURCE_ROOT; }; @@ -849,8 +846,6 @@ 9D3F1BAB1D48DDECB9F35916 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_PathStrokeType.cpp; path = ../../src/gui/graphics/geometry/juce_PathStrokeType.cpp; sourceTree = SOURCE_ROOT; }; C2700BB57B9EED7BFE975564 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_PathStrokeType.h; path = ../../src/gui/graphics/geometry/juce_PathStrokeType.h; sourceTree = SOURCE_ROOT; }; 132E3C38B4F0C6229EDF7000 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Point.h; path = ../../src/gui/graphics/geometry/juce_Point.h; sourceTree = SOURCE_ROOT; }; - 11D8021D49B895410A836486 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_PositionedRectangle.cpp; path = ../../src/gui/graphics/geometry/juce_PositionedRectangle.cpp; sourceTree = SOURCE_ROOT; }; - 469347B6414F2CE9DCEEA386 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_PositionedRectangle.h; path = ../../src/gui/graphics/geometry/juce_PositionedRectangle.h; sourceTree = SOURCE_ROOT; }; F8C44FF03700F6140950F373 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Rectangle.h; path = ../../src/gui/graphics/geometry/juce_Rectangle.h; sourceTree = SOURCE_ROOT; }; 1B170F70AF8AA0A39074F671 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RectangleList.cpp; path = ../../src/gui/graphics/geometry/juce_RectangleList.cpp; sourceTree = SOURCE_ROOT; }; 8B7D7435287A20CB2D8E3704 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RectangleList.h; path = ../../src/gui/graphics/geometry/juce_RectangleList.h; sourceTree = SOURCE_ROOT; }; @@ -1613,7 +1608,6 @@ BF4679D9201C5AAE6751536B = { isa = PBXGroup; children = ( 2ED8CC539A9D9BE611F67A9A, 5CD42FFF9F1A509D117BD0CB, - 4B550E0887AA76BBAF8BA5BF, C18F342C087F69D141B3FAF5, 4011751B9EFCA7B9345D7D7C, 29BC53FEE9BC27F44534C909, @@ -1623,8 +1617,6 @@ 9D3F1BAB1D48DDECB9F35916, C2700BB57B9EED7BFE975564, 132E3C38B4F0C6229EDF7000, - 11D8021D49B895410A836486, - 469347B6414F2CE9DCEEA386, F8C44FF03700F6140950F373, 1B170F70AF8AA0A39074F671, 8B7D7435287A20CB2D8E3704 ); name = geometry; sourceTree = ""; }; @@ -2178,11 +2170,9 @@ 803FFCA3DAC0C004A80143B4, F0556B3AD9D388177E26B90D, 0558FFF11AED944C6B3E5FB5, - 11109DE27B3E3E3863360113, CF73FAC91E319C464F07C966, B6D3EDA0F2E3516F3922F23F, E7C9FAA5F8A4AEDAD8A8CC1D, - DC4BB8AFC054ECD4141B47CC, 084C9F2D4F78134CB1EFE676, 4DAD08CD3A688747C9CA237B, 60FE8BFA252E3EF2D60B77AD, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index d8147cdfa1..e43cc466d1 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -745,7 +745,6 @@ - @@ -755,8 +754,6 @@ - - diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index be75265fc9..2b2bc83063 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -745,7 +745,6 @@ - @@ -755,8 +754,6 @@ - - diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index 461d28f8ec..699323ce91 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -747,7 +747,6 @@ - @@ -757,8 +756,6 @@ - - diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index bf34c05981..90fa07ec64 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -336,11 +336,9 @@ - - @@ -707,7 +705,6 @@ - diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index 0ba4ee7baa..a93669ecdb 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -865,9 +865,6 @@ Juce\Source\gui\graphics\geometry - - Juce\Source\gui\graphics\geometry - Juce\Source\gui\graphics\geometry @@ -877,9 +874,6 @@ Juce\Source\gui\graphics\geometry - - Juce\Source\gui\graphics\geometry - Juce\Source\gui\graphics\geometry @@ -2052,9 +2046,6 @@ Juce\Source\gui\graphics\geometry - - Juce\Source\gui\graphics\geometry - Juce\Source\gui\graphics\geometry diff --git a/Builds/iPhone/Juce.xcodeproj/project.pbxproj b/Builds/iPhone/Juce.xcodeproj/project.pbxproj index 3f2effc284..e6bae0712a 100644 --- a/Builds/iPhone/Juce.xcodeproj/project.pbxproj +++ b/Builds/iPhone/Juce.xcodeproj/project.pbxproj @@ -222,11 +222,9 @@ 803FFCA3DAC0C004A80143B4 = { isa = PBXBuildFile; fileRef = 91CB423DBC5F3CBEDD9CF2EF; }; F0556B3AD9D388177E26B90D = { isa = PBXBuildFile; fileRef = AF66A9951377E2D04C54CADD; }; 0558FFF11AED944C6B3E5FB5 = { isa = PBXBuildFile; fileRef = 2ED8CC539A9D9BE611F67A9A; }; - 11109DE27B3E3E3863360113 = { isa = PBXBuildFile; fileRef = 4B550E0887AA76BBAF8BA5BF; }; CF73FAC91E319C464F07C966 = { isa = PBXBuildFile; fileRef = 29BC53FEE9BC27F44534C909; }; B6D3EDA0F2E3516F3922F23F = { isa = PBXBuildFile; fileRef = 312F208B501E0D7764C6B613; }; E7C9FAA5F8A4AEDAD8A8CC1D = { isa = PBXBuildFile; fileRef = 9D3F1BAB1D48DDECB9F35916; }; - DC4BB8AFC054ECD4141B47CC = { isa = PBXBuildFile; fileRef = 11D8021D49B895410A836486; }; 084C9F2D4F78134CB1EFE676 = { isa = PBXBuildFile; fileRef = 1B170F70AF8AA0A39074F671; }; 4DAD08CD3A688747C9CA237B = { isa = PBXBuildFile; fileRef = 0F1C5770B363EF7DF64A876A; }; 60FE8BFA252E3EF2D60B77AD = { isa = PBXBuildFile; fileRef = 6619D27E74F623B1E8CE8F71; }; @@ -839,7 +837,6 @@ 932024E0F2A2CC22B7657691 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Typeface.h; path = ../../src/gui/graphics/fonts/juce_Typeface.h; sourceTree = SOURCE_ROOT; }; 2ED8CC539A9D9BE611F67A9A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_AffineTransform.cpp; path = ../../src/gui/graphics/geometry/juce_AffineTransform.cpp; sourceTree = SOURCE_ROOT; }; 5CD42FFF9F1A509D117BD0CB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_AffineTransform.h; path = ../../src/gui/graphics/geometry/juce_AffineTransform.h; sourceTree = SOURCE_ROOT; }; - 4B550E0887AA76BBAF8BA5BF = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_BorderSize.cpp; path = ../../src/gui/graphics/geometry/juce_BorderSize.cpp; sourceTree = SOURCE_ROOT; }; C18F342C087F69D141B3FAF5 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_BorderSize.h; path = ../../src/gui/graphics/geometry/juce_BorderSize.h; sourceTree = SOURCE_ROOT; }; 4011751B9EFCA7B9345D7D7C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Line.h; path = ../../src/gui/graphics/geometry/juce_Line.h; sourceTree = SOURCE_ROOT; }; 29BC53FEE9BC27F44534C909 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_Path.cpp; path = ../../src/gui/graphics/geometry/juce_Path.cpp; sourceTree = SOURCE_ROOT; }; @@ -849,8 +846,6 @@ 9D3F1BAB1D48DDECB9F35916 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_PathStrokeType.cpp; path = ../../src/gui/graphics/geometry/juce_PathStrokeType.cpp; sourceTree = SOURCE_ROOT; }; C2700BB57B9EED7BFE975564 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_PathStrokeType.h; path = ../../src/gui/graphics/geometry/juce_PathStrokeType.h; sourceTree = SOURCE_ROOT; }; 132E3C38B4F0C6229EDF7000 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Point.h; path = ../../src/gui/graphics/geometry/juce_Point.h; sourceTree = SOURCE_ROOT; }; - 11D8021D49B895410A836486 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_PositionedRectangle.cpp; path = ../../src/gui/graphics/geometry/juce_PositionedRectangle.cpp; sourceTree = SOURCE_ROOT; }; - 469347B6414F2CE9DCEEA386 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_PositionedRectangle.h; path = ../../src/gui/graphics/geometry/juce_PositionedRectangle.h; sourceTree = SOURCE_ROOT; }; F8C44FF03700F6140950F373 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_Rectangle.h; path = ../../src/gui/graphics/geometry/juce_Rectangle.h; sourceTree = SOURCE_ROOT; }; 1B170F70AF8AA0A39074F671 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RectangleList.cpp; path = ../../src/gui/graphics/geometry/juce_RectangleList.cpp; sourceTree = SOURCE_ROOT; }; 8B7D7435287A20CB2D8E3704 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RectangleList.h; path = ../../src/gui/graphics/geometry/juce_RectangleList.h; sourceTree = SOURCE_ROOT; }; @@ -1613,7 +1608,6 @@ BF4679D9201C5AAE6751536B = { isa = PBXGroup; children = ( 2ED8CC539A9D9BE611F67A9A, 5CD42FFF9F1A509D117BD0CB, - 4B550E0887AA76BBAF8BA5BF, C18F342C087F69D141B3FAF5, 4011751B9EFCA7B9345D7D7C, 29BC53FEE9BC27F44534C909, @@ -1623,8 +1617,6 @@ 9D3F1BAB1D48DDECB9F35916, C2700BB57B9EED7BFE975564, 132E3C38B4F0C6229EDF7000, - 11D8021D49B895410A836486, - 469347B6414F2CE9DCEEA386, F8C44FF03700F6140950F373, 1B170F70AF8AA0A39074F671, 8B7D7435287A20CB2D8E3704 ); name = geometry; sourceTree = ""; }; @@ -2178,11 +2170,9 @@ 803FFCA3DAC0C004A80143B4, F0556B3AD9D388177E26B90D, 0558FFF11AED944C6B3E5FB5, - 11109DE27B3E3E3863360113, CF73FAC91E319C464F07C966, B6D3EDA0F2E3516F3922F23F, E7C9FAA5F8A4AEDAD8A8CC1D, - DC4BB8AFC054ECD4141B47CC, 084C9F2D4F78134CB1EFE676, 4DAD08CD3A688747C9CA237B, 60FE8BFA252E3EF2D60B77AD, diff --git a/Juce.jucer b/Juce.jucer index 48554a183e..b3e6fde580 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -1092,8 +1092,6 @@ file="src/gui/graphics/geometry/juce_AffineTransform.cpp"/> - @@ -1109,10 +1107,6 @@ - - (8)); } @@ -235,7 +235,7 @@ private: void resized() { - comboBox.setBoundsInset (BorderSize (2)); + comboBox.setBoundsInset (BorderSize (2)); } // Our demo code will call this when we may need to update our contents diff --git a/extras/juce demo/Source/demos/TreeViewDemo.cpp b/extras/juce demo/Source/demos/TreeViewDemo.cpp index 05944f7142..f8dc165541 100644 --- a/extras/juce demo/Source/demos/TreeViewDemo.cpp +++ b/extras/juce demo/Source/demos/TreeViewDemo.cpp @@ -170,9 +170,9 @@ public: void resized() { if (treeView != 0) - treeView->setBoundsInset (BorderSize (40, 10, 10, 10)); + treeView->setBoundsInset (BorderSize (40, 10, 10, 10)); else if (fileTreeComp != 0) - fileTreeComp->setBoundsInset (BorderSize (40, 10, 10, 10)); + fileTreeComp->setBoundsInset (BorderSize (40, 10, 10, 10)); typeButton.changeWidthToFitText (22); typeButton.setTopLeftPosition (10, 10); diff --git a/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj b/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj index c0d52d3f44..a930178bf4 100644 --- a/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj +++ b/extras/the jucer/build/mac/Jucer.xcodeproj/project.pbxproj @@ -441,7 +441,14 @@ isa = PBXProject; buildConfigurationList = C0E91AC908A95435008D54AB /* Build configuration list for PBXProject "Jucer" */; compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); mainGroup = 20286C29FDCF999611CA2CEA /* Jucer */; projectDirPath = ""; projectRoot = ""; diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp b/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp index 05ee536b9d..9bb51efd7d 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp @@ -51,7 +51,7 @@ PaintElement::PaintElement (PaintRoutine* owner_, addChildComponent (border = new ResizableBorderComponent (this, this)); - border->setBorderThickness (BorderSize (borderThickness)); + border->setBorderThickness (BorderSize (borderThickness)); if (owner != 0) owner->getSelectedElements().addChangeListener (this); @@ -260,7 +260,7 @@ void PaintElement::paint (Graphics& g) if (selected) { - const BorderSize borderSize (border->getBorderThickness()); + const BorderSize borderSize (border->getBorderThickness()); drawResizableBorder (g, getWidth(), getHeight(), borderSize, (isMouseOverOrDragging() || border->isMouseOverOrDragging())); diff --git a/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp b/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp index 3d3b0fc0c8..dff4215b54 100644 --- a/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp +++ b/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp @@ -42,7 +42,7 @@ ComponentOverlayComponent::ComponentOverlayComponent (Component* const target_, addChildComponent (border = new ResizableBorderComponent (this, this)); - border->setBorderThickness (BorderSize (borderThickness)); + border->setBorderThickness (BorderSize (borderThickness)); target->addComponentListener (this); @@ -81,7 +81,7 @@ void ComponentOverlayComponent::paint (Graphics& g) if (selected) { - const BorderSize borderSize (border->getBorderThickness()); + const BorderSize borderSize (border->getBorderThickness()); drawResizableBorder (g, getWidth(), getHeight(), borderSize, (isMouseOverOrDragging() || border->isMouseOverOrDragging())); } diff --git a/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp b/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp index eb9f74b858..619b14e853 100644 --- a/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp +++ b/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp @@ -55,7 +55,7 @@ public: void resized() { - reloadButton->setBoundsInset (BorderSize (2)); + reloadButton->setBoundsInset (BorderSize (2)); } void buttonClicked (Button*) diff --git a/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp b/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp index e40cc5e0a6..11ca6bd858 100644 --- a/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp +++ b/extras/the jucer/src/utility/jucer_UtilityFunctions.cpp @@ -569,7 +569,7 @@ const String justificationToCode (const Justification& justification) //============================================================================== void drawResizableBorder (Graphics& g, int w, int h, - const BorderSize borderSize, + const BorderSize borderSize, const bool isMouseOver) { g.setColour (Colours::orange.withAlpha (isMouseOver ? 0.4f : 0.3f)); diff --git a/extras/the jucer/src/utility/jucer_UtilityFunctions.h b/extras/the jucer/src/utility/jucer_UtilityFunctions.h index aa6ca8f7f7..e5ca42084b 100644 --- a/extras/the jucer/src/utility/jucer_UtilityFunctions.h +++ b/extras/the jucer/src/utility/jucer_UtilityFunctions.h @@ -28,6 +28,555 @@ class JucerDocument; class ComponentLayout; +//============================================================================== +/** + A rectangle whose co-ordinates can be defined in terms of absolute or + proportional distances. + + Designed mainly for storing component positions, this gives you a lot of + control over how each co-ordinate is stored, either as an absolute position, + or as a proportion of the size of a parent rectangle. + + It also allows you to define the anchor points by which the rectangle is + positioned, so for example you could specify that the top right of the + rectangle should be an absolute distance from its parent's bottom-right corner. + + This object can be stored as a string, which takes the form "x y w h", including + symbols like '%' and letters to indicate the anchor point. See its toString() + method for more info. + + Example usage: + @code + class MyComponent + { + void resized() + { + // this will set the child component's x to be 20% of our width, its y + // to be 30, its width to be 150, and its height to be 50% of our + // height.. + const PositionedRectangle pos1 ("20% 30 150 50%"); + pos1.applyToComponent (*myChildComponent1); + + // this will inset the child component with a gap of 10 pixels + // around each of its edges.. + const PositionedRectangle pos2 ("10 10 20M 20M"); + pos2.applyToComponent (*myChildComponent2); + } + }; + @endcode +*/ +class PositionedRectangle +{ +public: + //============================================================================== + /** Creates an empty rectangle with all co-ordinates set to zero. + + The default anchor point is top-left; the default + */ + PositionedRectangle() throw() + : x (0.0), y (0.0), w (0.0), h (0.0), + xMode (anchorAtLeftOrTop | absoluteFromParentTopLeft), + yMode (anchorAtLeftOrTop | absoluteFromParentTopLeft), + wMode (absoluteSize), hMode (absoluteSize) + { + } + + /** Initialises a PositionedRectangle from a saved string version. + + The string must be in the format generated by toString(). + */ + PositionedRectangle (const String& stringVersion) throw() + { + StringArray tokens; + tokens.addTokens (stringVersion, false); + + decodePosString (tokens [0], xMode, x); + decodePosString (tokens [1], yMode, y); + decodeSizeString (tokens [2], wMode, w); + decodeSizeString (tokens [3], hMode, h); + } + + /** Creates a copy of another PositionedRectangle. */ + PositionedRectangle (const PositionedRectangle& other) throw() + : x (other.x), y (other.y), w (other.w), h (other.h), + xMode (other.xMode), yMode (other.yMode), + wMode (other.wMode), hMode (other.hMode) + { + } + + /** Copies another PositionedRectangle. */ + PositionedRectangle& operator= (const PositionedRectangle& other) throw() + { + x = other.x; + y = other.y; + w = other.w; + h = other.h; + xMode = other.xMode; + yMode = other.yMode; + wMode = other.wMode; + hMode = other.hMode; + + return *this; + } + + //============================================================================== + /** Returns a string version of this position, from which it can later be + re-generated. + + The format is four co-ordinates, "x y w h". + + - If a co-ordinate is absolute, it is stored as an integer, e.g. "100". + - If a co-ordinate is proportional to its parent's width or height, it is stored + as a percentage, e.g. "80%". + - If the X or Y co-ordinate is relative to the parent's right or bottom edge, the + number has "R" appended to it, e.g. "100R" means a distance of 100 pixels from + the parent's right-hand edge. + - If the X or Y co-ordinate is relative to the parent's centre, the number has "C" + appended to it, e.g. "-50C" would be 50 pixels left of the parent's centre. + - If the X or Y co-ordinate should be anchored at the component's right or bottom + edge, then it has "r" appended to it. So "-50Rr" would mean that this component's + right-hand edge should be 50 pixels left of the parent's right-hand edge. + - If the X or Y co-ordinate should be anchored at the component's centre, then it + has "c" appended to it. So "-50Rc" would mean that this component's + centre should be 50 pixels left of the parent's right-hand edge. "40%c" means that + this component's centre should be placed 40% across the parent's width. + - If it's a width or height that should use the parentSizeMinusAbsolute mode, then + the number has "M" appended to it. + + To reload a stored string, use the constructor that takes a string parameter. + */ + const String toString() const throw() + { + String s; + s.preallocateStorage (12); + addPosDescription (s, xMode, x); s << ' '; + addPosDescription (s, yMode, y); s << ' '; + addSizeDescription (s, wMode, w); s << ' '; + addSizeDescription (s, hMode, h); + return s; + } + + //============================================================================== + /** Calculates the absolute position, given the size of the space that + it should go in. + + This will work out any proportional distances and sizes relative to the + target rectangle, and will return the absolute position. + + @see applyToComponent + */ + const Rectangle getRectangle (const Rectangle& target) const throw() + { + jassert (! target.isEmpty()); + + double x_, y_, w_, h_; + applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); + applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); + return Rectangle (roundToInt (x_), roundToInt (y_), roundToInt (w_), roundToInt (h_)); + } + + /** Same as getRectangle(), but returning the values as doubles rather than ints. */ + void getRectangleDouble (const Rectangle& target, + double& x_, double& y_, double& w_, double& h_) const throw() + { + jassert (! target.isEmpty()); + applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); + applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); + } + + /** This sets the bounds of the given component to this position. + + This is equivalent to writing: + @code + comp.setBounds (getRectangle (Rectangle (0, 0, comp.getParentWidth(), comp.getParentHeight()))); + @endcode + + @see getRectangle, updateFromComponent + */ + void applyToComponent (Component& comp) const throw() + { + comp.setBounds (getRectangle (Rectangle (comp.getParentWidth(), comp.getParentHeight()))); + } + + //============================================================================== + /** Updates this object's co-ordinates to match the given rectangle. + + This will set all co-ordinates based on the given rectangle, re-calculating + any proportional distances, and using the current anchor points. + + So for example if the x co-ordinate mode is currently proportional, this will + re-calculate x based on the rectangle's relative position within the target + rectangle's width. + + If the target rectangle's width or height are zero then it may not be possible + to re-calculate some proportional co-ordinates. In this case, those co-ordinates + will not be changed. + */ + void updateFrom (const Rectangle& newPosition, + const Rectangle& targetSpaceToBeRelativeTo) throw() + { + updatePosAndSize (x, w, newPosition.getX(), newPosition.getWidth(), xMode, wMode, targetSpaceToBeRelativeTo.getX(), targetSpaceToBeRelativeTo.getWidth()); + updatePosAndSize (y, h, newPosition.getY(), newPosition.getHeight(), yMode, hMode, targetSpaceToBeRelativeTo.getY(), targetSpaceToBeRelativeTo.getHeight()); + } + + /** Same functionality as updateFrom(), but taking doubles instead of ints. + */ + void updateFromDouble (const double newX, const double newY, + const double newW, const double newH, + const Rectangle& target) throw() + { + updatePosAndSize (x, w, newX, newW, xMode, wMode, target.getX(), target.getWidth()); + updatePosAndSize (y, h, newY, newH, yMode, hMode, target.getY(), target.getHeight()); + } + + /** Updates this object's co-ordinates to match the bounds of this component. + + This is equivalent to calling updateFrom() with the component's bounds and + it parent size. + + If the component doesn't currently have a parent, then proportional co-ordinates + might not be updated because it would need to know the parent's size to do the + maths for this. + */ + void updateFromComponent (const Component& comp) throw() + { + if (comp.getParentComponent() == 0 && ! comp.isOnDesktop()) + updateFrom (comp.getBounds(), Rectangle()); + else + updateFrom (comp.getBounds(), Rectangle (comp.getParentWidth(), comp.getParentHeight())); + } + + //============================================================================== + /** Specifies the point within the rectangle, relative to which it should be positioned. */ + enum AnchorPoint + { + anchorAtLeftOrTop = 1 << 0, /**< The x or y co-ordinate specifies where the left or top edge of the rectangle should be. */ + anchorAtRightOrBottom = 1 << 1, /**< The x or y co-ordinate specifies where the right or bottom edge of the rectangle should be. */ + anchorAtCentre = 1 << 2 /**< The x or y co-ordinate specifies where the centre of the rectangle should be. */ + }; + + /** Specifies how an x or y co-ordinate should be interpreted. */ + enum PositionMode + { + absoluteFromParentTopLeft = 1 << 3, /**< The x or y co-ordinate specifies an absolute distance from the parent's top or left edge. */ + absoluteFromParentBottomRight = 1 << 4, /**< The x or y co-ordinate specifies an absolute distance from the parent's bottom or right edge. */ + absoluteFromParentCentre = 1 << 5, /**< The x or y co-ordinate specifies an absolute distance from the parent's centre. */ + proportionOfParentSize = 1 << 6 /**< The x or y co-ordinate specifies a proportion of the parent's width or height, measured from the parent's top or left. */ + }; + + /** Specifies how the width or height should be interpreted. */ + enum SizeMode + { + absoluteSize = 1 << 0, /**< The width or height specifies an absolute size. */ + parentSizeMinusAbsolute = 1 << 1, /**< The width or height is an amount that should be subtracted from the parent's width or height. */ + proportionalSize = 1 << 2, /**< The width or height specifies a proportion of the parent's width or height. */ + }; + + //============================================================================== + /** Sets all options for all co-ordinates. + + This requires a reference rectangle to be specified, because if you're changing any + of the modes from proportional to absolute or vice-versa, then it'll need to convert + the co-ordinates, and will need to know the parent size so it can calculate this. + */ + void setModes (const AnchorPoint xAnchor, const PositionMode xMode_, + const AnchorPoint yAnchor, const PositionMode yMode_, + const SizeMode widthMode, const SizeMode heightMode, + const Rectangle& target) throw() + { + if (xMode != (xAnchor | xMode_) || wMode != widthMode) + { + double tx, tw; + applyPosAndSize (tx, tw, x, w, xMode, wMode, target.getX(), target.getWidth()); + + xMode = (uint8) (xAnchor | xMode_); + wMode = (uint8) widthMode; + + updatePosAndSize (x, w, tx, tw, xMode, wMode, target.getX(), target.getWidth()); + } + + if (yMode != (yAnchor | yMode_) || hMode != heightMode) + { + double ty, th; + applyPosAndSize (ty, th, y, h, yMode, hMode, target.getY(), target.getHeight()); + + yMode = (uint8) (yAnchor | yMode_); + hMode = (uint8) heightMode; + + updatePosAndSize (y, h, ty, th, yMode, hMode, target.getY(), target.getHeight()); + } + } + + /** Returns the anchoring mode for the x co-ordinate. + To change any of the modes, use setModes(). + */ + AnchorPoint getAnchorPointX() const throw() + { + return (AnchorPoint) (xMode & (anchorAtLeftOrTop | anchorAtRightOrBottom | anchorAtCentre)); + } + + /** Returns the positioning mode for the x co-ordinate. + To change any of the modes, use setModes(). + */ + PositionMode getPositionModeX() const throw() + { + return (PositionMode) (xMode & (absoluteFromParentTopLeft | absoluteFromParentBottomRight + | absoluteFromParentCentre | proportionOfParentSize)); + } + + /** Returns the raw x co-ordinate. + + If the x position mode is absolute, then this will be the absolute value. If it's + proportional, then this will be a fractional proportion, where 1.0 means the full + width of the parent space. + */ + double getX() const throw() { return x; } + + /** Sets the raw value of the x co-ordinate. + + See getX() for the meaning of this value. + */ + void setX (const double newX) throw() { x = newX; } + + /** Returns the anchoring mode for the y co-ordinate. + To change any of the modes, use setModes(). + */ + AnchorPoint getAnchorPointY() const throw() + { + return (AnchorPoint) (yMode & (anchorAtLeftOrTop | anchorAtRightOrBottom | anchorAtCentre)); + } + + /** Returns the positioning mode for the y co-ordinate. + To change any of the modes, use setModes(). + */ + PositionMode getPositionModeY() const throw() + { + return (PositionMode) (yMode & (absoluteFromParentTopLeft | absoluteFromParentBottomRight + | absoluteFromParentCentre | proportionOfParentSize)); + } + + /** Returns the raw y co-ordinate. + + If the y position mode is absolute, then this will be the absolute value. If it's + proportional, then this will be a fractional proportion, where 1.0 means the full + height of the parent space. + */ + double getY() const throw() { return y; } + + /** Sets the raw value of the y co-ordinate. + + See getY() for the meaning of this value. + */ + void setY (const double newY) throw() { y = newY; } + + /** Returns the mode used to calculate the width. + To change any of the modes, use setModes(). + */ + SizeMode getWidthMode() const throw() { return (SizeMode) wMode; } + + /** Returns the raw width value. + + If the width mode is absolute, then this will be the absolute value. If the mode is + proportional, then this will be a fractional proportion, where 1.0 means the full + width of the parent space. + */ + double getWidth() const throw() { return w; } + + /** Sets the raw width value. + + See getWidth() for the details about what this value means. + */ + void setWidth (const double newWidth) throw() { w = newWidth; } + + /** Returns the mode used to calculate the height. + To change any of the modes, use setModes(). + */ + SizeMode getHeightMode() const throw() { return (SizeMode) hMode; } + + /** Returns the raw height value. + + If the height mode is absolute, then this will be the absolute value. If the mode is + proportional, then this will be a fractional proportion, where 1.0 means the full + height of the parent space. + */ + double getHeight() const throw() { return h; } + + /** Sets the raw height value. + + See getHeight() for the details about what this value means. + */ + void setHeight (const double newHeight) throw() { h = newHeight; } + + //============================================================================== + /** If the size and position are constance, and wouldn't be affected by changes + in the parent's size, then this will return true. + */ + bool isPositionAbsolute() const throw() + { + return xMode == absoluteFromParentTopLeft + && yMode == absoluteFromParentTopLeft + && wMode == absoluteSize + && hMode == absoluteSize; + } + + //============================================================================== + /** Compares two objects. */ + bool operator== (const PositionedRectangle& other) const throw() + { + return x == other.x && y == other.y + && w == other.w && h == other.h + && xMode == other.xMode && yMode == other.yMode + && wMode == other.wMode && hMode == other.hMode; + } + + /** Compares two objects. */ + bool operator!= (const PositionedRectangle& other) const throw() + { + return ! operator== (other); + } + +private: + //============================================================================== + double x, y, w, h; + uint8 xMode, yMode, wMode, hMode; + + void addPosDescription (String& s, const uint8 mode, const double value) const throw() + { + if ((mode & proportionOfParentSize) != 0) + { + s << (roundToInt (value * 100000.0) / 1000.0) << '%'; + } + else + { + s << (roundToInt (value * 100.0) / 100.0); + + if ((mode & absoluteFromParentBottomRight) != 0) + s << 'R'; + else if ((mode & absoluteFromParentCentre) != 0) + s << 'C'; + } + + if ((mode & anchorAtRightOrBottom) != 0) + s << 'r'; + else if ((mode & anchorAtCentre) != 0) + s << 'c'; + } + + void addSizeDescription (String& s, const uint8 mode, const double value) const throw() + { + if (mode == proportionalSize) + s << (roundToInt (value * 100000.0) / 1000.0) << '%'; + else if (mode == parentSizeMinusAbsolute) + s << (roundToInt (value * 100.0) / 100.0) << 'M'; + else + s << (roundToInt (value * 100.0) / 100.0); + } + + void decodePosString (const String& s, uint8& mode, double& value) throw() + { + if (s.containsChar ('r')) + mode = anchorAtRightOrBottom; + else if (s.containsChar ('c')) + mode = anchorAtCentre; + else + mode = anchorAtLeftOrTop; + + if (s.containsChar ('%')) + { + mode |= proportionOfParentSize; + value = s.removeCharacters ("%rcRC").getDoubleValue() / 100.0; + } + else + { + if (s.containsChar ('R')) + mode |= absoluteFromParentBottomRight; + else if (s.containsChar ('C')) + mode |= absoluteFromParentCentre; + else + mode |= absoluteFromParentTopLeft; + + value = s.removeCharacters ("rcRC").getDoubleValue(); + } + } + + void decodeSizeString (const String& s, uint8& mode, double& value) throw() + { + if (s.containsChar ('%')) + { + mode = proportionalSize; + value = s.upToFirstOccurrenceOf ("%", false, false).getDoubleValue() / 100.0; + } + else if (s.containsChar ('M')) + { + mode = parentSizeMinusAbsolute; + value = s.getDoubleValue(); + } + else + { + mode = absoluteSize; + value = s.getDoubleValue(); + } + } + + void applyPosAndSize (double& xOut, double& wOut, const double x_, const double w_, + const uint8 xMode_, const uint8 wMode_, + const int parentPos, const int parentSize) const throw() + { + if (wMode_ == proportionalSize) + wOut = roundToInt (w_ * parentSize); + else if (wMode_ == parentSizeMinusAbsolute) + wOut = jmax (0, parentSize - roundToInt (w_)); + else + wOut = roundToInt (w_); + + if ((xMode_ & proportionOfParentSize) != 0) + xOut = parentPos + x_ * parentSize; + else if ((xMode_ & absoluteFromParentBottomRight) != 0) + xOut = (parentPos + parentSize) - x_; + else if ((xMode_ & absoluteFromParentCentre) != 0) + xOut = x_ + (parentPos + parentSize / 2); + else + xOut = x_ + parentPos; + + if ((xMode_ & anchorAtRightOrBottom) != 0) + xOut -= wOut; + else if ((xMode_ & anchorAtCentre) != 0) + xOut -= wOut / 2; + } + + void updatePosAndSize (double& xOut, double& wOut, double x_, const double w_, + const uint8 xMode_, const uint8 wMode_, + const int parentPos, const int parentSize) const throw() + { + if (wMode_ == proportionalSize) + { + if (parentSize > 0) + wOut = w_ / parentSize; + } + else if (wMode_ == parentSizeMinusAbsolute) + wOut = parentSize - w_; + else + wOut = w_; + + if ((xMode_ & anchorAtRightOrBottom) != 0) + x_ += w_; + else if ((xMode_ & anchorAtCentre) != 0) + x_ += w_ / 2; + + if ((xMode_ & proportionOfParentSize) != 0) + { + if (parentSize > 0) + xOut = (x_ - parentPos) / parentSize; + } + else if ((xMode_ & absoluteFromParentBottomRight) != 0) + xOut = (parentPos + parentSize) - x_; + else if ((xMode_ & absoluteFromParentCentre) != 0) + xOut = x_ - (parentPos + parentSize / 2); + else + xOut = x_ - parentPos; + } +}; + //============================================================================== struct RelativePositionedRectangle { @@ -106,7 +655,7 @@ void positionToCode (const RelativePositionedRectangle& position, //============================================================================== void drawResizableBorder (Graphics& g, int w, int h, - const BorderSize borderSize, + const BorderSize borderSize, const bool isMouseOver); void drawMouseOverCorners (Graphics& g, int w, int h); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 71bf928b88..5b0336b6be 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -40617,7 +40617,7 @@ void Component::centreWithSize (const int width, const int height) width, height); } -void Component::setBoundsInset (const BorderSize& borders) +void Component::setBoundsInset (const BorderSize& borders) { setBounds (borders.subtractedFrom (ComponentHelpers::getParentOrMainMonitorBounds (*this))); } @@ -48199,7 +48199,7 @@ void Label::mouseDoubleClick (const MouseEvent& e) void Label::resized() { if (editor != 0) - editor->setBoundsInset (BorderSize (0)); + editor->setBoundsInset (BorderSize (0)); } void Label::focusGained (FocusChangeType cause) @@ -48698,10 +48698,8 @@ void ListBox::paintOverChildren (Graphics& g) void ListBox::resized() { - viewport->setBoundsInset (BorderSize (outlineThickness + ((headerComponent != 0) ? headerComponent->getHeight() : 0), - outlineThickness, - outlineThickness, - outlineThickness)); + viewport->setBoundsInset (BorderSize (outlineThickness + ((headerComponent != 0) ? headerComponent->getHeight() : 0), + outlineThickness, outlineThickness, outlineThickness)); viewport->setSingleStepSizes (20, getRowHeight()); @@ -53468,13 +53466,13 @@ void TextEditor::setIndents (const int newLeftIndent, topIndent = newTopIndent; } -void TextEditor::setBorder (const BorderSize& border) +void TextEditor::setBorder (const BorderSize& border) { borderSize = border; resized(); } -const BorderSize TextEditor::getBorder() const +const BorderSize TextEditor::getBorder() const { return borderSize; } @@ -55696,7 +55694,7 @@ void ToolbarItemPalette::replaceComponent (ToolbarItemComponent* const comp) void ToolbarItemPalette::resized() { - viewport.setBoundsInset (BorderSize (1)); + viewport.setBoundsInset (BorderSize (1)); Component* const itemHolder = viewport.getViewedComponent(); @@ -61673,7 +61671,7 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone jassert (component != 0); Rectangle limits, bounds (targetBounds); - BorderSize border; + BorderSize border; Component* const parent = component->getParentComponent(); @@ -62576,7 +62574,7 @@ bool ResizableBorderComponent::Zone::operator== (const ResizableBorderComponent: bool ResizableBorderComponent::Zone::operator!= (const ResizableBorderComponent::Zone& other) const throw() { return zone != other.zone; } const ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (const Rectangle& totalSize, - const BorderSize& border, + const BorderSize& border, const Point& position) { int z = 0; @@ -62698,7 +62696,7 @@ bool ResizableBorderComponent::hitTest (int x, int y) || y >= getHeight() - borderSize.getBottom(); } -void ResizableBorderComponent::setBorderThickness (const BorderSize& newBorderSize) +void ResizableBorderComponent::setBorderThickness (const BorderSize& newBorderSize) { if (borderSize != newBorderSize) { @@ -62707,7 +62705,7 @@ void ResizableBorderComponent::setBorderThickness (const BorderSize& newBorderSi } } -const BorderSize ResizableBorderComponent::getBorderThickness() const +const BorderSize ResizableBorderComponent::getBorderThickness() const { return borderSize; } @@ -64189,7 +64187,7 @@ namespace TabbedComponentHelpers delete comp; } - const Rectangle getTabArea (Rectangle& content, BorderSize& outline, + const Rectangle getTabArea (Rectangle& content, BorderSize& outline, const TabbedButtonBar::Orientation orientation, const int tabDepth) { switch (orientation) @@ -64387,7 +64385,7 @@ void TabbedComponent::paint (Graphics& g) g.fillAll (findColour (backgroundColourId)); Rectangle content (getLocalBounds()); - BorderSize outline (outlineThickness); + BorderSize outline (outlineThickness); TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth); g.reduceClipRegion (content); @@ -64406,10 +64404,10 @@ void TabbedComponent::paint (Graphics& g) void TabbedComponent::resized() { Rectangle content (getLocalBounds()); - BorderSize outline (outlineThickness); + BorderSize outline (outlineThickness); tabs->setBounds (TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth)); - content = BorderSize (edgeIndent).subtractedFrom (outline.subtractedFrom (content)); + content = BorderSize (edgeIndent).subtractedFrom (outline.subtractedFrom (content)); for (int i = contentComponents.size(); --i >= 0;) if (contentComponents.getReference (i) != 0) @@ -66554,7 +66552,7 @@ void LookAndFeel::drawCornerResizer (Graphics& g, } } -void LookAndFeel::drawResizableFrame (Graphics& g, int w, int h, const BorderSize& border) +void LookAndFeel::drawResizableFrame (Graphics& g, int w, int h, const BorderSize& border) { if (! border.isEmpty()) { @@ -66576,13 +66574,13 @@ void LookAndFeel::drawResizableFrame (Graphics& g, int w, int h, const BorderSiz } void LookAndFeel::fillResizableWindowBackground (Graphics& g, int /*w*/, int /*h*/, - const BorderSize& /*border*/, ResizableWindow& window) + const BorderSize& /*border*/, ResizableWindow& window) { g.fillAll (window.getBackgroundColour()); } void LookAndFeel::drawResizableWindowBorder (Graphics&, int /*w*/, int /*h*/, - const BorderSize& /*border*/, ResizableWindow&) + const BorderSize& /*border*/, ResizableWindow&) { } @@ -77609,7 +77607,7 @@ void DocumentWindow::paint (Graphics& g) { g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000))); - const BorderSize border (getBorderThickness()); + const BorderSize border (getBorderThickness()); g.fillRect (0, 0, getWidth(), border.getTop()); g.fillRect (0, border.getTop(), border.getLeft(), getHeight() - border.getTopAndBottom()); @@ -77667,15 +77665,15 @@ void DocumentWindow::resized() titleBarArea.getWidth(), menuBarHeight); } -const BorderSize DocumentWindow::getBorderThickness() +const BorderSize DocumentWindow::getBorderThickness() { - return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) - ? 0 : (resizableBorder != 0 ? 4 : 1)); + return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) + ? 0 : (resizableBorder != 0 ? 4 : 1)); } -const BorderSize DocumentWindow::getContentComponentBorder() +const BorderSize DocumentWindow::getContentComponentBorder() { - BorderSize border (getBorderThickness()); + BorderSize border (getBorderThickness()); border.setTop (border.getTop() + (isUsingNativeTitleBar() ? 0 : titleBarHeight) @@ -77691,7 +77689,7 @@ int DocumentWindow::getTitleBarHeight() const const Rectangle DocumentWindow::getTitleBarArea() { - const BorderSize border (getBorderThickness()); + const BorderSize border (getBorderThickness()); return Rectangle (border.getLeft(), border.getTop(), getWidth() - border.getLeftAndRight(), @@ -77900,18 +77898,18 @@ void ResizableWindow::setContentComponentSize (int width, int height) { jassert (width > 0 && height > 0); // not a great idea to give it a zero size.. - const BorderSize border (getContentComponentBorder()); + const BorderSize border (getContentComponentBorder()); setSize (width + border.getLeftAndRight(), height + border.getTopAndBottom()); } -const BorderSize ResizableWindow::getBorderThickness() +const BorderSize ResizableWindow::getBorderThickness() { - return BorderSize (isUsingNativeTitleBar() ? 0 : ((resizableBorder != 0 && ! isFullScreen()) ? 5 : 3)); + return BorderSize (isUsingNativeTitleBar() ? 0 : ((resizableBorder != 0 && ! isFullScreen()) ? 5 : 3)); } -const BorderSize ResizableWindow::getContentComponentBorder() +const BorderSize ResizableWindow::getContentComponentBorder() { return getBorderThickness(); } @@ -77977,7 +77975,7 @@ void ResizableWindow::childBoundsChanged (Component* child) jassert (child->getWidth() > 0); jassert (child->getHeight() > 0); - const BorderSize borders (getContentComponentBorder()); + const BorderSize borders (getContentComponentBorder()); setSize (child->getWidth() + borders.getLeftAndRight(), child->getHeight() + borders.getTopAndBottom()); @@ -77986,7 +77984,7 @@ void ResizableWindow::childBoundsChanged (Component* child) void ResizableWindow::activeWindowStatusChanged() { - const BorderSize border (getContentComponentBorder()); + const BorderSize border (getContentComponentBorder()); Rectangle area (getLocalBounds()); repaint (area.removeFromTop (border.getTop())); @@ -82706,21 +82704,19 @@ void Graphics::drawHorizontalLine (const int y, float left, float right) const context->drawHorizontalLine (y, left, right); } -void Graphics::drawLine (float x1, float y1, float x2, float y2) const +void Graphics::drawLine (const float x1, const float y1, const float x2, const float y2) const { context->drawLine (Line (x1, y1, x2, y2)); } -void Graphics::drawLine (const float startX, const float startY, - const float endX, const float endY, - const float lineThickness) const +void Graphics::drawLine (const Line& line) const { - drawLine (Line (startX, startY, endX, endY),lineThickness); + context->drawLine (line); } -void Graphics::drawLine (const Line& line) const +void Graphics::drawLine (const float x1, const float y1, const float x2, const float y2, const float lineThickness) const { - drawLine (line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY()); + drawLine (Line (x1, y1, x2, y2), lineThickness); } void Graphics::drawLine (const Line& line, const float lineThickness) const @@ -82730,42 +82726,35 @@ void Graphics::drawLine (const Line& line, const float lineThickness) con fillPath (p); } -void Graphics::drawDashedLine (const float startX, const float startY, - const float endX, const float endY, - const float* const dashLengths, - const int numDashLengths, - const float lineThickness) const +void Graphics::drawDashedLine (const Line& line, const float* const dashLengths, + const int numDashLengths, const float lineThickness, int n) const { - const double dx = endX - startX; - const double dy = endY - startY; - const double totalLen = juce_hypot (dx, dy); + jassert (n >= 0 && n < numDashLengths); // your start index must be valid! - if (totalLen >= 0.5) + const Point delta ((line.getEnd() - line.getStart()).toDouble()); + const double totalLen = delta.getDistanceFromOrigin(); + + if (totalLen >= 0.1) { const double onePixAlpha = 1.0 / totalLen; - double alpha = 0.0; - float x = startX; - float y = startY; - int n = 0; - - while (alpha < 1.0f) + for (double alpha = 0.0; alpha < 1.0;) { - alpha = jmin (1.0, alpha + dashLengths[n++] * onePixAlpha); - n = n % numDashLengths; - - const float oldX = x; - const float oldY = y; + jassert (dashLengths[n] > 0); // can't have zero-length dashes! - x = (float) (startX + dx * alpha); - y = (float) (startY + dy * alpha); + const double lastAlpha = alpha; + alpha = jmin (1.0, alpha + dashLengths [n] * onePixAlpha); + n = (n + 1) % numDashLengths; if ((n & 1) != 0) { + const Line segment (line.getStart() + (delta * lastAlpha).toFloat(), + line.getStart() + (delta * alpha).toFloat()); + if (lineThickness != 1.0f) - drawLine (oldX, oldY, x, y, lineThickness); + drawLine (segment, lineThickness); else - drawLine (oldX, oldY, x, y); + context->drawLine (segment); } } } @@ -91771,7 +91760,7 @@ const AffineTransform AffineTransform::inverted() const throw() bool AffineTransform::isSingularity() const throw() { - return (mat00 * mat11 - mat10 * mat01) == 0.0; + return (mat00 * mat11 - mat10 * mat01) == 0; } const AffineTransform AffineTransform::fromTargetPoints (const float x00, const float y00, @@ -91808,117 +91797,6 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_AffineTransform.cpp ***/ -/*** Start of inlined file: juce_BorderSize.cpp ***/ -BEGIN_JUCE_NAMESPACE - -BorderSize::BorderSize() throw() - : top (0), - left (0), - bottom (0), - right (0) -{ -} - -BorderSize::BorderSize (const BorderSize& other) throw() - : top (other.top), - left (other.left), - bottom (other.bottom), - right (other.right) -{ -} - -BorderSize::BorderSize (const int topGap, - const int leftGap, - const int bottomGap, - const int rightGap) throw() - : top (topGap), - left (leftGap), - bottom (bottomGap), - right (rightGap) -{ -} - -BorderSize::BorderSize (const int allGaps) throw() - : top (allGaps), - left (allGaps), - bottom (allGaps), - right (allGaps) -{ -} - -BorderSize::~BorderSize() throw() -{ -} - -void BorderSize::setTop (const int newTopGap) throw() -{ - top = newTopGap; -} - -void BorderSize::setLeft (const int newLeftGap) throw() -{ - left = newLeftGap; -} - -void BorderSize::setBottom (const int newBottomGap) throw() -{ - bottom = newBottomGap; -} - -void BorderSize::setRight (const int newRightGap) throw() -{ - right = newRightGap; -} - -const Rectangle BorderSize::subtractedFrom (const Rectangle& r) const throw() -{ - return Rectangle (r.getX() + left, - r.getY() + top, - r.getWidth() - (left + right), - r.getHeight() - (top + bottom)); -} - -void BorderSize::subtractFrom (Rectangle& r) const throw() -{ - r.setBounds (r.getX() + left, - r.getY() + top, - r.getWidth() - (left + right), - r.getHeight() - (top + bottom)); -} - -const Rectangle BorderSize::addedTo (const Rectangle& r) const throw() -{ - return Rectangle (r.getX() - left, - r.getY() - top, - r.getWidth() + (left + right), - r.getHeight() + (top + bottom)); -} - -void BorderSize::addTo (Rectangle& r) const throw() -{ - r.setBounds (r.getX() - left, - r.getY() - top, - r.getWidth() + (left + right), - r.getHeight() + (top + bottom)); -} - -bool BorderSize::operator== (const BorderSize& other) const throw() -{ - return top == other.top - && left == other.left - && bottom == other.bottom - && right == other.right; -} - -bool BorderSize::operator!= (const BorderSize& other) const throw() -{ - return ! operator== (other); -} - -END_JUCE_NAMESPACE -/*** End of inlined file: juce_BorderSize.cpp ***/ - - /*** Start of inlined file: juce_Path.cpp ***/ BEGIN_JUCE_NAMESPACE @@ -94438,13 +94316,6 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_PathStrokeType.cpp ***/ -/*** Start of inlined file: juce_PositionedRectangle.cpp ***/ -BEGIN_JUCE_NAMESPACE - -END_JUCE_NAMESPACE -/*** End of inlined file: juce_PositionedRectangle.cpp ***/ - - /*** Start of inlined file: juce_RectangleList.cpp ***/ BEGIN_JUCE_NAMESPACE @@ -241871,10 +241742,10 @@ public: if (GetWindowInfo (hwnd, &info)) { - windowBorder = BorderSize (info.rcClient.top - info.rcWindow.top, - info.rcClient.left - info.rcWindow.left, - info.rcWindow.bottom - info.rcClient.bottom, - info.rcWindow.right - info.rcClient.right); + windowBorder = BorderSize (info.rcClient.top - info.rcWindow.top, + info.rcClient.left - info.rcWindow.left, + info.rcWindow.bottom - info.rcClient.bottom, + info.rcWindow.right - info.rcClient.right); } #if JUCE_DIRECT2D @@ -242053,7 +241924,7 @@ public: return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0)); } - const BorderSize getFrameSize() const + const BorderSize getFrameSize() const { return windowBorder; } @@ -242316,7 +242187,7 @@ private: ScopedPointer direct2DContext; #endif bool fullScreen, isDragging, isMouseOver, hasCreatedCaret, constrainerIsResizing; - BorderSize windowBorder; + BorderSize windowBorder; HICON currentWindowIcon; ScopedPointer taskBarIcon; IDropTarget* dropTarget; @@ -257673,9 +257544,9 @@ public: return child == None; } - const BorderSize getFrameSize() const + const BorderSize getFrameSize() const { - return BorderSize(); + return BorderSize(); } bool setAlwaysOnTop (bool alwaysOnTop) @@ -258505,7 +258376,7 @@ private: bool fullScreen, mapped; Visual* visual; int depth; - BorderSize windowBorder; + BorderSize windowBorder; struct MotifWmHints { @@ -258919,7 +258790,7 @@ private: { if ((styleFlags & windowHasTitleBar) == 0) { - windowBorder = BorderSize (0); + windowBorder = BorderSize (0); } else if (windowBorder.getTopAndBottom() == 0 && windowBorder.getLeftAndRight() == 0) { @@ -258940,8 +258811,8 @@ private: const unsigned long* const sizes = (const unsigned long*) data; if (actualFormat == 32) - windowBorder = BorderSize ((int) sizes[2], (int) sizes[0], - (int) sizes[3], (int) sizes[1]); + windowBorder = BorderSize ((int) sizes[2], (int) sizes[0], + (int) sizes[3], (int) sizes[1]); XFree (data); } @@ -266453,7 +266324,7 @@ public: void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; bool contains (const Point& position, bool trueIfInAChildWindow) const; - const BorderSize getFrameSize() const; + const BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); void toBehind (ComponentPeer* other); @@ -267003,9 +266874,9 @@ bool UIViewComponentPeer::contains (const Point& position, bool trueIfInACh return v == view; } -const BorderSize UIViewComponentPeer::getFrameSize() const +const BorderSize UIViewComponentPeer::getFrameSize() const { - return BorderSize(); + return BorderSize(); } bool UIViewComponentPeer::setAlwaysOnTop (bool alwaysOnTop) @@ -271211,7 +271082,7 @@ public: void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; bool contains (const Point& position, bool trueIfInAChildWindow) const; - const BorderSize getFrameSize() const; + const BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); void toBehind (ComponentPeer* other); @@ -272206,9 +272077,9 @@ bool NSViewComponentPeer::contains (const Point& position, bool trueIfInACh return v == view; } -const BorderSize NSViewComponentPeer::getFrameSize() const +const BorderSize NSViewComponentPeer::getFrameSize() const { - BorderSize b; + BorderSize b; if (! isSharedWindow) { diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 821173e632..174b231f03 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 12 +#define JUCE_BUILDNUMBER 13 /** Current Juce version number. @@ -20668,7 +20668,7 @@ class Point public: /** Creates a point with co-ordinates (0, 0). */ - Point() throw() : x (0), y (0) {} + Point() throw() : x(), y() {} /** Creates a copy of another point. */ Point (const Point& other) throw() : x (other.x), y (other.y) {} @@ -20779,11 +20779,14 @@ public: const Point transformedBy (const AffineTransform& transform) const throw() { return Point (transform.mat00 * x + transform.mat01 * y + transform.mat02, transform.mat10 * x + transform.mat11 * y + transform.mat12); } + /** Casts this point to a Point object. */ + const Point toInt() const throw() { return Point (static_cast (x), static_cast (y)); } + /** Casts this point to a Point object. */ const Point toFloat() const throw() { return Point (static_cast (x), static_cast (y)); } - /** Casts this point to a Point object. */ - const Point toInt() const throw() { return Point (static_cast (x), static_cast (y)); } + /** Casts this point to a Point object. */ + const Point toDouble() const throw() { return Point (static_cast (x), static_cast (y)); } /** Returns the point as a string in the form "x, y". */ const String toString() const { return String (x) + ", " + String (y); } @@ -21930,7 +21933,7 @@ public: The default co-ordinates will be (0, 0, 0, 0). */ Rectangle() throw() - : x (0), y (0), w (0), h (0) + : x(), y(), w(), h() { } @@ -21951,7 +21954,7 @@ public: /** Creates a rectangle with a given size, and a position of (0, 0). */ Rectangle (const ValueType width, const ValueType height) throw() - : x (0), y (0), w (width), h (height) + : x(), y(), w (width), h (height) { } @@ -21962,8 +21965,8 @@ public: w (corner1.getX() - corner2.getX()), h (corner1.getY() - corner2.getY()) { - if (w < 0) w = -w; - if (h < 0) h = -h; + if (w < ValueType()) w = -w; + if (h < ValueType()) h = -h; } /** Creates a Rectangle from a set of left, right, top, bottom coordinates. @@ -21987,7 +21990,7 @@ public: ~Rectangle() throw() {} /** Returns true if the rectangle's width and height are both zero or less */ - bool isEmpty() const throw() { return w <= 0 || h <= 0; } + bool isEmpty() const throw() { return w <= ValueType() || h <= ValueType(); } /** Returns the x co-ordinate of the rectangle's left-hand-side. */ inline ValueType getX() const throw() { return x; } @@ -22382,12 +22385,12 @@ public: const int maxX = jmax (otherX, x); otherW = jmin (otherX + otherW, x + w) - maxX; - if (otherW > 0) + if (otherW > ValueType()) { const int maxY = jmax (otherY, y); otherH = jmin (otherY + otherH, y + h) - maxY; - if (otherH > 0) + if (otherH > ValueType()) { otherX = maxX; otherY = maxY; return true; @@ -22553,12 +22556,12 @@ public: const ValueType x = jmax (x1, x2); w1 = jmin (x1 + w1, x2 + w2) - x; - if (w1 > 0) + if (w1 > ValueType()) { const ValueType y = jmax (y1, y2); h1 = jmin (y1 + h1, y2 + h2) - y; - if (h1 > 0) + if (h1 > ValueType()) { x1 = x; y1 = y; return true; @@ -25780,21 +25783,19 @@ public: /** Draws a dashed line using a custom set of dash-lengths. - @param startX the line's start x co-ordinate - @param startY the line's start y co-ordinate - @param endX the line's end x co-ordinate - @param endY the line's end y co-ordinate + @param line the line to draw @param dashLengths a series of lengths to specify the on/off lengths - e.g. { 4, 5, 6, 7 } will draw a line of 4 pixels, skip 5 pixels, draw 6 pixels, skip 7 pixels, and then repeat. @param numDashLengths the number of elements in the array (this must be an even number). @param lineThickness the thickness of the line to draw + @param dashIndexToStartFrom the index in the dash-length array to use for the first segment @see PathStrokeType::createDashedStroke */ - void drawDashedLine (float startX, float startY, - float endX, float endY, + void drawDashedLine (const Line& line, const float* dashLengths, int numDashLengths, - float lineThickness = 1.0f) const; + float lineThickness = 1.0f, + int dashIndexToStartFrom = 0) const; /** Draws a vertical line of pixels at a given x position. @@ -26758,82 +26759,113 @@ private: @see Rectangle */ -class JUCE_API BorderSize +template +class BorderSize { public: /** Creates a null border. - All sizes are left as 0. */ - BorderSize() throw(); + BorderSize() throw() + : top(), left(), bottom(), right() + { + } /** Creates a copy of another border. */ - BorderSize (const BorderSize& other) throw(); + BorderSize (const BorderSize& other) throw() + : top (other.top), left (other.left), bottom (other.bottom), right (other.right) + { + } /** Creates a border with the given gaps. */ - BorderSize (int topGap, - int leftGap, - int bottomGap, - int rightGap) throw(); + BorderSize (ValueType topGap, ValueType leftGap, ValueType bottomGap, ValueType rightGap) throw() + : top (topGap), left (leftGap), bottom (bottomGap), right (rightGap) + { + } /** Creates a border with the given gap on all sides. */ - explicit BorderSize (int allGaps) throw(); - - /** Destructor. */ - ~BorderSize() throw(); + explicit BorderSize (ValueType allGaps) throw() + : top (allGaps), left (allGaps), bottom (allGaps), right (allGaps) + { + } /** Returns the gap that should be left at the top of the region. */ - int getTop() const throw() { return top; } + ValueType getTop() const throw() { return top; } /** Returns the gap that should be left at the top of the region. */ - int getLeft() const throw() { return left; } + ValueType getLeft() const throw() { return left; } /** Returns the gap that should be left at the top of the region. */ - int getBottom() const throw() { return bottom; } + ValueType getBottom() const throw() { return bottom; } /** Returns the gap that should be left at the top of the region. */ - int getRight() const throw() { return right; } + ValueType getRight() const throw() { return right; } /** Returns the sum of the top and bottom gaps. */ - int getTopAndBottom() const throw() { return top + bottom; } + ValueType getTopAndBottom() const throw() { return top + bottom; } /** Returns the sum of the left and right gaps. */ - int getLeftAndRight() const throw() { return left + right; } + ValueType getLeftAndRight() const throw() { return left + right; } /** Returns true if this border has no thickness along any edge. */ - bool isEmpty() const throw() { return left + right + top + bottom == 0; } + bool isEmpty() const throw() { return left + right + top + bottom == ValueType(); } /** Changes the top gap. */ - void setTop (int newTopGap) throw(); + void setTop (ValueType newTopGap) throw() { top = newTopGap; } /** Changes the left gap. */ - void setLeft (int newLeftGap) throw(); + void setLeft (ValueType newLeftGap) throw() { left = newLeftGap; } /** Changes the bottom gap. */ - void setBottom (int newBottomGap) throw(); + void setBottom (ValueType newBottomGap) throw() { bottom = newBottomGap; } /** Changes the right gap. */ - void setRight (int newRightGap) throw(); + void setRight (ValueType newRightGap) throw() { right = newRightGap; } /** Returns a rectangle with these borders removed from it. */ - const Rectangle subtractedFrom (const Rectangle& original) const throw(); + const Rectangle subtractedFrom (const Rectangle& original) const throw() + { + return Rectangle (original.getX() + left, + original.getY() + top, + original.getWidth() - (left + right), + original.getHeight() - (top + bottom)); + } /** Removes this border from a given rectangle. */ - void subtractFrom (Rectangle& rectangle) const throw(); + void subtractFrom (Rectangle& rectangle) const throw() + { + rectangle = subtractedFrom (rectangle); + } /** Returns a rectangle with these borders added around it. */ - const Rectangle addedTo (const Rectangle& original) const throw(); + const Rectangle addedTo (const Rectangle& original) const throw() + { + return Rectangle (original.getX() - left, + original.getY() - top, + original.getWidth() + (left + right), + original.getHeight() + (top + bottom)); + } /** Adds this border around a given rectangle. */ - void addTo (Rectangle& original) const throw(); + void addTo (Rectangle& rectangle) const throw() + { + rectangle = addedTo (rectangle); + } + + bool operator== (const BorderSize& other) const throw() + { + return top == other.top && left == other.left && bottom == other.bottom && right == other.right; + } - bool operator== (const BorderSize& other) const throw(); - bool operator!= (const BorderSize& other) const throw(); + bool operator!= (const BorderSize& other) const throw() + { + return ! operator== (other); + } private: - int top, left, bottom, right; + ValueType top, left, bottom, right; JUCE_LEAK_DETECTOR (BorderSize); }; @@ -27499,7 +27531,7 @@ public: @see setBounds */ - void setBoundsInset (const BorderSize& borders); + void setBoundsInset (const BorderSize& borders); /** Positions the component within a given rectangle, keeping its proportions unchanged. @@ -38929,13 +38961,13 @@ public: @see getBorder */ - void setBorder (const BorderSize& border); + void setBorder (const BorderSize& border); /** Returns the size of border around the edge of the component. @see setBorder */ - const BorderSize getBorder() const; + const BorderSize getBorder() const; /** Used to disable the auto-scrolling which keeps the cursor visible. @@ -39054,7 +39086,7 @@ private: ScopedPointer viewport; TextHolderComponent* textHolder; - BorderSize borderSize; + BorderSize borderSize; bool readOnly : 1; bool multiline : 1; @@ -52293,13 +52325,13 @@ public: @see getBorderThickness */ - void setBorderThickness (const BorderSize& newBorderSize); + void setBorderThickness (const BorderSize& newBorderSize); /** Returns the number of pixels wide that the draggable edges of this component are. @see setBorderThickness */ - const BorderSize getBorderThickness() const; + const BorderSize getBorderThickness() const; /** Represents the different sections of a resizable border, which allow it to resized in different ways. @@ -52329,7 +52361,7 @@ public: zone that the point lies within. */ static const Zone fromPositionOnBorder (const Rectangle& totalSize, - const BorderSize& border, + const BorderSize& border, const Point& position); /** Returns an appropriate mouse-cursor for this resize zone. */ @@ -52399,7 +52431,7 @@ protected: private: WeakReference component; ComponentBoundsConstrainer* constrainer; - BorderSize borderSize; + BorderSize borderSize; Rectangle originalBounds; Zone mouseZone; @@ -52709,12 +52741,12 @@ public: /** Returns the width of the frame to use around the window. @see getContentComponentBorder */ - virtual const BorderSize getBorderThickness(); + virtual const BorderSize getBorderThickness(); /** Returns the insets to use when positioning the content component. @see getBorderThickness */ - virtual const BorderSize getContentComponentBorder(); + virtual const BorderSize getContentComponentBorder(); /** A set of colour IDs to use to change the colour of various aspects of the window. @@ -55094,9 +55126,9 @@ public: /** @internal */ void lookAndFeelChanged(); /** @internal */ - const BorderSize getBorderThickness(); + const BorderSize getBorderThickness(); /** @internal */ - const BorderSize getContentComponentBorder(); + const BorderSize getContentComponentBorder(); /** @internal */ void mouseDoubleClick (const MouseEvent& e); /** @internal */ @@ -56671,15 +56703,15 @@ public: virtual void drawResizableFrame (Graphics& g, int w, int h, - const BorderSize& borders); + const BorderSize& borders); virtual void fillResizableWindowBackground (Graphics& g, int w, int h, - const BorderSize& border, + const BorderSize& border, ResizableWindow& window); virtual void drawResizableWindowBorder (Graphics& g, int w, int h, - const BorderSize& border, + const BorderSize& border, ResizableWindow& window); virtual void drawDocumentWindowTitleBar (DocumentWindow& window, @@ -60619,7 +60651,7 @@ public: Whether or not the window has a normal window frame depends on the flags that were set when the window was created by Component::addToDesktop() */ - virtual const BorderSize getFrameSize() const = 0; + virtual const BorderSize getFrameSize() const = 0; /** This is called when the window's bounds change. @@ -62665,560 +62697,6 @@ private: #endif #ifndef __JUCE_POINT_JUCEHEADER__ -#endif -#ifndef __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ - -/*** Start of inlined file: juce_PositionedRectangle.h ***/ -#ifndef __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ -#define __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ - -/** - A rectangle whose co-ordinates can be defined in terms of absolute or - proportional distances. - - Designed mainly for storing component positions, this gives you a lot of - control over how each co-ordinate is stored, either as an absolute position, - or as a proportion of the size of a parent rectangle. - - It also allows you to define the anchor points by which the rectangle is - positioned, so for example you could specify that the top right of the - rectangle should be an absolute distance from its parent's bottom-right corner. - - This object can be stored as a string, which takes the form "x y w h", including - symbols like '%' and letters to indicate the anchor point. See its toString() - method for more info. - - Example usage: - @code - class MyComponent - { - void resized() - { - // this will set the child component's x to be 20% of our width, its y - // to be 30, its width to be 150, and its height to be 50% of our - // height.. - const PositionedRectangle pos1 ("20% 30 150 50%"); - pos1.applyToComponent (*myChildComponent1); - - // this will inset the child component with a gap of 10 pixels - // around each of its edges.. - const PositionedRectangle pos2 ("10 10 20M 20M"); - pos2.applyToComponent (*myChildComponent2); - } - }; - @endcode -*/ -class PositionedRectangle -{ -public: - - /** Creates an empty rectangle with all co-ordinates set to zero. - - The default anchor point is top-left; the default - */ - PositionedRectangle() throw() - : x (0.0), y (0.0), w (0.0), h (0.0), - xMode (anchorAtLeftOrTop | absoluteFromParentTopLeft), - yMode (anchorAtLeftOrTop | absoluteFromParentTopLeft), - wMode (absoluteSize), hMode (absoluteSize) - { - } - - /** Initialises a PositionedRectangle from a saved string version. - - The string must be in the format generated by toString(). - */ - PositionedRectangle (const String& stringVersion) throw() - { - StringArray tokens; - tokens.addTokens (stringVersion, false); - - decodePosString (tokens [0], xMode, x); - decodePosString (tokens [1], yMode, y); - decodeSizeString (tokens [2], wMode, w); - decodeSizeString (tokens [3], hMode, h); - } - - /** Creates a copy of another PositionedRectangle. */ - PositionedRectangle (const PositionedRectangle& other) throw() - : x (other.x), y (other.y), w (other.w), h (other.h), - xMode (other.xMode), yMode (other.yMode), - wMode (other.wMode), hMode (other.hMode) - { - } - - /** Copies another PositionedRectangle. */ - PositionedRectangle& operator= (const PositionedRectangle& other) throw() - { - x = other.x; - y = other.y; - w = other.w; - h = other.h; - xMode = other.xMode; - yMode = other.yMode; - wMode = other.wMode; - hMode = other.hMode; - - return *this; - } - - /** Returns a string version of this position, from which it can later be - re-generated. - - The format is four co-ordinates, "x y w h". - - - If a co-ordinate is absolute, it is stored as an integer, e.g. "100". - - If a co-ordinate is proportional to its parent's width or height, it is stored - as a percentage, e.g. "80%". - - If the X or Y co-ordinate is relative to the parent's right or bottom edge, the - number has "R" appended to it, e.g. "100R" means a distance of 100 pixels from - the parent's right-hand edge. - - If the X or Y co-ordinate is relative to the parent's centre, the number has "C" - appended to it, e.g. "-50C" would be 50 pixels left of the parent's centre. - - If the X or Y co-ordinate should be anchored at the component's right or bottom - edge, then it has "r" appended to it. So "-50Rr" would mean that this component's - right-hand edge should be 50 pixels left of the parent's right-hand edge. - - If the X or Y co-ordinate should be anchored at the component's centre, then it - has "c" appended to it. So "-50Rc" would mean that this component's - centre should be 50 pixels left of the parent's right-hand edge. "40%c" means that - this component's centre should be placed 40% across the parent's width. - - If it's a width or height that should use the parentSizeMinusAbsolute mode, then - the number has "M" appended to it. - - To reload a stored string, use the constructor that takes a string parameter. - */ - const String toString() const throw() - { - String s; - s.preallocateStorage (12); - addPosDescription (s, xMode, x); s << ' '; - addPosDescription (s, yMode, y); s << ' '; - addSizeDescription (s, wMode, w); s << ' '; - addSizeDescription (s, hMode, h); - return s; - } - - /** Calculates the absolute position, given the size of the space that - it should go in. - - This will work out any proportional distances and sizes relative to the - target rectangle, and will return the absolute position. - - @see applyToComponent - */ - const Rectangle getRectangle (const Rectangle& target) const throw() - { - jassert (! target.isEmpty()); - - double x_, y_, w_, h_; - applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); - applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); - return Rectangle (roundToInt (x_), roundToInt (y_), roundToInt (w_), roundToInt (h_)); - } - - /** Same as getRectangle(), but returning the values as doubles rather than ints. */ - void getRectangleDouble (const Rectangle& target, - double& x_, double& y_, double& w_, double& h_) const throw() - { - jassert (! target.isEmpty()); - applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); - applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); - } - - /** This sets the bounds of the given component to this position. - - This is equivalent to writing: - @code - comp.setBounds (getRectangle (Rectangle (0, 0, comp.getParentWidth(), comp.getParentHeight()))); - @endcode - - @see getRectangle, updateFromComponent - */ - void applyToComponent (Component& comp) const throw() - { - comp.setBounds (getRectangle (Rectangle (comp.getParentWidth(), comp.getParentHeight()))); - } - - /** Updates this object's co-ordinates to match the given rectangle. - - This will set all co-ordinates based on the given rectangle, re-calculating - any proportional distances, and using the current anchor points. - - So for example if the x co-ordinate mode is currently proportional, this will - re-calculate x based on the rectangle's relative position within the target - rectangle's width. - - If the target rectangle's width or height are zero then it may not be possible - to re-calculate some proportional co-ordinates. In this case, those co-ordinates - will not be changed. - */ - void updateFrom (const Rectangle& newPosition, - const Rectangle& targetSpaceToBeRelativeTo) throw() - { - updatePosAndSize (x, w, newPosition.getX(), newPosition.getWidth(), xMode, wMode, targetSpaceToBeRelativeTo.getX(), targetSpaceToBeRelativeTo.getWidth()); - updatePosAndSize (y, h, newPosition.getY(), newPosition.getHeight(), yMode, hMode, targetSpaceToBeRelativeTo.getY(), targetSpaceToBeRelativeTo.getHeight()); - } - - /** Same functionality as updateFrom(), but taking doubles instead of ints. - */ - void updateFromDouble (const double newX, const double newY, - const double newW, const double newH, - const Rectangle& target) throw() - { - updatePosAndSize (x, w, newX, newW, xMode, wMode, target.getX(), target.getWidth()); - updatePosAndSize (y, h, newY, newH, yMode, hMode, target.getY(), target.getHeight()); - } - - /** Updates this object's co-ordinates to match the bounds of this component. - - This is equivalent to calling updateFrom() with the component's bounds and - it parent size. - - If the component doesn't currently have a parent, then proportional co-ordinates - might not be updated because it would need to know the parent's size to do the - maths for this. - */ - void updateFromComponent (const Component& comp) throw() - { - if (comp.getParentComponent() == 0 && ! comp.isOnDesktop()) - updateFrom (comp.getBounds(), Rectangle()); - else - updateFrom (comp.getBounds(), Rectangle (comp.getParentWidth(), comp.getParentHeight())); - } - - /** Specifies the point within the rectangle, relative to which it should be positioned. */ - enum AnchorPoint - { - anchorAtLeftOrTop = 1 << 0, /**< The x or y co-ordinate specifies where the left or top edge of the rectangle should be. */ - anchorAtRightOrBottom = 1 << 1, /**< The x or y co-ordinate specifies where the right or bottom edge of the rectangle should be. */ - anchorAtCentre = 1 << 2 /**< The x or y co-ordinate specifies where the centre of the rectangle should be. */ - }; - - /** Specifies how an x or y co-ordinate should be interpreted. */ - enum PositionMode - { - absoluteFromParentTopLeft = 1 << 3, /**< The x or y co-ordinate specifies an absolute distance from the parent's top or left edge. */ - absoluteFromParentBottomRight = 1 << 4, /**< The x or y co-ordinate specifies an absolute distance from the parent's bottom or right edge. */ - absoluteFromParentCentre = 1 << 5, /**< The x or y co-ordinate specifies an absolute distance from the parent's centre. */ - proportionOfParentSize = 1 << 6 /**< The x or y co-ordinate specifies a proportion of the parent's width or height, measured from the parent's top or left. */ - }; - - /** Specifies how the width or height should be interpreted. */ - enum SizeMode - { - absoluteSize = 1 << 0, /**< The width or height specifies an absolute size. */ - parentSizeMinusAbsolute = 1 << 1, /**< The width or height is an amount that should be subtracted from the parent's width or height. */ - proportionalSize = 1 << 2, /**< The width or height specifies a proportion of the parent's width or height. */ - }; - - /** Sets all options for all co-ordinates. - - This requires a reference rectangle to be specified, because if you're changing any - of the modes from proportional to absolute or vice-versa, then it'll need to convert - the co-ordinates, and will need to know the parent size so it can calculate this. - */ - void setModes (const AnchorPoint xAnchor, const PositionMode xMode_, - const AnchorPoint yAnchor, const PositionMode yMode_, - const SizeMode widthMode, const SizeMode heightMode, - const Rectangle& target) throw() - { - if (xMode != (xAnchor | xMode_) || wMode != widthMode) - { - double tx, tw; - applyPosAndSize (tx, tw, x, w, xMode, wMode, target.getX(), target.getWidth()); - - xMode = (uint8) (xAnchor | xMode_); - wMode = (uint8) widthMode; - - updatePosAndSize (x, w, tx, tw, xMode, wMode, target.getX(), target.getWidth()); - } - - if (yMode != (yAnchor | yMode_) || hMode != heightMode) - { - double ty, th; - applyPosAndSize (ty, th, y, h, yMode, hMode, target.getY(), target.getHeight()); - - yMode = (uint8) (yAnchor | yMode_); - hMode = (uint8) heightMode; - - updatePosAndSize (y, h, ty, th, yMode, hMode, target.getY(), target.getHeight()); - } - } - - /** Returns the anchoring mode for the x co-ordinate. - To change any of the modes, use setModes(). - */ - AnchorPoint getAnchorPointX() const throw() - { - return (AnchorPoint) (xMode & (anchorAtLeftOrTop | anchorAtRightOrBottom | anchorAtCentre)); - } - - /** Returns the positioning mode for the x co-ordinate. - To change any of the modes, use setModes(). - */ - PositionMode getPositionModeX() const throw() - { - return (PositionMode) (xMode & (absoluteFromParentTopLeft | absoluteFromParentBottomRight - | absoluteFromParentCentre | proportionOfParentSize)); - } - - /** Returns the raw x co-ordinate. - - If the x position mode is absolute, then this will be the absolute value. If it's - proportional, then this will be a fractional proportion, where 1.0 means the full - width of the parent space. - */ - double getX() const throw() { return x; } - - /** Sets the raw value of the x co-ordinate. - - See getX() for the meaning of this value. - */ - void setX (const double newX) throw() { x = newX; } - - /** Returns the anchoring mode for the y co-ordinate. - To change any of the modes, use setModes(). - */ - AnchorPoint getAnchorPointY() const throw() - { - return (AnchorPoint) (yMode & (anchorAtLeftOrTop | anchorAtRightOrBottom | anchorAtCentre)); - } - - /** Returns the positioning mode for the y co-ordinate. - To change any of the modes, use setModes(). - */ - PositionMode getPositionModeY() const throw() - { - return (PositionMode) (yMode & (absoluteFromParentTopLeft | absoluteFromParentBottomRight - | absoluteFromParentCentre | proportionOfParentSize)); - } - - /** Returns the raw y co-ordinate. - - If the y position mode is absolute, then this will be the absolute value. If it's - proportional, then this will be a fractional proportion, where 1.0 means the full - height of the parent space. - */ - double getY() const throw() { return y; } - - /** Sets the raw value of the y co-ordinate. - - See getY() for the meaning of this value. - */ - void setY (const double newY) throw() { y = newY; } - - /** Returns the mode used to calculate the width. - To change any of the modes, use setModes(). - */ - SizeMode getWidthMode() const throw() { return (SizeMode) wMode; } - - /** Returns the raw width value. - - If the width mode is absolute, then this will be the absolute value. If the mode is - proportional, then this will be a fractional proportion, where 1.0 means the full - width of the parent space. - */ - double getWidth() const throw() { return w; } - - /** Sets the raw width value. - - See getWidth() for the details about what this value means. - */ - void setWidth (const double newWidth) throw() { w = newWidth; } - - /** Returns the mode used to calculate the height. - To change any of the modes, use setModes(). - */ - SizeMode getHeightMode() const throw() { return (SizeMode) hMode; } - - /** Returns the raw height value. - - If the height mode is absolute, then this will be the absolute value. If the mode is - proportional, then this will be a fractional proportion, where 1.0 means the full - height of the parent space. - */ - double getHeight() const throw() { return h; } - - /** Sets the raw height value. - - See getHeight() for the details about what this value means. - */ - void setHeight (const double newHeight) throw() { h = newHeight; } - - /** If the size and position are constance, and wouldn't be affected by changes - in the parent's size, then this will return true. - */ - bool isPositionAbsolute() const throw() - { - return xMode == absoluteFromParentTopLeft - && yMode == absoluteFromParentTopLeft - && wMode == absoluteSize - && hMode == absoluteSize; - } - - /** Compares two objects. */ - bool operator== (const PositionedRectangle& other) const throw() - { - return x == other.x && y == other.y - && w == other.w && h == other.h - && xMode == other.xMode && yMode == other.yMode - && wMode == other.wMode && hMode == other.hMode; - } - - /** Compares two objects. */ - bool operator!= (const PositionedRectangle& other) const throw() - { - return ! operator== (other); - } - -private: - - double x, y, w, h; - uint8 xMode, yMode, wMode, hMode; - - void addPosDescription (String& s, const uint8 mode, const double value) const throw() - { - if ((mode & proportionOfParentSize) != 0) - { - s << (roundToInt (value * 100000.0) / 1000.0) << '%'; - } - else - { - s << (roundToInt (value * 100.0) / 100.0); - - if ((mode & absoluteFromParentBottomRight) != 0) - s << 'R'; - else if ((mode & absoluteFromParentCentre) != 0) - s << 'C'; - } - - if ((mode & anchorAtRightOrBottom) != 0) - s << 'r'; - else if ((mode & anchorAtCentre) != 0) - s << 'c'; - } - - void addSizeDescription (String& s, const uint8 mode, const double value) const throw() - { - if (mode == proportionalSize) - s << (roundToInt (value * 100000.0) / 1000.0) << '%'; - else if (mode == parentSizeMinusAbsolute) - s << (roundToInt (value * 100.0) / 100.0) << 'M'; - else - s << (roundToInt (value * 100.0) / 100.0); - } - - void decodePosString (const String& s, uint8& mode, double& value) throw() - { - if (s.containsChar ('r')) - mode = anchorAtRightOrBottom; - else if (s.containsChar ('c')) - mode = anchorAtCentre; - else - mode = anchorAtLeftOrTop; - - if (s.containsChar ('%')) - { - mode |= proportionOfParentSize; - value = s.removeCharacters ("%rcRC").getDoubleValue() / 100.0; - } - else - { - if (s.containsChar ('R')) - mode |= absoluteFromParentBottomRight; - else if (s.containsChar ('C')) - mode |= absoluteFromParentCentre; - else - mode |= absoluteFromParentTopLeft; - - value = s.removeCharacters ("rcRC").getDoubleValue(); - } - } - - void decodeSizeString (const String& s, uint8& mode, double& value) throw() - { - if (s.containsChar ('%')) - { - mode = proportionalSize; - value = s.upToFirstOccurrenceOf ("%", false, false).getDoubleValue() / 100.0; - } - else if (s.containsChar ('M')) - { - mode = parentSizeMinusAbsolute; - value = s.getDoubleValue(); - } - else - { - mode = absoluteSize; - value = s.getDoubleValue(); - } - } - - void applyPosAndSize (double& xOut, double& wOut, const double x_, const double w_, - const uint8 xMode_, const uint8 wMode_, - const int parentPos, const int parentSize) const throw() - { - if (wMode_ == proportionalSize) - wOut = roundToInt (w_ * parentSize); - else if (wMode_ == parentSizeMinusAbsolute) - wOut = jmax (0, parentSize - roundToInt (w_)); - else - wOut = roundToInt (w_); - - if ((xMode_ & proportionOfParentSize) != 0) - xOut = parentPos + x_ * parentSize; - else if ((xMode_ & absoluteFromParentBottomRight) != 0) - xOut = (parentPos + parentSize) - x_; - else if ((xMode_ & absoluteFromParentCentre) != 0) - xOut = x_ + (parentPos + parentSize / 2); - else - xOut = x_ + parentPos; - - if ((xMode_ & anchorAtRightOrBottom) != 0) - xOut -= wOut; - else if ((xMode_ & anchorAtCentre) != 0) - xOut -= wOut / 2; - } - - void updatePosAndSize (double& xOut, double& wOut, double x_, const double w_, - const uint8 xMode_, const uint8 wMode_, - const int parentPos, const int parentSize) const throw() - { - if (wMode_ == proportionalSize) - { - if (parentSize > 0) - wOut = w_ / parentSize; - } - else if (wMode_ == parentSizeMinusAbsolute) - wOut = parentSize - w_; - else - wOut = w_; - - if ((xMode_ & anchorAtRightOrBottom) != 0) - x_ += w_; - else if ((xMode_ & anchorAtCentre) != 0) - x_ += w_ / 2; - - if ((xMode_ & proportionOfParentSize) != 0) - { - if (parentSize > 0) - xOut = (x_ - parentPos) / parentSize; - } - else if ((xMode_ & absoluteFromParentBottomRight) != 0) - xOut = (parentPos + parentSize) - x_; - else if ((xMode_ & absoluteFromParentCentre) != 0) - xOut = x_ - (parentPos + parentSize / 2); - else - xOut = x_ - parentPos; - } - - JUCE_LEAK_DETECTOR (PositionedRectangle); -}; - -#endif // __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ -/*** End of inlined file: juce_PositionedRectangle.h ***/ - - #endif #ifndef __JUCE_RECTANGLE_JUCEHEADER__ diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 5de4f910ff..fcf6e97f74 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 12 +#define JUCE_BUILDNUMBER 13 /** Current Juce version number. diff --git a/src/gui/components/controls/juce_Label.cpp b/src/gui/components/controls/juce_Label.cpp index be94066e9f..f19b6b94f0 100644 --- a/src/gui/components/controls/juce_Label.cpp +++ b/src/gui/components/controls/juce_Label.cpp @@ -348,7 +348,7 @@ void Label::mouseDoubleClick (const MouseEvent& e) void Label::resized() { if (editor != 0) - editor->setBoundsInset (BorderSize (0)); + editor->setBoundsInset (BorderSize (0)); } void Label::focusGained (FocusChangeType cause) diff --git a/src/gui/components/controls/juce_ListBox.cpp b/src/gui/components/controls/juce_ListBox.cpp index 4614a287d4..94769be410 100644 --- a/src/gui/components/controls/juce_ListBox.cpp +++ b/src/gui/components/controls/juce_ListBox.cpp @@ -408,10 +408,8 @@ void ListBox::paintOverChildren (Graphics& g) void ListBox::resized() { - viewport->setBoundsInset (BorderSize (outlineThickness + ((headerComponent != 0) ? headerComponent->getHeight() : 0), - outlineThickness, - outlineThickness, - outlineThickness)); + viewport->setBoundsInset (BorderSize (outlineThickness + ((headerComponent != 0) ? headerComponent->getHeight() : 0), + outlineThickness, outlineThickness, outlineThickness)); viewport->setSingleStepSizes (20, getRowHeight()); diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index b57ef0fe34..95a9fe78e8 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -1468,13 +1468,13 @@ void TextEditor::setIndents (const int newLeftIndent, topIndent = newTopIndent; } -void TextEditor::setBorder (const BorderSize& border) +void TextEditor::setBorder (const BorderSize& border) { borderSize = border; resized(); } -const BorderSize TextEditor::getBorder() const +const BorderSize TextEditor::getBorder() const { return borderSize; } diff --git a/src/gui/components/controls/juce_TextEditor.h b/src/gui/components/controls/juce_TextEditor.h index ec225b938b..69444b6f1d 100644 --- a/src/gui/components/controls/juce_TextEditor.h +++ b/src/gui/components/controls/juce_TextEditor.h @@ -488,13 +488,13 @@ public: @see getBorder */ - void setBorder (const BorderSize& border); + void setBorder (const BorderSize& border); /** Returns the size of border around the edge of the component. @see setBorder */ - const BorderSize getBorder() const; + const BorderSize getBorder() const; /** Used to disable the auto-scrolling which keeps the cursor visible. @@ -616,7 +616,7 @@ private: ScopedPointer viewport; TextHolderComponent* textHolder; - BorderSize borderSize; + BorderSize borderSize; bool readOnly : 1; bool multiline : 1; diff --git a/src/gui/components/controls/juce_ToolbarItemPalette.cpp b/src/gui/components/controls/juce_ToolbarItemPalette.cpp index 1881549709..cd9083b922 100644 --- a/src/gui/components/controls/juce_ToolbarItemPalette.cpp +++ b/src/gui/components/controls/juce_ToolbarItemPalette.cpp @@ -79,7 +79,7 @@ void ToolbarItemPalette::replaceComponent (ToolbarItemComponent* const comp) void ToolbarItemPalette::resized() { - viewport.setBoundsInset (BorderSize (1)); + viewport.setBoundsInset (BorderSize (1)); Component* const itemHolder = viewport.getViewedComponent(); diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index 359f16c096..084f5e1db6 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -1126,7 +1126,7 @@ void Component::centreWithSize (const int width, const int height) width, height); } -void Component::setBoundsInset (const BorderSize& borders) +void Component::setBoundsInset (const BorderSize& borders) { setBounds (borders.subtractedFrom (ComponentHelpers::getParentOrMainMonitorBounds (*this))); } diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 5a3e61e6a7..910f57c9c0 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -545,7 +545,7 @@ public: @see setBounds */ - void setBoundsInset (const BorderSize& borders); + void setBoundsInset (const BorderSize& borders); /** Positions the component within a given rectangle, keeping its proportions unchanged. diff --git a/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp b/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp index 65e0df2261..3e0912dc72 100644 --- a/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp +++ b/src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp @@ -144,7 +144,7 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone jassert (component != 0); Rectangle limits, bounds (targetBounds); - BorderSize border; + BorderSize border; Component* const parent = component->getParentComponent(); diff --git a/src/gui/components/layout/juce_ResizableBorderComponent.cpp b/src/gui/components/layout/juce_ResizableBorderComponent.cpp index 5d61eadf66..21a85f0c9c 100644 --- a/src/gui/components/layout/juce_ResizableBorderComponent.cpp +++ b/src/gui/components/layout/juce_ResizableBorderComponent.cpp @@ -53,7 +53,7 @@ bool ResizableBorderComponent::Zone::operator== (const ResizableBorderComponent: bool ResizableBorderComponent::Zone::operator!= (const ResizableBorderComponent::Zone& other) const throw() { return zone != other.zone; } const ResizableBorderComponent::Zone ResizableBorderComponent::Zone::fromPositionOnBorder (const Rectangle& totalSize, - const BorderSize& border, + const BorderSize& border, const Point& position) { int z = 0; @@ -177,7 +177,7 @@ bool ResizableBorderComponent::hitTest (int x, int y) || y >= getHeight() - borderSize.getBottom(); } -void ResizableBorderComponent::setBorderThickness (const BorderSize& newBorderSize) +void ResizableBorderComponent::setBorderThickness (const BorderSize& newBorderSize) { if (borderSize != newBorderSize) { @@ -186,7 +186,7 @@ void ResizableBorderComponent::setBorderThickness (const BorderSize& newBorderSi } } -const BorderSize ResizableBorderComponent::getBorderThickness() const +const BorderSize ResizableBorderComponent::getBorderThickness() const { return borderSize; } diff --git a/src/gui/components/layout/juce_ResizableBorderComponent.h b/src/gui/components/layout/juce_ResizableBorderComponent.h index 2f8b5dfab5..849b726033 100644 --- a/src/gui/components/layout/juce_ResizableBorderComponent.h +++ b/src/gui/components/layout/juce_ResizableBorderComponent.h @@ -78,13 +78,13 @@ public: @see getBorderThickness */ - void setBorderThickness (const BorderSize& newBorderSize); + void setBorderThickness (const BorderSize& newBorderSize); /** Returns the number of pixels wide that the draggable edges of this component are. @see setBorderThickness */ - const BorderSize getBorderThickness() const; + const BorderSize getBorderThickness() const; //============================================================================== @@ -118,7 +118,7 @@ public: zone that the point lies within. */ static const Zone fromPositionOnBorder (const Rectangle& totalSize, - const BorderSize& border, + const BorderSize& border, const Point& position); /** Returns an appropriate mouse-cursor for this resize zone. */ @@ -189,7 +189,7 @@ protected: private: WeakReference component; ComponentBoundsConstrainer* constrainer; - BorderSize borderSize; + BorderSize borderSize; Rectangle originalBounds; Zone mouseZone; diff --git a/src/gui/components/layout/juce_TabbedComponent.cpp b/src/gui/components/layout/juce_TabbedComponent.cpp index a1f0f2ac59..c1726a7d44 100644 --- a/src/gui/components/layout/juce_TabbedComponent.cpp +++ b/src/gui/components/layout/juce_TabbedComponent.cpp @@ -42,7 +42,7 @@ namespace TabbedComponentHelpers delete comp; } - const Rectangle getTabArea (Rectangle& content, BorderSize& outline, + const Rectangle getTabArea (Rectangle& content, BorderSize& outline, const TabbedButtonBar::Orientation orientation, const int tabDepth) { switch (orientation) @@ -245,7 +245,7 @@ void TabbedComponent::paint (Graphics& g) g.fillAll (findColour (backgroundColourId)); Rectangle content (getLocalBounds()); - BorderSize outline (outlineThickness); + BorderSize outline (outlineThickness); TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth); g.reduceClipRegion (content); @@ -264,10 +264,10 @@ void TabbedComponent::paint (Graphics& g) void TabbedComponent::resized() { Rectangle content (getLocalBounds()); - BorderSize outline (outlineThickness); + BorderSize outline (outlineThickness); tabs->setBounds (TabbedComponentHelpers::getTabArea (content, outline, getOrientation(), tabDepth)); - content = BorderSize (edgeIndent).subtractedFrom (outline.subtractedFrom (content)); + content = BorderSize (edgeIndent).subtractedFrom (outline.subtractedFrom (content)); for (int i = contentComponents.size(); --i >= 0;) if (contentComponents.getReference (i) != 0) diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index cb5eef50d0..9940a3d497 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -1820,7 +1820,7 @@ void LookAndFeel::drawCornerResizer (Graphics& g, } } -void LookAndFeel::drawResizableFrame (Graphics& g, int w, int h, const BorderSize& border) +void LookAndFeel::drawResizableFrame (Graphics& g, int w, int h, const BorderSize& border) { if (! border.isEmpty()) { @@ -1843,13 +1843,13 @@ void LookAndFeel::drawResizableFrame (Graphics& g, int w, int h, const BorderSiz //============================================================================== void LookAndFeel::fillResizableWindowBackground (Graphics& g, int /*w*/, int /*h*/, - const BorderSize& /*border*/, ResizableWindow& window) + const BorderSize& /*border*/, ResizableWindow& window) { g.fillAll (window.getBackgroundColour()); } void LookAndFeel::drawResizableWindowBorder (Graphics&, int /*w*/, int /*h*/, - const BorderSize& /*border*/, ResizableWindow&) + const BorderSize& /*border*/, ResizableWindow&) { } diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.h b/src/gui/components/lookandfeel/juce_LookAndFeel.h index 627c61a25a..acebc266dc 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.h @@ -456,16 +456,16 @@ public: virtual void drawResizableFrame (Graphics& g, int w, int h, - const BorderSize& borders); + const BorderSize& borders); //============================================================================== virtual void fillResizableWindowBackground (Graphics& g, int w, int h, - const BorderSize& border, + const BorderSize& border, ResizableWindow& window); virtual void drawResizableWindowBorder (Graphics& g, int w, int h, - const BorderSize& border, + const BorderSize& border, ResizableWindow& window); //============================================================================== diff --git a/src/gui/components/windows/juce_ComponentPeer.h b/src/gui/components/windows/juce_ComponentPeer.h index f68cc00a4e..45968d7a78 100644 --- a/src/gui/components/windows/juce_ComponentPeer.h +++ b/src/gui/components/windows/juce_ComponentPeer.h @@ -206,7 +206,7 @@ public: Whether or not the window has a normal window frame depends on the flags that were set when the window was created by Component::addToDesktop() */ - virtual const BorderSize getFrameSize() const = 0; + virtual const BorderSize getFrameSize() const = 0; /** This is called when the window's bounds change. diff --git a/src/gui/components/windows/juce_DocumentWindow.cpp b/src/gui/components/windows/juce_DocumentWindow.cpp index 7661c774c7..7c1fc7831e 100644 --- a/src/gui/components/windows/juce_DocumentWindow.cpp +++ b/src/gui/components/windows/juce_DocumentWindow.cpp @@ -212,7 +212,7 @@ void DocumentWindow::paint (Graphics& g) { g.setColour (getBackgroundColour().overlaidWith (Colour (0x80000000))); - const BorderSize border (getBorderThickness()); + const BorderSize border (getBorderThickness()); g.fillRect (0, 0, getWidth(), border.getTop()); g.fillRect (0, border.getTop(), border.getLeft(), getHeight() - border.getTopAndBottom()); @@ -270,15 +270,15 @@ void DocumentWindow::resized() titleBarArea.getWidth(), menuBarHeight); } -const BorderSize DocumentWindow::getBorderThickness() +const BorderSize DocumentWindow::getBorderThickness() { - return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) - ? 0 : (resizableBorder != 0 ? 4 : 1)); + return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) + ? 0 : (resizableBorder != 0 ? 4 : 1)); } -const BorderSize DocumentWindow::getContentComponentBorder() +const BorderSize DocumentWindow::getContentComponentBorder() { - BorderSize border (getBorderThickness()); + BorderSize border (getBorderThickness()); border.setTop (border.getTop() + (isUsingNativeTitleBar() ? 0 : titleBarHeight) @@ -294,7 +294,7 @@ int DocumentWindow::getTitleBarHeight() const const Rectangle DocumentWindow::getTitleBarArea() { - const BorderSize border (getBorderThickness()); + const BorderSize border (getBorderThickness()); return Rectangle (border.getLeft(), border.getTop(), getWidth() - border.getLeftAndRight(), diff --git a/src/gui/components/windows/juce_DocumentWindow.h b/src/gui/components/windows/juce_DocumentWindow.h index 88f6b16a58..f9eff6fd78 100644 --- a/src/gui/components/windows/juce_DocumentWindow.h +++ b/src/gui/components/windows/juce_DocumentWindow.h @@ -238,9 +238,9 @@ public: /** @internal */ void lookAndFeelChanged(); /** @internal */ - const BorderSize getBorderThickness(); + const BorderSize getBorderThickness(); /** @internal */ - const BorderSize getContentComponentBorder(); + const BorderSize getContentComponentBorder(); /** @internal */ void mouseDoubleClick (const MouseEvent& e); /** @internal */ diff --git a/src/gui/components/windows/juce_ResizableWindow.cpp b/src/gui/components/windows/juce_ResizableWindow.cpp index 5e30c765a2..e2fb6a0c29 100644 --- a/src/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/gui/components/windows/juce_ResizableWindow.cpp @@ -131,18 +131,18 @@ void ResizableWindow::setContentComponentSize (int width, int height) { jassert (width > 0 && height > 0); // not a great idea to give it a zero size.. - const BorderSize border (getContentComponentBorder()); + const BorderSize border (getContentComponentBorder()); setSize (width + border.getLeftAndRight(), height + border.getTopAndBottom()); } -const BorderSize ResizableWindow::getBorderThickness() +const BorderSize ResizableWindow::getBorderThickness() { - return BorderSize (isUsingNativeTitleBar() ? 0 : ((resizableBorder != 0 && ! isFullScreen()) ? 5 : 3)); + return BorderSize (isUsingNativeTitleBar() ? 0 : ((resizableBorder != 0 && ! isFullScreen()) ? 5 : 3)); } -const BorderSize ResizableWindow::getContentComponentBorder() +const BorderSize ResizableWindow::getContentComponentBorder() { return getBorderThickness(); } @@ -208,7 +208,7 @@ void ResizableWindow::childBoundsChanged (Component* child) jassert (child->getWidth() > 0); jassert (child->getHeight() > 0); - const BorderSize borders (getContentComponentBorder()); + const BorderSize borders (getContentComponentBorder()); setSize (child->getWidth() + borders.getLeftAndRight(), child->getHeight() + borders.getTopAndBottom()); @@ -219,7 +219,7 @@ void ResizableWindow::childBoundsChanged (Component* child) //============================================================================== void ResizableWindow::activeWindowStatusChanged() { - const BorderSize border (getContentComponentBorder()); + const BorderSize border (getContentComponentBorder()); Rectangle area (getLocalBounds()); repaint (area.removeFromTop (border.getTop())); diff --git a/src/gui/components/windows/juce_ResizableWindow.h b/src/gui/components/windows/juce_ResizableWindow.h index f5035915f6..92fec37c16 100644 --- a/src/gui/components/windows/juce_ResizableWindow.h +++ b/src/gui/components/windows/juce_ResizableWindow.h @@ -271,12 +271,12 @@ public: /** Returns the width of the frame to use around the window. @see getContentComponentBorder */ - virtual const BorderSize getBorderThickness(); + virtual const BorderSize getBorderThickness(); /** Returns the insets to use when positioning the content component. @see getBorderThickness */ - virtual const BorderSize getContentComponentBorder(); + virtual const BorderSize getContentComponentBorder(); //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the window. diff --git a/src/gui/graphics/contexts/juce_Graphics.cpp b/src/gui/graphics/contexts/juce_Graphics.cpp index b41276c37c..f326fe6b92 100644 --- a/src/gui/graphics/contexts/juce_Graphics.cpp +++ b/src/gui/graphics/contexts/juce_Graphics.cpp @@ -560,21 +560,19 @@ void Graphics::drawHorizontalLine (const int y, float left, float right) const context->drawHorizontalLine (y, left, right); } -void Graphics::drawLine (float x1, float y1, float x2, float y2) const +void Graphics::drawLine (const float x1, const float y1, const float x2, const float y2) const { context->drawLine (Line (x1, y1, x2, y2)); } -void Graphics::drawLine (const float startX, const float startY, - const float endX, const float endY, - const float lineThickness) const +void Graphics::drawLine (const Line& line) const { - drawLine (Line (startX, startY, endX, endY),lineThickness); + context->drawLine (line); } -void Graphics::drawLine (const Line& line) const +void Graphics::drawLine (const float x1, const float y1, const float x2, const float y2, const float lineThickness) const { - drawLine (line.getStartX(), line.getStartY(), line.getEndX(), line.getEndY()); + drawLine (Line (x1, y1, x2, y2), lineThickness); } void Graphics::drawLine (const Line& line, const float lineThickness) const @@ -584,42 +582,35 @@ void Graphics::drawLine (const Line& line, const float lineThickness) con fillPath (p); } -void Graphics::drawDashedLine (const float startX, const float startY, - const float endX, const float endY, - const float* const dashLengths, - const int numDashLengths, - const float lineThickness) const +void Graphics::drawDashedLine (const Line& line, const float* const dashLengths, + const int numDashLengths, const float lineThickness, int n) const { - const double dx = endX - startX; - const double dy = endY - startY; - const double totalLen = juce_hypot (dx, dy); + jassert (n >= 0 && n < numDashLengths); // your start index must be valid! + + const Point delta ((line.getEnd() - line.getStart()).toDouble()); + const double totalLen = delta.getDistanceFromOrigin(); - if (totalLen >= 0.5) + if (totalLen >= 0.1) { const double onePixAlpha = 1.0 / totalLen; - double alpha = 0.0; - float x = startX; - float y = startY; - int n = 0; - - while (alpha < 1.0f) + for (double alpha = 0.0; alpha < 1.0;) { - alpha = jmin (1.0, alpha + dashLengths[n++] * onePixAlpha); - n = n % numDashLengths; - - const float oldX = x; - const float oldY = y; + jassert (dashLengths[n] > 0); // can't have zero-length dashes! - x = (float) (startX + dx * alpha); - y = (float) (startY + dy * alpha); + const double lastAlpha = alpha; + alpha = jmin (1.0, alpha + dashLengths [n] * onePixAlpha); + n = (n + 1) % numDashLengths; if ((n & 1) != 0) { + const Line segment (line.getStart() + (delta * lastAlpha).toFloat(), + line.getStart() + (delta * alpha).toFloat()); + if (lineThickness != 1.0f) - drawLine (oldX, oldY, x, y, lineThickness); + drawLine (segment, lineThickness); else - drawLine (oldX, oldY, x, y); + context->drawLine (segment); } } } diff --git a/src/gui/graphics/contexts/juce_Graphics.h b/src/gui/graphics/contexts/juce_Graphics.h index 54e195c8d7..6551a0ea4b 100644 --- a/src/gui/graphics/contexts/juce_Graphics.h +++ b/src/gui/graphics/contexts/juce_Graphics.h @@ -374,21 +374,19 @@ public: /** Draws a dashed line using a custom set of dash-lengths. - @param startX the line's start x co-ordinate - @param startY the line's start y co-ordinate - @param endX the line's end x co-ordinate - @param endY the line's end y co-ordinate + @param line the line to draw @param dashLengths a series of lengths to specify the on/off lengths - e.g. { 4, 5, 6, 7 } will draw a line of 4 pixels, skip 5 pixels, draw 6 pixels, skip 7 pixels, and then repeat. @param numDashLengths the number of elements in the array (this must be an even number). @param lineThickness the thickness of the line to draw + @param dashIndexToStartFrom the index in the dash-length array to use for the first segment @see PathStrokeType::createDashedStroke */ - void drawDashedLine (float startX, float startY, - float endX, float endY, + void drawDashedLine (const Line& line, const float* dashLengths, int numDashLengths, - float lineThickness = 1.0f) const; + float lineThickness = 1.0f, + int dashIndexToStartFrom = 0) const; /** Draws a vertical line of pixels at a given x position. diff --git a/src/gui/graphics/geometry/juce_AffineTransform.cpp b/src/gui/graphics/geometry/juce_AffineTransform.cpp index 2581da5d9f..62f70a7774 100644 --- a/src/gui/graphics/geometry/juce_AffineTransform.cpp +++ b/src/gui/graphics/geometry/juce_AffineTransform.cpp @@ -216,7 +216,7 @@ const AffineTransform AffineTransform::inverted() const throw() bool AffineTransform::isSingularity() const throw() { - return (mat00 * mat11 - mat10 * mat01) == 0.0; + return (mat00 * mat11 - mat10 * mat01) == 0; } const AffineTransform AffineTransform::fromTargetPoints (const float x00, const float y00, diff --git a/src/gui/graphics/geometry/juce_BorderSize.cpp b/src/gui/graphics/geometry/juce_BorderSize.cpp deleted file mode 100644 index d33d30d26c..0000000000 --- a/src/gui/graphics/geometry/juce_BorderSize.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - ============================================================================== - - 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_BorderSize.h" - - -//============================================================================== -BorderSize::BorderSize() throw() - : top (0), - left (0), - bottom (0), - right (0) -{ -} - -BorderSize::BorderSize (const BorderSize& other) throw() - : top (other.top), - left (other.left), - bottom (other.bottom), - right (other.right) -{ -} - -BorderSize::BorderSize (const int topGap, - const int leftGap, - const int bottomGap, - const int rightGap) throw() - : top (topGap), - left (leftGap), - bottom (bottomGap), - right (rightGap) -{ -} - -BorderSize::BorderSize (const int allGaps) throw() - : top (allGaps), - left (allGaps), - bottom (allGaps), - right (allGaps) -{ -} - -BorderSize::~BorderSize() throw() -{ -} - -//============================================================================== -void BorderSize::setTop (const int newTopGap) throw() -{ - top = newTopGap; -} - -void BorderSize::setLeft (const int newLeftGap) throw() -{ - left = newLeftGap; -} - -void BorderSize::setBottom (const int newBottomGap) throw() -{ - bottom = newBottomGap; -} - -void BorderSize::setRight (const int newRightGap) throw() -{ - right = newRightGap; -} - -//============================================================================== -const Rectangle BorderSize::subtractedFrom (const Rectangle& r) const throw() -{ - return Rectangle (r.getX() + left, - r.getY() + top, - r.getWidth() - (left + right), - r.getHeight() - (top + bottom)); -} - -void BorderSize::subtractFrom (Rectangle& r) const throw() -{ - r.setBounds (r.getX() + left, - r.getY() + top, - r.getWidth() - (left + right), - r.getHeight() - (top + bottom)); -} - -const Rectangle BorderSize::addedTo (const Rectangle& r) const throw() -{ - return Rectangle (r.getX() - left, - r.getY() - top, - r.getWidth() + (left + right), - r.getHeight() + (top + bottom)); -} - -void BorderSize::addTo (Rectangle& r) const throw() -{ - r.setBounds (r.getX() - left, - r.getY() - top, - r.getWidth() + (left + right), - r.getHeight() + (top + bottom)); -} - -bool BorderSize::operator== (const BorderSize& other) const throw() -{ - return top == other.top - && left == other.left - && bottom == other.bottom - && right == other.right; -} - -bool BorderSize::operator!= (const BorderSize& other) const throw() -{ - return ! operator== (other); -} - - -END_JUCE_NAMESPACE diff --git a/src/gui/graphics/geometry/juce_BorderSize.h b/src/gui/graphics/geometry/juce_BorderSize.h index 767a43664a..ccb09f958b 100644 --- a/src/gui/graphics/geometry/juce_BorderSize.h +++ b/src/gui/graphics/geometry/juce_BorderSize.h @@ -38,87 +38,118 @@ @see Rectangle */ -class JUCE_API BorderSize +template +class BorderSize { public: //============================================================================== /** Creates a null border. - All sizes are left as 0. */ - BorderSize() throw(); + BorderSize() throw() + : top(), left(), bottom(), right() + { + } /** Creates a copy of another border. */ - BorderSize (const BorderSize& other) throw(); + BorderSize (const BorderSize& other) throw() + : top (other.top), left (other.left), bottom (other.bottom), right (other.right) + { + } /** Creates a border with the given gaps. */ - BorderSize (int topGap, - int leftGap, - int bottomGap, - int rightGap) throw(); + BorderSize (ValueType topGap, ValueType leftGap, ValueType bottomGap, ValueType rightGap) throw() + : top (topGap), left (leftGap), bottom (bottomGap), right (rightGap) + { + } /** Creates a border with the given gap on all sides. */ - explicit BorderSize (int allGaps) throw(); - - /** Destructor. */ - ~BorderSize() throw(); + explicit BorderSize (ValueType allGaps) throw() + : top (allGaps), left (allGaps), bottom (allGaps), right (allGaps) + { + } //============================================================================== /** Returns the gap that should be left at the top of the region. */ - int getTop() const throw() { return top; } + ValueType getTop() const throw() { return top; } /** Returns the gap that should be left at the top of the region. */ - int getLeft() const throw() { return left; } + ValueType getLeft() const throw() { return left; } /** Returns the gap that should be left at the top of the region. */ - int getBottom() const throw() { return bottom; } + ValueType getBottom() const throw() { return bottom; } /** Returns the gap that should be left at the top of the region. */ - int getRight() const throw() { return right; } + ValueType getRight() const throw() { return right; } /** Returns the sum of the top and bottom gaps. */ - int getTopAndBottom() const throw() { return top + bottom; } + ValueType getTopAndBottom() const throw() { return top + bottom; } /** Returns the sum of the left and right gaps. */ - int getLeftAndRight() const throw() { return left + right; } + ValueType getLeftAndRight() const throw() { return left + right; } /** Returns true if this border has no thickness along any edge. */ - bool isEmpty() const throw() { return left + right + top + bottom == 0; } + bool isEmpty() const throw() { return left + right + top + bottom == ValueType(); } //============================================================================== /** Changes the top gap. */ - void setTop (int newTopGap) throw(); + void setTop (ValueType newTopGap) throw() { top = newTopGap; } /** Changes the left gap. */ - void setLeft (int newLeftGap) throw(); + void setLeft (ValueType newLeftGap) throw() { left = newLeftGap; } /** Changes the bottom gap. */ - void setBottom (int newBottomGap) throw(); + void setBottom (ValueType newBottomGap) throw() { bottom = newBottomGap; } /** Changes the right gap. */ - void setRight (int newRightGap) throw(); + void setRight (ValueType newRightGap) throw() { right = newRightGap; } //============================================================================== /** Returns a rectangle with these borders removed from it. */ - const Rectangle subtractedFrom (const Rectangle& original) const throw(); + const Rectangle subtractedFrom (const Rectangle& original) const throw() + { + return Rectangle (original.getX() + left, + original.getY() + top, + original.getWidth() - (left + right), + original.getHeight() - (top + bottom)); + } /** Removes this border from a given rectangle. */ - void subtractFrom (Rectangle& rectangle) const throw(); + void subtractFrom (Rectangle& rectangle) const throw() + { + rectangle = subtractedFrom (rectangle); + } /** Returns a rectangle with these borders added around it. */ - const Rectangle addedTo (const Rectangle& original) const throw(); + const Rectangle addedTo (const Rectangle& original) const throw() + { + return Rectangle (original.getX() - left, + original.getY() - top, + original.getWidth() + (left + right), + original.getHeight() + (top + bottom)); + } + /** Adds this border around a given rectangle. */ - void addTo (Rectangle& original) const throw(); + void addTo (Rectangle& rectangle) const throw() + { + rectangle = addedTo (rectangle); + } //============================================================================== - bool operator== (const BorderSize& other) const throw(); - bool operator!= (const BorderSize& other) const throw(); + bool operator== (const BorderSize& other) const throw() + { + return top == other.top && left == other.left && bottom == other.bottom && right == other.right; + } + bool operator!= (const BorderSize& other) const throw() + { + return ! operator== (other); + } private: //============================================================================== - int top, left, bottom, right; + ValueType top, left, bottom, right; JUCE_LEAK_DETECTOR (BorderSize); }; diff --git a/src/gui/graphics/geometry/juce_Point.h b/src/gui/graphics/geometry/juce_Point.h index ec40ead08f..d35cafbb54 100644 --- a/src/gui/graphics/geometry/juce_Point.h +++ b/src/gui/graphics/geometry/juce_Point.h @@ -44,7 +44,7 @@ class Point public: //============================================================================== /** Creates a point with co-ordinates (0, 0). */ - Point() throw() : x (0), y (0) {} + Point() throw() : x(), y() {} /** Creates a copy of another point. */ Point (const Point& other) throw() : x (other.x), y (other.y) {} @@ -156,11 +156,14 @@ public: const Point transformedBy (const AffineTransform& transform) const throw() { return Point (transform.mat00 * x + transform.mat01 * y + transform.mat02, transform.mat10 * x + transform.mat11 * y + transform.mat12); } + /** Casts this point to a Point object. */ + const Point toInt() const throw() { return Point (static_cast (x), static_cast (y)); } + /** Casts this point to a Point object. */ const Point toFloat() const throw() { return Point (static_cast (x), static_cast (y)); } - /** Casts this point to a Point object. */ - const Point toInt() const throw() { return Point (static_cast (x), static_cast (y)); } + /** Casts this point to a Point object. */ + const Point toDouble() const throw() { return Point (static_cast (x), static_cast (y)); } /** Returns the point as a string in the form "x, y". */ const String toString() const { return String (x) + ", " + String (y); } diff --git a/src/gui/graphics/geometry/juce_PositionedRectangle.cpp b/src/gui/graphics/geometry/juce_PositionedRectangle.cpp deleted file mode 100644 index 541c7f02fa..0000000000 --- a/src/gui/graphics/geometry/juce_PositionedRectangle.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - ============================================================================== - - 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_PositionedRectangle.h" - - - -END_JUCE_NAMESPACE diff --git a/src/gui/graphics/geometry/juce_PositionedRectangle.h b/src/gui/graphics/geometry/juce_PositionedRectangle.h deleted file mode 100644 index 63b47a019f..0000000000 --- a/src/gui/graphics/geometry/juce_PositionedRectangle.h +++ /dev/null @@ -1,584 +0,0 @@ -/* - ============================================================================== - - 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_POSITIONEDRECTANGLE_JUCEHEADER__ -#define __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ - -#include "../../components/juce_Component.h" - - -//============================================================================== -/** - A rectangle whose co-ordinates can be defined in terms of absolute or - proportional distances. - - Designed mainly for storing component positions, this gives you a lot of - control over how each co-ordinate is stored, either as an absolute position, - or as a proportion of the size of a parent rectangle. - - It also allows you to define the anchor points by which the rectangle is - positioned, so for example you could specify that the top right of the - rectangle should be an absolute distance from its parent's bottom-right corner. - - This object can be stored as a string, which takes the form "x y w h", including - symbols like '%' and letters to indicate the anchor point. See its toString() - method for more info. - - Example usage: - @code - class MyComponent - { - void resized() - { - // this will set the child component's x to be 20% of our width, its y - // to be 30, its width to be 150, and its height to be 50% of our - // height.. - const PositionedRectangle pos1 ("20% 30 150 50%"); - pos1.applyToComponent (*myChildComponent1); - - // this will inset the child component with a gap of 10 pixels - // around each of its edges.. - const PositionedRectangle pos2 ("10 10 20M 20M"); - pos2.applyToComponent (*myChildComponent2); - } - }; - @endcode -*/ -class PositionedRectangle -{ -public: - //============================================================================== - /** Creates an empty rectangle with all co-ordinates set to zero. - - The default anchor point is top-left; the default - */ - PositionedRectangle() throw() - : x (0.0), y (0.0), w (0.0), h (0.0), - xMode (anchorAtLeftOrTop | absoluteFromParentTopLeft), - yMode (anchorAtLeftOrTop | absoluteFromParentTopLeft), - wMode (absoluteSize), hMode (absoluteSize) - { - } - - /** Initialises a PositionedRectangle from a saved string version. - - The string must be in the format generated by toString(). - */ - PositionedRectangle (const String& stringVersion) throw() - { - StringArray tokens; - tokens.addTokens (stringVersion, false); - - decodePosString (tokens [0], xMode, x); - decodePosString (tokens [1], yMode, y); - decodeSizeString (tokens [2], wMode, w); - decodeSizeString (tokens [3], hMode, h); - } - - /** Creates a copy of another PositionedRectangle. */ - PositionedRectangle (const PositionedRectangle& other) throw() - : x (other.x), y (other.y), w (other.w), h (other.h), - xMode (other.xMode), yMode (other.yMode), - wMode (other.wMode), hMode (other.hMode) - { - } - - /** Copies another PositionedRectangle. */ - PositionedRectangle& operator= (const PositionedRectangle& other) throw() - { - x = other.x; - y = other.y; - w = other.w; - h = other.h; - xMode = other.xMode; - yMode = other.yMode; - wMode = other.wMode; - hMode = other.hMode; - - return *this; - } - - //============================================================================== - /** Returns a string version of this position, from which it can later be - re-generated. - - The format is four co-ordinates, "x y w h". - - - If a co-ordinate is absolute, it is stored as an integer, e.g. "100". - - If a co-ordinate is proportional to its parent's width or height, it is stored - as a percentage, e.g. "80%". - - If the X or Y co-ordinate is relative to the parent's right or bottom edge, the - number has "R" appended to it, e.g. "100R" means a distance of 100 pixels from - the parent's right-hand edge. - - If the X or Y co-ordinate is relative to the parent's centre, the number has "C" - appended to it, e.g. "-50C" would be 50 pixels left of the parent's centre. - - If the X or Y co-ordinate should be anchored at the component's right or bottom - edge, then it has "r" appended to it. So "-50Rr" would mean that this component's - right-hand edge should be 50 pixels left of the parent's right-hand edge. - - If the X or Y co-ordinate should be anchored at the component's centre, then it - has "c" appended to it. So "-50Rc" would mean that this component's - centre should be 50 pixels left of the parent's right-hand edge. "40%c" means that - this component's centre should be placed 40% across the parent's width. - - If it's a width or height that should use the parentSizeMinusAbsolute mode, then - the number has "M" appended to it. - - To reload a stored string, use the constructor that takes a string parameter. - */ - const String toString() const throw() - { - String s; - s.preallocateStorage (12); - addPosDescription (s, xMode, x); s << ' '; - addPosDescription (s, yMode, y); s << ' '; - addSizeDescription (s, wMode, w); s << ' '; - addSizeDescription (s, hMode, h); - return s; - } - - //============================================================================== - /** Calculates the absolute position, given the size of the space that - it should go in. - - This will work out any proportional distances and sizes relative to the - target rectangle, and will return the absolute position. - - @see applyToComponent - */ - const Rectangle getRectangle (const Rectangle& target) const throw() - { - jassert (! target.isEmpty()); - - double x_, y_, w_, h_; - applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); - applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); - return Rectangle (roundToInt (x_), roundToInt (y_), roundToInt (w_), roundToInt (h_)); - } - - /** Same as getRectangle(), but returning the values as doubles rather than ints. */ - void getRectangleDouble (const Rectangle& target, - double& x_, double& y_, double& w_, double& h_) const throw() - { - jassert (! target.isEmpty()); - applyPosAndSize (x_, w_, x, w, xMode, wMode, target.getX(), target.getWidth()); - applyPosAndSize (y_, h_, y, h, yMode, hMode, target.getY(), target.getHeight()); - } - - /** This sets the bounds of the given component to this position. - - This is equivalent to writing: - @code - comp.setBounds (getRectangle (Rectangle (0, 0, comp.getParentWidth(), comp.getParentHeight()))); - @endcode - - @see getRectangle, updateFromComponent - */ - void applyToComponent (Component& comp) const throw() - { - comp.setBounds (getRectangle (Rectangle (comp.getParentWidth(), comp.getParentHeight()))); - } - - //============================================================================== - /** Updates this object's co-ordinates to match the given rectangle. - - This will set all co-ordinates based on the given rectangle, re-calculating - any proportional distances, and using the current anchor points. - - So for example if the x co-ordinate mode is currently proportional, this will - re-calculate x based on the rectangle's relative position within the target - rectangle's width. - - If the target rectangle's width or height are zero then it may not be possible - to re-calculate some proportional co-ordinates. In this case, those co-ordinates - will not be changed. - */ - void updateFrom (const Rectangle& newPosition, - const Rectangle& targetSpaceToBeRelativeTo) throw() - { - updatePosAndSize (x, w, newPosition.getX(), newPosition.getWidth(), xMode, wMode, targetSpaceToBeRelativeTo.getX(), targetSpaceToBeRelativeTo.getWidth()); - updatePosAndSize (y, h, newPosition.getY(), newPosition.getHeight(), yMode, hMode, targetSpaceToBeRelativeTo.getY(), targetSpaceToBeRelativeTo.getHeight()); - } - - /** Same functionality as updateFrom(), but taking doubles instead of ints. - */ - void updateFromDouble (const double newX, const double newY, - const double newW, const double newH, - const Rectangle& target) throw() - { - updatePosAndSize (x, w, newX, newW, xMode, wMode, target.getX(), target.getWidth()); - updatePosAndSize (y, h, newY, newH, yMode, hMode, target.getY(), target.getHeight()); - } - - /** Updates this object's co-ordinates to match the bounds of this component. - - This is equivalent to calling updateFrom() with the component's bounds and - it parent size. - - If the component doesn't currently have a parent, then proportional co-ordinates - might not be updated because it would need to know the parent's size to do the - maths for this. - */ - void updateFromComponent (const Component& comp) throw() - { - if (comp.getParentComponent() == 0 && ! comp.isOnDesktop()) - updateFrom (comp.getBounds(), Rectangle()); - else - updateFrom (comp.getBounds(), Rectangle (comp.getParentWidth(), comp.getParentHeight())); - } - - //============================================================================== - /** Specifies the point within the rectangle, relative to which it should be positioned. */ - enum AnchorPoint - { - anchorAtLeftOrTop = 1 << 0, /**< The x or y co-ordinate specifies where the left or top edge of the rectangle should be. */ - anchorAtRightOrBottom = 1 << 1, /**< The x or y co-ordinate specifies where the right or bottom edge of the rectangle should be. */ - anchorAtCentre = 1 << 2 /**< The x or y co-ordinate specifies where the centre of the rectangle should be. */ - }; - - /** Specifies how an x or y co-ordinate should be interpreted. */ - enum PositionMode - { - absoluteFromParentTopLeft = 1 << 3, /**< The x or y co-ordinate specifies an absolute distance from the parent's top or left edge. */ - absoluteFromParentBottomRight = 1 << 4, /**< The x or y co-ordinate specifies an absolute distance from the parent's bottom or right edge. */ - absoluteFromParentCentre = 1 << 5, /**< The x or y co-ordinate specifies an absolute distance from the parent's centre. */ - proportionOfParentSize = 1 << 6 /**< The x or y co-ordinate specifies a proportion of the parent's width or height, measured from the parent's top or left. */ - }; - - /** Specifies how the width or height should be interpreted. */ - enum SizeMode - { - absoluteSize = 1 << 0, /**< The width or height specifies an absolute size. */ - parentSizeMinusAbsolute = 1 << 1, /**< The width or height is an amount that should be subtracted from the parent's width or height. */ - proportionalSize = 1 << 2, /**< The width or height specifies a proportion of the parent's width or height. */ - }; - - //============================================================================== - /** Sets all options for all co-ordinates. - - This requires a reference rectangle to be specified, because if you're changing any - of the modes from proportional to absolute or vice-versa, then it'll need to convert - the co-ordinates, and will need to know the parent size so it can calculate this. - */ - void setModes (const AnchorPoint xAnchor, const PositionMode xMode_, - const AnchorPoint yAnchor, const PositionMode yMode_, - const SizeMode widthMode, const SizeMode heightMode, - const Rectangle& target) throw() - { - if (xMode != (xAnchor | xMode_) || wMode != widthMode) - { - double tx, tw; - applyPosAndSize (tx, tw, x, w, xMode, wMode, target.getX(), target.getWidth()); - - xMode = (uint8) (xAnchor | xMode_); - wMode = (uint8) widthMode; - - updatePosAndSize (x, w, tx, tw, xMode, wMode, target.getX(), target.getWidth()); - } - - if (yMode != (yAnchor | yMode_) || hMode != heightMode) - { - double ty, th; - applyPosAndSize (ty, th, y, h, yMode, hMode, target.getY(), target.getHeight()); - - yMode = (uint8) (yAnchor | yMode_); - hMode = (uint8) heightMode; - - updatePosAndSize (y, h, ty, th, yMode, hMode, target.getY(), target.getHeight()); - } - } - - /** Returns the anchoring mode for the x co-ordinate. - To change any of the modes, use setModes(). - */ - AnchorPoint getAnchorPointX() const throw() - { - return (AnchorPoint) (xMode & (anchorAtLeftOrTop | anchorAtRightOrBottom | anchorAtCentre)); - } - - /** Returns the positioning mode for the x co-ordinate. - To change any of the modes, use setModes(). - */ - PositionMode getPositionModeX() const throw() - { - return (PositionMode) (xMode & (absoluteFromParentTopLeft | absoluteFromParentBottomRight - | absoluteFromParentCentre | proportionOfParentSize)); - } - - /** Returns the raw x co-ordinate. - - If the x position mode is absolute, then this will be the absolute value. If it's - proportional, then this will be a fractional proportion, where 1.0 means the full - width of the parent space. - */ - double getX() const throw() { return x; } - - /** Sets the raw value of the x co-ordinate. - - See getX() for the meaning of this value. - */ - void setX (const double newX) throw() { x = newX; } - - /** Returns the anchoring mode for the y co-ordinate. - To change any of the modes, use setModes(). - */ - AnchorPoint getAnchorPointY() const throw() - { - return (AnchorPoint) (yMode & (anchorAtLeftOrTop | anchorAtRightOrBottom | anchorAtCentre)); - } - - /** Returns the positioning mode for the y co-ordinate. - To change any of the modes, use setModes(). - */ - PositionMode getPositionModeY() const throw() - { - return (PositionMode) (yMode & (absoluteFromParentTopLeft | absoluteFromParentBottomRight - | absoluteFromParentCentre | proportionOfParentSize)); - } - - /** Returns the raw y co-ordinate. - - If the y position mode is absolute, then this will be the absolute value. If it's - proportional, then this will be a fractional proportion, where 1.0 means the full - height of the parent space. - */ - double getY() const throw() { return y; } - - /** Sets the raw value of the y co-ordinate. - - See getY() for the meaning of this value. - */ - void setY (const double newY) throw() { y = newY; } - - /** Returns the mode used to calculate the width. - To change any of the modes, use setModes(). - */ - SizeMode getWidthMode() const throw() { return (SizeMode) wMode; } - - /** Returns the raw width value. - - If the width mode is absolute, then this will be the absolute value. If the mode is - proportional, then this will be a fractional proportion, where 1.0 means the full - width of the parent space. - */ - double getWidth() const throw() { return w; } - - /** Sets the raw width value. - - See getWidth() for the details about what this value means. - */ - void setWidth (const double newWidth) throw() { w = newWidth; } - - /** Returns the mode used to calculate the height. - To change any of the modes, use setModes(). - */ - SizeMode getHeightMode() const throw() { return (SizeMode) hMode; } - - /** Returns the raw height value. - - If the height mode is absolute, then this will be the absolute value. If the mode is - proportional, then this will be a fractional proportion, where 1.0 means the full - height of the parent space. - */ - double getHeight() const throw() { return h; } - - /** Sets the raw height value. - - See getHeight() for the details about what this value means. - */ - void setHeight (const double newHeight) throw() { h = newHeight; } - - //============================================================================== - /** If the size and position are constance, and wouldn't be affected by changes - in the parent's size, then this will return true. - */ - bool isPositionAbsolute() const throw() - { - return xMode == absoluteFromParentTopLeft - && yMode == absoluteFromParentTopLeft - && wMode == absoluteSize - && hMode == absoluteSize; - } - - //============================================================================== - /** Compares two objects. */ - bool operator== (const PositionedRectangle& other) const throw() - { - return x == other.x && y == other.y - && w == other.w && h == other.h - && xMode == other.xMode && yMode == other.yMode - && wMode == other.wMode && hMode == other.hMode; - } - - /** Compares two objects. */ - bool operator!= (const PositionedRectangle& other) const throw() - { - return ! operator== (other); - } - -private: - //============================================================================== - double x, y, w, h; - uint8 xMode, yMode, wMode, hMode; - - void addPosDescription (String& s, const uint8 mode, const double value) const throw() - { - if ((mode & proportionOfParentSize) != 0) - { - s << (roundToInt (value * 100000.0) / 1000.0) << '%'; - } - else - { - s << (roundToInt (value * 100.0) / 100.0); - - if ((mode & absoluteFromParentBottomRight) != 0) - s << 'R'; - else if ((mode & absoluteFromParentCentre) != 0) - s << 'C'; - } - - if ((mode & anchorAtRightOrBottom) != 0) - s << 'r'; - else if ((mode & anchorAtCentre) != 0) - s << 'c'; - } - - void addSizeDescription (String& s, const uint8 mode, const double value) const throw() - { - if (mode == proportionalSize) - s << (roundToInt (value * 100000.0) / 1000.0) << '%'; - else if (mode == parentSizeMinusAbsolute) - s << (roundToInt (value * 100.0) / 100.0) << 'M'; - else - s << (roundToInt (value * 100.0) / 100.0); - } - - void decodePosString (const String& s, uint8& mode, double& value) throw() - { - if (s.containsChar ('r')) - mode = anchorAtRightOrBottom; - else if (s.containsChar ('c')) - mode = anchorAtCentre; - else - mode = anchorAtLeftOrTop; - - if (s.containsChar ('%')) - { - mode |= proportionOfParentSize; - value = s.removeCharacters ("%rcRC").getDoubleValue() / 100.0; - } - else - { - if (s.containsChar ('R')) - mode |= absoluteFromParentBottomRight; - else if (s.containsChar ('C')) - mode |= absoluteFromParentCentre; - else - mode |= absoluteFromParentTopLeft; - - value = s.removeCharacters ("rcRC").getDoubleValue(); - } - } - - void decodeSizeString (const String& s, uint8& mode, double& value) throw() - { - if (s.containsChar ('%')) - { - mode = proportionalSize; - value = s.upToFirstOccurrenceOf ("%", false, false).getDoubleValue() / 100.0; - } - else if (s.containsChar ('M')) - { - mode = parentSizeMinusAbsolute; - value = s.getDoubleValue(); - } - else - { - mode = absoluteSize; - value = s.getDoubleValue(); - } - } - - void applyPosAndSize (double& xOut, double& wOut, const double x_, const double w_, - const uint8 xMode_, const uint8 wMode_, - const int parentPos, const int parentSize) const throw() - { - if (wMode_ == proportionalSize) - wOut = roundToInt (w_ * parentSize); - else if (wMode_ == parentSizeMinusAbsolute) - wOut = jmax (0, parentSize - roundToInt (w_)); - else - wOut = roundToInt (w_); - - if ((xMode_ & proportionOfParentSize) != 0) - xOut = parentPos + x_ * parentSize; - else if ((xMode_ & absoluteFromParentBottomRight) != 0) - xOut = (parentPos + parentSize) - x_; - else if ((xMode_ & absoluteFromParentCentre) != 0) - xOut = x_ + (parentPos + parentSize / 2); - else - xOut = x_ + parentPos; - - if ((xMode_ & anchorAtRightOrBottom) != 0) - xOut -= wOut; - else if ((xMode_ & anchorAtCentre) != 0) - xOut -= wOut / 2; - } - - void updatePosAndSize (double& xOut, double& wOut, double x_, const double w_, - const uint8 xMode_, const uint8 wMode_, - const int parentPos, const int parentSize) const throw() - { - if (wMode_ == proportionalSize) - { - if (parentSize > 0) - wOut = w_ / parentSize; - } - else if (wMode_ == parentSizeMinusAbsolute) - wOut = parentSize - w_; - else - wOut = w_; - - if ((xMode_ & anchorAtRightOrBottom) != 0) - x_ += w_; - else if ((xMode_ & anchorAtCentre) != 0) - x_ += w_ / 2; - - if ((xMode_ & proportionOfParentSize) != 0) - { - if (parentSize > 0) - xOut = (x_ - parentPos) / parentSize; - } - else if ((xMode_ & absoluteFromParentBottomRight) != 0) - xOut = (parentPos + parentSize) - x_; - else if ((xMode_ & absoluteFromParentCentre) != 0) - xOut = x_ - (parentPos + parentSize / 2); - else - xOut = x_ - parentPos; - } - - JUCE_LEAK_DETECTOR (PositionedRectangle); -}; - - -#endif // __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ diff --git a/src/gui/graphics/geometry/juce_Rectangle.h b/src/gui/graphics/geometry/juce_Rectangle.h index 001aac3451..4ddfcb9b56 100644 --- a/src/gui/graphics/geometry/juce_Rectangle.h +++ b/src/gui/graphics/geometry/juce_Rectangle.h @@ -47,7 +47,7 @@ public: The default co-ordinates will be (0, 0, 0, 0). */ Rectangle() throw() - : x (0), y (0), w (0), h (0) + : x(), y(), w(), h() { } @@ -68,7 +68,7 @@ public: /** Creates a rectangle with a given size, and a position of (0, 0). */ Rectangle (const ValueType width, const ValueType height) throw() - : x (0), y (0), w (width), h (height) + : x(), y(), w (width), h (height) { } @@ -79,8 +79,8 @@ public: w (corner1.getX() - corner2.getX()), h (corner1.getY() - corner2.getY()) { - if (w < 0) w = -w; - if (h < 0) h = -h; + if (w < ValueType()) w = -w; + if (h < ValueType()) h = -h; } /** Creates a Rectangle from a set of left, right, top, bottom coordinates. @@ -105,7 +105,7 @@ public: //============================================================================== /** Returns true if the rectangle's width and height are both zero or less */ - bool isEmpty() const throw() { return w <= 0 || h <= 0; } + bool isEmpty() const throw() { return w <= ValueType() || h <= ValueType(); } /** Returns the x co-ordinate of the rectangle's left-hand-side. */ inline ValueType getX() const throw() { return x; } @@ -503,12 +503,12 @@ public: const int maxX = jmax (otherX, x); otherW = jmin (otherX + otherW, x + w) - maxX; - if (otherW > 0) + if (otherW > ValueType()) { const int maxY = jmax (otherY, y); otherH = jmin (otherY + otherH, y + h) - maxY; - if (otherH > 0) + if (otherH > ValueType()) { otherX = maxX; otherY = maxY; return true; @@ -675,12 +675,12 @@ public: const ValueType x = jmax (x1, x2); w1 = jmin (x1 + w1, x2 + w2) - x; - if (w1 > 0) + if (w1 > ValueType()) { const ValueType y = jmax (y1, y2); h1 = jmin (y1 + h1, y2 + h2) - y; - if (h1 > 0) + if (h1 > ValueType()) { x1 = x; y1 = y; return true; diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index 8d7e46f0d6..fd18f13381 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -722,9 +722,6 @@ #ifndef __JUCE_POINT_JUCEHEADER__ #include "gui/graphics/geometry/juce_Point.h" #endif -#ifndef __JUCE_POSITIONEDRECTANGLE_JUCEHEADER__ - #include "gui/graphics/geometry/juce_PositionedRectangle.h" -#endif #ifndef __JUCE_RECTANGLE_JUCEHEADER__ #include "gui/graphics/geometry/juce_Rectangle.h" #endif diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index 1b92aa6758..7b8c4966ed 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -1040,9 +1040,9 @@ public: return child == None; } - const BorderSize getFrameSize() const + const BorderSize getFrameSize() const { - return BorderSize(); + return BorderSize(); } bool setAlwaysOnTop (bool alwaysOnTop) @@ -1876,7 +1876,7 @@ private: bool fullScreen, mapped; Visual* visual; int depth; - BorderSize windowBorder; + BorderSize windowBorder; struct MotifWmHints { @@ -2291,7 +2291,7 @@ private: { if ((styleFlags & windowHasTitleBar) == 0) { - windowBorder = BorderSize (0); + windowBorder = BorderSize (0); } else if (windowBorder.getTopAndBottom() == 0 && windowBorder.getLeftAndRight() == 0) { @@ -2312,8 +2312,8 @@ private: const unsigned long* const sizes = (const unsigned long*) data; if (actualFormat == 32) - windowBorder = BorderSize ((int) sizes[2], (int) sizes[0], - (int) sizes[3], (int) sizes[1]); + windowBorder = BorderSize ((int) sizes[2], (int) sizes[0], + (int) sizes[3], (int) sizes[1]); XFree (data); } diff --git a/src/native/mac/juce_iphone_UIViewComponentPeer.mm b/src/native/mac/juce_iphone_UIViewComponentPeer.mm index 61e9b32ed9..2e2c16f09c 100644 --- a/src/native/mac/juce_iphone_UIViewComponentPeer.mm +++ b/src/native/mac/juce_iphone_UIViewComponentPeer.mm @@ -117,7 +117,7 @@ public: void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; bool contains (const Point& position, bool trueIfInAChildWindow) const; - const BorderSize getFrameSize() const; + const BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); void toBehind (ComponentPeer* other); @@ -680,9 +680,9 @@ bool UIViewComponentPeer::contains (const Point& position, bool trueIfInACh return v == view; } -const BorderSize UIViewComponentPeer::getFrameSize() const +const BorderSize UIViewComponentPeer::getFrameSize() const { - return BorderSize(); + return BorderSize(); } bool UIViewComponentPeer::setAlwaysOnTop (bool alwaysOnTop) diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index fae5828983..c73b0ecbd9 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -166,7 +166,7 @@ public: void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; bool contains (const Point& position, bool trueIfInAChildWindow) const; - const BorderSize getFrameSize() const; + const BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); void toBehind (ComponentPeer* other); @@ -1178,9 +1178,9 @@ bool NSViewComponentPeer::contains (const Point& position, bool trueIfInACh return v == view; } -const BorderSize NSViewComponentPeer::getFrameSize() const +const BorderSize NSViewComponentPeer::getFrameSize() const { - BorderSize b; + BorderSize b; if (! isSharedWindow) { diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index 182ce99c9c..c14232c1eb 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -560,10 +560,10 @@ public: if (GetWindowInfo (hwnd, &info)) { - windowBorder = BorderSize (info.rcClient.top - info.rcWindow.top, - info.rcClient.left - info.rcWindow.left, - info.rcWindow.bottom - info.rcClient.bottom, - info.rcWindow.right - info.rcClient.right); + windowBorder = BorderSize (info.rcClient.top - info.rcWindow.top, + info.rcClient.left - info.rcWindow.left, + info.rcWindow.bottom - info.rcClient.bottom, + info.rcWindow.right - info.rcClient.right); } #if JUCE_DIRECT2D @@ -742,7 +742,7 @@ public: return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0)); } - const BorderSize getFrameSize() const + const BorderSize getFrameSize() const { return windowBorder; } @@ -1010,7 +1010,7 @@ private: ScopedPointer direct2DContext; #endif bool fullScreen, isDragging, isMouseOver, hasCreatedCaret, constrainerIsResizing; - BorderSize windowBorder; + BorderSize windowBorder; HICON currentWindowIcon; ScopedPointer taskBarIcon; IDropTarget* dropTarget;