From e0ca6d6ca4b9a00fe57e6c2a849c0747a35a7ebe Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Mon, 3 Jan 2011 18:08:28 +0000 Subject: [PATCH] Small fixes for ComboBox items and AudioThumbnail. Reorganisation of all the RelativeCoordinate classes into their own folder. New RelativeCoordinatePositionerBase class and internal work on DrawablePath. --- Builds/Linux/Makefile | 54 +- Builds/MacOSX/Juce.xcodeproj/project.pbxproj | 58 +- Builds/VisualStudio2005/Juce.vcproj | 20 +- Builds/VisualStudio2008/Juce.vcproj | 20 +- Builds/VisualStudio2008_DLL/Juce.vcproj | 20 +- Builds/VisualStudio2010/Juce.vcxproj | 18 +- Builds/VisualStudio2010/Juce.vcxproj.filters | 57 +- Builds/iPhone/Juce.xcodeproj/project.pbxproj | 58 +- Juce.jucer | 38 +- amalgamation/juce_amalgamated_template.cpp | 9 +- juce_amalgamated.cpp | 1365 ++++++++++------- juce_amalgamated.h | 1035 +++++++------ .../juce_AudioThumbnail.cpp | 5 + src/core/juce_StandardHeader.h | 2 +- src/gui/components/controls/juce_ComboBox.cpp | 25 +- src/gui/components/controls/juce_ComboBox.h | 1 + .../juce_MarkerList.cpp | 0 .../{layout => positioning}/juce_MarkerList.h | 2 +- .../positioning/juce_RelativeCoordinate.cpp | 176 +++ .../positioning/juce_RelativeCoordinate.h | 138 ++ .../juce_RelativeCoordinatePositioner.cpp | 279 ++++ .../juce_RelativeCoordinatePositioner.h | 83 + .../juce_RelativeParallelogram.cpp | 133 ++ .../positioning/juce_RelativeParallelogram.h | 66 + .../positioning/juce_RelativePoint.cpp | 111 ++ .../positioning/juce_RelativePoint.h | 98 ++ .../positioning/juce_RelativePointPath.cpp | 306 ++++ .../positioning/juce_RelativePointPath.h | 196 +++ .../positioning/juce_RelativeRectangle.cpp | 189 +++ .../positioning/juce_RelativeRectangle.h | 107 ++ src/gui/graphics/drawables/juce_Drawable.h | 2 +- .../drawables/juce_DrawableComposite.h | 4 +- .../graphics/drawables/juce_DrawableImage.h | 1 + .../graphics/drawables/juce_DrawablePath.cpp | 156 +- .../graphics/drawables/juce_DrawablePath.h | 12 +- .../drawables/juce_DrawableRectangle.h | 1 + .../graphics/drawables/juce_DrawableShape.h | 1 + .../graphics/drawables/juce_DrawableText.h | 1 + .../geometry/juce_RelativeCoordinate.cpp | 1017 ------------ .../geometry/juce_RelativeCoordinate.h | 462 ------ src/juce_app_includes.h | 27 +- src/text/juce_XmlElement.h | 1 + 42 files changed, 3722 insertions(+), 2632 deletions(-) rename src/gui/components/{layout => positioning}/juce_MarkerList.cpp (100%) rename src/gui/components/{layout => positioning}/juce_MarkerList.h (96%) create mode 100644 src/gui/components/positioning/juce_RelativeCoordinate.cpp create mode 100644 src/gui/components/positioning/juce_RelativeCoordinate.h create mode 100644 src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp create mode 100644 src/gui/components/positioning/juce_RelativeCoordinatePositioner.h create mode 100644 src/gui/components/positioning/juce_RelativeParallelogram.cpp create mode 100644 src/gui/components/positioning/juce_RelativeParallelogram.h create mode 100644 src/gui/components/positioning/juce_RelativePoint.cpp create mode 100644 src/gui/components/positioning/juce_RelativePoint.h create mode 100644 src/gui/components/positioning/juce_RelativePointPath.cpp create mode 100644 src/gui/components/positioning/juce_RelativePointPath.h create mode 100644 src/gui/components/positioning/juce_RelativeRectangle.cpp create mode 100644 src/gui/components/positioning/juce_RelativeRectangle.h delete mode 100644 src/gui/graphics/geometry/juce_RelativeCoordinate.cpp delete mode 100644 src/gui/graphics/geometry/juce_RelativeCoordinate.h diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index 06001ac06a..c581f3bf37 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -174,7 +174,6 @@ OBJECTS := \ $(OBJDIR)/juce_ComponentBuilder_2aa6c5a.o \ $(OBJDIR)/juce_ComponentMovementWatcher_cbb3e7cc.o \ $(OBJDIR)/juce_GroupComponent_456e237a.o \ - $(OBJDIR)/juce_MarkerList_aea878b4.o \ $(OBJDIR)/juce_MultiDocumentPanel_50e05aac.o \ $(OBJDIR)/juce_ResizableBorderComponent_7f4f2182.o \ $(OBJDIR)/juce_ResizableCornerComponent_1cac2df9.o \ @@ -197,6 +196,13 @@ OBJECTS := \ $(OBJDIR)/juce_MouseHoverDetector_d4af7a00.o \ $(OBJDIR)/juce_MouseInputSource_8904aa23.o \ $(OBJDIR)/juce_MouseListener_eb73f8a0.o \ + $(OBJDIR)/juce_MarkerList_2fbb4ef.o \ + $(OBJDIR)/juce_RelativeCoordinate_ab2eee5b.o \ + $(OBJDIR)/juce_RelativeCoordinatePositioner_c1352791.o \ + $(OBJDIR)/juce_RelativeParallelogram_5d17dbe6.o \ + $(OBJDIR)/juce_RelativePoint_9d2cc957.o \ + $(OBJDIR)/juce_RelativePointPath_a4fed61c.o \ + $(OBJDIR)/juce_RelativeRectangle_cc5440b6.o \ $(OBJDIR)/juce_BooleanPropertyComponent_92b54aa5.o \ $(OBJDIR)/juce_ButtonPropertyComponent_3675d6bb.o \ $(OBJDIR)/juce_ChoicePropertyComponent_b9b44bac.o \ @@ -255,7 +261,6 @@ OBJECTS := \ $(OBJDIR)/juce_PathStrokeType_506dcb86.o \ $(OBJDIR)/juce_PositionedRectangle_1b6e8982.o \ $(OBJDIR)/juce_RectangleList_b6ae7ee8.o \ - $(OBJDIR)/juce_RelativeCoordinate_23fb9d3.o \ $(OBJDIR)/juce_GIFLoader_61887b90.o \ $(OBJDIR)/juce_JPEGLoader_412d2ccc.o \ $(OBJDIR)/juce_PNGLoader_7f80a3b5.o \ @@ -1039,11 +1044,6 @@ $(OBJDIR)/juce_GroupComponent_456e237a.o: ../../src/gui/components/layout/juce_G @echo "Compiling juce_GroupComponent.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_MarkerList_aea878b4.o: ../../src/gui/components/layout/juce_MarkerList.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling juce_MarkerList.cpp" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - $(OBJDIR)/juce_MultiDocumentPanel_50e05aac.o: ../../src/gui/components/layout/juce_MultiDocumentPanel.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_MultiDocumentPanel.cpp" @@ -1154,6 +1154,41 @@ $(OBJDIR)/juce_MouseListener_eb73f8a0.o: ../../src/gui/components/mouse/juce_Mou @echo "Compiling juce_MouseListener.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" +$(OBJDIR)/juce_MarkerList_2fbb4ef.o: ../../src/gui/components/positioning/juce_MarkerList.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_MarkerList.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + +$(OBJDIR)/juce_RelativeCoordinate_ab2eee5b.o: ../../src/gui/components/positioning/juce_RelativeCoordinate.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_RelativeCoordinate.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + +$(OBJDIR)/juce_RelativeCoordinatePositioner_c1352791.o: ../../src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_RelativeCoordinatePositioner.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + +$(OBJDIR)/juce_RelativeParallelogram_5d17dbe6.o: ../../src/gui/components/positioning/juce_RelativeParallelogram.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_RelativeParallelogram.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + +$(OBJDIR)/juce_RelativePoint_9d2cc957.o: ../../src/gui/components/positioning/juce_RelativePoint.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_RelativePoint.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + +$(OBJDIR)/juce_RelativePointPath_a4fed61c.o: ../../src/gui/components/positioning/juce_RelativePointPath.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_RelativePointPath.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + +$(OBJDIR)/juce_RelativeRectangle_cc5440b6.o: ../../src/gui/components/positioning/juce_RelativeRectangle.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling juce_RelativeRectangle.cpp" + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + $(OBJDIR)/juce_BooleanPropertyComponent_92b54aa5.o: ../../src/gui/components/properties/juce_BooleanPropertyComponent.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_BooleanPropertyComponent.cpp" @@ -1444,11 +1479,6 @@ $(OBJDIR)/juce_RectangleList_b6ae7ee8.o: ../../src/gui/graphics/geometry/juce_Re @echo "Compiling juce_RectangleList.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_RelativeCoordinate_23fb9d3.o: ../../src/gui/graphics/geometry/juce_RelativeCoordinate.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling juce_RelativeCoordinate.cpp" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - $(OBJDIR)/juce_GIFLoader_61887b90.o: ../../src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_GIFLoader.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index 800016d767..6d7fec9bec 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -143,7 +143,6 @@ 9AA76460DA7D34CE6A69E2B1 = { isa = PBXBuildFile; fileRef = 45E5EE9E0173683D721FABDA; }; 4E81BC4A50CF1883F529E152 = { isa = PBXBuildFile; fileRef = F8FCCCE06D31FEF697FCD80D; }; 8FBB6BF0C5406E1BA481CFEF = { isa = PBXBuildFile; fileRef = A6AD7357F905309D1B461EB7; }; - 260EF664D324038F9DC6C35B = { isa = PBXBuildFile; fileRef = F665A039C3A85EFDAA3E1245; }; F5F3F25D9F377128DC74D95B = { isa = PBXBuildFile; fileRef = FF046140CCF1EDB0DFF80178; }; C64A2BF05224582134872415 = { isa = PBXBuildFile; fileRef = A95F42C5CB0C2E5052B31568; }; 0A9C9486A6B31F21B1472D2B = { isa = PBXBuildFile; fileRef = A31221E2A50CCE9DF06B5F4B; }; @@ -166,6 +165,13 @@ 968B31D8101A937444C6DFB3 = { isa = PBXBuildFile; fileRef = 2531C57B0C861A48E3F3A673; }; E064E329741F36C329989203 = { isa = PBXBuildFile; fileRef = 441257DD380138C03568FCBD; }; 61E659ADBF9D832ED8F24540 = { isa = PBXBuildFile; fileRef = 2886656DF7ACC9DDC888827F; }; + 9379C833B875207E5DFC5A3F = { isa = PBXBuildFile; fileRef = 82DFF1BD3665DC32672FCCE8; }; + F1A6C2E3226F87860BFC4EBC = { isa = PBXBuildFile; fileRef = D39C0B853C3EBBBD11E7C71E; }; + 144872E56AED1981C0973B24 = { isa = PBXBuildFile; fileRef = D31704DAB806B6AF3ED52DC7; }; + 95648DF5676EBEF57009D09A = { isa = PBXBuildFile; fileRef = 243EF1A31A779413BC2D5B98; }; + 2FE59D80851A0A392EF2F923 = { isa = PBXBuildFile; fileRef = 36BB6DDF702EC9B3DAC851FF; }; + 621D2E6CDA267030405166C2 = { isa = PBXBuildFile; fileRef = 9DA988F1D7CE29E0DFED7EF0; }; + 90347B7C32ACE8A11FC1B708 = { isa = PBXBuildFile; fileRef = 072D77C3834B1B3FB77F277B; }; FAC87D81FE5168E37645A113 = { isa = PBXBuildFile; fileRef = 1C3FFBA02AE51EDD72A6250B; }; E5BB4B5EBFE206E09D0E6E10 = { isa = PBXBuildFile; fileRef = C45E7E6B6E45DEFBF80940DD; }; 1906C642BF6CA67821512855 = { isa = PBXBuildFile; fileRef = ECCBF2452804ECB2D5B4BC50; }; @@ -224,7 +230,6 @@ E7C9FAA5F8A4AEDAD8A8CC1D = { isa = PBXBuildFile; fileRef = 9D3F1BAB1D48DDECB9F35916; }; DC4BB8AFC054ECD4141B47CC = { isa = PBXBuildFile; fileRef = 11D8021D49B895410A836486; }; 084C9F2D4F78134CB1EFE676 = { isa = PBXBuildFile; fileRef = 1B170F70AF8AA0A39074F671; }; - 1110DD0779F44F625316D083 = { isa = PBXBuildFile; fileRef = 2AA4DDD1F26188A570F4DBE2; }; 4DAD08CD3A688747C9CA237B = { isa = PBXBuildFile; fileRef = 0F1C5770B363EF7DF64A876A; }; 60FE8BFA252E3EF2D60B77AD = { isa = PBXBuildFile; fileRef = 6619D27E74F623B1E8CE8F71; }; C592CC923C5495467EF05D48 = { isa = PBXBuildFile; fileRef = EAF0F2EAB230F7539B91A7FB; }; @@ -667,8 +672,6 @@ 44CDA79090B115C3B62A2168 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ComponentMovementWatcher.h; path = ../../src/gui/components/layout/juce_ComponentMovementWatcher.h; sourceTree = SOURCE_ROOT; }; A6AD7357F905309D1B461EB7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_GroupComponent.cpp; path = ../../src/gui/components/layout/juce_GroupComponent.cpp; sourceTree = SOURCE_ROOT; }; E9242E8425497D889C764C66 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_GroupComponent.h; path = ../../src/gui/components/layout/juce_GroupComponent.h; sourceTree = SOURCE_ROOT; }; - F665A039C3A85EFDAA3E1245 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MarkerList.cpp; path = ../../src/gui/components/layout/juce_MarkerList.cpp; sourceTree = SOURCE_ROOT; }; - 8A9F1A98C0C96BF655F606AB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MarkerList.h; path = ../../src/gui/components/layout/juce_MarkerList.h; sourceTree = SOURCE_ROOT; }; FF046140CCF1EDB0DFF80178 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MultiDocumentPanel.cpp; path = ../../src/gui/components/layout/juce_MultiDocumentPanel.cpp; sourceTree = SOURCE_ROOT; }; B6A223FB5B4A9388C83D6FC7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MultiDocumentPanel.h; path = ../../src/gui/components/layout/juce_MultiDocumentPanel.h; sourceTree = SOURCE_ROOT; }; A95F42C5CB0C2E5052B31568 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ResizableBorderComponent.cpp; path = ../../src/gui/components/layout/juce_ResizableBorderComponent.cpp; sourceTree = SOURCE_ROOT; }; @@ -718,6 +721,20 @@ 2886656DF7ACC9DDC888827F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MouseListener.cpp; path = ../../src/gui/components/mouse/juce_MouseListener.cpp; sourceTree = SOURCE_ROOT; }; 0C28F27F9D1CE6CD65185760 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MouseListener.h; path = ../../src/gui/components/mouse/juce_MouseListener.h; sourceTree = SOURCE_ROOT; }; 89AA49DD2A63D80E90A56768 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_TooltipClient.h; path = ../../src/gui/components/mouse/juce_TooltipClient.h; sourceTree = SOURCE_ROOT; }; + 82DFF1BD3665DC32672FCCE8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MarkerList.cpp; path = ../../src/gui/components/positioning/juce_MarkerList.cpp; sourceTree = SOURCE_ROOT; }; + 5B6CD1833A98F9844B7E3FF4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MarkerList.h; path = ../../src/gui/components/positioning/juce_MarkerList.h; sourceTree = SOURCE_ROOT; }; + D39C0B853C3EBBBD11E7C71E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeCoordinate.cpp; path = ../../src/gui/components/positioning/juce_RelativeCoordinate.cpp; sourceTree = SOURCE_ROOT; }; + 657546D70AB7B2709619E07A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeCoordinate.h; path = ../../src/gui/components/positioning/juce_RelativeCoordinate.h; sourceTree = SOURCE_ROOT; }; + D31704DAB806B6AF3ED52DC7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeCoordinatePositioner.cpp; path = ../../src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp; sourceTree = SOURCE_ROOT; }; + 574EC603B2B1189687851319 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeCoordinatePositioner.h; path = ../../src/gui/components/positioning/juce_RelativeCoordinatePositioner.h; sourceTree = SOURCE_ROOT; }; + 243EF1A31A779413BC2D5B98 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeParallelogram.cpp; path = ../../src/gui/components/positioning/juce_RelativeParallelogram.cpp; sourceTree = SOURCE_ROOT; }; + 72EFFDE39C7255D50F926944 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeParallelogram.h; path = ../../src/gui/components/positioning/juce_RelativeParallelogram.h; sourceTree = SOURCE_ROOT; }; + 36BB6DDF702EC9B3DAC851FF = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativePoint.cpp; path = ../../src/gui/components/positioning/juce_RelativePoint.cpp; sourceTree = SOURCE_ROOT; }; + A3B6342C6207D452F6AD985C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativePoint.h; path = ../../src/gui/components/positioning/juce_RelativePoint.h; sourceTree = SOURCE_ROOT; }; + 9DA988F1D7CE29E0DFED7EF0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativePointPath.cpp; path = ../../src/gui/components/positioning/juce_RelativePointPath.cpp; sourceTree = SOURCE_ROOT; }; + C1A3232DDB617A20D9C26526 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativePointPath.h; path = ../../src/gui/components/positioning/juce_RelativePointPath.h; sourceTree = SOURCE_ROOT; }; + 072D77C3834B1B3FB77F277B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeRectangle.cpp; path = ../../src/gui/components/positioning/juce_RelativeRectangle.cpp; sourceTree = SOURCE_ROOT; }; + 749CA35420339A25BA4E500F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeRectangle.h; path = ../../src/gui/components/positioning/juce_RelativeRectangle.h; sourceTree = SOURCE_ROOT; }; 1C3FFBA02AE51EDD72A6250B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_BooleanPropertyComponent.cpp; path = ../../src/gui/components/properties/juce_BooleanPropertyComponent.cpp; sourceTree = SOURCE_ROOT; }; B422688E380911F3C21E3F04 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_BooleanPropertyComponent.h; path = ../../src/gui/components/properties/juce_BooleanPropertyComponent.h; sourceTree = SOURCE_ROOT; }; C45E7E6B6E45DEFBF80940DD = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ButtonPropertyComponent.cpp; path = ../../src/gui/components/properties/juce_ButtonPropertyComponent.cpp; sourceTree = SOURCE_ROOT; }; @@ -843,8 +860,6 @@ 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; }; - 2AA4DDD1F26188A570F4DBE2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeCoordinate.cpp; path = ../../src/gui/graphics/geometry/juce_RelativeCoordinate.cpp; sourceTree = SOURCE_ROOT; }; - 54D9BBB69BDA3837240F7749 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeCoordinate.h; path = ../../src/gui/graphics/geometry/juce_RelativeCoordinate.h; sourceTree = SOURCE_ROOT; }; 0F1C5770B363EF7DF64A876A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_GIFLoader.cpp; path = ../../src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp; sourceTree = SOURCE_ROOT; }; 6619D27E74F623B1E8CE8F71 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_JPEGLoader.cpp; path = ../../src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp; sourceTree = SOURCE_ROOT; }; EAF0F2EAB230F7539B91A7FB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_PNGLoader.cpp; path = ../../src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp; sourceTree = SOURCE_ROOT; }; @@ -1400,8 +1415,6 @@ 44CDA79090B115C3B62A2168, A6AD7357F905309D1B461EB7, E9242E8425497D889C764C66, - F665A039C3A85EFDAA3E1245, - 8A9F1A98C0C96BF655F606AB, FF046140CCF1EDB0DFF80178, B6A223FB5B4A9388C83D6FC7, A95F42C5CB0C2E5052B31568, @@ -1454,6 +1467,21 @@ 2886656DF7ACC9DDC888827F, 0C28F27F9D1CE6CD65185760, 89AA49DD2A63D80E90A56768 ); name = mouse; sourceTree = ""; }; + 362862B72D7FF7997C44CECF = { isa = PBXGroup; children = ( + 82DFF1BD3665DC32672FCCE8, + 5B6CD1833A98F9844B7E3FF4, + D39C0B853C3EBBBD11E7C71E, + 657546D70AB7B2709619E07A, + D31704DAB806B6AF3ED52DC7, + 574EC603B2B1189687851319, + 243EF1A31A779413BC2D5B98, + 72EFFDE39C7255D50F926944, + 36BB6DDF702EC9B3DAC851FF, + A3B6342C6207D452F6AD985C, + 9DA988F1D7CE29E0DFED7EF0, + C1A3232DDB617A20D9C26526, + 072D77C3834B1B3FB77F277B, + 749CA35420339A25BA4E500F ); name = positioning; sourceTree = ""; }; 0F03F34FC3542EF0CF8B31E6 = { isa = PBXGroup; children = ( 1C3FFBA02AE51EDD72A6250B, B422688E380911F3C21E3F04, @@ -1533,6 +1561,7 @@ EAE72EDE682D52DF77747660, 870DE7235866DA3B81B683B8, 4F37E36BA5E052B3BD4B87AD, + 362862B72D7FF7997C44CECF, 0F03F34FC3542EF0CF8B31E6, 5C03BF1C4CF3DEE1E0D6A3A1, 48D41BA310DED74E900A5AB0 ); name = components; sourceTree = ""; }; @@ -1608,9 +1637,7 @@ 469347B6414F2CE9DCEEA386, F8C44FF03700F6140950F373, 1B170F70AF8AA0A39074F671, - 8B7D7435287A20CB2D8E3704, - 2AA4DDD1F26188A570F4DBE2, - 54D9BBB69BDA3837240F7749 ); name = geometry; sourceTree = ""; }; + 8B7D7435287A20CB2D8E3704 ); name = geometry; sourceTree = ""; }; D71FD838B3FD1536FCA839A4 = { isa = PBXGroup; children = ( 0F1C5770B363EF7DF64A876A, 6619D27E74F623B1E8CE8F71, @@ -2082,7 +2109,6 @@ 9AA76460DA7D34CE6A69E2B1, 4E81BC4A50CF1883F529E152, 8FBB6BF0C5406E1BA481CFEF, - 260EF664D324038F9DC6C35B, F5F3F25D9F377128DC74D95B, C64A2BF05224582134872415, 0A9C9486A6B31F21B1472D2B, @@ -2105,6 +2131,13 @@ 968B31D8101A937444C6DFB3, E064E329741F36C329989203, 61E659ADBF9D832ED8F24540, + 9379C833B875207E5DFC5A3F, + F1A6C2E3226F87860BFC4EBC, + 144872E56AED1981C0973B24, + 95648DF5676EBEF57009D09A, + 2FE59D80851A0A392EF2F923, + 621D2E6CDA267030405166C2, + 90347B7C32ACE8A11FC1B708, FAC87D81FE5168E37645A113, E5BB4B5EBFE206E09D0E6E10, 1906C642BF6CA67821512855, @@ -2163,7 +2196,6 @@ E7C9FAA5F8A4AEDAD8A8CC1D, DC4BB8AFC054ECD4141B47CC, 084C9F2D4F78134CB1EFE676, - 1110DD0779F44F625316D083, 4DAD08CD3A688747C9CA237B, 60FE8BFA252E3EF2D60B77AD, C592CC923C5495467EF05D48, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index 777a348135..81e8a63990 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -548,8 +548,6 @@ - - @@ -606,6 +604,22 @@ + + + + + + + + + + + + + + + + @@ -750,8 +764,6 @@ - - diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index 3e667a2b01..d588f87638 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -548,8 +548,6 @@ - - @@ -606,6 +604,22 @@ + + + + + + + + + + + + + + + + @@ -750,8 +764,6 @@ - - diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index 45e4a4a7bb..7e3266456c 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -550,8 +550,6 @@ - - @@ -608,6 +606,22 @@ + + + + + + + + + + + + + + + + @@ -752,8 +766,6 @@ - - diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index 67e2ac3826..78ce4ae49b 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -257,7 +257,6 @@ - @@ -280,6 +279,13 @@ + + + + + + + @@ -338,7 +344,6 @@ - @@ -608,7 +613,6 @@ - @@ -636,6 +640,13 @@ + + + + + + + @@ -703,7 +714,6 @@ - diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index 04f398f6d0..b16e9db5ff 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -101,6 +101,9 @@ {B0D9CCC8-4718-BF06-EA13-DA2333E77AEE} + + {34D7048B-783F-B48F-2D42-7F22515A2741} + {6A81EDB6-D54A-343C-8BB0-CCE4DAA4823F} @@ -625,9 +628,6 @@ Juce\Source\gui\components\layout - - Juce\Source\gui\components\layout - Juce\Source\gui\components\layout @@ -694,6 +694,27 @@ Juce\Source\gui\components\mouse + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + Juce\Source\gui\components\properties @@ -868,9 +889,6 @@ Juce\Source\gui\graphics\geometry - - Juce\Source\gui\graphics\geometry - Juce\Source\gui\graphics\imaging\image_file_formats @@ -1752,9 +1770,6 @@ Juce\Source\gui\components\layout - - Juce\Source\gui\components\layout - Juce\Source\gui\components\layout @@ -1836,6 +1851,27 @@ Juce\Source\gui\components\mouse + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + + + Juce\Source\gui\components\positioning + Juce\Source\gui\components\properties @@ -2037,9 +2073,6 @@ Juce\Source\gui\graphics\geometry - - Juce\Source\gui\graphics\geometry - Juce\Source\gui\graphics\imaging diff --git a/Builds/iPhone/Juce.xcodeproj/project.pbxproj b/Builds/iPhone/Juce.xcodeproj/project.pbxproj index 408c9dc847..fc40598bfd 100644 --- a/Builds/iPhone/Juce.xcodeproj/project.pbxproj +++ b/Builds/iPhone/Juce.xcodeproj/project.pbxproj @@ -143,7 +143,6 @@ 9AA76460DA7D34CE6A69E2B1 = { isa = PBXBuildFile; fileRef = 45E5EE9E0173683D721FABDA; }; 4E81BC4A50CF1883F529E152 = { isa = PBXBuildFile; fileRef = F8FCCCE06D31FEF697FCD80D; }; 8FBB6BF0C5406E1BA481CFEF = { isa = PBXBuildFile; fileRef = A6AD7357F905309D1B461EB7; }; - 260EF664D324038F9DC6C35B = { isa = PBXBuildFile; fileRef = F665A039C3A85EFDAA3E1245; }; F5F3F25D9F377128DC74D95B = { isa = PBXBuildFile; fileRef = FF046140CCF1EDB0DFF80178; }; C64A2BF05224582134872415 = { isa = PBXBuildFile; fileRef = A95F42C5CB0C2E5052B31568; }; 0A9C9486A6B31F21B1472D2B = { isa = PBXBuildFile; fileRef = A31221E2A50CCE9DF06B5F4B; }; @@ -166,6 +165,13 @@ 968B31D8101A937444C6DFB3 = { isa = PBXBuildFile; fileRef = 2531C57B0C861A48E3F3A673; }; E064E329741F36C329989203 = { isa = PBXBuildFile; fileRef = 441257DD380138C03568FCBD; }; 61E659ADBF9D832ED8F24540 = { isa = PBXBuildFile; fileRef = 2886656DF7ACC9DDC888827F; }; + 9379C833B875207E5DFC5A3F = { isa = PBXBuildFile; fileRef = 82DFF1BD3665DC32672FCCE8; }; + F1A6C2E3226F87860BFC4EBC = { isa = PBXBuildFile; fileRef = D39C0B853C3EBBBD11E7C71E; }; + 144872E56AED1981C0973B24 = { isa = PBXBuildFile; fileRef = D31704DAB806B6AF3ED52DC7; }; + 95648DF5676EBEF57009D09A = { isa = PBXBuildFile; fileRef = 243EF1A31A779413BC2D5B98; }; + 2FE59D80851A0A392EF2F923 = { isa = PBXBuildFile; fileRef = 36BB6DDF702EC9B3DAC851FF; }; + 621D2E6CDA267030405166C2 = { isa = PBXBuildFile; fileRef = 9DA988F1D7CE29E0DFED7EF0; }; + 90347B7C32ACE8A11FC1B708 = { isa = PBXBuildFile; fileRef = 072D77C3834B1B3FB77F277B; }; FAC87D81FE5168E37645A113 = { isa = PBXBuildFile; fileRef = 1C3FFBA02AE51EDD72A6250B; }; E5BB4B5EBFE206E09D0E6E10 = { isa = PBXBuildFile; fileRef = C45E7E6B6E45DEFBF80940DD; }; 1906C642BF6CA67821512855 = { isa = PBXBuildFile; fileRef = ECCBF2452804ECB2D5B4BC50; }; @@ -224,7 +230,6 @@ E7C9FAA5F8A4AEDAD8A8CC1D = { isa = PBXBuildFile; fileRef = 9D3F1BAB1D48DDECB9F35916; }; DC4BB8AFC054ECD4141B47CC = { isa = PBXBuildFile; fileRef = 11D8021D49B895410A836486; }; 084C9F2D4F78134CB1EFE676 = { isa = PBXBuildFile; fileRef = 1B170F70AF8AA0A39074F671; }; - 1110DD0779F44F625316D083 = { isa = PBXBuildFile; fileRef = 2AA4DDD1F26188A570F4DBE2; }; 4DAD08CD3A688747C9CA237B = { isa = PBXBuildFile; fileRef = 0F1C5770B363EF7DF64A876A; }; 60FE8BFA252E3EF2D60B77AD = { isa = PBXBuildFile; fileRef = 6619D27E74F623B1E8CE8F71; }; C592CC923C5495467EF05D48 = { isa = PBXBuildFile; fileRef = EAF0F2EAB230F7539B91A7FB; }; @@ -667,8 +672,6 @@ 44CDA79090B115C3B62A2168 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ComponentMovementWatcher.h; path = ../../src/gui/components/layout/juce_ComponentMovementWatcher.h; sourceTree = SOURCE_ROOT; }; A6AD7357F905309D1B461EB7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_GroupComponent.cpp; path = ../../src/gui/components/layout/juce_GroupComponent.cpp; sourceTree = SOURCE_ROOT; }; E9242E8425497D889C764C66 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_GroupComponent.h; path = ../../src/gui/components/layout/juce_GroupComponent.h; sourceTree = SOURCE_ROOT; }; - F665A039C3A85EFDAA3E1245 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MarkerList.cpp; path = ../../src/gui/components/layout/juce_MarkerList.cpp; sourceTree = SOURCE_ROOT; }; - 8A9F1A98C0C96BF655F606AB = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MarkerList.h; path = ../../src/gui/components/layout/juce_MarkerList.h; sourceTree = SOURCE_ROOT; }; FF046140CCF1EDB0DFF80178 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MultiDocumentPanel.cpp; path = ../../src/gui/components/layout/juce_MultiDocumentPanel.cpp; sourceTree = SOURCE_ROOT; }; B6A223FB5B4A9388C83D6FC7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MultiDocumentPanel.h; path = ../../src/gui/components/layout/juce_MultiDocumentPanel.h; sourceTree = SOURCE_ROOT; }; A95F42C5CB0C2E5052B31568 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ResizableBorderComponent.cpp; path = ../../src/gui/components/layout/juce_ResizableBorderComponent.cpp; sourceTree = SOURCE_ROOT; }; @@ -718,6 +721,20 @@ 2886656DF7ACC9DDC888827F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MouseListener.cpp; path = ../../src/gui/components/mouse/juce_MouseListener.cpp; sourceTree = SOURCE_ROOT; }; 0C28F27F9D1CE6CD65185760 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MouseListener.h; path = ../../src/gui/components/mouse/juce_MouseListener.h; sourceTree = SOURCE_ROOT; }; 89AA49DD2A63D80E90A56768 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_TooltipClient.h; path = ../../src/gui/components/mouse/juce_TooltipClient.h; sourceTree = SOURCE_ROOT; }; + 82DFF1BD3665DC32672FCCE8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_MarkerList.cpp; path = ../../src/gui/components/positioning/juce_MarkerList.cpp; sourceTree = SOURCE_ROOT; }; + 5B6CD1833A98F9844B7E3FF4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_MarkerList.h; path = ../../src/gui/components/positioning/juce_MarkerList.h; sourceTree = SOURCE_ROOT; }; + D39C0B853C3EBBBD11E7C71E = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeCoordinate.cpp; path = ../../src/gui/components/positioning/juce_RelativeCoordinate.cpp; sourceTree = SOURCE_ROOT; }; + 657546D70AB7B2709619E07A = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeCoordinate.h; path = ../../src/gui/components/positioning/juce_RelativeCoordinate.h; sourceTree = SOURCE_ROOT; }; + D31704DAB806B6AF3ED52DC7 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeCoordinatePositioner.cpp; path = ../../src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp; sourceTree = SOURCE_ROOT; }; + 574EC603B2B1189687851319 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeCoordinatePositioner.h; path = ../../src/gui/components/positioning/juce_RelativeCoordinatePositioner.h; sourceTree = SOURCE_ROOT; }; + 243EF1A31A779413BC2D5B98 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeParallelogram.cpp; path = ../../src/gui/components/positioning/juce_RelativeParallelogram.cpp; sourceTree = SOURCE_ROOT; }; + 72EFFDE39C7255D50F926944 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeParallelogram.h; path = ../../src/gui/components/positioning/juce_RelativeParallelogram.h; sourceTree = SOURCE_ROOT; }; + 36BB6DDF702EC9B3DAC851FF = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativePoint.cpp; path = ../../src/gui/components/positioning/juce_RelativePoint.cpp; sourceTree = SOURCE_ROOT; }; + A3B6342C6207D452F6AD985C = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativePoint.h; path = ../../src/gui/components/positioning/juce_RelativePoint.h; sourceTree = SOURCE_ROOT; }; + 9DA988F1D7CE29E0DFED7EF0 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativePointPath.cpp; path = ../../src/gui/components/positioning/juce_RelativePointPath.cpp; sourceTree = SOURCE_ROOT; }; + C1A3232DDB617A20D9C26526 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativePointPath.h; path = ../../src/gui/components/positioning/juce_RelativePointPath.h; sourceTree = SOURCE_ROOT; }; + 072D77C3834B1B3FB77F277B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeRectangle.cpp; path = ../../src/gui/components/positioning/juce_RelativeRectangle.cpp; sourceTree = SOURCE_ROOT; }; + 749CA35420339A25BA4E500F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeRectangle.h; path = ../../src/gui/components/positioning/juce_RelativeRectangle.h; sourceTree = SOURCE_ROOT; }; 1C3FFBA02AE51EDD72A6250B = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_BooleanPropertyComponent.cpp; path = ../../src/gui/components/properties/juce_BooleanPropertyComponent.cpp; sourceTree = SOURCE_ROOT; }; B422688E380911F3C21E3F04 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_BooleanPropertyComponent.h; path = ../../src/gui/components/properties/juce_BooleanPropertyComponent.h; sourceTree = SOURCE_ROOT; }; C45E7E6B6E45DEFBF80940DD = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ButtonPropertyComponent.cpp; path = ../../src/gui/components/properties/juce_ButtonPropertyComponent.cpp; sourceTree = SOURCE_ROOT; }; @@ -843,8 +860,6 @@ 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; }; - 2AA4DDD1F26188A570F4DBE2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_RelativeCoordinate.cpp; path = ../../src/gui/graphics/geometry/juce_RelativeCoordinate.cpp; sourceTree = SOURCE_ROOT; }; - 54D9BBB69BDA3837240F7749 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_RelativeCoordinate.h; path = ../../src/gui/graphics/geometry/juce_RelativeCoordinate.h; sourceTree = SOURCE_ROOT; }; 0F1C5770B363EF7DF64A876A = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_GIFLoader.cpp; path = ../../src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp; sourceTree = SOURCE_ROOT; }; 6619D27E74F623B1E8CE8F71 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_JPEGLoader.cpp; path = ../../src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp; sourceTree = SOURCE_ROOT; }; EAF0F2EAB230F7539B91A7FB = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_PNGLoader.cpp; path = ../../src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp; sourceTree = SOURCE_ROOT; }; @@ -1400,8 +1415,6 @@ 44CDA79090B115C3B62A2168, A6AD7357F905309D1B461EB7, E9242E8425497D889C764C66, - F665A039C3A85EFDAA3E1245, - 8A9F1A98C0C96BF655F606AB, FF046140CCF1EDB0DFF80178, B6A223FB5B4A9388C83D6FC7, A95F42C5CB0C2E5052B31568, @@ -1454,6 +1467,21 @@ 2886656DF7ACC9DDC888827F, 0C28F27F9D1CE6CD65185760, 89AA49DD2A63D80E90A56768 ); name = mouse; sourceTree = ""; }; + 362862B72D7FF7997C44CECF = { isa = PBXGroup; children = ( + 82DFF1BD3665DC32672FCCE8, + 5B6CD1833A98F9844B7E3FF4, + D39C0B853C3EBBBD11E7C71E, + 657546D70AB7B2709619E07A, + D31704DAB806B6AF3ED52DC7, + 574EC603B2B1189687851319, + 243EF1A31A779413BC2D5B98, + 72EFFDE39C7255D50F926944, + 36BB6DDF702EC9B3DAC851FF, + A3B6342C6207D452F6AD985C, + 9DA988F1D7CE29E0DFED7EF0, + C1A3232DDB617A20D9C26526, + 072D77C3834B1B3FB77F277B, + 749CA35420339A25BA4E500F ); name = positioning; sourceTree = ""; }; 0F03F34FC3542EF0CF8B31E6 = { isa = PBXGroup; children = ( 1C3FFBA02AE51EDD72A6250B, B422688E380911F3C21E3F04, @@ -1533,6 +1561,7 @@ EAE72EDE682D52DF77747660, 870DE7235866DA3B81B683B8, 4F37E36BA5E052B3BD4B87AD, + 362862B72D7FF7997C44CECF, 0F03F34FC3542EF0CF8B31E6, 5C03BF1C4CF3DEE1E0D6A3A1, 48D41BA310DED74E900A5AB0 ); name = components; sourceTree = ""; }; @@ -1608,9 +1637,7 @@ 469347B6414F2CE9DCEEA386, F8C44FF03700F6140950F373, 1B170F70AF8AA0A39074F671, - 8B7D7435287A20CB2D8E3704, - 2AA4DDD1F26188A570F4DBE2, - 54D9BBB69BDA3837240F7749 ); name = geometry; sourceTree = ""; }; + 8B7D7435287A20CB2D8E3704 ); name = geometry; sourceTree = ""; }; D71FD838B3FD1536FCA839A4 = { isa = PBXGroup; children = ( 0F1C5770B363EF7DF64A876A, 6619D27E74F623B1E8CE8F71, @@ -2082,7 +2109,6 @@ 9AA76460DA7D34CE6A69E2B1, 4E81BC4A50CF1883F529E152, 8FBB6BF0C5406E1BA481CFEF, - 260EF664D324038F9DC6C35B, F5F3F25D9F377128DC74D95B, C64A2BF05224582134872415, 0A9C9486A6B31F21B1472D2B, @@ -2105,6 +2131,13 @@ 968B31D8101A937444C6DFB3, E064E329741F36C329989203, 61E659ADBF9D832ED8F24540, + 9379C833B875207E5DFC5A3F, + F1A6C2E3226F87860BFC4EBC, + 144872E56AED1981C0973B24, + 95648DF5676EBEF57009D09A, + 2FE59D80851A0A392EF2F923, + 621D2E6CDA267030405166C2, + 90347B7C32ACE8A11FC1B708, FAC87D81FE5168E37645A113, E5BB4B5EBFE206E09D0E6E10, 1906C642BF6CA67821512855, @@ -2163,7 +2196,6 @@ E7C9FAA5F8A4AEDAD8A8CC1D, DC4BB8AFC054ECD4141B47CC, 084C9F2D4F78134CB1EFE676, - 1110DD0779F44F625316D083, 4DAD08CD3A688747C9CA237B, 60FE8BFA252E3EF2D60B77AD, C592CC923C5495467EF05D48, diff --git a/Juce.jucer b/Juce.jucer index 6fdbeec275..eb4780ea44 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -728,10 +728,6 @@ file="src/gui/components/layout/juce_GroupComponent.cpp"/> - - + + + + + + + + + + + + + + + + @@ -1101,10 +1127,6 @@ file="src/gui/graphics/geometry/juce_RectangleList.cpp"/> - - diff --git a/amalgamation/juce_amalgamated_template.cpp b/amalgamation/juce_amalgamated_template.cpp index 24c286e1e8..dddfdd032c 100644 --- a/amalgamation/juce_amalgamated_template.cpp +++ b/amalgamation/juce_amalgamated_template.cpp @@ -277,7 +277,6 @@ #include "../src/gui/components/layout/juce_ComponentBoundsConstrainer.cpp" #include "../src/gui/components/layout/juce_ComponentMovementWatcher.cpp" #include "../src/gui/components/layout/juce_GroupComponent.cpp" - #include "../src/gui/components/layout/juce_MarkerList.cpp" #include "../src/gui/components/layout/juce_MultiDocumentPanel.cpp" #include "../src/gui/components/layout/juce_ResizableBorderComponent.cpp" #include "../src/gui/components/layout/juce_ResizableCornerComponent.cpp" @@ -327,7 +326,13 @@ #include "../src/gui/components/windows/juce_ThreadWithProgressWindow.cpp" #include "../src/gui/components/windows/juce_TooltipWindow.cpp" #include "../src/gui/components/windows/juce_TopLevelWindow.cpp" - #include "../src/gui/graphics/geometry/juce_RelativeCoordinate.cpp" + #include "../src/gui/components/positioning/juce_MarkerList.cpp" + #include "../src/gui/components/positioning/juce_RelativeCoordinate.cpp" + #include "../src/gui/components/positioning/juce_RelativePoint.cpp" + #include "../src/gui/components/positioning/juce_RelativeRectangle.cpp" + #include "../src/gui/components/positioning/juce_RelativePointPath.cpp" + #include "../src/gui/components/positioning/juce_RelativeParallelogram.cpp" + #include "../src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp" #endif #if JUCE_BUILD_MISC // (put these in misc to balance the file sizes and avoid problems in iphone build) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 0d43590634..716c04f8c5 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -22405,6 +22405,11 @@ bool AudioThumbnail::isFullyLoaded() const throw() return numSamplesFinished >= totalSamples - samplesPerThumbSample; } +int64 AudioThumbnail::getNumSamplesFinished() const throw() +{ + return numSamplesFinished; +} + float AudioThumbnail::getApproximatePeak() const { int peak = 0; @@ -47593,6 +47598,19 @@ void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMess } } +bool ComboBox::selectIfEnabled (const int index) +{ + const ItemInfo* const item = getItemForIndex (index); + + if (item != 0 && item->isEnabled) + { + setSelectedItemIndex (index); + return true; + } + + return false; +} + void ComboBox::valueChanged (Value&) { if (lastCurrentId != (int) currentId.getValue()) @@ -47738,12 +47756,20 @@ bool ComboBox::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::upKey) || key.isKeyCode (KeyPress::leftKey)) { - setSelectedItemIndex (jmax (0, getSelectedItemIndex() - 1)); + int index = getSelectedItemIndex() - 1; + + while (index >= 0 && ! selectIfEnabled (index)) + --index; + return true; } else if (key.isKeyCode (KeyPress::downKey) || key.isKeyCode (KeyPress::rightKey)) { - setSelectedItemIndex (jmin (getSelectedItemIndex() + 1, getNumItems() - 1)); + int index = getSelectedItemIndex() + 1; + + while (index < getNumItems() && ! selectIfEnabled (index)) + ++index; + return true; } else if (key.isKeyCode (KeyPress::returnKey)) @@ -62037,253 +62063,6 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_GroupComponent.cpp ***/ -/*** Start of inlined file: juce_MarkerList.cpp ***/ -BEGIN_JUCE_NAMESPACE - -MarkerList::MarkerList() -{ -} - -MarkerList::MarkerList (const MarkerList& other) -{ - operator= (other); -} - -MarkerList& MarkerList::operator= (const MarkerList& other) -{ - if (other != *this) - { - markers.clear(); - markers.addCopiesOf (other.markers); - markersHaveChanged(); - } - - return *this; -} - -MarkerList::~MarkerList() -{ - listeners.call (&MarkerList::Listener::markerListBeingDeleted, this); -} - -bool MarkerList::operator== (const MarkerList& other) const throw() -{ - if (other.markers.size() != markers.size()) - return false; - - for (int i = markers.size(); --i >= 0;) - { - const Marker* const m1 = markers.getUnchecked(i); - jassert (m1 != 0); - - const Marker* const m2 = other.getMarker (m1->name); - - if (m2 == 0 || *m1 != *m2) - return false; - } - - return true; -} - -bool MarkerList::operator!= (const MarkerList& other) const throw() -{ - return ! operator== (other); -} - -int MarkerList::getNumMarkers() const throw() -{ - return markers.size(); -} - -const MarkerList::Marker* MarkerList::getMarker (const int index) const throw() -{ - return markers [index]; -} - -const MarkerList::Marker* MarkerList::getMarker (const String& name) const throw() -{ - for (int i = 0; i < markers.size(); ++i) - { - const Marker* const m = markers.getUnchecked(i); - - if (m->name == name) - return m; - } - - return 0; -} - -void MarkerList::setMarker (const String& name, const RelativeCoordinate& position) -{ - Marker* const m = const_cast (getMarker (name)); - - if (m != 0) - { - if (m->position != position) - { - m->position = position; - markersHaveChanged(); - } - - return; - } - - markers.add (new Marker (name, position)); - markersHaveChanged(); -} - -void MarkerList::removeMarker (const int index) -{ - if (isPositiveAndBelow (index, markers.size())) - { - markers.remove (index); - markersHaveChanged(); - } -} - -void MarkerList::removeMarker (const String& name) -{ - for (int i = 0; i < markers.size(); ++i) - { - const Marker* const m = markers.getUnchecked(i); - - if (m->name == name) - { - markers.remove (i); - markersHaveChanged(); - } - } -} - -void MarkerList::markersHaveChanged() -{ - listeners.call (&MarkerList::Listener::markersChanged, this); -} - -void MarkerList::Listener::markerListBeingDeleted (MarkerList*) -{ -} - -void MarkerList::addListener (Listener* listener) -{ - listeners.add (listener); -} - -void MarkerList::removeListener (Listener* listener) -{ - listeners.remove (listener); -} - -MarkerList::Marker::Marker (const Marker& other) - : name (other.name), position (other.position) -{ -} - -MarkerList::Marker::Marker (const String& name_, const RelativeCoordinate& position_) - : name (name_), position (position_) -{ -} - -bool MarkerList::Marker::operator== (const Marker& other) const throw() -{ - return name == other.name && position == other.position; -} - -bool MarkerList::Marker::operator!= (const Marker& other) const throw() -{ - return ! operator== (other); -} - -const Identifier MarkerList::ValueTreeWrapper::markerTag ("Marker"); -const Identifier MarkerList::ValueTreeWrapper::nameProperty ("name"); -const Identifier MarkerList::ValueTreeWrapper::posProperty ("position"); - -MarkerList::ValueTreeWrapper::ValueTreeWrapper (const ValueTree& state_) - : state (state_) -{ -} - -int MarkerList::ValueTreeWrapper::getNumMarkers() const -{ - return state.getNumChildren(); -} - -const ValueTree MarkerList::ValueTreeWrapper::getMarkerState (int index) const -{ - return state.getChild (index); -} - -const ValueTree MarkerList::ValueTreeWrapper::getMarkerState (const String& name) const -{ - return state.getChildWithProperty (nameProperty, name); -} - -bool MarkerList::ValueTreeWrapper::containsMarker (const ValueTree& marker) const -{ - return marker.isAChildOf (state); -} - -const MarkerList::Marker MarkerList::ValueTreeWrapper::getMarker (const ValueTree& marker) const -{ - jassert (containsMarker (marker)); - - return MarkerList::Marker (marker [nameProperty], RelativeCoordinate (marker [posProperty].toString())); -} - -void MarkerList::ValueTreeWrapper::setMarker (const MarkerList::Marker& m, UndoManager* undoManager) -{ - ValueTree marker (state.getChildWithProperty (nameProperty, m.name)); - - if (marker.isValid()) - { - marker.setProperty (posProperty, m.position.toString(), undoManager); - } - else - { - marker = ValueTree (markerTag); - marker.setProperty (nameProperty, m.name, 0); - marker.setProperty (posProperty, m.position.toString(), 0); - state.addChild (marker, -1, undoManager); - } -} - -void MarkerList::ValueTreeWrapper::removeMarker (const ValueTree& marker, UndoManager* undoManager) -{ - state.removeChild (marker, undoManager); -} - -void MarkerList::ValueTreeWrapper::applyTo (MarkerList& markerList) -{ - const int numMarkers = getNumMarkers(); - - StringArray updatedMarkers; - - int i; - for (i = 0; i < numMarkers; ++i) - { - const ValueTree marker (state.getChild (i)); - const String name (marker [nameProperty].toString()); - markerList.setMarker (name, RelativeCoordinate (marker [posProperty].toString())); - updatedMarkers.add (name); - } - - for (i = markerList.getNumMarkers(); --i >= 0;) - if (! updatedMarkers.contains (markerList.getMarker (i)->name)) - markerList.removeMarker (i); -} - -void MarkerList::ValueTreeWrapper::readFrom (const MarkerList& markerList, UndoManager* undoManager) -{ - state.removeAllChildren (undoManager); - - for (int i = 0; i < markerList.getNumMarkers(); ++i) - setMarker (*markerList.getMarker(i), undoManager); -} - -END_JUCE_NAMESPACE -/*** End of inlined file: juce_MarkerList.cpp ***/ - - /*** Start of inlined file: juce_MultiDocumentPanel.cpp ***/ BEGIN_JUCE_NAMESPACE @@ -79674,283 +79453,255 @@ END_JUCE_NAMESPACE /*** End of inlined file: juce_TopLevelWindow.cpp ***/ -/*** Start of inlined file: juce_RelativeCoordinate.cpp ***/ +/*** Start of inlined file: juce_MarkerList.cpp ***/ BEGIN_JUCE_NAMESPACE -namespace RelativeCoordinateHelpers +MarkerList::MarkerList() { - void skipComma (const juce_wchar* const s, int& i) - { - while (CharacterFunctions::isWhitespace (s[i])) - ++i; +} - if (s[i] == ',') - ++i; +MarkerList::MarkerList (const MarkerList& other) +{ + operator= (other); +} + +MarkerList& MarkerList::operator= (const MarkerList& other) +{ + if (other != *this) + { + markers.clear(); + markers.addCopiesOf (other.markers); + markersHaveChanged(); + } + + return *this; +} + +MarkerList::~MarkerList() +{ + listeners.call (&MarkerList::Listener::markerListBeingDeleted, this); +} + +bool MarkerList::operator== (const MarkerList& other) const throw() +{ + if (other.markers.size() != markers.size()) + return false; + + for (int i = markers.size(); --i >= 0;) + { + const Marker* const m1 = markers.getUnchecked(i); + jassert (m1 != 0); + + const Marker* const m2 = other.getMarker (m1->name); + + if (m2 == 0 || *m1 != *m2) + return false; + } + + return true; +} + +bool MarkerList::operator!= (const MarkerList& other) const throw() +{ + return ! operator== (other); +} + +int MarkerList::getNumMarkers() const throw() +{ + return markers.size(); +} + +const MarkerList::Marker* MarkerList::getMarker (const int index) const throw() +{ + return markers [index]; +} + +const MarkerList::Marker* MarkerList::getMarker (const String& name) const throw() +{ + for (int i = 0; i < markers.size(); ++i) + { + const Marker* const m = markers.getUnchecked(i); + + if (m->name == name) + return m; + } + + return 0; +} + +void MarkerList::setMarker (const String& name, const RelativeCoordinate& position) +{ + Marker* const m = const_cast (getMarker (name)); + + if (m != 0) + { + if (m->position != position) + { + m->position = position; + markersHaveChanged(); + } + + return; + } + + markers.add (new Marker (name, position)); + markersHaveChanged(); +} + +void MarkerList::removeMarker (const int index) +{ + if (isPositiveAndBelow (index, markers.size())) + { + markers.remove (index); + markersHaveChanged(); } } -class RelativeComponentPositioner : public Component::Positioner, - public ComponentListener, - public MarkerList::Listener, - public Expression::EvaluationContext +void MarkerList::removeMarker (const String& name) { -public: - RelativeComponentPositioner (Component& component_) - : Component::Positioner (component_), registeredOk (false) + for (int i = 0; i < markers.size(); ++i) { - } + const Marker* const m = markers.getUnchecked(i); - ~RelativeComponentPositioner() - { - unregisterListeners(); - } - - const Expression getSymbolValue (const String& objectName, const String& member) const - { - jassert (objectName.isNotEmpty()); - - if (member.isNotEmpty()) + if (m->name == name) { - const Component* comp = getSourceComponent (objectName); - - if (comp == 0) - { - if (objectName == RelativeCoordinate::Strings::parent) - comp = getComponent().getParentComponent(); - else if (objectName == RelativeCoordinate::Strings::this_ || objectName == getComponent().getComponentID()) - comp = &getComponent(); - } - - if (comp != 0) - { - if (member == RelativeCoordinate::Strings::left) return xToExpression (comp, 0); - if (member == RelativeCoordinate::Strings::right) return xToExpression (comp, comp->getWidth()); - if (member == RelativeCoordinate::Strings::top) return yToExpression (comp, 0); - if (member == RelativeCoordinate::Strings::bottom) return yToExpression (comp, comp->getHeight()); - } - } - - for (int i = sourceMarkerLists.size(); --i >= 0;) - { - MarkerList* const markerList = sourceMarkerLists.getUnchecked(i); - const MarkerList::Marker* const marker = markerList->getMarker (objectName); - - if (marker != 0) - return marker->position.getExpression(); - } - - return Expression::EvaluationContext::getSymbolValue (objectName, member); - } - - void componentMovedOrResized (Component&, bool /*wasMoved*/, bool /*wasResized*/) - { - apply(); - } - - void componentParentHierarchyChanged (Component&) - { - apply(); - } - - void componentBeingDeleted (Component& component) - { - jassert (sourceComponents.contains (&component)); - sourceComponents.removeValue (&component); - } - - void markersChanged (MarkerList*) - { - apply(); - } - - void markerListBeingDeleted (MarkerList* markerList) - { - jassert (sourceMarkerLists.contains (markerList)); - sourceMarkerLists.removeValue (markerList); - } - - void apply() - { - if (! registeredOk) - { - unregisterListeners(); - registeredOk = registerCoordinates(); - } - - applyToComponentBounds(); - } - -protected: - bool addCoordinate (const RelativeCoordinate& coord) - { - return registerListeners (coord.getExpression()); - } - - virtual bool registerCoordinates() = 0; - virtual void applyToComponentBounds() = 0; - -private: - Array sourceComponents; - Array sourceMarkerLists; - bool registeredOk; - - bool registerListeners (const Expression& e) - { - bool ok = true; - - if (e.getType() == Expression::symbolType) - { - String objectName, memberName; - e.getSymbolParts (objectName, memberName); - - if (memberName.isNotEmpty()) - ok = registerComponent (objectName) && ok; - else - ok = registerMarker (objectName) && ok; - } - else - { - for (int i = e.getNumInputs(); --i >= 0;) - ok = registerListeners (e.getInput (i)) && ok; - } - - return ok; - } - - bool registerComponent (const String& componentID) - { - Component* comp = findComponent (componentID); - - if (comp == 0) - { - if (componentID == RelativeCoordinate::Strings::parent) - comp = getComponent().getParentComponent(); - else if (componentID == RelativeCoordinate::Strings::this_ || componentID == getComponent().getComponentID()) - comp = &getComponent(); - } - - if (comp != 0) - { - if (comp != &getComponent()) - registerComponentListener (comp); - - return true; - } - else - { - // The component we want doesn't exist, so watch the parent in case the hierarchy changes and it appears later.. - Component* const parent = getComponent().getParentComponent(); - - if (parent != 0) - registerComponentListener (parent); - else - registerComponentListener (&getComponent()); - - return false; + markers.remove (i); + markersHaveChanged(); } } +} - bool registerMarker (const String markerName) +void MarkerList::markersHaveChanged() +{ + listeners.call (&MarkerList::Listener::markersChanged, this); +} + +void MarkerList::Listener::markerListBeingDeleted (MarkerList*) +{ +} + +void MarkerList::addListener (Listener* listener) +{ + listeners.add (listener); +} + +void MarkerList::removeListener (Listener* listener) +{ + listeners.remove (listener); +} + +MarkerList::Marker::Marker (const Marker& other) + : name (other.name), position (other.position) +{ +} + +MarkerList::Marker::Marker (const String& name_, const RelativeCoordinate& position_) + : name (name_), position (position_) +{ +} + +bool MarkerList::Marker::operator== (const Marker& other) const throw() +{ + return name == other.name && position == other.position; +} + +bool MarkerList::Marker::operator!= (const Marker& other) const throw() +{ + return ! operator== (other); +} + +const Identifier MarkerList::ValueTreeWrapper::markerTag ("Marker"); +const Identifier MarkerList::ValueTreeWrapper::nameProperty ("name"); +const Identifier MarkerList::ValueTreeWrapper::posProperty ("position"); + +MarkerList::ValueTreeWrapper::ValueTreeWrapper (const ValueTree& state_) + : state (state_) +{ +} + +int MarkerList::ValueTreeWrapper::getNumMarkers() const +{ + return state.getNumChildren(); +} + +const ValueTree MarkerList::ValueTreeWrapper::getMarkerState (int index) const +{ + return state.getChild (index); +} + +const ValueTree MarkerList::ValueTreeWrapper::getMarkerState (const String& name) const +{ + return state.getChildWithProperty (nameProperty, name); +} + +bool MarkerList::ValueTreeWrapper::containsMarker (const ValueTree& marker) const +{ + return marker.isAChildOf (state); +} + +const MarkerList::Marker MarkerList::ValueTreeWrapper::getMarker (const ValueTree& marker) const +{ + jassert (containsMarker (marker)); + + return MarkerList::Marker (marker [nameProperty], RelativeCoordinate (marker [posProperty].toString())); +} + +void MarkerList::ValueTreeWrapper::setMarker (const MarkerList::Marker& m, UndoManager* undoManager) +{ + ValueTree marker (state.getChildWithProperty (nameProperty, m.name)); + + if (marker.isValid()) { - Component* const parent = getComponent().getParentComponent(); + marker.setProperty (posProperty, m.position.toString(), undoManager); + } + else + { + marker = ValueTree (markerTag); + marker.setProperty (nameProperty, m.name, 0); + marker.setProperty (posProperty, m.position.toString(), 0); + state.addChild (marker, -1, undoManager); + } +} - if (parent != 0) - { - MarkerList* list = parent->getMarkers (true); +void MarkerList::ValueTreeWrapper::removeMarker (const ValueTree& marker, UndoManager* undoManager) +{ + state.removeChild (marker, undoManager); +} - if (list == 0 || list->getMarker (markerName) == 0) - list = parent->getMarkers (false); +void MarkerList::ValueTreeWrapper::applyTo (MarkerList& markerList) +{ + const int numMarkers = getNumMarkers(); - if (list != 0 && list->getMarker (markerName) != 0) - { - registerMarkerListListener (list); - return true; - } - else - { - // The marker we want doesn't exist, so watch all lists in case they change and the marker appears later.. - registerMarkerListListener (parent->getMarkers (true)); - registerMarkerListListener (parent->getMarkers (false)); - } - } + StringArray updatedMarkers; - return false; + int i; + for (i = 0; i < numMarkers; ++i) + { + const ValueTree marker (state.getChild (i)); + const String name (marker [nameProperty].toString()); + markerList.setMarker (name, RelativeCoordinate (marker [posProperty].toString())); + updatedMarkers.add (name); } - void registerComponentListener (Component* const comp) - { - if (comp != 0 && ! sourceComponents.contains (comp)) - { - comp->addComponentListener (this); - sourceComponents.add (comp); - } - } + for (i = markerList.getNumMarkers(); --i >= 0;) + if (! updatedMarkers.contains (markerList.getMarker (i)->name)) + markerList.removeMarker (i); +} - void registerMarkerListListener (MarkerList* const list) - { - if (list != 0 && ! sourceMarkerLists.contains (list)) - { - list->addListener (this); - sourceMarkerLists.add (list); - } - } +void MarkerList::ValueTreeWrapper::readFrom (const MarkerList& markerList, UndoManager* undoManager) +{ + state.removeAllChildren (undoManager); - void unregisterListeners() - { - int i; - for (i = sourceComponents.size(); --i >= 0;) - sourceComponents.getUnchecked(i)->removeComponentListener (this); + for (int i = 0; i < markerList.getNumMarkers(); ++i) + setMarker (*markerList.getMarker(i), undoManager); +} - for (i = sourceMarkerLists.size(); --i >= 0;) - sourceMarkerLists.getUnchecked(i)->removeListener (this); +END_JUCE_NAMESPACE +/*** End of inlined file: juce_MarkerList.cpp ***/ - sourceComponents.clear(); - sourceMarkerLists.clear(); - } - Component* findComponent (const String& componentID) const - { - Component* const parent = getComponent().getParentComponent(); - - if (parent != 0) - { - for (int i = parent->getNumChildComponents(); --i >= 0;) - { - Component* const c = parent->getChildComponent(i); - - if (c->getComponentID() == componentID) - return c; - } - } - - return 0; - } - - Component* getSourceComponent (const String& objectName) const - { - for (int i = sourceComponents.size(); --i >= 0;) - { - Component* const comp = sourceComponents.getUnchecked(i); - - if (comp->getComponentID() == objectName) - return comp; - } - - return 0; - } - - const Expression xToExpression (const Component* const source, const int x) const - { - return Expression ((double) (getComponent().getLocalPoint (source, Point (x, 0)).getX() + getComponent().getX())); - } - - const Expression yToExpression (const Component* const source, const int y) const - { - return Expression ((double) (getComponent().getLocalPoint (source, Point (0, y)).getY() + getComponent().getY())); - } - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeComponentPositioner); -}; +/*** Start of inlined file: juce_RelativeCoordinate.cpp ***/ +BEGIN_JUCE_NAMESPACE const String RelativeCoordinate::Strings::parent ("parent"); const String RelativeCoordinate::Strings::this_ ("this"); @@ -80092,6 +79843,25 @@ void RelativeCoordinate::renameSymbolIfUsed (const String& oldName, const String term = term.withRenamedSymbol (oldName, newName); } +END_JUCE_NAMESPACE +/*** End of inlined file: juce_RelativeCoordinate.cpp ***/ + + +/*** Start of inlined file: juce_RelativePoint.cpp ***/ +BEGIN_JUCE_NAMESPACE + +namespace RelativePointHelpers +{ + void skipComma (const juce_wchar* const s, int& i) + { + while (CharacterFunctions::isWhitespace (s[i])) + ++i; + + if (s[i] == ',') + ++i; + } +} + RelativePoint::RelativePoint() { } @@ -80115,7 +79885,7 @@ RelativePoint::RelativePoint (const String& s) { int i = 0; x = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); + RelativePointHelpers::skipComma (s, i); y = RelativeCoordinate (Expression::parse (s, i)); } @@ -80157,6 +79927,25 @@ bool RelativePoint::isDynamic() const return x.isDynamic() || y.isDynamic(); } +END_JUCE_NAMESPACE +/*** End of inlined file: juce_RelativePoint.cpp ***/ + + +/*** Start of inlined file: juce_RelativeRectangle.cpp ***/ +BEGIN_JUCE_NAMESPACE + +namespace RelativeRectangleHelpers +{ + inline void skipComma (const juce_wchar* const s, int& i) + { + while (CharacterFunctions::isWhitespace (s[i])) + ++i; + + if (s[i] == ',') + ++i; + } +} + RelativeRectangle::RelativeRectangle() { } @@ -80179,11 +79968,11 @@ RelativeRectangle::RelativeRectangle (const String& s) { int i = 0; left = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); + RelativeRectangleHelpers::skipComma (s, i); top = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); + RelativeRectangleHelpers::skipComma (s, i); right = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); + RelativeRectangleHelpers::skipComma (s, i); bottom = RelativeCoordinate (Expression::parse (s, i)); } @@ -80233,11 +80022,11 @@ void RelativeRectangle::renameSymbolIfUsed (const String& oldName, const String& bottom.renameSymbolIfUsed (oldName, newName); } -class RelativeRectangleComponentPositioner : public RelativeComponentPositioner +class RelativeRectangleComponentPositioner : public RelativeCoordinatePositionerBase { public: RelativeRectangleComponentPositioner (Component& component_, const RelativeRectangle& rectangle_) - : RelativeComponentPositioner (component_), + : RelativeCoordinatePositionerBase (component_), rectangle (rectangle_) { } @@ -80298,6 +80087,13 @@ void RelativeRectangle::applyToComponent (Component& component) const } } +END_JUCE_NAMESPACE +/*** End of inlined file: juce_RelativeRectangle.cpp ***/ + + +/*** Start of inlined file: juce_RelativePointPath.cpp ***/ +BEGIN_JUCE_NAMESPACE + RelativePointPath::RelativePointPath() : usesNonZeroWinding (true), containsDynamicPoints (false) @@ -80308,16 +80104,8 @@ RelativePointPath::RelativePointPath (const RelativePointPath& other) : usesNonZeroWinding (true), containsDynamicPoints (false) { - ValueTree state (DrawablePath::valueTreeType); - other.writeTo (state, 0); - parse (state); -} - -RelativePointPath::RelativePointPath (const ValueTree& drawable) - : usesNonZeroWinding (true), - containsDynamicPoints (false) -{ - parse (drawable); + for (int i = 0; i < other.elements.size(); ++i) + elements.add (other.elements.getUnchecked(i)->clone()); } RelativePointPath::RelativePointPath (const Path& path) @@ -80340,65 +80128,51 @@ RelativePointPath::RelativePointPath (const Path& path) } } -void RelativePointPath::writeTo (ValueTree state, UndoManager* undoManager) const -{ - DrawablePath::ValueTreeWrapper wrapper (state); - wrapper.setUsesNonZeroWinding (usesNonZeroWinding, undoManager); - - ValueTree pathTree (wrapper.getPathState()); - pathTree.removeAllChildren (undoManager); - - for (int i = 0; i < elements.size(); ++i) - pathTree.addChild (elements.getUnchecked(i)->createTree(), -1, undoManager); -} - -void RelativePointPath::parse (const ValueTree& state) -{ - DrawablePath::ValueTreeWrapper wrapper (state); - usesNonZeroWinding = wrapper.usesNonZeroWinding(); - RelativePoint points[3]; - - const ValueTree pathTree (wrapper.getPathState()); - const int num = pathTree.getNumChildren(); - for (int i = 0; i < num; ++i) - { - const DrawablePath::ValueTreeWrapper::Element e (pathTree.getChild(i)); - - const int numCps = e.getNumControlPoints(); - for (int j = 0; j < numCps; ++j) - { - points[j] = e.getControlPoint (j); - containsDynamicPoints = containsDynamicPoints || points[j].isDynamic(); - } - - const Identifier type (e.getType()); - - if (type == DrawablePath::ValueTreeWrapper::Element::startSubPathElement) - elements.add (new StartSubPath (points[0])); - else if (type == DrawablePath::ValueTreeWrapper::Element::closeSubPathElement) - elements.add (new CloseSubPath()); - else if (type == DrawablePath::ValueTreeWrapper::Element::lineToElement) - elements.add (new LineTo (points[0])); - else if (type == DrawablePath::ValueTreeWrapper::Element::quadraticToElement) - elements.add (new QuadraticTo (points[0], points[1])); - else if (type == DrawablePath::ValueTreeWrapper::Element::cubicToElement) - elements.add (new CubicTo (points[0], points[1], points[2])); - else - jassertfalse; - } -} - RelativePointPath::~RelativePointPath() { } +bool RelativePointPath::operator== (const RelativePointPath& other) const throw() +{ + if (elements.size() != other.elements.size() + || usesNonZeroWinding != other.usesNonZeroWinding + || containsDynamicPoints != other.containsDynamicPoints) + return false; + + for (int i = 0; i < elements.size(); ++i) + { + ElementBase* const e1 = elements.getUnchecked(i); + ElementBase* const e2 = other.elements.getUnchecked(i); + + if (e1->type != e2->type) + return false; + + int numPoints1, numPoints2; + RelativePoint* const points1 = e1->getControlPoints (numPoints1); + RelativePoint* const points2 = e2->getControlPoints (numPoints2); + + jassert (numPoints1 == numPoints2); + + for (int j = numPoints1; --j >= 0;) + if (points1[j] != points2[j]) + return false; + } + + return true; +} + +bool RelativePointPath::operator!= (const RelativePointPath& other) const throw() +{ + return ! operator== (other); +} + void RelativePointPath::swapWith (RelativePointPath& other) throw() { elements.swapWithArray (other.elements); swapVariables (usesNonZeroWinding, other.usesNonZeroWinding); } -void RelativePointPath::createPath (Path& path, Expression::EvaluationContext* coordFinder) +void RelativePointPath::createPath (Path& path, Expression::EvaluationContext* coordFinder) const { for (int i = 0; i < elements.size(); ++i) elements.getUnchecked(i)->addToPath (path, coordFinder); @@ -80409,10 +80183,31 @@ bool RelativePointPath::containsAnyDynamicPoints() const return containsDynamicPoints; } +void RelativePointPath::addElement (ElementBase* newElement) +{ + if (newElement != 0) + { + elements.add (newElement); + containsDynamicPoints = containsDynamicPoints || newElement->isDynamic(); + } +} + RelativePointPath::ElementBase::ElementBase (const ElementType type_) : type (type_) { } +bool RelativePointPath::ElementBase::isDynamic() +{ + int numPoints; + const RelativePoint* const points = getControlPoints (numPoints); + + for (int i = numPoints; --i >= 0;) + if (points[i].isDynamic()) + return true; + + return false; +} + RelativePointPath::StartSubPath::StartSubPath (const RelativePoint& pos) : ElementBase (startSubPathElement), startPos (pos) { @@ -80436,6 +80231,11 @@ RelativePoint* RelativePointPath::StartSubPath::getControlPoints (int& numPoints return &startPos; } +RelativePointPath::ElementBase* RelativePointPath::StartSubPath::clone() const +{ + return new StartSubPath (startPos); +} + RelativePointPath::CloseSubPath::CloseSubPath() : ElementBase (closeSubPathElement) { @@ -80457,6 +80257,11 @@ RelativePoint* RelativePointPath::CloseSubPath::getControlPoints (int& numPoints return 0; } +RelativePointPath::ElementBase* RelativePointPath::CloseSubPath::clone() const +{ + return new CloseSubPath(); +} + RelativePointPath::LineTo::LineTo (const RelativePoint& endPoint_) : ElementBase (lineToElement), endPoint (endPoint_) { @@ -80480,6 +80285,11 @@ RelativePoint* RelativePointPath::LineTo::getControlPoints (int& numPoints) return &endPoint; } +RelativePointPath::ElementBase* RelativePointPath::LineTo::clone() const +{ + return new LineTo (endPoint); +} + RelativePointPath::QuadraticTo::QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint) : ElementBase (quadraticToElement) { @@ -80507,6 +80317,11 @@ RelativePoint* RelativePointPath::QuadraticTo::getControlPoints (int& numPoints) return controlPoints; } +RelativePointPath::ElementBase* RelativePointPath::QuadraticTo::clone() const +{ + return new QuadraticTo (controlPoints[0], controlPoints[1]); +} + RelativePointPath::CubicTo::CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint) : ElementBase (cubicToElement) { @@ -80537,6 +80352,18 @@ RelativePoint* RelativePointPath::CubicTo::getControlPoints (int& numPoints) return controlPoints; } +RelativePointPath::ElementBase* RelativePointPath::CubicTo::clone() const +{ + return new CubicTo (controlPoints[0], controlPoints[1], controlPoints[2]); +} + +END_JUCE_NAMESPACE +/*** End of inlined file: juce_RelativePointPath.cpp ***/ + + +/*** Start of inlined file: juce_RelativeParallelogram.cpp ***/ +BEGIN_JUCE_NAMESPACE + RelativeParallelogram::RelativeParallelogram() { } @@ -80638,7 +80465,259 @@ const Point RelativeParallelogram::getPointForInternalCoord (const Point< } END_JUCE_NAMESPACE -/*** End of inlined file: juce_RelativeCoordinate.cpp ***/ +/*** End of inlined file: juce_RelativeParallelogram.cpp ***/ + + +/*** Start of inlined file: juce_RelativeCoordinatePositioner.cpp ***/ +BEGIN_JUCE_NAMESPACE + +RelativeCoordinatePositionerBase::RelativeCoordinatePositionerBase (Component& component_) + : Component::Positioner (component_), registeredOk (false) +{ +} + +RelativeCoordinatePositionerBase::~RelativeCoordinatePositionerBase() +{ + unregisterListeners(); +} + +const Expression RelativeCoordinatePositionerBase::getSymbolValue (const String& objectName, const String& member) const +{ + jassert (objectName.isNotEmpty()); + + if (member.isNotEmpty()) + { + const Component* comp = getSourceComponent (objectName); + + if (comp == 0) + { + if (objectName == RelativeCoordinate::Strings::parent) + comp = getComponent().getParentComponent(); + else if (objectName == RelativeCoordinate::Strings::this_ || objectName == getComponent().getComponentID()) + comp = &getComponent(); + } + + if (comp != 0) + { + if (member == RelativeCoordinate::Strings::left) return xToExpression (comp, 0); + if (member == RelativeCoordinate::Strings::right) return xToExpression (comp, comp->getWidth()); + if (member == RelativeCoordinate::Strings::top) return yToExpression (comp, 0); + if (member == RelativeCoordinate::Strings::bottom) return yToExpression (comp, comp->getHeight()); + } + } + + for (int i = sourceMarkerLists.size(); --i >= 0;) + { + MarkerList* const markerList = sourceMarkerLists.getUnchecked(i); + const MarkerList::Marker* const marker = markerList->getMarker (objectName); + + if (marker != 0) + return marker->position.getExpression(); + } + + return Expression::EvaluationContext::getSymbolValue (objectName, member); +} + +void RelativeCoordinatePositionerBase::componentMovedOrResized (Component&, bool /*wasMoved*/, bool /*wasResized*/) +{ + apply(); +} + +void RelativeCoordinatePositionerBase::componentParentHierarchyChanged (Component&) +{ + apply(); +} + +void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& component) +{ + jassert (sourceComponents.contains (&component)); + sourceComponents.removeValue (&component); +} + +void RelativeCoordinatePositionerBase::markersChanged (MarkerList*) +{ + apply(); +} + +void RelativeCoordinatePositionerBase::markerListBeingDeleted (MarkerList* markerList) +{ + jassert (sourceMarkerLists.contains (markerList)); + sourceMarkerLists.removeValue (markerList); +} + +void RelativeCoordinatePositionerBase::apply() +{ + if (! registeredOk) + { + unregisterListeners(); + registeredOk = registerCoordinates(); + } + + applyToComponentBounds(); +} + +bool RelativeCoordinatePositionerBase::addCoordinate (const RelativeCoordinate& coord) +{ + return registerListeners (coord.getExpression()); +} + +bool RelativeCoordinatePositionerBase::registerListeners (const Expression& e) +{ + bool ok = true; + + if (e.getType() == Expression::symbolType) + { + String objectName, memberName; + e.getSymbolParts (objectName, memberName); + + if (memberName.isNotEmpty()) + ok = registerComponent (objectName) && ok; + else + ok = registerMarker (objectName) && ok; + } + else + { + for (int i = e.getNumInputs(); --i >= 0;) + ok = registerListeners (e.getInput (i)) && ok; + } + + return ok; +} + +bool RelativeCoordinatePositionerBase::registerComponent (const String& componentID) +{ + Component* comp = findComponent (componentID); + + if (comp == 0) + { + if (componentID == RelativeCoordinate::Strings::parent) + comp = getComponent().getParentComponent(); + else if (componentID == RelativeCoordinate::Strings::this_ || componentID == getComponent().getComponentID()) + comp = &getComponent(); + } + + if (comp != 0) + { + if (comp != &getComponent()) + registerComponentListener (comp); + + return true; + } + else + { + // The component we want doesn't exist, so watch the parent in case the hierarchy changes and it appears later.. + Component* const parent = getComponent().getParentComponent(); + + if (parent != 0) + registerComponentListener (parent); + else + registerComponentListener (&getComponent()); + + return false; + } +} + +bool RelativeCoordinatePositionerBase::registerMarker (const String markerName) +{ + Component* const parent = getComponent().getParentComponent(); + + if (parent != 0) + { + MarkerList* list = parent->getMarkers (true); + + if (list == 0 || list->getMarker (markerName) == 0) + list = parent->getMarkers (false); + + if (list != 0 && list->getMarker (markerName) != 0) + { + registerMarkerListListener (list); + return true; + } + else + { + // The marker we want doesn't exist, so watch all lists in case they change and the marker appears later.. + registerMarkerListListener (parent->getMarkers (true)); + registerMarkerListListener (parent->getMarkers (false)); + } + } + + return false; +} + +void RelativeCoordinatePositionerBase::registerComponentListener (Component* const comp) +{ + if (comp != 0 && ! sourceComponents.contains (comp)) + { + comp->addComponentListener (this); + sourceComponents.add (comp); + } +} + +void RelativeCoordinatePositionerBase::registerMarkerListListener (MarkerList* const list) +{ + if (list != 0 && ! sourceMarkerLists.contains (list)) + { + list->addListener (this); + sourceMarkerLists.add (list); + } +} + +void RelativeCoordinatePositionerBase::unregisterListeners() +{ + int i; + for (i = sourceComponents.size(); --i >= 0;) + sourceComponents.getUnchecked(i)->removeComponentListener (this); + + for (i = sourceMarkerLists.size(); --i >= 0;) + sourceMarkerLists.getUnchecked(i)->removeListener (this); + + sourceComponents.clear(); + sourceMarkerLists.clear(); +} + +Component* RelativeCoordinatePositionerBase::findComponent (const String& componentID) const +{ + Component* const parent = getComponent().getParentComponent(); + + if (parent != 0) + { + for (int i = parent->getNumChildComponents(); --i >= 0;) + { + Component* const c = parent->getChildComponent(i); + + if (c->getComponentID() == componentID) + return c; + } + } + + return 0; +} + +Component* RelativeCoordinatePositionerBase::getSourceComponent (const String& objectName) const +{ + for (int i = sourceComponents.size(); --i >= 0;) + { + Component* const comp = sourceComponents.getUnchecked(i); + + if (comp->getComponentID() == objectName) + return comp; + } + + return 0; +} + +const Expression RelativeCoordinatePositionerBase::xToExpression (const Component* const source, const int x) const +{ + return Expression ((double) (getComponent().getLocalPoint (source, Point (x, 0)).getX() + getComponent().getX())); +} + +const Expression RelativeCoordinatePositionerBase::yToExpression (const Component* const source, const int y) const +{ + return Expression ((double) (getComponent().getLocalPoint (source, Point (0, y)).getY() + getComponent().getY())); +} + +END_JUCE_NAMESPACE +/*** End of inlined file: juce_RelativeCoordinatePositioner.cpp ***/ #endif @@ -87439,8 +87518,10 @@ DrawablePath::DrawablePath() DrawablePath::DrawablePath (const DrawablePath& other) : DrawableShape (other) { - if (other.relativePath != 0) - relativePath = new RelativePointPath (*other.relativePath); + const RelativePointPath* const relativePath = other.getRelativePath(); + + if (relativePath != 0) + setPath (*relativePath); else setPath (other.path); } @@ -87472,14 +87553,88 @@ const Path& DrawablePath::getStrokePath() const bool DrawablePath::rebuildPath (Path& path) const { - if (relativePath != 0) + return false; +} + +void DrawablePath::applyRelativePath (const RelativePointPath& relativePath) +{ + Path newPath; + relativePath.createPath (newPath, 0); + + if (path != newPath) + { + path.swapWithPath (newPath); + pathChanged(); + } +} + +class DrawablePath::RelativePositioner : public RelativeCoordinatePositionerBase +{ +public: + RelativePositioner (DrawablePath& component_, const RelativePointPath& path_) + : RelativeCoordinatePositionerBase (component_), + path (path_), + owner (component_) { - path.clear(); - relativePath->createPath (path, getParent()); - return true; } - return false; + bool registerCoordinates() + { + bool ok = true; + + for (int i = 0; i < path.elements.size(); ++i) + { + RelativePointPath::ElementBase* const e = path.elements.getUnchecked(i); + + int numPoints; + RelativePoint* const points = e->getControlPoints (numPoints); + + for (int j = numPoints; --j >= 0;) + { + ok = addCoordinate (points[j].x) && ok; + ok = addCoordinate (points[j].y) && ok; + } + } + + return ok; + } + + void applyToComponentBounds() + { + owner.applyRelativePath (path); + } + + const RelativePointPath path; + +private: + DrawablePath& owner; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativePositioner); +}; + +const RelativePointPath* DrawablePath::getRelativePath() const +{ + RelativePositioner* current = dynamic_cast (getPositioner()); + return current != 0 ? &(current->path) : 0; +} + +void DrawablePath::setPath (const RelativePointPath& source) +{ + if (source.containsAnyDynamicPoints()) + { + const RelativePointPath* current = getRelativePath(); + + if (current == 0 || source != *current) + { + RelativePositioner* const p = new RelativePositioner (*this, source); + setPositioner (p); + p->apply(); + } + } + else + { + applyRelativePath (source); + } } const Identifier DrawablePath::valueTreeType ("Path"); @@ -87510,6 +87665,47 @@ void DrawablePath::ValueTreeWrapper::setUsesNonZeroWinding (bool b, UndoManager* state.setProperty (nonZeroWinding, b, undoManager); } +void DrawablePath::ValueTreeWrapper::readFrom (const RelativePointPath& relativePath, UndoManager* undoManager) +{ + setUsesNonZeroWinding (relativePath.usesNonZeroWinding, undoManager); + + ValueTree pathTree (getPathState()); + pathTree.removeAllChildren (undoManager); + + for (int i = 0; i < relativePath.elements.size(); ++i) + pathTree.addChild (relativePath.elements.getUnchecked(i)->createTree(), -1, undoManager); +} + +void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) const +{ + relativePath.usesNonZeroWinding = usesNonZeroWinding(); + RelativePoint points[3]; + + const ValueTree pathTree (state.getChildWithName (path)); + const int num = pathTree.getNumChildren(); + for (int i = 0; i < num; ++i) + { + const Element e (pathTree.getChild(i)); + + const int numCps = e.getNumControlPoints(); + for (int j = 0; j < numCps; ++j) + points[j] = e.getControlPoint (j); + + const Identifier type (e.getType()); + + RelativePointPath::ElementBase* newElement = 0; + + if (type == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); + else if (type == Element::closeSubPathElement) newElement = new RelativePointPath::CloseSubPath(); + else if (type == Element::lineToElement) newElement = new RelativePointPath::LineTo (points[0]); + else if (type == Element::quadraticToElement) newElement = new RelativePointPath::QuadraticTo (points[0], points[1]); + else if (type == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); + else jassertfalse; + + relativePath.addElement (newElement); + } +} + const Identifier DrawablePath::ValueTreeWrapper::Element::mode ("mode"); const Identifier DrawablePath::ValueTreeWrapper::Element::startSubPathElement ("Move"); const Identifier DrawablePath::ValueTreeWrapper::Element::closeSubPathElement ("Close"); @@ -87843,23 +88039,16 @@ void DrawablePath::refreshFromValueTree (const ValueTree& tree, ComponentBuilder if (refreshFillTypes (v, getParent(), builder.getImageProvider())) repaint(); - ScopedPointer newRelativePath (new RelativePointPath (tree)); - - Path newPath; - newRelativePath->createPath (newPath, getParent()); - - if (! newRelativePath->containsAnyDynamicPoints()) - newRelativePath = 0; - const PathStrokeType newStroke (v.getStrokeType()); - if (strokeType != newStroke || path != newPath) + if (strokeType != newStroke) { - path.swapWithPath (newPath); strokeType = newStroke; - pathChanged(); + strokeChanged(); } - relativePath = newRelativePath; + RelativePointPath newRelativePath; + v.writeTo (newRelativePath); + setPath (newRelativePath); } const ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const @@ -87870,14 +88059,16 @@ const ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* v.setID (getComponentID()); writeTo (v, imageProvider, 0); + const RelativePointPath* const relativePath = getRelativePath(); + if (relativePath != 0) { - relativePath->writeTo (tree, 0); + v.readFrom (*relativePath, 0); } else { RelativePointPath rp (path); - rp.writeTo (tree, 0); + v.readFrom (rp, 0); } return tree; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 67e41e7d43..556415f142 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 4 +#define JUCE_BUILDNUMBER 6 /** Current Juce version number. @@ -10428,6 +10428,7 @@ private: friend class XmlDocument; friend class LinkedListPointer; friend class LinkedListPointer ; + friend class LinkedListPointer ::Appender; LinkedListPointer nextListItem; LinkedListPointer firstChildElement; @@ -39567,6 +39568,7 @@ private: ItemInfo* getItemForId (int itemId) const throw(); ItemInfo* getItemForIndex (int index) const throw(); + bool selectIfEnabled (int index); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBox); }; @@ -45348,8 +45350,6 @@ private: #ifndef __JUCE_RELATIVECOORDINATE_JUCEHEADER__ #define __JUCE_RELATIVECOORDINATE_JUCEHEADER__ -class Component; - /** Expresses a coordinate as a dynamically evaluated expression. @@ -45447,313 +45447,6 @@ private: Expression term; }; -/** - An X-Y position stored as a pair of RelativeCoordinate values. - - @see RelativeCoordinate, RelativeRectangle -*/ -class JUCE_API RelativePoint -{ -public: - /** Creates a point at the origin. */ - RelativePoint(); - - /** Creates an absolute point, relative to the origin. */ - RelativePoint (const Point& absolutePoint); - - /** Creates an absolute point, relative to the origin. */ - RelativePoint (float absoluteX, float absoluteY); - - /** Creates an absolute point from two coordinates. */ - RelativePoint (const RelativeCoordinate& x, const RelativeCoordinate& y); - - /** Creates a point from a stringified representation. - The string must contain a pair of coordinates, separated by space or a comma. The syntax for the coordinate - strings is explained in the RelativeCoordinate class. - @see toString - */ - RelativePoint (const String& stringVersion); - - bool operator== (const RelativePoint& other) const throw(); - bool operator!= (const RelativePoint& other) const throw(); - - /** Calculates the absolute position of this point. - - You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may - be needed to calculate the result. - */ - const Point resolve (const Expression::EvaluationContext* evaluationContext) const; - - /** Changes the values of this point's coordinates to make it resolve to the specified position. - - Calling this will leave any anchor points unchanged, but will set any absolute - or relative positions to whatever values are necessary to make the resultant position - match the position that is provided. - */ - void moveToAbsolute (const Point& newPos, const Expression::EvaluationContext* evaluationContext); - - /** Returns a string which represents this point. - This returns a comma-separated pair of coordinates. For details of the string syntax used by the - coordinates, see the RelativeCoordinate constructor notes. - The string that is returned can be passed to the RelativePoint constructor to recreate the point. - */ - const String toString() const; - - /** Renames a symbol if it is used by any of the coordinates. - This calls RelativeCoordinate::renameAnchorIfUsed() on its X and Y coordinates. - */ - void renameSymbolIfUsed (const String& oldName, const String& newName); - - /** Returns true if this point depends on any other coordinates for its position. */ - bool isDynamic() const; - - // The actual X and Y coords... - RelativeCoordinate x, y; -}; - -/** - An rectangle stored as a set of RelativeCoordinate values. - - The rectangle's top, left, bottom and right edge positions are each stored as a RelativeCoordinate. - - @see RelativeCoordinate, RelativePoint -*/ -class JUCE_API RelativeRectangle -{ -public: - - /** Creates a zero-size rectangle at the origin. */ - RelativeRectangle(); - - /** Creates an absolute rectangle, relative to the origin. */ - explicit RelativeRectangle (const Rectangle& rect, const String& componentName); - - /** Creates a rectangle from four coordinates. */ - RelativeRectangle (const RelativeCoordinate& left, const RelativeCoordinate& right, - const RelativeCoordinate& top, const RelativeCoordinate& bottom); - - /** Creates a rectangle from a stringified representation. - The string must contain a sequence of 4 coordinates, separated by commas, in the order - left, top, right, bottom. The syntax for the coordinate strings is explained in the - RelativeCoordinate class. - @see toString - */ - explicit RelativeRectangle (const String& stringVersion); - - bool operator== (const RelativeRectangle& other) const throw(); - bool operator!= (const RelativeRectangle& other) const throw(); - - /** Calculates the absolute position of this rectangle. - - You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may - be needed to calculate the result. - */ - const Rectangle resolve (const Expression::EvaluationContext* evaluationContext) const; - - /** Changes the values of this rectangle's coordinates to make it resolve to the specified position. - - Calling this will leave any anchor points unchanged, but will set any absolute - or relative positions to whatever values are necessary to make the resultant position - match the position that is provided. - */ - void moveToAbsolute (const Rectangle& newPos, const Expression::EvaluationContext* evaluationContext); - - /** Returns true if this rectangle depends on any other coordinates for its position. */ - bool isDynamic() const; - - /** Returns a string which represents this point. - This returns a comma-separated list of coordinates, in the order left, top, right, bottom. For details of - the string syntax used by the coordinates, see the RelativeCoordinate constructor notes. - The string that is returned can be passed to the RelativeRectangle constructor to recreate the rectangle. - */ - const String toString() const; - - /** Renames a symbol if it is used by any of the coordinates. - This calls RelativeCoordinate::renameSymbolIfUsed() on the rectangle's coordinates. - */ - void renameSymbolIfUsed (const String& oldName, const String& newName); - - /** */ - void applyToComponent (Component& component) const; - - // The actual rectangle coords... - RelativeCoordinate left, right, top, bottom; -}; - -/** - A path object that consists of RelativePoint coordinates rather than the normal fixed ones. - - One of these paths can be converted into a Path object for drawing and manipulation, but - unlike a Path, its points can be dynamic instead of just fixed. - - @see RelativePoint, RelativeCoordinate -*/ -class JUCE_API RelativePointPath -{ -public: - - RelativePointPath(); - RelativePointPath (const RelativePointPath& other); - RelativePointPath (const ValueTree& drawable); - RelativePointPath (const Path& path); - ~RelativePointPath(); - - /** Resolves this points in this path and adds them to a normal Path object. */ - void createPath (Path& path, Expression::EvaluationContext* coordFinder); - - /** Returns true if the path contains any non-fixed points. */ - bool containsAnyDynamicPoints() const; - - /** Writes the path to this drawable encoding. */ - void writeTo (ValueTree state, UndoManager* undoManager) const; - - /** Quickly swaps the contents of this path with another. */ - void swapWith (RelativePointPath& other) throw(); - - /** The types of element that may be contained in this path. - @see RelativePointPath::ElementBase - */ - enum ElementType - { - nullElement, - startSubPathElement, - closeSubPathElement, - lineToElement, - quadraticToElement, - cubicToElement - }; - - /** Base class for the elements that make up a RelativePointPath. - */ - class JUCE_API ElementBase - { - public: - ElementBase (ElementType type); - virtual ~ElementBase() {} - virtual const ValueTree createTree() const = 0; - virtual void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const = 0; - virtual RelativePoint* getControlPoints (int& numPoints) = 0; - - const ElementType type; - - private: - JUCE_DECLARE_NON_COPYABLE (ElementBase); - }; - - class JUCE_API StartSubPath : public ElementBase - { - public: - StartSubPath (const RelativePoint& pos); - ~StartSubPath() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint startPos; - - private: - JUCE_DECLARE_NON_COPYABLE (StartSubPath); - }; - - class JUCE_API CloseSubPath : public ElementBase - { - public: - CloseSubPath(); - ~CloseSubPath() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - private: - JUCE_DECLARE_NON_COPYABLE (CloseSubPath); - }; - - class JUCE_API LineTo : public ElementBase - { - public: - LineTo (const RelativePoint& endPoint); - ~LineTo() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint endPoint; - - private: - JUCE_DECLARE_NON_COPYABLE (LineTo); - }; - - class JUCE_API QuadraticTo : public ElementBase - { - public: - QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint); - ~QuadraticTo() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint controlPoints[2]; - - private: - JUCE_DECLARE_NON_COPYABLE (QuadraticTo); - }; - - class JUCE_API CubicTo : public ElementBase - { - public: - CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint); - ~CubicTo() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint controlPoints[3]; - - private: - JUCE_DECLARE_NON_COPYABLE (CubicTo); - }; - - OwnedArray elements; - bool usesNonZeroWinding; - -private: - bool containsDynamicPoints; - - void parse (const ValueTree& state); - - RelativePointPath& operator= (const RelativePointPath&); -}; - -/** - A parallelogram defined by three RelativePoint positions. - - @see RelativePoint, RelativeCoordinate -*/ -class JUCE_API RelativeParallelogram -{ -public: - - RelativeParallelogram(); - RelativeParallelogram (const Rectangle& simpleRectangle); - RelativeParallelogram (const RelativePoint& topLeft, const RelativePoint& topRight, const RelativePoint& bottomLeft); - RelativeParallelogram (const String& topLeft, const String& topRight, const String& bottomLeft); - ~RelativeParallelogram(); - - void resolveThreePoints (Point* points, Expression::EvaluationContext* coordFinder) const; - void resolveFourCorners (Point* points, Expression::EvaluationContext* coordFinder) const; - const Rectangle getBounds (Expression::EvaluationContext* coordFinder) const; - void getPath (Path& path, Expression::EvaluationContext* coordFinder) const; - const AffineTransform resetToPerpendicular (Expression::EvaluationContext* coordFinder); - - bool operator== (const RelativeParallelogram& other) const throw(); - bool operator!= (const RelativeParallelogram& other) const throw(); - - static const Point getInternalCoordForPoint (const Point* parallelogramCorners, Point point) throw(); - static const Point getPointForInternalCoord (const Point* parallelogramCorners, const Point& internalPoint) throw(); - - RelativePoint topLeft, topRight, bottomLeft; -}; - #endif // __JUCE_RELATIVECOORDINATE_JUCEHEADER__ /*** End of inlined file: juce_RelativeCoordinate.h ***/ @@ -54025,148 +53718,6 @@ private: /*** End of inlined file: juce_GroupComponent.h ***/ -#endif -#ifndef __JUCE_MARKERLIST_JUCEHEADER__ - -/*** Start of inlined file: juce_MarkerList.h ***/ -#ifndef __JUCE_MARKERLIST_JUCEHEADER__ -#define __JUCE_MARKERLIST_JUCEHEADER__ - -/** - Holds a set of named marker points along a one-dimensional axis. - - This class is used to store sets of X and Y marker points in components. - @see Component::getMarkers(). -*/ -class JUCE_API MarkerList -{ -public: - - /** Creates an empty marker list. */ - MarkerList(); - /** Creates a copy of another marker list. */ - MarkerList (const MarkerList& other); - /** Copies another marker list to this one. */ - MarkerList& operator= (const MarkerList& other); - /** Destructor. */ - ~MarkerList(); - - /** Represents a marker in a MarkerList. */ - class JUCE_API Marker - { - public: - /** Creates a copy of another Marker. */ - Marker (const Marker& other); - /** Creates a Marker with a given name and position. */ - Marker (const String& name, const RelativeCoordinate& position); - - /** The marker's name. */ - String name; - - /** The marker's position. */ - RelativeCoordinate position; - - /** Returns true if both the names and positions of these two markers match. */ - bool operator== (const Marker&) const throw(); - /** Returns true if either the name or position of these two markers differ. */ - bool operator!= (const Marker&) const throw(); - }; - - /** Returns the number of markers in the list. */ - int getNumMarkers() const throw(); - - /** Returns one of the markers in the list, by its index. */ - const Marker* getMarker (int index) const throw(); - - /** Returns a named marker, or 0 if no such name is found. - Note that name comparisons are case-sensitive. - */ - const Marker* getMarker (const String& name) const throw(); - - /** Sets the position of a marker. - - If the name already exists, then the existing marker is moved; if it doesn't exist, then a - new marker is added. - */ - void setMarker (const String& name, const RelativeCoordinate& position); - - /** Deletes the marker at the given list index. */ - void removeMarker (int index); - - /** Deletes the marker with the given name. */ - void removeMarker (const String& name); - - /** Returns true if all the markers in these two lists match exactly. */ - bool operator== (const MarkerList& other) const throw(); - /** Returns true if not all the markers in these two lists match exactly. */ - bool operator!= (const MarkerList& other) const throw(); - - /** - A class for receiving events when changes are made to a MarkerList. - - You can register a MarkerList::Listener with a MarkerList using the MarkerList::addListener() - method, and it will be called when markers are moved, added, or deleted. - - @see MarkerList::addListener, MarkerList::removeListener - */ - class JUCE_API Listener - { - public: - /** Destructor. */ - virtual ~Listener() {} - - /** Called when something in the given marker list changes. */ - virtual void markersChanged (MarkerList* markerList) = 0; - - /** Called when the given marker list is being deleted. */ - virtual void markerListBeingDeleted (MarkerList* markerList); - }; - - /** Registers a listener that will be called when the markers are changed. */ - void addListener (Listener* listener); - - /** Deregisters a previously-registered listener. */ - void removeListener (Listener* listener); - - /** Synchronously calls markersChanged() on all the registered listeners. */ - void markersHaveChanged(); - - /** Forms a wrapper around a ValueTree that can be used for storing a MarkerList. */ - class ValueTreeWrapper - { - public: - ValueTreeWrapper (const ValueTree& state); - - ValueTree& getState() throw() { return state; } - int getNumMarkers() const; - const ValueTree getMarkerState (int index) const; - const ValueTree getMarkerState (const String& name) const; - bool containsMarker (const ValueTree& state) const; - const MarkerList::Marker getMarker (const ValueTree& state) const; - void setMarker (const MarkerList::Marker& marker, UndoManager* undoManager); - void removeMarker (const ValueTree& state, UndoManager* undoManager); - - void applyTo (MarkerList& markerList); - void readFrom (const MarkerList& markerList, UndoManager* undoManager); - - static const Identifier markerTag, nameProperty, posProperty; - - private: - ValueTree state; - }; - -private: - - OwnedArray markers; - ListenerList listeners; - - JUCE_LEAK_DETECTOR (MarkerList); -}; - -#endif // __JUCE_MARKERLIST_JUCEHEADER__ -/*** End of inlined file: juce_MarkerList.h ***/ - - #endif #ifndef __JUCE_MULTIDOCUMENTPANEL_JUCEHEADER__ @@ -57865,6 +57416,572 @@ private: #endif #ifndef __JUCE_TOOLTIPCLIENT_JUCEHEADER__ +#endif +#ifndef __JUCE_MARKERLIST_JUCEHEADER__ + +/*** Start of inlined file: juce_MarkerList.h ***/ +#ifndef __JUCE_MARKERLIST_JUCEHEADER__ +#define __JUCE_MARKERLIST_JUCEHEADER__ + +/** + Holds a set of named marker points along a one-dimensional axis. + + This class is used to store sets of X and Y marker points in components. + @see Component::getMarkers(). +*/ +class JUCE_API MarkerList +{ +public: + + /** Creates an empty marker list. */ + MarkerList(); + /** Creates a copy of another marker list. */ + MarkerList (const MarkerList& other); + /** Copies another marker list to this one. */ + MarkerList& operator= (const MarkerList& other); + /** Destructor. */ + ~MarkerList(); + + /** Represents a marker in a MarkerList. */ + class JUCE_API Marker + { + public: + /** Creates a copy of another Marker. */ + Marker (const Marker& other); + /** Creates a Marker with a given name and position. */ + Marker (const String& name, const RelativeCoordinate& position); + + /** The marker's name. */ + String name; + + /** The marker's position. */ + RelativeCoordinate position; + + /** Returns true if both the names and positions of these two markers match. */ + bool operator== (const Marker&) const throw(); + /** Returns true if either the name or position of these two markers differ. */ + bool operator!= (const Marker&) const throw(); + }; + + /** Returns the number of markers in the list. */ + int getNumMarkers() const throw(); + + /** Returns one of the markers in the list, by its index. */ + const Marker* getMarker (int index) const throw(); + + /** Returns a named marker, or 0 if no such name is found. + Note that name comparisons are case-sensitive. + */ + const Marker* getMarker (const String& name) const throw(); + + /** Sets the position of a marker. + + If the name already exists, then the existing marker is moved; if it doesn't exist, then a + new marker is added. + */ + void setMarker (const String& name, const RelativeCoordinate& position); + + /** Deletes the marker at the given list index. */ + void removeMarker (int index); + + /** Deletes the marker with the given name. */ + void removeMarker (const String& name); + + /** Returns true if all the markers in these two lists match exactly. */ + bool operator== (const MarkerList& other) const throw(); + /** Returns true if not all the markers in these two lists match exactly. */ + bool operator!= (const MarkerList& other) const throw(); + + /** + A class for receiving events when changes are made to a MarkerList. + + You can register a MarkerList::Listener with a MarkerList using the MarkerList::addListener() + method, and it will be called when markers are moved, added, or deleted. + + @see MarkerList::addListener, MarkerList::removeListener + */ + class JUCE_API Listener + { + public: + /** Destructor. */ + virtual ~Listener() {} + + /** Called when something in the given marker list changes. */ + virtual void markersChanged (MarkerList* markerList) = 0; + + /** Called when the given marker list is being deleted. */ + virtual void markerListBeingDeleted (MarkerList* markerList); + }; + + /** Registers a listener that will be called when the markers are changed. */ + void addListener (Listener* listener); + + /** Deregisters a previously-registered listener. */ + void removeListener (Listener* listener); + + /** Synchronously calls markersChanged() on all the registered listeners. */ + void markersHaveChanged(); + + /** Forms a wrapper around a ValueTree that can be used for storing a MarkerList. */ + class ValueTreeWrapper + { + public: + ValueTreeWrapper (const ValueTree& state); + + ValueTree& getState() throw() { return state; } + int getNumMarkers() const; + const ValueTree getMarkerState (int index) const; + const ValueTree getMarkerState (const String& name) const; + bool containsMarker (const ValueTree& state) const; + const MarkerList::Marker getMarker (const ValueTree& state) const; + void setMarker (const MarkerList::Marker& marker, UndoManager* undoManager); + void removeMarker (const ValueTree& state, UndoManager* undoManager); + + void applyTo (MarkerList& markerList); + void readFrom (const MarkerList& markerList, UndoManager* undoManager); + + static const Identifier markerTag, nameProperty, posProperty; + + private: + ValueTree state; + }; + +private: + + OwnedArray markers; + ListenerList listeners; + + JUCE_LEAK_DETECTOR (MarkerList); +}; + +#endif // __JUCE_MARKERLIST_JUCEHEADER__ +/*** End of inlined file: juce_MarkerList.h ***/ + + +#endif +#ifndef __JUCE_RELATIVECOORDINATE_JUCEHEADER__ + +#endif +#ifndef __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ + +/*** Start of inlined file: juce_RelativeCoordinatePositioner.h ***/ +#ifndef __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ +#define __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ + +/** + Base class for Component::Positioners that are based upon relative coordinates. +*/ +class RelativeCoordinatePositionerBase : public Component::Positioner, + public ComponentListener, + public MarkerList::Listener, + public Expression::EvaluationContext +{ +public: + RelativeCoordinatePositionerBase (Component& component_); + ~RelativeCoordinatePositionerBase(); + + const Expression getSymbolValue (const String& objectName, const String& member) const; + + void componentMovedOrResized (Component&, bool, bool); + void componentParentHierarchyChanged (Component&); + void componentBeingDeleted (Component& component); + void markersChanged (MarkerList*); + void markerListBeingDeleted (MarkerList* markerList); + + void apply(); + +protected: + bool addCoordinate (const RelativeCoordinate& coord); + + virtual bool registerCoordinates() = 0; + virtual void applyToComponentBounds() = 0; + +private: + Array sourceComponents; + Array sourceMarkerLists; + bool registeredOk; + + bool registerListeners (const Expression& e); + bool registerComponent (const String& componentID); + bool registerMarker (const String markerName); + void registerComponentListener (Component* const comp); + void registerMarkerListListener (MarkerList* const list); + void unregisterListeners(); + Component* findComponent (const String& componentID) const; + Component* getSourceComponent (const String& objectName) const; + const Expression xToExpression (const Component* const source, const int x) const; + const Expression yToExpression (const Component* const source, const int y) const; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase); +}; + +#endif // __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ +/*** End of inlined file: juce_RelativeCoordinatePositioner.h ***/ + + +#endif +#ifndef __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ + +/*** Start of inlined file: juce_RelativeParallelogram.h ***/ +#ifndef __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ +#define __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ + + +/*** Start of inlined file: juce_RelativePoint.h ***/ +#ifndef __JUCE_RELATIVEPOINT_JUCEHEADER__ +#define __JUCE_RELATIVEPOINT_JUCEHEADER__ + +/** + An X-Y position stored as a pair of RelativeCoordinate values. + + @see RelativeCoordinate, RelativeRectangle +*/ +class JUCE_API RelativePoint +{ +public: + /** Creates a point at the origin. */ + RelativePoint(); + + /** Creates an absolute point, relative to the origin. */ + RelativePoint (const Point& absolutePoint); + + /** Creates an absolute point, relative to the origin. */ + RelativePoint (float absoluteX, float absoluteY); + + /** Creates an absolute point from two coordinates. */ + RelativePoint (const RelativeCoordinate& x, const RelativeCoordinate& y); + + /** Creates a point from a stringified representation. + The string must contain a pair of coordinates, separated by space or a comma. The syntax for the coordinate + strings is explained in the RelativeCoordinate class. + @see toString + */ + RelativePoint (const String& stringVersion); + + bool operator== (const RelativePoint& other) const throw(); + bool operator!= (const RelativePoint& other) const throw(); + + /** Calculates the absolute position of this point. + + You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may + be needed to calculate the result. + */ + const Point resolve (const Expression::EvaluationContext* evaluationContext) const; + + /** Changes the values of this point's coordinates to make it resolve to the specified position. + + Calling this will leave any anchor points unchanged, but will set any absolute + or relative positions to whatever values are necessary to make the resultant position + match the position that is provided. + */ + void moveToAbsolute (const Point& newPos, const Expression::EvaluationContext* evaluationContext); + + /** Returns a string which represents this point. + This returns a comma-separated pair of coordinates. For details of the string syntax used by the + coordinates, see the RelativeCoordinate constructor notes. + The string that is returned can be passed to the RelativePoint constructor to recreate the point. + */ + const String toString() const; + + /** Renames a symbol if it is used by any of the coordinates. + This calls RelativeCoordinate::renameAnchorIfUsed() on its X and Y coordinates. + */ + void renameSymbolIfUsed (const String& oldName, const String& newName); + + /** Returns true if this point depends on any other coordinates for its position. */ + bool isDynamic() const; + + // The actual X and Y coords... + RelativeCoordinate x, y; +}; + +#endif // __JUCE_RELATIVEPOINT_JUCEHEADER__ +/*** End of inlined file: juce_RelativePoint.h ***/ + +/** + A parallelogram defined by three RelativePoint positions. + + @see RelativePoint, RelativeCoordinate +*/ +class JUCE_API RelativeParallelogram +{ +public: + + RelativeParallelogram(); + RelativeParallelogram (const Rectangle& simpleRectangle); + RelativeParallelogram (const RelativePoint& topLeft, const RelativePoint& topRight, const RelativePoint& bottomLeft); + RelativeParallelogram (const String& topLeft, const String& topRight, const String& bottomLeft); + ~RelativeParallelogram(); + + void resolveThreePoints (Point* points, Expression::EvaluationContext* coordFinder) const; + void resolveFourCorners (Point* points, Expression::EvaluationContext* coordFinder) const; + const Rectangle getBounds (Expression::EvaluationContext* coordFinder) const; + void getPath (Path& path, Expression::EvaluationContext* coordFinder) const; + const AffineTransform resetToPerpendicular (Expression::EvaluationContext* coordFinder); + + bool operator== (const RelativeParallelogram& other) const throw(); + bool operator!= (const RelativeParallelogram& other) const throw(); + + static const Point getInternalCoordForPoint (const Point* parallelogramCorners, Point point) throw(); + static const Point getPointForInternalCoord (const Point* parallelogramCorners, const Point& internalPoint) throw(); + + RelativePoint topLeft, topRight, bottomLeft; +}; + +#endif // __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ +/*** End of inlined file: juce_RelativeParallelogram.h ***/ + + +#endif +#ifndef __JUCE_RELATIVEPOINT_JUCEHEADER__ + +#endif +#ifndef __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ + +/*** Start of inlined file: juce_RelativePointPath.h ***/ +#ifndef __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ +#define __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ + +class DrawablePath; + +/** + A path object that consists of RelativePoint coordinates rather than the normal fixed ones. + + One of these paths can be converted into a Path object for drawing and manipulation, but + unlike a Path, its points can be dynamic instead of just fixed. + + @see RelativePoint, RelativeCoordinate +*/ +class JUCE_API RelativePointPath +{ +public: + + RelativePointPath(); + RelativePointPath (const RelativePointPath& other); + RelativePointPath (const Path& path); + ~RelativePointPath(); + + bool operator== (const RelativePointPath& other) const throw(); + bool operator!= (const RelativePointPath& other) const throw(); + + /** Resolves this points in this path and adds them to a normal Path object. */ + void createPath (Path& path, Expression::EvaluationContext* coordFinder) const; + + /** Returns true if the path contains any non-fixed points. */ + bool containsAnyDynamicPoints() const; + + /** Quickly swaps the contents of this path with another. */ + void swapWith (RelativePointPath& other) throw(); + + /** The types of element that may be contained in this path. + @see RelativePointPath::ElementBase + */ + enum ElementType + { + nullElement, + startSubPathElement, + closeSubPathElement, + lineToElement, + quadraticToElement, + cubicToElement + }; + + /** Base class for the elements that make up a RelativePointPath. + */ + class JUCE_API ElementBase + { + public: + ElementBase (ElementType type); + virtual ~ElementBase() {} + virtual const ValueTree createTree() const = 0; + virtual void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const = 0; + virtual RelativePoint* getControlPoints (int& numPoints) = 0; + virtual ElementBase* clone() const = 0; + bool isDynamic(); + + const ElementType type; + + private: + JUCE_DECLARE_NON_COPYABLE (ElementBase); + }; + + class JUCE_API StartSubPath : public ElementBase + { + public: + StartSubPath (const RelativePoint& pos); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint startPos; + + private: + JUCE_DECLARE_NON_COPYABLE (StartSubPath); + }; + + class JUCE_API CloseSubPath : public ElementBase + { + public: + CloseSubPath(); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + private: + JUCE_DECLARE_NON_COPYABLE (CloseSubPath); + }; + + class JUCE_API LineTo : public ElementBase + { + public: + LineTo (const RelativePoint& endPoint); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint endPoint; + + private: + JUCE_DECLARE_NON_COPYABLE (LineTo); + }; + + class JUCE_API QuadraticTo : public ElementBase + { + public: + QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint controlPoints[2]; + + private: + JUCE_DECLARE_NON_COPYABLE (QuadraticTo); + }; + + class JUCE_API CubicTo : public ElementBase + { + public: + CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint controlPoints[3]; + + private: + JUCE_DECLARE_NON_COPYABLE (CubicTo); + }; + + void addElement (ElementBase* newElement); + + OwnedArray elements; + bool usesNonZeroWinding; + +private: + class Positioner; + friend class Positioner; + bool containsDynamicPoints; + + void applyTo (DrawablePath& path) const; + + RelativePointPath& operator= (const RelativePointPath&); + JUCE_LEAK_DETECTOR (RelativePointPath); +}; + +#endif // __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ +/*** End of inlined file: juce_RelativePointPath.h ***/ + + +#endif +#ifndef __JUCE_RELATIVERECTANGLE_JUCEHEADER__ + +/*** Start of inlined file: juce_RelativeRectangle.h ***/ +#ifndef __JUCE_RELATIVERECTANGLE_JUCEHEADER__ +#define __JUCE_RELATIVERECTANGLE_JUCEHEADER__ + +class Component; + +/** + An rectangle stored as a set of RelativeCoordinate values. + + The rectangle's top, left, bottom and right edge positions are each stored as a RelativeCoordinate. + + @see RelativeCoordinate, RelativePoint +*/ +class JUCE_API RelativeRectangle +{ +public: + + /** Creates a zero-size rectangle at the origin. */ + RelativeRectangle(); + + /** Creates an absolute rectangle, relative to the origin. */ + explicit RelativeRectangle (const Rectangle& rect, const String& componentName); + + /** Creates a rectangle from four coordinates. */ + RelativeRectangle (const RelativeCoordinate& left, const RelativeCoordinate& right, + const RelativeCoordinate& top, const RelativeCoordinate& bottom); + + /** Creates a rectangle from a stringified representation. + The string must contain a sequence of 4 coordinates, separated by commas, in the order + left, top, right, bottom. The syntax for the coordinate strings is explained in the + RelativeCoordinate class. + @see toString + */ + explicit RelativeRectangle (const String& stringVersion); + + bool operator== (const RelativeRectangle& other) const throw(); + bool operator!= (const RelativeRectangle& other) const throw(); + + /** Calculates the absolute position of this rectangle. + + You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may + be needed to calculate the result. + */ + const Rectangle resolve (const Expression::EvaluationContext* evaluationContext) const; + + /** Changes the values of this rectangle's coordinates to make it resolve to the specified position. + + Calling this will leave any anchor points unchanged, but will set any absolute + or relative positions to whatever values are necessary to make the resultant position + match the position that is provided. + */ + void moveToAbsolute (const Rectangle& newPos, const Expression::EvaluationContext* evaluationContext); + + /** Returns true if this rectangle depends on any other coordinates for its position. */ + bool isDynamic() const; + + /** Returns a string which represents this point. + This returns a comma-separated list of coordinates, in the order left, top, right, bottom. For details of + the string syntax used by the coordinates, see the RelativeCoordinate constructor notes. + The string that is returned can be passed to the RelativeRectangle constructor to recreate the rectangle. + */ + const String toString() const; + + /** Renames a symbol if it is used by any of the coordinates. + This calls RelativeCoordinate::renameSymbolIfUsed() on the rectangle's coordinates. + */ + void renameSymbolIfUsed (const String& oldName, const String& newName); + + /** Creates and sets an appropriate Component::Positioner object for the given component, which will + keep it positioned with this rectangle. + */ + void applyToComponent (Component& component) const; + + // The actual rectangle coords... + RelativeCoordinate left, right, top, bottom; +}; + +#endif // __JUCE_RELATIVERECTANGLE_JUCEHEADER__ +/*** End of inlined file: juce_RelativeRectangle.h ***/ + + #endif #ifndef __JUCE_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__ @@ -62027,6 +62144,9 @@ public: */ void setPath (const Path& newPath); + /** */ + void setPath (const RelativePointPath& source); + /** Returns the current path. */ const Path& getPath() const; @@ -62091,6 +62211,9 @@ public: ValueTree getPathState(); + void readFrom (const RelativePointPath& path, UndoManager* undoManager); + void writeTo (RelativePointPath& path) const; + static const Identifier nonZeroWinding, point1, point2, point3; }; @@ -62099,7 +62222,10 @@ protected: private: - ScopedPointer relativePath; + class RelativePositioner; + friend class RelativePositioner; + void applyRelativePath (const RelativePointPath& newPath); + const RelativePointPath* getRelativePath() const; DrawablePath& operator= (const DrawablePath&); JUCE_LEAK_DETECTOR (DrawablePath); @@ -62812,9 +62938,6 @@ private: #endif #ifndef __JUCE_RECTANGLELIST_JUCEHEADER__ -#endif -#ifndef __JUCE_RELATIVECOORDINATE_JUCEHEADER__ - #endif #ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ diff --git a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp index d72be65769..23fd0d6a99 100644 --- a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp +++ b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp @@ -731,6 +731,11 @@ bool AudioThumbnail::isFullyLoaded() const throw() return numSamplesFinished >= totalSamples - samplesPerThumbSample; } +int64 AudioThumbnail::getNumSamplesFinished() const throw() +{ + return numSamplesFinished; +} + float AudioThumbnail::getApproximatePeak() const { int peak = 0; diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 29ebfae444..450e334036 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 4 +#define JUCE_BUILDNUMBER 6 /** Current Juce version number. diff --git a/src/gui/components/controls/juce_ComboBox.cpp b/src/gui/components/controls/juce_ComboBox.cpp index 64a36154bb..2f1635a55a 100644 --- a/src/gui/components/controls/juce_ComboBox.cpp +++ b/src/gui/components/controls/juce_ComboBox.cpp @@ -289,6 +289,19 @@ void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMess } } +bool ComboBox::selectIfEnabled (const int index) +{ + const ItemInfo* const item = getItemForIndex (index); + + if (item != 0 && item->isEnabled) + { + setSelectedItemIndex (index); + return true; + } + + return false; +} + void ComboBox::valueChanged (Value&) { if (lastCurrentId != (int) currentId.getValue()) @@ -438,12 +451,20 @@ bool ComboBox::keyPressed (const KeyPress& key) { if (key.isKeyCode (KeyPress::upKey) || key.isKeyCode (KeyPress::leftKey)) { - setSelectedItemIndex (jmax (0, getSelectedItemIndex() - 1)); + int index = getSelectedItemIndex() - 1; + + while (index >= 0 && ! selectIfEnabled (index)) + --index; + return true; } else if (key.isKeyCode (KeyPress::downKey) || key.isKeyCode (KeyPress::rightKey)) { - setSelectedItemIndex (jmin (getSelectedItemIndex() + 1, getNumItems() - 1)); + int index = getSelectedItemIndex() + 1; + + while (index < getNumItems() && ! selectIfEnabled (index)) + ++index; + return true; } else if (key.isKeyCode (KeyPress::returnKey)) diff --git a/src/gui/components/controls/juce_ComboBox.h b/src/gui/components/controls/juce_ComboBox.h index 9cead1222c..df89593428 100644 --- a/src/gui/components/controls/juce_ComboBox.h +++ b/src/gui/components/controls/juce_ComboBox.h @@ -397,6 +397,7 @@ private: ItemInfo* getItemForId (int itemId) const throw(); ItemInfo* getItemForIndex (int index) const throw(); + bool selectIfEnabled (int index); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBox); }; diff --git a/src/gui/components/layout/juce_MarkerList.cpp b/src/gui/components/positioning/juce_MarkerList.cpp similarity index 100% rename from src/gui/components/layout/juce_MarkerList.cpp rename to src/gui/components/positioning/juce_MarkerList.cpp diff --git a/src/gui/components/layout/juce_MarkerList.h b/src/gui/components/positioning/juce_MarkerList.h similarity index 96% rename from src/gui/components/layout/juce_MarkerList.h rename to src/gui/components/positioning/juce_MarkerList.h index 016b4c49e6..079b167ee9 100644 --- a/src/gui/components/layout/juce_MarkerList.h +++ b/src/gui/components/positioning/juce_MarkerList.h @@ -27,7 +27,7 @@ #define __JUCE_MARKERLIST_JUCEHEADER__ #include "../../../containers/juce_ValueTree.h" -#include "../../graphics/geometry/juce_RelativeCoordinate.h" +#include "../positioning/juce_RelativeCoordinate.h" //============================================================================== diff --git a/src/gui/components/positioning/juce_RelativeCoordinate.cpp b/src/gui/components/positioning/juce_RelativeCoordinate.cpp new file mode 100644 index 0000000000..9861000402 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeCoordinate.cpp @@ -0,0 +1,176 @@ +/* + ============================================================================== + + 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_RelativeCoordinate.h" + + +//============================================================================== +const String RelativeCoordinate::Strings::parent ("parent"); +const String RelativeCoordinate::Strings::this_ ("this"); +const String RelativeCoordinate::Strings::left ("left"); +const String RelativeCoordinate::Strings::right ("right"); +const String RelativeCoordinate::Strings::top ("top"); +const String RelativeCoordinate::Strings::bottom ("bottom"); +const String RelativeCoordinate::Strings::parentLeft ("parent.left"); +const String RelativeCoordinate::Strings::parentTop ("parent.top"); +const String RelativeCoordinate::Strings::parentRight ("parent.right"); +const String RelativeCoordinate::Strings::parentBottom ("parent.bottom"); + +//============================================================================== +RelativeCoordinate::RelativeCoordinate() +{ +} + +RelativeCoordinate::RelativeCoordinate (const Expression& term_) + : term (term_) +{ +} + +RelativeCoordinate::RelativeCoordinate (const RelativeCoordinate& other) + : term (other.term) +{ +} + +RelativeCoordinate& RelativeCoordinate::operator= (const RelativeCoordinate& other) +{ + term = other.term; + return *this; +} + +RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin) + : term (absoluteDistanceFromOrigin) +{ +} + +RelativeCoordinate::RelativeCoordinate (const String& s) +{ + try + { + term = Expression (s); + } + catch (...) + {} +} + +RelativeCoordinate::~RelativeCoordinate() +{ +} + +bool RelativeCoordinate::operator== (const RelativeCoordinate& other) const throw() +{ + return term.toString() == other.term.toString(); +} + +bool RelativeCoordinate::operator!= (const RelativeCoordinate& other) const throw() +{ + return ! operator== (other); +} + +double RelativeCoordinate::resolve (const Expression::EvaluationContext* context) const +{ + try + { + if (context != 0) + return term.evaluate (*context); + else + return term.evaluate(); + } + catch (...) + {} + + return 0.0; +} + +bool RelativeCoordinate::isRecursive (const Expression::EvaluationContext* context) const +{ + try + { + if (context != 0) + term.evaluate (*context); + else + term.evaluate(); + } + catch (...) + { + return true; + } + + return false; +} + +void RelativeCoordinate::moveToAbsolute (double newPos, const Expression::EvaluationContext* context) +{ + try + { + if (context != 0) + { + term = term.adjustedToGiveNewResult (newPos, *context); + } + else + { + Expression::EvaluationContext defaultContext; + term = term.adjustedToGiveNewResult (newPos, defaultContext); + } + } + catch (...) + {} +} + +bool RelativeCoordinate::references (const String& coordName, const Expression::EvaluationContext* context) const +{ + try + { + return term.referencesSymbol (coordName, context); + } + catch (...) + {} + + return false; +} + +bool RelativeCoordinate::isDynamic() const +{ + return term.usesAnySymbols(); +} + +const String RelativeCoordinate::toString() const +{ + return term.toString(); +} + +void RelativeCoordinate::renameSymbolIfUsed (const String& oldName, const String& newName) +{ + jassert (newName.isNotEmpty() && newName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_")); + + if (term.referencesSymbol (oldName, 0)) + term = term.withRenamedSymbol (oldName, newName); +} + + +END_JUCE_NAMESPACE diff --git a/src/gui/components/positioning/juce_RelativeCoordinate.h b/src/gui/components/positioning/juce_RelativeCoordinate.h new file mode 100644 index 0000000000..d9dceb6e70 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeCoordinate.h @@ -0,0 +1,138 @@ +/* + ============================================================================== + + 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_RELATIVECOORDINATE_JUCEHEADER__ +#define __JUCE_RELATIVECOORDINATE_JUCEHEADER__ + +#include "../../graphics/geometry/juce_Path.h" +#include "../../graphics/geometry/juce_Rectangle.h" +#include "../../../maths/juce_Expression.h" + + +//============================================================================== +/** + Expresses a coordinate as a dynamically evaluated expression. + + @see RelativePoint, RelativeRectangle +*/ +class JUCE_API RelativeCoordinate +{ +public: + //============================================================================== + /** Creates a zero coordinate. */ + RelativeCoordinate(); + RelativeCoordinate (const Expression& expression); + RelativeCoordinate (const RelativeCoordinate& other); + RelativeCoordinate& operator= (const RelativeCoordinate& other); + + /** Creates an absolute position from the parent origin on either the X or Y axis. + + @param absoluteDistanceFromOrigin the distance from the origin + */ + RelativeCoordinate (double absoluteDistanceFromOrigin); + + /** Recreates a coordinate from a string description. + The string will be parsed by ExpressionParser::parse(). + @param stringVersion the expression to use + @see toString + */ + RelativeCoordinate (const String& stringVersion); + + /** Destructor. */ + ~RelativeCoordinate(); + + bool operator== (const RelativeCoordinate& other) const throw(); + bool operator!= (const RelativeCoordinate& other) const throw(); + + //============================================================================== + /** Calculates the absolute position of this coordinate. + + You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may + be needed to calculate the result. + */ + double resolve (const Expression::EvaluationContext* evaluationContext) const; + + /** Returns true if this coordinate uses the specified coord name at any level in its evaluation. + This will recursively check any coordinates upon which this one depends. + */ + bool references (const String& coordName, const Expression::EvaluationContext* evaluationContext) const; + + /** Returns true if there's a recursive loop when trying to resolve this coordinate's position. */ + bool isRecursive (const Expression::EvaluationContext* evaluationContext) const; + + /** Returns true if this coordinate depends on any other coordinates for its position. */ + bool isDynamic() const; + + //============================================================================== + /** Changes the value of this coord to make it resolve to the specified position. + + Calling this will leave the anchor points unchanged, but will set this coordinate's absolute + or relative position to whatever value is necessary to make its resultant position + match the position that is provided. + */ + void moveToAbsolute (double absoluteTargetPosition, const Expression::EvaluationContext* evaluationContext); + + /** Changes the name of a symbol if it is used as part of the coordinate's expression. */ + void renameSymbolIfUsed (const String& oldName, const String& newName); + + /** Returns the expression that defines this coordinate. */ + const Expression& getExpression() const { return term; } + + + //============================================================================== + /** Returns a string which represents this coordinate. + For details of the string syntax, see the constructor notes. + */ + const String toString() const; + + //============================================================================== + /** A set of static strings that are commonly used by the RelativeCoordinate class. + + As well as avoiding using string literals in your code, using these preset values + has the advantage that all instances of the same string will share the same, reference-counted + String object, so if you have thousands of points which all refer to the same + anchor points, this can save a significant amount of memory allocation. + */ + struct Strings + { + static const String parent; /**< "parent" */ + static const String this_; /**< "this" */ + static const String left; /**< "left" */ + static const String right; /**< "right" */ + static const String top; /**< "top" */ + static const String bottom; /**< "bottom" */ + static const String parentLeft; /**< "parent.left" */ + static const String parentTop; /**< "parent.top" */ + static const String parentRight; /**< "parent.right" */ + static const String parentBottom; /**< "parent.bottom" */ + }; + +private: + //============================================================================== + Expression term; +}; + + +#endif // __JUCE_RELATIVECOORDINATE_JUCEHEADER__ diff --git a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp new file mode 100644 index 0000000000..7e77fcb9cf --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.cpp @@ -0,0 +1,279 @@ +/* + ============================================================================== + + 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_RelativeCoordinatePositioner.h" + + +//============================================================================== +RelativeCoordinatePositionerBase::RelativeCoordinatePositionerBase (Component& component_) + : Component::Positioner (component_), registeredOk (false) +{ +} + +RelativeCoordinatePositionerBase::~RelativeCoordinatePositionerBase() +{ + unregisterListeners(); +} + +const Expression RelativeCoordinatePositionerBase::getSymbolValue (const String& objectName, const String& member) const +{ + jassert (objectName.isNotEmpty()); + + if (member.isNotEmpty()) + { + const Component* comp = getSourceComponent (objectName); + + if (comp == 0) + { + if (objectName == RelativeCoordinate::Strings::parent) + comp = getComponent().getParentComponent(); + else if (objectName == RelativeCoordinate::Strings::this_ || objectName == getComponent().getComponentID()) + comp = &getComponent(); + } + + if (comp != 0) + { + if (member == RelativeCoordinate::Strings::left) return xToExpression (comp, 0); + if (member == RelativeCoordinate::Strings::right) return xToExpression (comp, comp->getWidth()); + if (member == RelativeCoordinate::Strings::top) return yToExpression (comp, 0); + if (member == RelativeCoordinate::Strings::bottom) return yToExpression (comp, comp->getHeight()); + } + } + + for (int i = sourceMarkerLists.size(); --i >= 0;) + { + MarkerList* const markerList = sourceMarkerLists.getUnchecked(i); + const MarkerList::Marker* const marker = markerList->getMarker (objectName); + + if (marker != 0) + return marker->position.getExpression(); + } + + return Expression::EvaluationContext::getSymbolValue (objectName, member); +} + +void RelativeCoordinatePositionerBase::componentMovedOrResized (Component&, bool /*wasMoved*/, bool /*wasResized*/) +{ + apply(); +} + +void RelativeCoordinatePositionerBase::componentParentHierarchyChanged (Component&) +{ + apply(); +} + +void RelativeCoordinatePositionerBase::componentBeingDeleted (Component& component) +{ + jassert (sourceComponents.contains (&component)); + sourceComponents.removeValue (&component); +} + +void RelativeCoordinatePositionerBase::markersChanged (MarkerList*) +{ + apply(); +} + +void RelativeCoordinatePositionerBase::markerListBeingDeleted (MarkerList* markerList) +{ + jassert (sourceMarkerLists.contains (markerList)); + sourceMarkerLists.removeValue (markerList); +} + +void RelativeCoordinatePositionerBase::apply() +{ + if (! registeredOk) + { + unregisterListeners(); + registeredOk = registerCoordinates(); + } + + applyToComponentBounds(); +} + +bool RelativeCoordinatePositionerBase::addCoordinate (const RelativeCoordinate& coord) +{ + return registerListeners (coord.getExpression()); +} + +bool RelativeCoordinatePositionerBase::registerListeners (const Expression& e) +{ + bool ok = true; + + if (e.getType() == Expression::symbolType) + { + String objectName, memberName; + e.getSymbolParts (objectName, memberName); + + if (memberName.isNotEmpty()) + ok = registerComponent (objectName) && ok; + else + ok = registerMarker (objectName) && ok; + } + else + { + for (int i = e.getNumInputs(); --i >= 0;) + ok = registerListeners (e.getInput (i)) && ok; + } + + return ok; +} + +bool RelativeCoordinatePositionerBase::registerComponent (const String& componentID) +{ + Component* comp = findComponent (componentID); + + if (comp == 0) + { + if (componentID == RelativeCoordinate::Strings::parent) + comp = getComponent().getParentComponent(); + else if (componentID == RelativeCoordinate::Strings::this_ || componentID == getComponent().getComponentID()) + comp = &getComponent(); + } + + if (comp != 0) + { + if (comp != &getComponent()) + registerComponentListener (comp); + + return true; + } + else + { + // The component we want doesn't exist, so watch the parent in case the hierarchy changes and it appears later.. + Component* const parent = getComponent().getParentComponent(); + + if (parent != 0) + registerComponentListener (parent); + else + registerComponentListener (&getComponent()); + + return false; + } +} + +bool RelativeCoordinatePositionerBase::registerMarker (const String markerName) +{ + Component* const parent = getComponent().getParentComponent(); + + if (parent != 0) + { + MarkerList* list = parent->getMarkers (true); + + if (list == 0 || list->getMarker (markerName) == 0) + list = parent->getMarkers (false); + + if (list != 0 && list->getMarker (markerName) != 0) + { + registerMarkerListListener (list); + return true; + } + else + { + // The marker we want doesn't exist, so watch all lists in case they change and the marker appears later.. + registerMarkerListListener (parent->getMarkers (true)); + registerMarkerListListener (parent->getMarkers (false)); + } + } + + return false; +} + +void RelativeCoordinatePositionerBase::registerComponentListener (Component* const comp) +{ + if (comp != 0 && ! sourceComponents.contains (comp)) + { + comp->addComponentListener (this); + sourceComponents.add (comp); + } +} + +void RelativeCoordinatePositionerBase::registerMarkerListListener (MarkerList* const list) +{ + if (list != 0 && ! sourceMarkerLists.contains (list)) + { + list->addListener (this); + sourceMarkerLists.add (list); + } +} + +void RelativeCoordinatePositionerBase::unregisterListeners() +{ + int i; + for (i = sourceComponents.size(); --i >= 0;) + sourceComponents.getUnchecked(i)->removeComponentListener (this); + + for (i = sourceMarkerLists.size(); --i >= 0;) + sourceMarkerLists.getUnchecked(i)->removeListener (this); + + sourceComponents.clear(); + sourceMarkerLists.clear(); +} + +Component* RelativeCoordinatePositionerBase::findComponent (const String& componentID) const +{ + Component* const parent = getComponent().getParentComponent(); + + if (parent != 0) + { + for (int i = parent->getNumChildComponents(); --i >= 0;) + { + Component* const c = parent->getChildComponent(i); + + if (c->getComponentID() == componentID) + return c; + } + } + + return 0; +} + +Component* RelativeCoordinatePositionerBase::getSourceComponent (const String& objectName) const +{ + for (int i = sourceComponents.size(); --i >= 0;) + { + Component* const comp = sourceComponents.getUnchecked(i); + + if (comp->getComponentID() == objectName) + return comp; + } + + return 0; +} + +const Expression RelativeCoordinatePositionerBase::xToExpression (const Component* const source, const int x) const +{ + return Expression ((double) (getComponent().getLocalPoint (source, Point (x, 0)).getX() + getComponent().getX())); +} + +const Expression RelativeCoordinatePositionerBase::yToExpression (const Component* const source, const int y) const +{ + return Expression ((double) (getComponent().getLocalPoint (source, Point (0, y)).getY() + getComponent().getY())); +} + +END_JUCE_NAMESPACE diff --git a/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h new file mode 100644 index 0000000000..826679bf99 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeCoordinatePositioner.h @@ -0,0 +1,83 @@ +/* + ============================================================================== + + 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_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ +#define __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ + +#include "juce_RelativeCoordinate.h" +#include "juce_MarkerList.h" +#include "../juce_Component.h" + + +//============================================================================== +/** + Base class for Component::Positioners that are based upon relative coordinates. +*/ +class RelativeCoordinatePositionerBase : public Component::Positioner, + public ComponentListener, + public MarkerList::Listener, + public Expression::EvaluationContext +{ +public: + RelativeCoordinatePositionerBase (Component& component_); + ~RelativeCoordinatePositionerBase(); + + const Expression getSymbolValue (const String& objectName, const String& member) const; + + void componentMovedOrResized (Component&, bool, bool); + void componentParentHierarchyChanged (Component&); + void componentBeingDeleted (Component& component); + void markersChanged (MarkerList*); + void markerListBeingDeleted (MarkerList* markerList); + + void apply(); + +protected: + bool addCoordinate (const RelativeCoordinate& coord); + + virtual bool registerCoordinates() = 0; + virtual void applyToComponentBounds() = 0; + +private: + Array sourceComponents; + Array sourceMarkerLists; + bool registeredOk; + + bool registerListeners (const Expression& e); + bool registerComponent (const String& componentID); + bool registerMarker (const String markerName); + void registerComponentListener (Component* const comp); + void registerMarkerListListener (MarkerList* const list); + void unregisterListeners(); + Component* findComponent (const String& componentID) const; + Component* getSourceComponent (const String& objectName) const; + const Expression xToExpression (const Component* const source, const int x) const; + const Expression yToExpression (const Component* const source, const int y) const; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeCoordinatePositionerBase); +}; + + +#endif // __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ diff --git a/src/gui/components/positioning/juce_RelativeParallelogram.cpp b/src/gui/components/positioning/juce_RelativeParallelogram.cpp new file mode 100644 index 0000000000..2a142df1f0 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeParallelogram.cpp @@ -0,0 +1,133 @@ +/* + ============================================================================== + + 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_RelativeParallelogram.h" + +//============================================================================== +RelativeParallelogram::RelativeParallelogram() +{ +} + +RelativeParallelogram::RelativeParallelogram (const Rectangle& r) + : topLeft (r.getTopLeft()), topRight (r.getTopRight()), bottomLeft (r.getBottomLeft()) +{ +} + +RelativeParallelogram::RelativeParallelogram (const RelativePoint& topLeft_, const RelativePoint& topRight_, const RelativePoint& bottomLeft_) + : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_) +{ +} + +RelativeParallelogram::RelativeParallelogram (const String& topLeft_, const String& topRight_, const String& bottomLeft_) + : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_) +{ +} + +RelativeParallelogram::~RelativeParallelogram() +{ +} + +void RelativeParallelogram::resolveThreePoints (Point* points, Expression::EvaluationContext* const coordFinder) const +{ + points[0] = topLeft.resolve (coordFinder); + points[1] = topRight.resolve (coordFinder); + points[2] = bottomLeft.resolve (coordFinder); +} + +void RelativeParallelogram::resolveFourCorners (Point* points, Expression::EvaluationContext* const coordFinder) const +{ + resolveThreePoints (points, coordFinder); + points[3] = points[1] + (points[2] - points[0]); +} + +const Rectangle RelativeParallelogram::getBounds (Expression::EvaluationContext* const coordFinder) const +{ + Point points[4]; + resolveFourCorners (points, coordFinder); + return Rectangle::findAreaContainingPoints (points, 4); +} + +void RelativeParallelogram::getPath (Path& path, Expression::EvaluationContext* const coordFinder) const +{ + Point points[4]; + resolveFourCorners (points, coordFinder); + + path.startNewSubPath (points[0]); + path.lineTo (points[1]); + path.lineTo (points[3]); + path.lineTo (points[2]); + path.closeSubPath(); +} + +const AffineTransform RelativeParallelogram::resetToPerpendicular (Expression::EvaluationContext* const coordFinder) +{ + Point corners[3]; + resolveThreePoints (corners, coordFinder); + + const Line top (corners[0], corners[1]); + const Line left (corners[0], corners[2]); + const Point newTopRight (corners[0] + Point (top.getLength(), 0.0f)); + const Point newBottomLeft (corners[0] + Point (0.0f, left.getLength())); + + topRight.moveToAbsolute (newTopRight, coordFinder); + bottomLeft.moveToAbsolute (newBottomLeft, coordFinder); + + return AffineTransform::fromTargetPoints (corners[0].getX(), corners[0].getY(), corners[0].getX(), corners[0].getY(), + corners[1].getX(), corners[1].getY(), newTopRight.getX(), newTopRight.getY(), + corners[2].getX(), corners[2].getY(), newBottomLeft.getX(), newBottomLeft.getY()); +} + +bool RelativeParallelogram::operator== (const RelativeParallelogram& other) const throw() +{ + return topLeft == other.topLeft && topRight == other.topRight && bottomLeft == other.bottomLeft; +} + +bool RelativeParallelogram::operator!= (const RelativeParallelogram& other) const throw() +{ + return ! operator== (other); +} + +const Point RelativeParallelogram::getInternalCoordForPoint (const Point* const corners, Point target) throw() +{ + const Point tr (corners[1] - corners[0]); + const Point bl (corners[2] - corners[0]); + target -= corners[0]; + + return Point (Line (Point(), tr).getIntersection (Line (target, target - bl)).getDistanceFromOrigin(), + Line (Point(), bl).getIntersection (Line (target, target - tr)).getDistanceFromOrigin()); +} + +const Point RelativeParallelogram::getPointForInternalCoord (const Point* const corners, const Point& point) throw() +{ + return corners[0] + + Line (Point(), corners[1] - corners[0]).getPointAlongLine (point.getX()) + + Line (Point(), corners[2] - corners[0]).getPointAlongLine (point.getY()); +} + +END_JUCE_NAMESPACE diff --git a/src/gui/components/positioning/juce_RelativeParallelogram.h b/src/gui/components/positioning/juce_RelativeParallelogram.h new file mode 100644 index 0000000000..1d3c5bd41d --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeParallelogram.h @@ -0,0 +1,66 @@ +/* + ============================================================================== + + 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_RELATIVEPARALLELOGRAM_JUCEHEADER__ +#define __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ + +#include "juce_RelativePoint.h" + + +//============================================================================== +/** + A parallelogram defined by three RelativePoint positions. + + @see RelativePoint, RelativeCoordinate +*/ +class JUCE_API RelativeParallelogram +{ +public: + //============================================================================== + RelativeParallelogram(); + RelativeParallelogram (const Rectangle& simpleRectangle); + RelativeParallelogram (const RelativePoint& topLeft, const RelativePoint& topRight, const RelativePoint& bottomLeft); + RelativeParallelogram (const String& topLeft, const String& topRight, const String& bottomLeft); + ~RelativeParallelogram(); + + //============================================================================== + void resolveThreePoints (Point* points, Expression::EvaluationContext* coordFinder) const; + void resolveFourCorners (Point* points, Expression::EvaluationContext* coordFinder) const; + const Rectangle getBounds (Expression::EvaluationContext* coordFinder) const; + void getPath (Path& path, Expression::EvaluationContext* coordFinder) const; + const AffineTransform resetToPerpendicular (Expression::EvaluationContext* coordFinder); + + bool operator== (const RelativeParallelogram& other) const throw(); + bool operator!= (const RelativeParallelogram& other) const throw(); + + static const Point getInternalCoordForPoint (const Point* parallelogramCorners, Point point) throw(); + static const Point getPointForInternalCoord (const Point* parallelogramCorners, const Point& internalPoint) throw(); + + //============================================================================== + RelativePoint topLeft, topRight, bottomLeft; +}; + + +#endif // __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ diff --git a/src/gui/components/positioning/juce_RelativePoint.cpp b/src/gui/components/positioning/juce_RelativePoint.cpp new file mode 100644 index 0000000000..1b5ec9f36c --- /dev/null +++ b/src/gui/components/positioning/juce_RelativePoint.cpp @@ -0,0 +1,111 @@ +/* + ============================================================================== + + 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_RelativePoint.h" + +namespace RelativePointHelpers +{ + void skipComma (const juce_wchar* const s, int& i) + { + while (CharacterFunctions::isWhitespace (s[i])) + ++i; + + if (s[i] == ',') + ++i; + } +} + +//============================================================================== +RelativePoint::RelativePoint() +{ +} + +RelativePoint::RelativePoint (const Point& absolutePoint) + : x (absolutePoint.getX()), y (absolutePoint.getY()) +{ +} + +RelativePoint::RelativePoint (const float x_, const float y_) + : x (x_), y (y_) +{ +} + +RelativePoint::RelativePoint (const RelativeCoordinate& x_, const RelativeCoordinate& y_) + : x (x_), y (y_) +{ +} + +RelativePoint::RelativePoint (const String& s) +{ + int i = 0; + x = RelativeCoordinate (Expression::parse (s, i)); + RelativePointHelpers::skipComma (s, i); + y = RelativeCoordinate (Expression::parse (s, i)); +} + +bool RelativePoint::operator== (const RelativePoint& other) const throw() +{ + return x == other.x && y == other.y; +} + +bool RelativePoint::operator!= (const RelativePoint& other) const throw() +{ + return ! operator== (other); +} + +const Point RelativePoint::resolve (const Expression::EvaluationContext* context) const +{ + return Point ((float) x.resolve (context), + (float) y.resolve (context)); +} + +void RelativePoint::moveToAbsolute (const Point& newPos, const Expression::EvaluationContext* context) +{ + x.moveToAbsolute (newPos.getX(), context); + y.moveToAbsolute (newPos.getY(), context); +} + +const String RelativePoint::toString() const +{ + return x.toString() + ", " + y.toString(); +} + +void RelativePoint::renameSymbolIfUsed (const String& oldName, const String& newName) +{ + x.renameSymbolIfUsed (oldName, newName); + y.renameSymbolIfUsed (oldName, newName); +} + +bool RelativePoint::isDynamic() const +{ + return x.isDynamic() || y.isDynamic(); +} + + +END_JUCE_NAMESPACE diff --git a/src/gui/components/positioning/juce_RelativePoint.h b/src/gui/components/positioning/juce_RelativePoint.h new file mode 100644 index 0000000000..1d614e7ce8 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativePoint.h @@ -0,0 +1,98 @@ +/* + ============================================================================== + + 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_RELATIVEPOINT_JUCEHEADER__ +#define __JUCE_RELATIVEPOINT_JUCEHEADER__ + +#include "juce_RelativeCoordinate.h" + + +//============================================================================== +/** + An X-Y position stored as a pair of RelativeCoordinate values. + + @see RelativeCoordinate, RelativeRectangle +*/ +class JUCE_API RelativePoint +{ +public: + /** Creates a point at the origin. */ + RelativePoint(); + + /** Creates an absolute point, relative to the origin. */ + RelativePoint (const Point& absolutePoint); + + /** Creates an absolute point, relative to the origin. */ + RelativePoint (float absoluteX, float absoluteY); + + /** Creates an absolute point from two coordinates. */ + RelativePoint (const RelativeCoordinate& x, const RelativeCoordinate& y); + + /** Creates a point from a stringified representation. + The string must contain a pair of coordinates, separated by space or a comma. The syntax for the coordinate + strings is explained in the RelativeCoordinate class. + @see toString + */ + RelativePoint (const String& stringVersion); + + bool operator== (const RelativePoint& other) const throw(); + bool operator!= (const RelativePoint& other) const throw(); + + /** Calculates the absolute position of this point. + + You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may + be needed to calculate the result. + */ + const Point resolve (const Expression::EvaluationContext* evaluationContext) const; + + /** Changes the values of this point's coordinates to make it resolve to the specified position. + + Calling this will leave any anchor points unchanged, but will set any absolute + or relative positions to whatever values are necessary to make the resultant position + match the position that is provided. + */ + void moveToAbsolute (const Point& newPos, const Expression::EvaluationContext* evaluationContext); + + /** Returns a string which represents this point. + This returns a comma-separated pair of coordinates. For details of the string syntax used by the + coordinates, see the RelativeCoordinate constructor notes. + The string that is returned can be passed to the RelativePoint constructor to recreate the point. + */ + const String toString() const; + + /** Renames a symbol if it is used by any of the coordinates. + This calls RelativeCoordinate::renameAnchorIfUsed() on its X and Y coordinates. + */ + void renameSymbolIfUsed (const String& oldName, const String& newName); + + /** Returns true if this point depends on any other coordinates for its position. */ + bool isDynamic() const; + + // The actual X and Y coords... + RelativeCoordinate x, y; +}; + + +#endif // __JUCE_RELATIVEPOINT_JUCEHEADER__ diff --git a/src/gui/components/positioning/juce_RelativePointPath.cpp b/src/gui/components/positioning/juce_RelativePointPath.cpp new file mode 100644 index 0000000000..902499d688 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativePointPath.cpp @@ -0,0 +1,306 @@ +/* + ============================================================================== + + 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_RelativePointPath.h" +#include "../../graphics/drawables/juce_DrawablePath.h" + + +//============================================================================== +RelativePointPath::RelativePointPath() + : usesNonZeroWinding (true), + containsDynamicPoints (false) +{ +} + +RelativePointPath::RelativePointPath (const RelativePointPath& other) + : usesNonZeroWinding (true), + containsDynamicPoints (false) +{ + for (int i = 0; i < other.elements.size(); ++i) + elements.add (other.elements.getUnchecked(i)->clone()); +} + +RelativePointPath::RelativePointPath (const Path& path) +{ + usesNonZeroWinding = path.isUsingNonZeroWinding(); + + Path::Iterator i (path); + + while (i.next()) + { + switch (i.elementType) + { + case Path::Iterator::startNewSubPath: elements.add (new StartSubPath (RelativePoint (i.x1, i.y1))); break; + case Path::Iterator::lineTo: elements.add (new LineTo (RelativePoint (i.x1, i.y1))); break; + case Path::Iterator::quadraticTo: elements.add (new QuadraticTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2))); break; + case Path::Iterator::cubicTo: elements.add (new CubicTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2), RelativePoint (i.x3, i.y3))); break; + case Path::Iterator::closePath: elements.add (new CloseSubPath()); break; + default: jassertfalse; break; + } + } +} + +RelativePointPath::~RelativePointPath() +{ +} + +bool RelativePointPath::operator== (const RelativePointPath& other) const throw() +{ + if (elements.size() != other.elements.size() + || usesNonZeroWinding != other.usesNonZeroWinding + || containsDynamicPoints != other.containsDynamicPoints) + return false; + + for (int i = 0; i < elements.size(); ++i) + { + ElementBase* const e1 = elements.getUnchecked(i); + ElementBase* const e2 = other.elements.getUnchecked(i); + + if (e1->type != e2->type) + return false; + + int numPoints1, numPoints2; + RelativePoint* const points1 = e1->getControlPoints (numPoints1); + RelativePoint* const points2 = e2->getControlPoints (numPoints2); + + jassert (numPoints1 == numPoints2); + + for (int j = numPoints1; --j >= 0;) + if (points1[j] != points2[j]) + return false; + } + + return true; +} + +bool RelativePointPath::operator!= (const RelativePointPath& other) const throw() +{ + return ! operator== (other); +} + +void RelativePointPath::swapWith (RelativePointPath& other) throw() +{ + elements.swapWithArray (other.elements); + swapVariables (usesNonZeroWinding, other.usesNonZeroWinding); +} + +void RelativePointPath::createPath (Path& path, Expression::EvaluationContext* coordFinder) const +{ + for (int i = 0; i < elements.size(); ++i) + elements.getUnchecked(i)->addToPath (path, coordFinder); +} + +bool RelativePointPath::containsAnyDynamicPoints() const +{ + return containsDynamicPoints; +} + +void RelativePointPath::addElement (ElementBase* newElement) +{ + if (newElement != 0) + { + elements.add (newElement); + containsDynamicPoints = containsDynamicPoints || newElement->isDynamic(); + } +} + +//============================================================================== +RelativePointPath::ElementBase::ElementBase (const ElementType type_) : type (type_) +{ +} + +bool RelativePointPath::ElementBase::isDynamic() +{ + int numPoints; + const RelativePoint* const points = getControlPoints (numPoints); + + for (int i = numPoints; --i >= 0;) + if (points[i].isDynamic()) + return true; + + return false; +} + +//============================================================================== +RelativePointPath::StartSubPath::StartSubPath (const RelativePoint& pos) + : ElementBase (startSubPathElement), startPos (pos) +{ +} + +const ValueTree RelativePointPath::StartSubPath::createTree() const +{ + ValueTree v (DrawablePath::ValueTreeWrapper::Element::startSubPathElement); + v.setProperty (DrawablePath::ValueTreeWrapper::point1, startPos.toString(), 0); + return v; +} + +void RelativePointPath::StartSubPath::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const +{ + path.startNewSubPath (startPos.resolve (coordFinder)); +} + +RelativePoint* RelativePointPath::StartSubPath::getControlPoints (int& numPoints) +{ + numPoints = 1; + return &startPos; +} + +RelativePointPath::ElementBase* RelativePointPath::StartSubPath::clone() const +{ + return new StartSubPath (startPos); +} + +//============================================================================== +RelativePointPath::CloseSubPath::CloseSubPath() + : ElementBase (closeSubPathElement) +{ +} + +const ValueTree RelativePointPath::CloseSubPath::createTree() const +{ + return ValueTree (DrawablePath::ValueTreeWrapper::Element::closeSubPathElement); +} + +void RelativePointPath::CloseSubPath::addToPath (Path& path, Expression::EvaluationContext*) const +{ + path.closeSubPath(); +} + +RelativePoint* RelativePointPath::CloseSubPath::getControlPoints (int& numPoints) +{ + numPoints = 0; + return 0; +} + +RelativePointPath::ElementBase* RelativePointPath::CloseSubPath::clone() const +{ + return new CloseSubPath(); +} + +//============================================================================== +RelativePointPath::LineTo::LineTo (const RelativePoint& endPoint_) + : ElementBase (lineToElement), endPoint (endPoint_) +{ +} + +const ValueTree RelativePointPath::LineTo::createTree() const +{ + ValueTree v (DrawablePath::ValueTreeWrapper::Element::lineToElement); + v.setProperty (DrawablePath::ValueTreeWrapper::point1, endPoint.toString(), 0); + return v; +} + +void RelativePointPath::LineTo::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const +{ + path.lineTo (endPoint.resolve (coordFinder)); +} + +RelativePoint* RelativePointPath::LineTo::getControlPoints (int& numPoints) +{ + numPoints = 1; + return &endPoint; +} + +RelativePointPath::ElementBase* RelativePointPath::LineTo::clone() const +{ + return new LineTo (endPoint); +} + +//============================================================================== +RelativePointPath::QuadraticTo::QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint) + : ElementBase (quadraticToElement) +{ + controlPoints[0] = controlPoint; + controlPoints[1] = endPoint; +} + +const ValueTree RelativePointPath::QuadraticTo::createTree() const +{ + ValueTree v (DrawablePath::ValueTreeWrapper::Element::quadraticToElement); + v.setProperty (DrawablePath::ValueTreeWrapper::point1, controlPoints[0].toString(), 0); + v.setProperty (DrawablePath::ValueTreeWrapper::point2, controlPoints[1].toString(), 0); + return v; +} + +void RelativePointPath::QuadraticTo::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const +{ + path.quadraticTo (controlPoints[0].resolve (coordFinder), + controlPoints[1].resolve (coordFinder)); +} + +RelativePoint* RelativePointPath::QuadraticTo::getControlPoints (int& numPoints) +{ + numPoints = 2; + return controlPoints; +} + +RelativePointPath::ElementBase* RelativePointPath::QuadraticTo::clone() const +{ + return new QuadraticTo (controlPoints[0], controlPoints[1]); +} + + +//============================================================================== +RelativePointPath::CubicTo::CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint) + : ElementBase (cubicToElement) +{ + controlPoints[0] = controlPoint1; + controlPoints[1] = controlPoint2; + controlPoints[2] = endPoint; +} + +const ValueTree RelativePointPath::CubicTo::createTree() const +{ + ValueTree v (DrawablePath::ValueTreeWrapper::Element::cubicToElement); + v.setProperty (DrawablePath::ValueTreeWrapper::point1, controlPoints[0].toString(), 0); + v.setProperty (DrawablePath::ValueTreeWrapper::point2, controlPoints[1].toString(), 0); + v.setProperty (DrawablePath::ValueTreeWrapper::point3, controlPoints[2].toString(), 0); + return v; +} + +void RelativePointPath::CubicTo::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const +{ + path.cubicTo (controlPoints[0].resolve (coordFinder), + controlPoints[1].resolve (coordFinder), + controlPoints[2].resolve (coordFinder)); +} + +RelativePoint* RelativePointPath::CubicTo::getControlPoints (int& numPoints) +{ + numPoints = 3; + return controlPoints; +} + +RelativePointPath::ElementBase* RelativePointPath::CubicTo::clone() const +{ + return new CubicTo (controlPoints[0], controlPoints[1], controlPoints[2]); +} + + +END_JUCE_NAMESPACE diff --git a/src/gui/components/positioning/juce_RelativePointPath.h b/src/gui/components/positioning/juce_RelativePointPath.h new file mode 100644 index 0000000000..a1cf98b89f --- /dev/null +++ b/src/gui/components/positioning/juce_RelativePointPath.h @@ -0,0 +1,196 @@ +/* + ============================================================================== + + 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_RELATIVEPOINTPATH_JUCEHEADER__ +#define __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ + +#include "juce_RelativePoint.h" +#include "../../../containers/juce_OwnedArray.h" +#include "../../../containers/juce_ValueTree.h" +class DrawablePath; + +//============================================================================== +/** + A path object that consists of RelativePoint coordinates rather than the normal fixed ones. + + One of these paths can be converted into a Path object for drawing and manipulation, but + unlike a Path, its points can be dynamic instead of just fixed. + + @see RelativePoint, RelativeCoordinate +*/ +class JUCE_API RelativePointPath +{ +public: + //============================================================================== + RelativePointPath(); + RelativePointPath (const RelativePointPath& other); + RelativePointPath (const Path& path); + ~RelativePointPath(); + + bool operator== (const RelativePointPath& other) const throw(); + bool operator!= (const RelativePointPath& other) const throw(); + + //============================================================================== + /** Resolves this points in this path and adds them to a normal Path object. */ + void createPath (Path& path, Expression::EvaluationContext* coordFinder) const; + + /** Returns true if the path contains any non-fixed points. */ + bool containsAnyDynamicPoints() const; + + /** Quickly swaps the contents of this path with another. */ + void swapWith (RelativePointPath& other) throw(); + + //============================================================================== + /** The types of element that may be contained in this path. + @see RelativePointPath::ElementBase + */ + enum ElementType + { + nullElement, + startSubPathElement, + closeSubPathElement, + lineToElement, + quadraticToElement, + cubicToElement + }; + + //============================================================================== + /** Base class for the elements that make up a RelativePointPath. + */ + class JUCE_API ElementBase + { + public: + ElementBase (ElementType type); + virtual ~ElementBase() {} + virtual const ValueTree createTree() const = 0; + virtual void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const = 0; + virtual RelativePoint* getControlPoints (int& numPoints) = 0; + virtual ElementBase* clone() const = 0; + bool isDynamic(); + + const ElementType type; + + private: + JUCE_DECLARE_NON_COPYABLE (ElementBase); + }; + + //============================================================================== + class JUCE_API StartSubPath : public ElementBase + { + public: + StartSubPath (const RelativePoint& pos); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint startPos; + + private: + JUCE_DECLARE_NON_COPYABLE (StartSubPath); + }; + + //============================================================================== + class JUCE_API CloseSubPath : public ElementBase + { + public: + CloseSubPath(); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + private: + JUCE_DECLARE_NON_COPYABLE (CloseSubPath); + }; + + //============================================================================== + class JUCE_API LineTo : public ElementBase + { + public: + LineTo (const RelativePoint& endPoint); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint endPoint; + + private: + JUCE_DECLARE_NON_COPYABLE (LineTo); + }; + + //============================================================================== + class JUCE_API QuadraticTo : public ElementBase + { + public: + QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint controlPoints[2]; + + private: + JUCE_DECLARE_NON_COPYABLE (QuadraticTo); + }; + + //============================================================================== + class JUCE_API CubicTo : public ElementBase + { + public: + CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint); + const ValueTree createTree() const; + void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; + RelativePoint* getControlPoints (int& numPoints); + ElementBase* clone() const; + + RelativePoint controlPoints[3]; + + private: + JUCE_DECLARE_NON_COPYABLE (CubicTo); + }; + + //============================================================================== + void addElement (ElementBase* newElement); + + //============================================================================== + OwnedArray elements; + bool usesNonZeroWinding; + +private: + class Positioner; + friend class Positioner; + bool containsDynamicPoints; + + void applyTo (DrawablePath& path) const; + + RelativePointPath& operator= (const RelativePointPath&); + JUCE_LEAK_DETECTOR (RelativePointPath); +}; + + +#endif // __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ diff --git a/src/gui/components/positioning/juce_RelativeRectangle.cpp b/src/gui/components/positioning/juce_RelativeRectangle.cpp new file mode 100644 index 0000000000..8f314cda05 --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeRectangle.cpp @@ -0,0 +1,189 @@ +/* + ============================================================================== + + 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_RelativeRectangle.h" +#include "juce_RelativeCoordinatePositioner.h" + +namespace RelativeRectangleHelpers +{ + inline void skipComma (const juce_wchar* const s, int& i) + { + while (CharacterFunctions::isWhitespace (s[i])) + ++i; + + if (s[i] == ',') + ++i; + } +} + +//============================================================================== +RelativeRectangle::RelativeRectangle() +{ +} + +RelativeRectangle::RelativeRectangle (const RelativeCoordinate& left_, const RelativeCoordinate& right_, + const RelativeCoordinate& top_, const RelativeCoordinate& bottom_) + : left (left_), right (right_), top (top_), bottom (bottom_) +{ +} + +RelativeRectangle::RelativeRectangle (const Rectangle& rect, const String& componentName) + : left (rect.getX()), + right (Expression::symbol (componentName + "." + RelativeCoordinate::Strings::left) + Expression ((double) rect.getWidth())), + top (rect.getY()), + bottom (Expression::symbol (componentName + "." + RelativeCoordinate::Strings::top) + Expression ((double) rect.getHeight())) +{ +} + +RelativeRectangle::RelativeRectangle (const String& s) +{ + int i = 0; + left = RelativeCoordinate (Expression::parse (s, i)); + RelativeRectangleHelpers::skipComma (s, i); + top = RelativeCoordinate (Expression::parse (s, i)); + RelativeRectangleHelpers::skipComma (s, i); + right = RelativeCoordinate (Expression::parse (s, i)); + RelativeRectangleHelpers::skipComma (s, i); + bottom = RelativeCoordinate (Expression::parse (s, i)); +} + +bool RelativeRectangle::operator== (const RelativeRectangle& other) const throw() +{ + return left == other.left && top == other.top && right == other.right && bottom == other.bottom; +} + +bool RelativeRectangle::operator!= (const RelativeRectangle& other) const throw() +{ + return ! operator== (other); +} + +const Rectangle RelativeRectangle::resolve (const Expression::EvaluationContext* context) const +{ + const double l = left.resolve (context); + const double r = right.resolve (context); + const double t = top.resolve (context); + const double b = bottom.resolve (context); + + return Rectangle ((float) l, (float) t, (float) jmax (0.0, r - l), (float) jmax (0.0, b - t)); +} + +void RelativeRectangle::moveToAbsolute (const Rectangle& newPos, const Expression::EvaluationContext* context) +{ + left.moveToAbsolute (newPos.getX(), context); + right.moveToAbsolute (newPos.getRight(), context); + top.moveToAbsolute (newPos.getY(), context); + bottom.moveToAbsolute (newPos.getBottom(), context); +} + +bool RelativeRectangle::isDynamic() const +{ + return left.isDynamic() || right.isDynamic() || top.isDynamic() || bottom.isDynamic(); +} + +const String RelativeRectangle::toString() const +{ + return left.toString() + ", " + top.toString() + ", " + right.toString() + ", " + bottom.toString(); +} + +void RelativeRectangle::renameSymbolIfUsed (const String& oldName, const String& newName) +{ + left.renameSymbolIfUsed (oldName, newName); + right.renameSymbolIfUsed (oldName, newName); + top.renameSymbolIfUsed (oldName, newName); + bottom.renameSymbolIfUsed (oldName, newName); +} + +//============================================================================== +class RelativeRectangleComponentPositioner : public RelativeCoordinatePositionerBase +{ +public: + RelativeRectangleComponentPositioner (Component& component_, const RelativeRectangle& rectangle_) + : RelativeCoordinatePositionerBase (component_), + rectangle (rectangle_) + { + } + + bool registerCoordinates() + { + bool ok = addCoordinate (rectangle.left); + ok = addCoordinate (rectangle.right) && ok; + ok = addCoordinate (rectangle.top) && ok; + ok = addCoordinate (rectangle.bottom) && ok; + return ok; + } + + bool isUsingRectangle (const RelativeRectangle& other) const throw() + { + return rectangle == other; + } + + void applyToComponentBounds() + { + for (int i = 4; --i >= 0;) + { + const Rectangle newBounds (rectangle.resolve (this).getSmallestIntegerContainer()); + + if (newBounds == getComponent().getBounds()) + return; + + getComponent().setBounds (newBounds); + } + + jassertfalse; // must be a recursive reference! + } + +private: + const RelativeRectangle rectangle; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeRectangleComponentPositioner); +}; + +void RelativeRectangle::applyToComponent (Component& component) const +{ + if (isDynamic()) + { + RelativeRectangleComponentPositioner* current = dynamic_cast (component.getPositioner()); + + if (current == 0 || ! current->isUsingRectangle (*this)) + { + RelativeRectangleComponentPositioner* p = new RelativeRectangleComponentPositioner (component, *this); + + component.setPositioner (p); + p->apply(); + } + } + else + { + component.setPositioner (0); + component.setBounds (resolve (0).getSmallestIntegerContainer()); + } +} + + +END_JUCE_NAMESPACE diff --git a/src/gui/components/positioning/juce_RelativeRectangle.h b/src/gui/components/positioning/juce_RelativeRectangle.h new file mode 100644 index 0000000000..691f75d3ea --- /dev/null +++ b/src/gui/components/positioning/juce_RelativeRectangle.h @@ -0,0 +1,107 @@ +/* + ============================================================================== + + 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_RELATIVERECTANGLE_JUCEHEADER__ +#define __JUCE_RELATIVERECTANGLE_JUCEHEADER__ + +#include "juce_RelativeCoordinate.h" +class Component; + +//============================================================================== +/** + An rectangle stored as a set of RelativeCoordinate values. + + The rectangle's top, left, bottom and right edge positions are each stored as a RelativeCoordinate. + + @see RelativeCoordinate, RelativePoint +*/ +class JUCE_API RelativeRectangle +{ +public: + //============================================================================== + /** Creates a zero-size rectangle at the origin. */ + RelativeRectangle(); + + /** Creates an absolute rectangle, relative to the origin. */ + explicit RelativeRectangle (const Rectangle& rect, const String& componentName); + + /** Creates a rectangle from four coordinates. */ + RelativeRectangle (const RelativeCoordinate& left, const RelativeCoordinate& right, + const RelativeCoordinate& top, const RelativeCoordinate& bottom); + + /** Creates a rectangle from a stringified representation. + The string must contain a sequence of 4 coordinates, separated by commas, in the order + left, top, right, bottom. The syntax for the coordinate strings is explained in the + RelativeCoordinate class. + @see toString + */ + explicit RelativeRectangle (const String& stringVersion); + + bool operator== (const RelativeRectangle& other) const throw(); + bool operator!= (const RelativeRectangle& other) const throw(); + + //============================================================================== + /** Calculates the absolute position of this rectangle. + + You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may + be needed to calculate the result. + */ + const Rectangle resolve (const Expression::EvaluationContext* evaluationContext) const; + + /** Changes the values of this rectangle's coordinates to make it resolve to the specified position. + + Calling this will leave any anchor points unchanged, but will set any absolute + or relative positions to whatever values are necessary to make the resultant position + match the position that is provided. + */ + void moveToAbsolute (const Rectangle& newPos, const Expression::EvaluationContext* evaluationContext); + + /** Returns true if this rectangle depends on any other coordinates for its position. */ + bool isDynamic() const; + + /** Returns a string which represents this point. + This returns a comma-separated list of coordinates, in the order left, top, right, bottom. For details of + the string syntax used by the coordinates, see the RelativeCoordinate constructor notes. + The string that is returned can be passed to the RelativeRectangle constructor to recreate the rectangle. + */ + const String toString() const; + + /** Renames a symbol if it is used by any of the coordinates. + This calls RelativeCoordinate::renameSymbolIfUsed() on the rectangle's coordinates. + */ + void renameSymbolIfUsed (const String& oldName, const String& newName); + + /** Creates and sets an appropriate Component::Positioner object for the given component, which will + keep it positioned with this rectangle. + */ + void applyToComponent (Component& component) const; + + //============================================================================== + // The actual rectangle coords... + RelativeCoordinate left, right, top, bottom; +}; + + +#endif // __JUCE_RELATIVERECTANGLE_JUCEHEADER__ diff --git a/src/gui/graphics/drawables/juce_Drawable.h b/src/gui/graphics/drawables/juce_Drawable.h index ada330f38a..7489c54bdc 100644 --- a/src/gui/graphics/drawables/juce_Drawable.h +++ b/src/gui/graphics/drawables/juce_Drawable.h @@ -27,7 +27,7 @@ #define __JUCE_DRAWABLE_JUCEHEADER__ #include "../../components/juce_Component.h" -#include "../geometry/juce_RelativeCoordinate.h" +#include "../../components/positioning/juce_RelativeCoordinate.h" #include "../../../containers/juce_ValueTree.h" #include "../../components/layout/juce_ComponentBuilder.h" class DrawableComposite; diff --git a/src/gui/graphics/drawables/juce_DrawableComposite.h b/src/gui/graphics/drawables/juce_DrawableComposite.h index bc3efd2148..f3c32657ff 100644 --- a/src/gui/graphics/drawables/juce_DrawableComposite.h +++ b/src/gui/graphics/drawables/juce_DrawableComposite.h @@ -27,7 +27,9 @@ #define __JUCE_DRAWABLECOMPOSITE_JUCEHEADER__ #include "juce_Drawable.h" -#include "../../components/layout/juce_MarkerList.h" +#include "../../components/positioning/juce_MarkerList.h" +#include "../../components/positioning/juce_RelativeParallelogram.h" +#include "../../components/positioning/juce_RelativeRectangle.h" //============================================================================== diff --git a/src/gui/graphics/drawables/juce_DrawableImage.h b/src/gui/graphics/drawables/juce_DrawableImage.h index aa0f5b3047..624efd7b0f 100644 --- a/src/gui/graphics/drawables/juce_DrawableImage.h +++ b/src/gui/graphics/drawables/juce_DrawableImage.h @@ -28,6 +28,7 @@ #include "juce_Drawable.h" #include "../imaging/juce_Image.h" +#include "../../components/positioning/juce_RelativeParallelogram.h" //============================================================================== diff --git a/src/gui/graphics/drawables/juce_DrawablePath.cpp b/src/gui/graphics/drawables/juce_DrawablePath.cpp index 1a0d880ddd..f48836d9ec 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.cpp +++ b/src/gui/graphics/drawables/juce_DrawablePath.cpp @@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_DrawablePath.h" #include "juce_DrawableComposite.h" +#include "../../components/positioning/juce_RelativeCoordinatePositioner.h" //============================================================================== @@ -39,8 +40,10 @@ DrawablePath::DrawablePath() DrawablePath::DrawablePath (const DrawablePath& other) : DrawableShape (other) { - if (other.relativePath != 0) - relativePath = new RelativePointPath (*other.relativePath); + const RelativePointPath* const relativePath = other.getRelativePath(); + + if (relativePath != 0) + setPath (*relativePath); else setPath (other.path); } @@ -73,14 +76,89 @@ const Path& DrawablePath::getStrokePath() const bool DrawablePath::rebuildPath (Path& path) const { - if (relativePath != 0) + return false; +} + +void DrawablePath::applyRelativePath (const RelativePointPath& relativePath) +{ + Path newPath; + relativePath.createPath (newPath, 0); + + if (path != newPath) + { + path.swapWithPath (newPath); + pathChanged(); + } +} + +//============================================================================== +class DrawablePath::RelativePositioner : public RelativeCoordinatePositionerBase +{ +public: + RelativePositioner (DrawablePath& component_, const RelativePointPath& path_) + : RelativeCoordinatePositionerBase (component_), + path (path_), + owner (component_) { - path.clear(); - relativePath->createPath (path, getParent()); - return true; } - return false; + bool registerCoordinates() + { + bool ok = true; + + for (int i = 0; i < path.elements.size(); ++i) + { + RelativePointPath::ElementBase* const e = path.elements.getUnchecked(i); + + int numPoints; + RelativePoint* const points = e->getControlPoints (numPoints); + + for (int j = numPoints; --j >= 0;) + { + ok = addCoordinate (points[j].x) && ok; + ok = addCoordinate (points[j].y) && ok; + } + } + + return ok; + } + + void applyToComponentBounds() + { + owner.applyRelativePath (path); + } + + const RelativePointPath path; + +private: + DrawablePath& owner; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativePositioner); +}; + +const RelativePointPath* DrawablePath::getRelativePath() const +{ + RelativePositioner* current = dynamic_cast (getPositioner()); + return current != 0 ? &(current->path) : 0; +} + +void DrawablePath::setPath (const RelativePointPath& source) +{ + if (source.containsAnyDynamicPoints()) + { + const RelativePointPath* current = getRelativePath(); + + if (current == 0 || source != *current) + { + RelativePositioner* const p = new RelativePositioner (*this, source); + setPositioner (p); + p->apply(); + } + } + else + { + applyRelativePath (source); + } } //============================================================================== @@ -113,6 +191,47 @@ void DrawablePath::ValueTreeWrapper::setUsesNonZeroWinding (bool b, UndoManager* state.setProperty (nonZeroWinding, b, undoManager); } +void DrawablePath::ValueTreeWrapper::readFrom (const RelativePointPath& relativePath, UndoManager* undoManager) +{ + setUsesNonZeroWinding (relativePath.usesNonZeroWinding, undoManager); + + ValueTree pathTree (getPathState()); + pathTree.removeAllChildren (undoManager); + + for (int i = 0; i < relativePath.elements.size(); ++i) + pathTree.addChild (relativePath.elements.getUnchecked(i)->createTree(), -1, undoManager); +} + +void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) const +{ + relativePath.usesNonZeroWinding = usesNonZeroWinding(); + RelativePoint points[3]; + + const ValueTree pathTree (state.getChildWithName (path)); + const int num = pathTree.getNumChildren(); + for (int i = 0; i < num; ++i) + { + const Element e (pathTree.getChild(i)); + + const int numCps = e.getNumControlPoints(); + for (int j = 0; j < numCps; ++j) + points[j] = e.getControlPoint (j); + + const Identifier type (e.getType()); + + RelativePointPath::ElementBase* newElement = 0; + + if (type == Element::startSubPathElement) newElement = new RelativePointPath::StartSubPath (points[0]); + else if (type == Element::closeSubPathElement) newElement = new RelativePointPath::CloseSubPath(); + else if (type == Element::lineToElement) newElement = new RelativePointPath::LineTo (points[0]); + else if (type == Element::quadraticToElement) newElement = new RelativePointPath::QuadraticTo (points[0], points[1]); + else if (type == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); + else jassertfalse; + + relativePath.addElement (newElement); + } +} + //============================================================================== const Identifier DrawablePath::ValueTreeWrapper::Element::mode ("mode"); const Identifier DrawablePath::ValueTreeWrapper::Element::startSubPathElement ("Move"); @@ -448,23 +567,16 @@ void DrawablePath::refreshFromValueTree (const ValueTree& tree, ComponentBuilder if (refreshFillTypes (v, getParent(), builder.getImageProvider())) repaint(); - ScopedPointer newRelativePath (new RelativePointPath (tree)); - - Path newPath; - newRelativePath->createPath (newPath, getParent()); - - if (! newRelativePath->containsAnyDynamicPoints()) - newRelativePath = 0; - const PathStrokeType newStroke (v.getStrokeType()); - if (strokeType != newStroke || path != newPath) + if (strokeType != newStroke) { - path.swapWithPath (newPath); strokeType = newStroke; - pathChanged(); + strokeChanged(); } - relativePath = newRelativePath; + RelativePointPath newRelativePath; + v.writeTo (newRelativePath); + setPath (newRelativePath); } const ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const @@ -475,14 +587,16 @@ const ValueTree DrawablePath::createValueTree (ComponentBuilder::ImageProvider* v.setID (getComponentID()); writeTo (v, imageProvider, 0); + const RelativePointPath* const relativePath = getRelativePath(); + if (relativePath != 0) { - relativePath->writeTo (tree, 0); + v.readFrom (*relativePath, 0); } else { RelativePointPath rp (path); - rp.writeTo (tree, 0); + v.readFrom (rp, 0); } return tree; diff --git a/src/gui/graphics/drawables/juce_DrawablePath.h b/src/gui/graphics/drawables/juce_DrawablePath.h index 84c65bdf45..fd21612703 100644 --- a/src/gui/graphics/drawables/juce_DrawablePath.h +++ b/src/gui/graphics/drawables/juce_DrawablePath.h @@ -27,6 +27,7 @@ #define __JUCE_DRAWABLEPATH_JUCEHEADER__ #include "juce_DrawableShape.h" +#include "../../components/positioning/juce_RelativePointPath.h" //============================================================================== @@ -54,6 +55,9 @@ public: */ void setPath (const Path& newPath); + /** */ + void setPath (const RelativePointPath& source); + /** Returns the current path. */ const Path& getPath() const; @@ -120,6 +124,9 @@ public: ValueTree getPathState(); + void readFrom (const RelativePointPath& path, UndoManager* undoManager); + void writeTo (RelativePointPath& path) const; + static const Identifier nonZeroWinding, point1, point2, point3; }; @@ -128,7 +135,10 @@ protected: private: //============================================================================== - ScopedPointer relativePath; + class RelativePositioner; + friend class RelativePositioner; + void applyRelativePath (const RelativePointPath& newPath); + const RelativePointPath* getRelativePath() const; DrawablePath& operator= (const DrawablePath&); JUCE_LEAK_DETECTOR (DrawablePath); diff --git a/src/gui/graphics/drawables/juce_DrawableRectangle.h b/src/gui/graphics/drawables/juce_DrawableRectangle.h index 28a019bf6d..9dca2b4976 100644 --- a/src/gui/graphics/drawables/juce_DrawableRectangle.h +++ b/src/gui/graphics/drawables/juce_DrawableRectangle.h @@ -27,6 +27,7 @@ #define __JUCE_DRAWABLERECTANGLE_JUCEHEADER__ #include "juce_DrawableShape.h" +#include "../../components/positioning/juce_RelativeParallelogram.h" //============================================================================== diff --git a/src/gui/graphics/drawables/juce_DrawableShape.h b/src/gui/graphics/drawables/juce_DrawableShape.h index 8a4baefcad..f155ae76c6 100644 --- a/src/gui/graphics/drawables/juce_DrawableShape.h +++ b/src/gui/graphics/drawables/juce_DrawableShape.h @@ -29,6 +29,7 @@ #include "juce_Drawable.h" #include "../contexts/juce_FillType.h" #include "../colour/juce_ColourGradient.h" +#include "../../components/positioning/juce_RelativePoint.h" //============================================================================== diff --git a/src/gui/graphics/drawables/juce_DrawableText.h b/src/gui/graphics/drawables/juce_DrawableText.h index 6288262dd9..fee6dd477a 100644 --- a/src/gui/graphics/drawables/juce_DrawableText.h +++ b/src/gui/graphics/drawables/juce_DrawableText.h @@ -28,6 +28,7 @@ #include "juce_Drawable.h" #include "../fonts/juce_GlyphArrangement.h" +#include "../../components/positioning/juce_RelativeParallelogram.h" //============================================================================== diff --git a/src/gui/graphics/geometry/juce_RelativeCoordinate.cpp b/src/gui/graphics/geometry/juce_RelativeCoordinate.cpp deleted file mode 100644 index 59f89c1d08..0000000000 --- a/src/gui/graphics/geometry/juce_RelativeCoordinate.cpp +++ /dev/null @@ -1,1017 +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_RelativeCoordinate.h" -#include "../drawables/juce_DrawablePath.h" -#include "../../components/layout/juce_MarkerList.h" -#include "../../../io/streams/juce_MemoryOutputStream.h" - - -//============================================================================== -namespace RelativeCoordinateHelpers -{ - void skipComma (const juce_wchar* const s, int& i) - { - while (CharacterFunctions::isWhitespace (s[i])) - ++i; - - if (s[i] == ',') - ++i; - } -} - -//============================================================================== -class RelativeComponentPositioner : public Component::Positioner, - public ComponentListener, - public MarkerList::Listener, - public Expression::EvaluationContext -{ -public: - RelativeComponentPositioner (Component& component_) - : Component::Positioner (component_), registeredOk (false) - { - } - - ~RelativeComponentPositioner() - { - unregisterListeners(); - } - - const Expression getSymbolValue (const String& objectName, const String& member) const - { - jassert (objectName.isNotEmpty()); - - if (member.isNotEmpty()) - { - const Component* comp = getSourceComponent (objectName); - - if (comp == 0) - { - if (objectName == RelativeCoordinate::Strings::parent) - comp = getComponent().getParentComponent(); - else if (objectName == RelativeCoordinate::Strings::this_ || objectName == getComponent().getComponentID()) - comp = &getComponent(); - } - - if (comp != 0) - { - if (member == RelativeCoordinate::Strings::left) return xToExpression (comp, 0); - if (member == RelativeCoordinate::Strings::right) return xToExpression (comp, comp->getWidth()); - if (member == RelativeCoordinate::Strings::top) return yToExpression (comp, 0); - if (member == RelativeCoordinate::Strings::bottom) return yToExpression (comp, comp->getHeight()); - } - } - - for (int i = sourceMarkerLists.size(); --i >= 0;) - { - MarkerList* const markerList = sourceMarkerLists.getUnchecked(i); - const MarkerList::Marker* const marker = markerList->getMarker (objectName); - - if (marker != 0) - return marker->position.getExpression(); - } - - return Expression::EvaluationContext::getSymbolValue (objectName, member); - } - - void componentMovedOrResized (Component&, bool /*wasMoved*/, bool /*wasResized*/) - { - apply(); - } - - void componentParentHierarchyChanged (Component&) - { - apply(); - } - - void componentBeingDeleted (Component& component) - { - jassert (sourceComponents.contains (&component)); - sourceComponents.removeValue (&component); - } - - void markersChanged (MarkerList*) - { - apply(); - } - - void markerListBeingDeleted (MarkerList* markerList) - { - jassert (sourceMarkerLists.contains (markerList)); - sourceMarkerLists.removeValue (markerList); - } - - void apply() - { - if (! registeredOk) - { - unregisterListeners(); - registeredOk = registerCoordinates(); - } - - applyToComponentBounds(); - } - -protected: - bool addCoordinate (const RelativeCoordinate& coord) - { - return registerListeners (coord.getExpression()); - } - - virtual bool registerCoordinates() = 0; - virtual void applyToComponentBounds() = 0; - -private: - Array sourceComponents; - Array sourceMarkerLists; - bool registeredOk; - - bool registerListeners (const Expression& e) - { - bool ok = true; - - if (e.getType() == Expression::symbolType) - { - String objectName, memberName; - e.getSymbolParts (objectName, memberName); - - if (memberName.isNotEmpty()) - ok = registerComponent (objectName) && ok; - else - ok = registerMarker (objectName) && ok; - } - else - { - for (int i = e.getNumInputs(); --i >= 0;) - ok = registerListeners (e.getInput (i)) && ok; - } - - return ok; - } - - bool registerComponent (const String& componentID) - { - Component* comp = findComponent (componentID); - - if (comp == 0) - { - if (componentID == RelativeCoordinate::Strings::parent) - comp = getComponent().getParentComponent(); - else if (componentID == RelativeCoordinate::Strings::this_ || componentID == getComponent().getComponentID()) - comp = &getComponent(); - } - - if (comp != 0) - { - if (comp != &getComponent()) - registerComponentListener (comp); - - return true; - } - else - { - // The component we want doesn't exist, so watch the parent in case the hierarchy changes and it appears later.. - Component* const parent = getComponent().getParentComponent(); - - if (parent != 0) - registerComponentListener (parent); - else - registerComponentListener (&getComponent()); - - return false; - } - } - - bool registerMarker (const String markerName) - { - Component* const parent = getComponent().getParentComponent(); - - if (parent != 0) - { - MarkerList* list = parent->getMarkers (true); - - if (list == 0 || list->getMarker (markerName) == 0) - list = parent->getMarkers (false); - - if (list != 0 && list->getMarker (markerName) != 0) - { - registerMarkerListListener (list); - return true; - } - else - { - // The marker we want doesn't exist, so watch all lists in case they change and the marker appears later.. - registerMarkerListListener (parent->getMarkers (true)); - registerMarkerListListener (parent->getMarkers (false)); - } - } - - return false; - } - - void registerComponentListener (Component* const comp) - { - if (comp != 0 && ! sourceComponents.contains (comp)) - { - comp->addComponentListener (this); - sourceComponents.add (comp); - } - } - - void registerMarkerListListener (MarkerList* const list) - { - if (list != 0 && ! sourceMarkerLists.contains (list)) - { - list->addListener (this); - sourceMarkerLists.add (list); - } - } - - void unregisterListeners() - { - int i; - for (i = sourceComponents.size(); --i >= 0;) - sourceComponents.getUnchecked(i)->removeComponentListener (this); - - for (i = sourceMarkerLists.size(); --i >= 0;) - sourceMarkerLists.getUnchecked(i)->removeListener (this); - - sourceComponents.clear(); - sourceMarkerLists.clear(); - } - - Component* findComponent (const String& componentID) const - { - Component* const parent = getComponent().getParentComponent(); - - if (parent != 0) - { - for (int i = parent->getNumChildComponents(); --i >= 0;) - { - Component* const c = parent->getChildComponent(i); - - if (c->getComponentID() == componentID) - return c; - } - } - - return 0; - } - - Component* getSourceComponent (const String& objectName) const - { - for (int i = sourceComponents.size(); --i >= 0;) - { - Component* const comp = sourceComponents.getUnchecked(i); - - if (comp->getComponentID() == objectName) - return comp; - } - - return 0; - } - - const Expression xToExpression (const Component* const source, const int x) const - { - return Expression ((double) (getComponent().getLocalPoint (source, Point (x, 0)).getX() + getComponent().getX())); - } - - const Expression yToExpression (const Component* const source, const int y) const - { - return Expression ((double) (getComponent().getLocalPoint (source, Point (0, y)).getY() + getComponent().getY())); - } - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeComponentPositioner); -}; - - -//============================================================================== -const String RelativeCoordinate::Strings::parent ("parent"); -const String RelativeCoordinate::Strings::this_ ("this"); -const String RelativeCoordinate::Strings::left ("left"); -const String RelativeCoordinate::Strings::right ("right"); -const String RelativeCoordinate::Strings::top ("top"); -const String RelativeCoordinate::Strings::bottom ("bottom"); -const String RelativeCoordinate::Strings::parentLeft ("parent.left"); -const String RelativeCoordinate::Strings::parentTop ("parent.top"); -const String RelativeCoordinate::Strings::parentRight ("parent.right"); -const String RelativeCoordinate::Strings::parentBottom ("parent.bottom"); - -//============================================================================== -RelativeCoordinate::RelativeCoordinate() -{ -} - -RelativeCoordinate::RelativeCoordinate (const Expression& term_) - : term (term_) -{ -} - -RelativeCoordinate::RelativeCoordinate (const RelativeCoordinate& other) - : term (other.term) -{ -} - -RelativeCoordinate& RelativeCoordinate::operator= (const RelativeCoordinate& other) -{ - term = other.term; - return *this; -} - -RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin) - : term (absoluteDistanceFromOrigin) -{ -} - -RelativeCoordinate::RelativeCoordinate (const String& s) -{ - try - { - term = Expression (s); - } - catch (...) - {} -} - -RelativeCoordinate::~RelativeCoordinate() -{ -} - -bool RelativeCoordinate::operator== (const RelativeCoordinate& other) const throw() -{ - return term.toString() == other.term.toString(); -} - -bool RelativeCoordinate::operator!= (const RelativeCoordinate& other) const throw() -{ - return ! operator== (other); -} - -double RelativeCoordinate::resolve (const Expression::EvaluationContext* context) const -{ - try - { - if (context != 0) - return term.evaluate (*context); - else - return term.evaluate(); - } - catch (...) - {} - - return 0.0; -} - -bool RelativeCoordinate::isRecursive (const Expression::EvaluationContext* context) const -{ - try - { - if (context != 0) - term.evaluate (*context); - else - term.evaluate(); - } - catch (...) - { - return true; - } - - return false; -} - -void RelativeCoordinate::moveToAbsolute (double newPos, const Expression::EvaluationContext* context) -{ - try - { - if (context != 0) - { - term = term.adjustedToGiveNewResult (newPos, *context); - } - else - { - Expression::EvaluationContext defaultContext; - term = term.adjustedToGiveNewResult (newPos, defaultContext); - } - } - catch (...) - {} -} - -bool RelativeCoordinate::references (const String& coordName, const Expression::EvaluationContext* context) const -{ - try - { - return term.referencesSymbol (coordName, context); - } - catch (...) - {} - - return false; -} - -bool RelativeCoordinate::isDynamic() const -{ - return term.usesAnySymbols(); -} - -const String RelativeCoordinate::toString() const -{ - return term.toString(); -} - -void RelativeCoordinate::renameSymbolIfUsed (const String& oldName, const String& newName) -{ - jassert (newName.isNotEmpty() && newName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_")); - - if (term.referencesSymbol (oldName, 0)) - term = term.withRenamedSymbol (oldName, newName); -} - -//============================================================================== -RelativePoint::RelativePoint() -{ -} - -RelativePoint::RelativePoint (const Point& absolutePoint) - : x (absolutePoint.getX()), y (absolutePoint.getY()) -{ -} - -RelativePoint::RelativePoint (const float x_, const float y_) - : x (x_), y (y_) -{ -} - -RelativePoint::RelativePoint (const RelativeCoordinate& x_, const RelativeCoordinate& y_) - : x (x_), y (y_) -{ -} - -RelativePoint::RelativePoint (const String& s) -{ - int i = 0; - x = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); - y = RelativeCoordinate (Expression::parse (s, i)); -} - -bool RelativePoint::operator== (const RelativePoint& other) const throw() -{ - return x == other.x && y == other.y; -} - -bool RelativePoint::operator!= (const RelativePoint& other) const throw() -{ - return ! operator== (other); -} - -const Point RelativePoint::resolve (const Expression::EvaluationContext* context) const -{ - return Point ((float) x.resolve (context), - (float) y.resolve (context)); -} - -void RelativePoint::moveToAbsolute (const Point& newPos, const Expression::EvaluationContext* context) -{ - x.moveToAbsolute (newPos.getX(), context); - y.moveToAbsolute (newPos.getY(), context); -} - -const String RelativePoint::toString() const -{ - return x.toString() + ", " + y.toString(); -} - -void RelativePoint::renameSymbolIfUsed (const String& oldName, const String& newName) -{ - x.renameSymbolIfUsed (oldName, newName); - y.renameSymbolIfUsed (oldName, newName); -} - -bool RelativePoint::isDynamic() const -{ - return x.isDynamic() || y.isDynamic(); -} - - -//============================================================================== -RelativeRectangle::RelativeRectangle() -{ -} - -RelativeRectangle::RelativeRectangle (const RelativeCoordinate& left_, const RelativeCoordinate& right_, - const RelativeCoordinate& top_, const RelativeCoordinate& bottom_) - : left (left_), right (right_), top (top_), bottom (bottom_) -{ -} - -RelativeRectangle::RelativeRectangle (const Rectangle& rect, const String& componentName) - : left (rect.getX()), - right (Expression::symbol (componentName + "." + RelativeCoordinate::Strings::left) + Expression ((double) rect.getWidth())), - top (rect.getY()), - bottom (Expression::symbol (componentName + "." + RelativeCoordinate::Strings::top) + Expression ((double) rect.getHeight())) -{ -} - -RelativeRectangle::RelativeRectangle (const String& s) -{ - int i = 0; - left = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); - top = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); - right = RelativeCoordinate (Expression::parse (s, i)); - RelativeCoordinateHelpers::skipComma (s, i); - bottom = RelativeCoordinate (Expression::parse (s, i)); -} - -bool RelativeRectangle::operator== (const RelativeRectangle& other) const throw() -{ - return left == other.left && top == other.top && right == other.right && bottom == other.bottom; -} - -bool RelativeRectangle::operator!= (const RelativeRectangle& other) const throw() -{ - return ! operator== (other); -} - -const Rectangle RelativeRectangle::resolve (const Expression::EvaluationContext* context) const -{ - const double l = left.resolve (context); - const double r = right.resolve (context); - const double t = top.resolve (context); - const double b = bottom.resolve (context); - - return Rectangle ((float) l, (float) t, (float) jmax (0.0, r - l), (float) jmax (0.0, b - t)); -} - -void RelativeRectangle::moveToAbsolute (const Rectangle& newPos, const Expression::EvaluationContext* context) -{ - left.moveToAbsolute (newPos.getX(), context); - right.moveToAbsolute (newPos.getRight(), context); - top.moveToAbsolute (newPos.getY(), context); - bottom.moveToAbsolute (newPos.getBottom(), context); -} - -bool RelativeRectangle::isDynamic() const -{ - return left.isDynamic() || right.isDynamic() || top.isDynamic() || bottom.isDynamic(); -} - -const String RelativeRectangle::toString() const -{ - return left.toString() + ", " + top.toString() + ", " + right.toString() + ", " + bottom.toString(); -} - -void RelativeRectangle::renameSymbolIfUsed (const String& oldName, const String& newName) -{ - left.renameSymbolIfUsed (oldName, newName); - right.renameSymbolIfUsed (oldName, newName); - top.renameSymbolIfUsed (oldName, newName); - bottom.renameSymbolIfUsed (oldName, newName); -} - - -//============================================================================== -class RelativeRectangleComponentPositioner : public RelativeComponentPositioner -{ -public: - RelativeRectangleComponentPositioner (Component& component_, const RelativeRectangle& rectangle_) - : RelativeComponentPositioner (component_), - rectangle (rectangle_) - { - } - - bool registerCoordinates() - { - bool ok = addCoordinate (rectangle.left); - ok = addCoordinate (rectangle.right) && ok; - ok = addCoordinate (rectangle.top) && ok; - ok = addCoordinate (rectangle.bottom) && ok; - return ok; - } - - bool isUsingRectangle (const RelativeRectangle& other) const throw() - { - return rectangle == other; - } - - void applyToComponentBounds() - { - for (int i = 4; --i >= 0;) - { - const Rectangle newBounds (rectangle.resolve (this).getSmallestIntegerContainer()); - - if (newBounds == getComponent().getBounds()) - return; - - getComponent().setBounds (newBounds); - } - - jassertfalse; // must be a recursive reference! - } - -private: - const RelativeRectangle rectangle; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RelativeRectangleComponentPositioner); -}; - -void RelativeRectangle::applyToComponent (Component& component) const -{ - if (isDynamic()) - { - RelativeRectangleComponentPositioner* current = dynamic_cast (component.getPositioner()); - - if (current == 0 || ! current->isUsingRectangle (*this)) - { - RelativeRectangleComponentPositioner* p = new RelativeRectangleComponentPositioner (component, *this); - - component.setPositioner (p); - p->apply(); - } - } - else - { - component.setPositioner (0); - component.setBounds (resolve (0).getSmallestIntegerContainer()); - } -} - - -//============================================================================== -RelativePointPath::RelativePointPath() - : usesNonZeroWinding (true), - containsDynamicPoints (false) -{ -} - -RelativePointPath::RelativePointPath (const RelativePointPath& other) - : usesNonZeroWinding (true), - containsDynamicPoints (false) -{ - ValueTree state (DrawablePath::valueTreeType); - other.writeTo (state, 0); - parse (state); -} - -RelativePointPath::RelativePointPath (const ValueTree& drawable) - : usesNonZeroWinding (true), - containsDynamicPoints (false) -{ - parse (drawable); -} - -RelativePointPath::RelativePointPath (const Path& path) -{ - usesNonZeroWinding = path.isUsingNonZeroWinding(); - - Path::Iterator i (path); - - while (i.next()) - { - switch (i.elementType) - { - case Path::Iterator::startNewSubPath: elements.add (new StartSubPath (RelativePoint (i.x1, i.y1))); break; - case Path::Iterator::lineTo: elements.add (new LineTo (RelativePoint (i.x1, i.y1))); break; - case Path::Iterator::quadraticTo: elements.add (new QuadraticTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2))); break; - case Path::Iterator::cubicTo: elements.add (new CubicTo (RelativePoint (i.x1, i.y1), RelativePoint (i.x2, i.y2), RelativePoint (i.x3, i.y3))); break; - case Path::Iterator::closePath: elements.add (new CloseSubPath()); break; - default: jassertfalse; break; - } - } -} - -void RelativePointPath::writeTo (ValueTree state, UndoManager* undoManager) const -{ - DrawablePath::ValueTreeWrapper wrapper (state); - wrapper.setUsesNonZeroWinding (usesNonZeroWinding, undoManager); - - ValueTree pathTree (wrapper.getPathState()); - pathTree.removeAllChildren (undoManager); - - for (int i = 0; i < elements.size(); ++i) - pathTree.addChild (elements.getUnchecked(i)->createTree(), -1, undoManager); -} - -void RelativePointPath::parse (const ValueTree& state) -{ - DrawablePath::ValueTreeWrapper wrapper (state); - usesNonZeroWinding = wrapper.usesNonZeroWinding(); - RelativePoint points[3]; - - const ValueTree pathTree (wrapper.getPathState()); - const int num = pathTree.getNumChildren(); - for (int i = 0; i < num; ++i) - { - const DrawablePath::ValueTreeWrapper::Element e (pathTree.getChild(i)); - - const int numCps = e.getNumControlPoints(); - for (int j = 0; j < numCps; ++j) - { - points[j] = e.getControlPoint (j); - containsDynamicPoints = containsDynamicPoints || points[j].isDynamic(); - } - - const Identifier type (e.getType()); - - if (type == DrawablePath::ValueTreeWrapper::Element::startSubPathElement) - elements.add (new StartSubPath (points[0])); - else if (type == DrawablePath::ValueTreeWrapper::Element::closeSubPathElement) - elements.add (new CloseSubPath()); - else if (type == DrawablePath::ValueTreeWrapper::Element::lineToElement) - elements.add (new LineTo (points[0])); - else if (type == DrawablePath::ValueTreeWrapper::Element::quadraticToElement) - elements.add (new QuadraticTo (points[0], points[1])); - else if (type == DrawablePath::ValueTreeWrapper::Element::cubicToElement) - elements.add (new CubicTo (points[0], points[1], points[2])); - else - jassertfalse; - } -} - -RelativePointPath::~RelativePointPath() -{ -} - -void RelativePointPath::swapWith (RelativePointPath& other) throw() -{ - elements.swapWithArray (other.elements); - swapVariables (usesNonZeroWinding, other.usesNonZeroWinding); -} - -void RelativePointPath::createPath (Path& path, Expression::EvaluationContext* coordFinder) -{ - for (int i = 0; i < elements.size(); ++i) - elements.getUnchecked(i)->addToPath (path, coordFinder); -} - -bool RelativePointPath::containsAnyDynamicPoints() const -{ - return containsDynamicPoints; -} - -//============================================================================== -RelativePointPath::ElementBase::ElementBase (const ElementType type_) : type (type_) -{ -} - -//============================================================================== -RelativePointPath::StartSubPath::StartSubPath (const RelativePoint& pos) - : ElementBase (startSubPathElement), startPos (pos) -{ -} - -const ValueTree RelativePointPath::StartSubPath::createTree() const -{ - ValueTree v (DrawablePath::ValueTreeWrapper::Element::startSubPathElement); - v.setProperty (DrawablePath::ValueTreeWrapper::point1, startPos.toString(), 0); - return v; -} - -void RelativePointPath::StartSubPath::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const -{ - path.startNewSubPath (startPos.resolve (coordFinder)); -} - -RelativePoint* RelativePointPath::StartSubPath::getControlPoints (int& numPoints) -{ - numPoints = 1; - return &startPos; -} - -//============================================================================== -RelativePointPath::CloseSubPath::CloseSubPath() - : ElementBase (closeSubPathElement) -{ -} - -const ValueTree RelativePointPath::CloseSubPath::createTree() const -{ - return ValueTree (DrawablePath::ValueTreeWrapper::Element::closeSubPathElement); -} - -void RelativePointPath::CloseSubPath::addToPath (Path& path, Expression::EvaluationContext*) const -{ - path.closeSubPath(); -} - -RelativePoint* RelativePointPath::CloseSubPath::getControlPoints (int& numPoints) -{ - numPoints = 0; - return 0; -} - -//============================================================================== -RelativePointPath::LineTo::LineTo (const RelativePoint& endPoint_) - : ElementBase (lineToElement), endPoint (endPoint_) -{ -} - -const ValueTree RelativePointPath::LineTo::createTree() const -{ - ValueTree v (DrawablePath::ValueTreeWrapper::Element::lineToElement); - v.setProperty (DrawablePath::ValueTreeWrapper::point1, endPoint.toString(), 0); - return v; -} - -void RelativePointPath::LineTo::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const -{ - path.lineTo (endPoint.resolve (coordFinder)); -} - -RelativePoint* RelativePointPath::LineTo::getControlPoints (int& numPoints) -{ - numPoints = 1; - return &endPoint; -} - -//============================================================================== -RelativePointPath::QuadraticTo::QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint) - : ElementBase (quadraticToElement) -{ - controlPoints[0] = controlPoint; - controlPoints[1] = endPoint; -} - -const ValueTree RelativePointPath::QuadraticTo::createTree() const -{ - ValueTree v (DrawablePath::ValueTreeWrapper::Element::quadraticToElement); - v.setProperty (DrawablePath::ValueTreeWrapper::point1, controlPoints[0].toString(), 0); - v.setProperty (DrawablePath::ValueTreeWrapper::point2, controlPoints[1].toString(), 0); - return v; -} - -void RelativePointPath::QuadraticTo::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const -{ - path.quadraticTo (controlPoints[0].resolve (coordFinder), - controlPoints[1].resolve (coordFinder)); -} - -RelativePoint* RelativePointPath::QuadraticTo::getControlPoints (int& numPoints) -{ - numPoints = 2; - return controlPoints; -} - -//============================================================================== -RelativePointPath::CubicTo::CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint) - : ElementBase (cubicToElement) -{ - controlPoints[0] = controlPoint1; - controlPoints[1] = controlPoint2; - controlPoints[2] = endPoint; -} - -const ValueTree RelativePointPath::CubicTo::createTree() const -{ - ValueTree v (DrawablePath::ValueTreeWrapper::Element::cubicToElement); - v.setProperty (DrawablePath::ValueTreeWrapper::point1, controlPoints[0].toString(), 0); - v.setProperty (DrawablePath::ValueTreeWrapper::point2, controlPoints[1].toString(), 0); - v.setProperty (DrawablePath::ValueTreeWrapper::point3, controlPoints[2].toString(), 0); - return v; -} - -void RelativePointPath::CubicTo::addToPath (Path& path, Expression::EvaluationContext* coordFinder) const -{ - path.cubicTo (controlPoints[0].resolve (coordFinder), - controlPoints[1].resolve (coordFinder), - controlPoints[2].resolve (coordFinder)); -} - -RelativePoint* RelativePointPath::CubicTo::getControlPoints (int& numPoints) -{ - numPoints = 3; - return controlPoints; -} - - -//============================================================================== -RelativeParallelogram::RelativeParallelogram() -{ -} - -RelativeParallelogram::RelativeParallelogram (const Rectangle& r) - : topLeft (r.getTopLeft()), topRight (r.getTopRight()), bottomLeft (r.getBottomLeft()) -{ -} - -RelativeParallelogram::RelativeParallelogram (const RelativePoint& topLeft_, const RelativePoint& topRight_, const RelativePoint& bottomLeft_) - : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_) -{ -} - -RelativeParallelogram::RelativeParallelogram (const String& topLeft_, const String& topRight_, const String& bottomLeft_) - : topLeft (topLeft_), topRight (topRight_), bottomLeft (bottomLeft_) -{ -} - -RelativeParallelogram::~RelativeParallelogram() -{ -} - -void RelativeParallelogram::resolveThreePoints (Point* points, Expression::EvaluationContext* const coordFinder) const -{ - points[0] = topLeft.resolve (coordFinder); - points[1] = topRight.resolve (coordFinder); - points[2] = bottomLeft.resolve (coordFinder); -} - -void RelativeParallelogram::resolveFourCorners (Point* points, Expression::EvaluationContext* const coordFinder) const -{ - resolveThreePoints (points, coordFinder); - points[3] = points[1] + (points[2] - points[0]); -} - -const Rectangle RelativeParallelogram::getBounds (Expression::EvaluationContext* const coordFinder) const -{ - Point points[4]; - resolveFourCorners (points, coordFinder); - return Rectangle::findAreaContainingPoints (points, 4); -} - -void RelativeParallelogram::getPath (Path& path, Expression::EvaluationContext* const coordFinder) const -{ - Point points[4]; - resolveFourCorners (points, coordFinder); - - path.startNewSubPath (points[0]); - path.lineTo (points[1]); - path.lineTo (points[3]); - path.lineTo (points[2]); - path.closeSubPath(); -} - -const AffineTransform RelativeParallelogram::resetToPerpendicular (Expression::EvaluationContext* const coordFinder) -{ - Point corners[3]; - resolveThreePoints (corners, coordFinder); - - const Line top (corners[0], corners[1]); - const Line left (corners[0], corners[2]); - const Point newTopRight (corners[0] + Point (top.getLength(), 0.0f)); - const Point newBottomLeft (corners[0] + Point (0.0f, left.getLength())); - - topRight.moveToAbsolute (newTopRight, coordFinder); - bottomLeft.moveToAbsolute (newBottomLeft, coordFinder); - - return AffineTransform::fromTargetPoints (corners[0].getX(), corners[0].getY(), corners[0].getX(), corners[0].getY(), - corners[1].getX(), corners[1].getY(), newTopRight.getX(), newTopRight.getY(), - corners[2].getX(), corners[2].getY(), newBottomLeft.getX(), newBottomLeft.getY()); -} - -bool RelativeParallelogram::operator== (const RelativeParallelogram& other) const throw() -{ - return topLeft == other.topLeft && topRight == other.topRight && bottomLeft == other.bottomLeft; -} - -bool RelativeParallelogram::operator!= (const RelativeParallelogram& other) const throw() -{ - return ! operator== (other); -} - -const Point RelativeParallelogram::getInternalCoordForPoint (const Point* const corners, Point target) throw() -{ - const Point tr (corners[1] - corners[0]); - const Point bl (corners[2] - corners[0]); - target -= corners[0]; - - return Point (Line (Point(), tr).getIntersection (Line (target, target - bl)).getDistanceFromOrigin(), - Line (Point(), bl).getIntersection (Line (target, target - tr)).getDistanceFromOrigin()); -} - -const Point RelativeParallelogram::getPointForInternalCoord (const Point* const corners, const Point& point) throw() -{ - return corners[0] - + Line (Point(), corners[1] - corners[0]).getPointAlongLine (point.getX()) - + Line (Point(), corners[2] - corners[0]).getPointAlongLine (point.getY()); -} - - -END_JUCE_NAMESPACE diff --git a/src/gui/graphics/geometry/juce_RelativeCoordinate.h b/src/gui/graphics/geometry/juce_RelativeCoordinate.h deleted file mode 100644 index dc26ac3f7d..0000000000 --- a/src/gui/graphics/geometry/juce_RelativeCoordinate.h +++ /dev/null @@ -1,462 +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_RELATIVECOORDINATE_JUCEHEADER__ -#define __JUCE_RELATIVECOORDINATE_JUCEHEADER__ - -#include "juce_Path.h" -#include "juce_Rectangle.h" -#include "../../../maths/juce_Expression.h" -#include "../../../containers/juce_OwnedArray.h" -#include "../../../containers/juce_ValueTree.h" -class Component; - - -//============================================================================== -/** - Expresses a coordinate as a dynamically evaluated expression. - - @see RelativePoint, RelativeRectangle -*/ -class JUCE_API RelativeCoordinate -{ -public: - //============================================================================== - /** Creates a zero coordinate. */ - RelativeCoordinate(); - RelativeCoordinate (const Expression& expression); - RelativeCoordinate (const RelativeCoordinate& other); - RelativeCoordinate& operator= (const RelativeCoordinate& other); - - /** Creates an absolute position from the parent origin on either the X or Y axis. - - @param absoluteDistanceFromOrigin the distance from the origin - */ - RelativeCoordinate (double absoluteDistanceFromOrigin); - - /** Recreates a coordinate from a string description. - The string will be parsed by ExpressionParser::parse(). - @param stringVersion the expression to use - @see toString - */ - RelativeCoordinate (const String& stringVersion); - - /** Destructor. */ - ~RelativeCoordinate(); - - bool operator== (const RelativeCoordinate& other) const throw(); - bool operator!= (const RelativeCoordinate& other) const throw(); - - //============================================================================== - /** Calculates the absolute position of this coordinate. - - You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may - be needed to calculate the result. - */ - double resolve (const Expression::EvaluationContext* evaluationContext) const; - - /** Returns true if this coordinate uses the specified coord name at any level in its evaluation. - This will recursively check any coordinates upon which this one depends. - */ - bool references (const String& coordName, const Expression::EvaluationContext* evaluationContext) const; - - /** Returns true if there's a recursive loop when trying to resolve this coordinate's position. */ - bool isRecursive (const Expression::EvaluationContext* evaluationContext) const; - - /** Returns true if this coordinate depends on any other coordinates for its position. */ - bool isDynamic() const; - - //============================================================================== - /** Changes the value of this coord to make it resolve to the specified position. - - Calling this will leave the anchor points unchanged, but will set this coordinate's absolute - or relative position to whatever value is necessary to make its resultant position - match the position that is provided. - */ - void moveToAbsolute (double absoluteTargetPosition, const Expression::EvaluationContext* evaluationContext); - - /** Changes the name of a symbol if it is used as part of the coordinate's expression. */ - void renameSymbolIfUsed (const String& oldName, const String& newName); - - /** Returns the expression that defines this coordinate. */ - const Expression& getExpression() const { return term; } - - - //============================================================================== - /** Returns a string which represents this coordinate. - For details of the string syntax, see the constructor notes. - */ - const String toString() const; - - //============================================================================== - /** A set of static strings that are commonly used by the RelativeCoordinate class. - - As well as avoiding using string literals in your code, using these preset values - has the advantage that all instances of the same string will share the same, reference-counted - String object, so if you have thousands of points which all refer to the same - anchor points, this can save a significant amount of memory allocation. - */ - struct Strings - { - static const String parent; /**< "parent" */ - static const String this_; /**< "this" */ - static const String left; /**< "left" */ - static const String right; /**< "right" */ - static const String top; /**< "top" */ - static const String bottom; /**< "bottom" */ - static const String parentLeft; /**< "parent.left" */ - static const String parentTop; /**< "parent.top" */ - static const String parentRight; /**< "parent.right" */ - static const String parentBottom; /**< "parent.bottom" */ - }; - -private: - //============================================================================== - Expression term; -}; - - -//============================================================================== -/** - An X-Y position stored as a pair of RelativeCoordinate values. - - @see RelativeCoordinate, RelativeRectangle -*/ -class JUCE_API RelativePoint -{ -public: - /** Creates a point at the origin. */ - RelativePoint(); - - /** Creates an absolute point, relative to the origin. */ - RelativePoint (const Point& absolutePoint); - - /** Creates an absolute point, relative to the origin. */ - RelativePoint (float absoluteX, float absoluteY); - - /** Creates an absolute point from two coordinates. */ - RelativePoint (const RelativeCoordinate& x, const RelativeCoordinate& y); - - /** Creates a point from a stringified representation. - The string must contain a pair of coordinates, separated by space or a comma. The syntax for the coordinate - strings is explained in the RelativeCoordinate class. - @see toString - */ - RelativePoint (const String& stringVersion); - - bool operator== (const RelativePoint& other) const throw(); - bool operator!= (const RelativePoint& other) const throw(); - - /** Calculates the absolute position of this point. - - You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may - be needed to calculate the result. - */ - const Point resolve (const Expression::EvaluationContext* evaluationContext) const; - - /** Changes the values of this point's coordinates to make it resolve to the specified position. - - Calling this will leave any anchor points unchanged, but will set any absolute - or relative positions to whatever values are necessary to make the resultant position - match the position that is provided. - */ - void moveToAbsolute (const Point& newPos, const Expression::EvaluationContext* evaluationContext); - - /** Returns a string which represents this point. - This returns a comma-separated pair of coordinates. For details of the string syntax used by the - coordinates, see the RelativeCoordinate constructor notes. - The string that is returned can be passed to the RelativePoint constructor to recreate the point. - */ - const String toString() const; - - /** Renames a symbol if it is used by any of the coordinates. - This calls RelativeCoordinate::renameAnchorIfUsed() on its X and Y coordinates. - */ - void renameSymbolIfUsed (const String& oldName, const String& newName); - - /** Returns true if this point depends on any other coordinates for its position. */ - bool isDynamic() const; - - // The actual X and Y coords... - RelativeCoordinate x, y; -}; - - -//============================================================================== -/** - An rectangle stored as a set of RelativeCoordinate values. - - The rectangle's top, left, bottom and right edge positions are each stored as a RelativeCoordinate. - - @see RelativeCoordinate, RelativePoint -*/ -class JUCE_API RelativeRectangle -{ -public: - //============================================================================== - /** Creates a zero-size rectangle at the origin. */ - RelativeRectangle(); - - /** Creates an absolute rectangle, relative to the origin. */ - explicit RelativeRectangle (const Rectangle& rect, const String& componentName); - - /** Creates a rectangle from four coordinates. */ - RelativeRectangle (const RelativeCoordinate& left, const RelativeCoordinate& right, - const RelativeCoordinate& top, const RelativeCoordinate& bottom); - - /** Creates a rectangle from a stringified representation. - The string must contain a sequence of 4 coordinates, separated by commas, in the order - left, top, right, bottom. The syntax for the coordinate strings is explained in the - RelativeCoordinate class. - @see toString - */ - explicit RelativeRectangle (const String& stringVersion); - - bool operator== (const RelativeRectangle& other) const throw(); - bool operator!= (const RelativeRectangle& other) const throw(); - - //============================================================================== - /** Calculates the absolute position of this rectangle. - - You'll need to provide a suitable Expression::EvaluationContext for looking up any coordinates that may - be needed to calculate the result. - */ - const Rectangle resolve (const Expression::EvaluationContext* evaluationContext) const; - - /** Changes the values of this rectangle's coordinates to make it resolve to the specified position. - - Calling this will leave any anchor points unchanged, but will set any absolute - or relative positions to whatever values are necessary to make the resultant position - match the position that is provided. - */ - void moveToAbsolute (const Rectangle& newPos, const Expression::EvaluationContext* evaluationContext); - - /** Returns true if this rectangle depends on any other coordinates for its position. */ - bool isDynamic() const; - - /** Returns a string which represents this point. - This returns a comma-separated list of coordinates, in the order left, top, right, bottom. For details of - the string syntax used by the coordinates, see the RelativeCoordinate constructor notes. - The string that is returned can be passed to the RelativeRectangle constructor to recreate the rectangle. - */ - const String toString() const; - - /** Renames a symbol if it is used by any of the coordinates. - This calls RelativeCoordinate::renameSymbolIfUsed() on the rectangle's coordinates. - */ - void renameSymbolIfUsed (const String& oldName, const String& newName); - - /** */ - void applyToComponent (Component& component) const; - - // The actual rectangle coords... - RelativeCoordinate left, right, top, bottom; -}; - - -//============================================================================== -/** - A path object that consists of RelativePoint coordinates rather than the normal fixed ones. - - One of these paths can be converted into a Path object for drawing and manipulation, but - unlike a Path, its points can be dynamic instead of just fixed. - - @see RelativePoint, RelativeCoordinate -*/ -class JUCE_API RelativePointPath -{ -public: - //============================================================================== - RelativePointPath(); - RelativePointPath (const RelativePointPath& other); - RelativePointPath (const ValueTree& drawable); - RelativePointPath (const Path& path); - ~RelativePointPath(); - - //============================================================================== - /** Resolves this points in this path and adds them to a normal Path object. */ - void createPath (Path& path, Expression::EvaluationContext* coordFinder); - - /** Returns true if the path contains any non-fixed points. */ - bool containsAnyDynamicPoints() const; - - /** Writes the path to this drawable encoding. */ - void writeTo (ValueTree state, UndoManager* undoManager) const; - - /** Quickly swaps the contents of this path with another. */ - void swapWith (RelativePointPath& other) throw(); - - //============================================================================== - /** The types of element that may be contained in this path. - @see RelativePointPath::ElementBase - */ - enum ElementType - { - nullElement, - startSubPathElement, - closeSubPathElement, - lineToElement, - quadraticToElement, - cubicToElement - }; - - //============================================================================== - /** Base class for the elements that make up a RelativePointPath. - */ - class JUCE_API ElementBase - { - public: - ElementBase (ElementType type); - virtual ~ElementBase() {} - virtual const ValueTree createTree() const = 0; - virtual void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const = 0; - virtual RelativePoint* getControlPoints (int& numPoints) = 0; - - const ElementType type; - - private: - JUCE_DECLARE_NON_COPYABLE (ElementBase); - }; - - class JUCE_API StartSubPath : public ElementBase - { - public: - StartSubPath (const RelativePoint& pos); - ~StartSubPath() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint startPos; - - private: - JUCE_DECLARE_NON_COPYABLE (StartSubPath); - }; - - class JUCE_API CloseSubPath : public ElementBase - { - public: - CloseSubPath(); - ~CloseSubPath() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - private: - JUCE_DECLARE_NON_COPYABLE (CloseSubPath); - }; - - class JUCE_API LineTo : public ElementBase - { - public: - LineTo (const RelativePoint& endPoint); - ~LineTo() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint endPoint; - - private: - JUCE_DECLARE_NON_COPYABLE (LineTo); - }; - - class JUCE_API QuadraticTo : public ElementBase - { - public: - QuadraticTo (const RelativePoint& controlPoint, const RelativePoint& endPoint); - ~QuadraticTo() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint controlPoints[2]; - - private: - JUCE_DECLARE_NON_COPYABLE (QuadraticTo); - }; - - class JUCE_API CubicTo : public ElementBase - { - public: - CubicTo (const RelativePoint& controlPoint1, const RelativePoint& controlPoint2, const RelativePoint& endPoint); - ~CubicTo() {} - const ValueTree createTree() const; - void addToPath (Path& path, Expression::EvaluationContext* coordFinder) const; - RelativePoint* getControlPoints (int& numPoints); - - RelativePoint controlPoints[3]; - - private: - JUCE_DECLARE_NON_COPYABLE (CubicTo); - }; - - //============================================================================== - OwnedArray elements; - bool usesNonZeroWinding; - -private: - bool containsDynamicPoints; - - void parse (const ValueTree& state); - - RelativePointPath& operator= (const RelativePointPath&); -}; - -//============================================================================== -/** - A parallelogram defined by three RelativePoint positions. - - @see RelativePoint, RelativeCoordinate -*/ -class JUCE_API RelativeParallelogram -{ -public: - //============================================================================== - RelativeParallelogram(); - RelativeParallelogram (const Rectangle& simpleRectangle); - RelativeParallelogram (const RelativePoint& topLeft, const RelativePoint& topRight, const RelativePoint& bottomLeft); - RelativeParallelogram (const String& topLeft, const String& topRight, const String& bottomLeft); - ~RelativeParallelogram(); - - //============================================================================== - void resolveThreePoints (Point* points, Expression::EvaluationContext* coordFinder) const; - void resolveFourCorners (Point* points, Expression::EvaluationContext* coordFinder) const; - const Rectangle getBounds (Expression::EvaluationContext* coordFinder) const; - void getPath (Path& path, Expression::EvaluationContext* coordFinder) const; - const AffineTransform resetToPerpendicular (Expression::EvaluationContext* coordFinder); - - bool operator== (const RelativeParallelogram& other) const throw(); - bool operator!= (const RelativeParallelogram& other) const throw(); - - static const Point getInternalCoordForPoint (const Point* parallelogramCorners, Point point) throw(); - static const Point getPointForInternalCoord (const Point* parallelogramCorners, const Point& internalPoint) throw(); - - //============================================================================== - RelativePoint topLeft, topRight, bottomLeft; -}; - - -#endif // __JUCE_RELATIVECOORDINATE_JUCEHEADER__ diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index 89f0b7362b..722b3cd111 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -437,9 +437,6 @@ #ifndef __JUCE_GROUPCOMPONENT_JUCEHEADER__ #include "gui/components/layout/juce_GroupComponent.h" #endif -#ifndef __JUCE_MARKERLIST_JUCEHEADER__ - #include "gui/components/layout/juce_MarkerList.h" -#endif #ifndef __JUCE_MULTIDOCUMENTPANEL_JUCEHEADER__ #include "gui/components/layout/juce_MultiDocumentPanel.h" #endif @@ -521,6 +518,27 @@ #ifndef __JUCE_TOOLTIPCLIENT_JUCEHEADER__ #include "gui/components/mouse/juce_TooltipClient.h" #endif +#ifndef __JUCE_MARKERLIST_JUCEHEADER__ + #include "gui/components/positioning/juce_MarkerList.h" +#endif +#ifndef __JUCE_RELATIVECOORDINATE_JUCEHEADER__ + #include "gui/components/positioning/juce_RelativeCoordinate.h" +#endif +#ifndef __JUCE_RELATIVECOORDINATEPOSITIONER_JUCEHEADER__ + #include "gui/components/positioning/juce_RelativeCoordinatePositioner.h" +#endif +#ifndef __JUCE_RELATIVEPARALLELOGRAM_JUCEHEADER__ + #include "gui/components/positioning/juce_RelativeParallelogram.h" +#endif +#ifndef __JUCE_RELATIVEPOINT_JUCEHEADER__ + #include "gui/components/positioning/juce_RelativePoint.h" +#endif +#ifndef __JUCE_RELATIVEPOINTPATH_JUCEHEADER__ + #include "gui/components/positioning/juce_RelativePointPath.h" +#endif +#ifndef __JUCE_RELATIVERECTANGLE_JUCEHEADER__ + #include "gui/components/positioning/juce_RelativeRectangle.h" +#endif #ifndef __JUCE_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__ #include "gui/components/properties/juce_BooleanPropertyComponent.h" #endif @@ -722,9 +740,6 @@ #ifndef __JUCE_RECTANGLELIST_JUCEHEADER__ #include "gui/graphics/geometry/juce_RectangleList.h" #endif -#ifndef __JUCE_RELATIVECOORDINATE_JUCEHEADER__ - #include "gui/graphics/geometry/juce_RelativeCoordinate.h" -#endif #ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ #include "gui/graphics/imaging/juce_CameraDevice.h" #endif diff --git a/src/text/juce_XmlElement.h b/src/text/juce_XmlElement.h index e34e93b78f..9081f68c26 100644 --- a/src/text/juce_XmlElement.h +++ b/src/text/juce_XmlElement.h @@ -703,6 +703,7 @@ private: friend class XmlDocument; friend class LinkedListPointer; friend class LinkedListPointer ; + friend class LinkedListPointer ::Appender; LinkedListPointer nextListItem; LinkedListPointer firstChildElement;