diff --git a/Builds/Linux/Makefile b/Builds/Linux/Makefile index b40eb105a9..794f302f33 100644 --- a/Builds/Linux/Makefile +++ b/Builds/Linux/Makefile @@ -122,7 +122,6 @@ OBJECTS := \ $(OBJDIR)/juce_ActionListenerList_9e099ae4.o \ $(OBJDIR)/juce_AsyncUpdater_a7e1cb89.o \ $(OBJDIR)/juce_ChangeBroadcaster_3eb8fecc.o \ - $(OBJDIR)/juce_ChangeListenerList_c2dafc5e.o \ $(OBJDIR)/juce_InterprocessConnection_13086b6d.o \ $(OBJDIR)/juce_InterprocessConnectionServer_a4d7b350.o \ $(OBJDIR)/juce_Message_ac79f635.o \ @@ -779,11 +778,6 @@ $(OBJDIR)/juce_ChangeBroadcaster_3eb8fecc.o: ../../src/events/juce_ChangeBroadca @echo "Compiling juce_ChangeBroadcaster.cpp" @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" -$(OBJDIR)/juce_ChangeListenerList_c2dafc5e.o: ../../src/events/juce_ChangeListenerList.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling juce_ChangeListenerList.cpp" - @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" - $(OBJDIR)/juce_InterprocessConnection_13086b6d.o: ../../src/events/juce_InterprocessConnection.cpp -@mkdir -p $(OBJDIR) @echo "Compiling juce_InterprocessConnection.cpp" diff --git a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj index a15c9f6f77..0b6da29176 100644 --- a/Builds/MacOSX/Juce.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Juce.xcodeproj/project.pbxproj @@ -91,7 +91,6 @@ 5BE4BAA99FDC6F1B3177096F = { isa = PBXBuildFile; fileRef = 5A46476E16BA4F9DA95E9E6A; }; 55737E2F1817DE642AA7DA05 = { isa = PBXBuildFile; fileRef = 1617348BBF5D103619D76911; }; 6D2C50B0A69855A7F8C062E7 = { isa = PBXBuildFile; fileRef = B80F8CD026033ACCCE11A1A4; }; - 769227C780221EE89081BDFF = { isa = PBXBuildFile; fileRef = F978BD0E708FA56FD1EAE238; }; 70EE7A1273945B62B013DB43 = { isa = PBXBuildFile; fileRef = AE68ECB6E063BD8D4984C0B3; }; 9DF800566462E24A14246EAE = { isa = PBXBuildFile; fileRef = 843A7B398E9411F0AF28D65D; }; 89F0DA39878F8A41E60B8C67 = { isa = PBXBuildFile; fileRef = 9CF077D3ED7B7B56F351AAF6; }; @@ -563,8 +562,6 @@ B80F8CD026033ACCCE11A1A4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ChangeBroadcaster.cpp; path = ../../src/events/juce_ChangeBroadcaster.cpp; sourceTree = SOURCE_ROOT; }; 5F454A6B5A82ECE2396C5716 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ChangeBroadcaster.h; path = ../../src/events/juce_ChangeBroadcaster.h; sourceTree = SOURCE_ROOT; }; B2D08C8EEE3E22026533D2EA = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ChangeListener.h; path = ../../src/events/juce_ChangeListener.h; sourceTree = SOURCE_ROOT; }; - F978BD0E708FA56FD1EAE238 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ChangeListenerList.cpp; path = ../../src/events/juce_ChangeListenerList.cpp; sourceTree = SOURCE_ROOT; }; - 4D15D2E39EAC0DDFCFC2FCE6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ChangeListenerList.h; path = ../../src/events/juce_ChangeListenerList.h; sourceTree = SOURCE_ROOT; }; AE68ECB6E063BD8D4984C0B3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_InterprocessConnection.cpp; path = ../../src/events/juce_InterprocessConnection.cpp; sourceTree = SOURCE_ROOT; }; 4B935D7360C9F166C80A158D = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_InterprocessConnection.h; path = ../../src/events/juce_InterprocessConnection.h; sourceTree = SOURCE_ROOT; }; 843A7B398E9411F0AF28D65D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_InterprocessConnectionServer.cpp; path = ../../src/events/juce_InterprocessConnectionServer.cpp; sourceTree = SOURCE_ROOT; }; @@ -1293,8 +1290,6 @@ B80F8CD026033ACCCE11A1A4, 5F454A6B5A82ECE2396C5716, B2D08C8EEE3E22026533D2EA, - F978BD0E708FA56FD1EAE238, - 4D15D2E39EAC0DDFCFC2FCE6, AE68ECB6E063BD8D4984C0B3, 4B935D7360C9F166C80A158D, 843A7B398E9411F0AF28D65D, @@ -2016,7 +2011,6 @@ 5BE4BAA99FDC6F1B3177096F, 55737E2F1817DE642AA7DA05, 6D2C50B0A69855A7F8C062E7, - 769227C780221EE89081BDFF, 70EE7A1273945B62B013DB43, 9DF800566462E24A14246EAE, 89F0DA39878F8A41E60B8C67, diff --git a/Builds/VisualStudio2005/Juce.vcproj b/Builds/VisualStudio2005/Juce.vcproj index 8454b730c9..ce011d1ca4 100644 --- a/Builds/VisualStudio2005/Juce.vcproj +++ b/Builds/VisualStudio2005/Juce.vcproj @@ -430,8 +430,6 @@ - - diff --git a/Builds/VisualStudio2008/Juce.vcproj b/Builds/VisualStudio2008/Juce.vcproj index 408d6dcbd1..04fe6697b7 100644 --- a/Builds/VisualStudio2008/Juce.vcproj +++ b/Builds/VisualStudio2008/Juce.vcproj @@ -430,8 +430,6 @@ - - diff --git a/Builds/VisualStudio2008_DLL/Juce.vcproj b/Builds/VisualStudio2008_DLL/Juce.vcproj index 1e0c471ccc..d72532cbaa 100644 --- a/Builds/VisualStudio2008_DLL/Juce.vcproj +++ b/Builds/VisualStudio2008_DLL/Juce.vcproj @@ -432,8 +432,6 @@ - - diff --git a/Builds/VisualStudio2010/Juce.vcxproj b/Builds/VisualStudio2010/Juce.vcxproj index 9c753e4dd2..421c1f46c2 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj +++ b/Builds/VisualStudio2010/Juce.vcxproj @@ -205,7 +205,6 @@ - @@ -556,7 +555,6 @@ - diff --git a/Builds/VisualStudio2010/Juce.vcxproj.filters b/Builds/VisualStudio2010/Juce.vcxproj.filters index cb6dde432f..6da4c7d4b9 100644 --- a/Builds/VisualStudio2010/Juce.vcxproj.filters +++ b/Builds/VisualStudio2010/Juce.vcxproj.filters @@ -463,9 +463,6 @@ Juce\Source\events - - Juce\Source\events - Juce\Source\events @@ -1590,9 +1587,6 @@ Juce\Source\events - - Juce\Source\events - Juce\Source\events diff --git a/Builds/iPhone/Juce.xcodeproj/project.pbxproj b/Builds/iPhone/Juce.xcodeproj/project.pbxproj index 8edaa5342c..cdf9877597 100644 --- a/Builds/iPhone/Juce.xcodeproj/project.pbxproj +++ b/Builds/iPhone/Juce.xcodeproj/project.pbxproj @@ -91,7 +91,6 @@ 5BE4BAA99FDC6F1B3177096F = { isa = PBXBuildFile; fileRef = 5A46476E16BA4F9DA95E9E6A; }; 55737E2F1817DE642AA7DA05 = { isa = PBXBuildFile; fileRef = 1617348BBF5D103619D76911; }; 6D2C50B0A69855A7F8C062E7 = { isa = PBXBuildFile; fileRef = B80F8CD026033ACCCE11A1A4; }; - 769227C780221EE89081BDFF = { isa = PBXBuildFile; fileRef = F978BD0E708FA56FD1EAE238; }; 70EE7A1273945B62B013DB43 = { isa = PBXBuildFile; fileRef = AE68ECB6E063BD8D4984C0B3; }; 9DF800566462E24A14246EAE = { isa = PBXBuildFile; fileRef = 843A7B398E9411F0AF28D65D; }; 89F0DA39878F8A41E60B8C67 = { isa = PBXBuildFile; fileRef = 9CF077D3ED7B7B56F351AAF6; }; @@ -563,8 +562,6 @@ B80F8CD026033ACCCE11A1A4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ChangeBroadcaster.cpp; path = ../../src/events/juce_ChangeBroadcaster.cpp; sourceTree = SOURCE_ROOT; }; 5F454A6B5A82ECE2396C5716 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ChangeBroadcaster.h; path = ../../src/events/juce_ChangeBroadcaster.h; sourceTree = SOURCE_ROOT; }; B2D08C8EEE3E22026533D2EA = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ChangeListener.h; path = ../../src/events/juce_ChangeListener.h; sourceTree = SOURCE_ROOT; }; - F978BD0E708FA56FD1EAE238 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_ChangeListenerList.cpp; path = ../../src/events/juce_ChangeListenerList.cpp; sourceTree = SOURCE_ROOT; }; - 4D15D2E39EAC0DDFCFC2FCE6 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_ChangeListenerList.h; path = ../../src/events/juce_ChangeListenerList.h; sourceTree = SOURCE_ROOT; }; AE68ECB6E063BD8D4984C0B3 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_InterprocessConnection.cpp; path = ../../src/events/juce_InterprocessConnection.cpp; sourceTree = SOURCE_ROOT; }; 4B935D7360C9F166C80A158D = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = juce_InterprocessConnection.h; path = ../../src/events/juce_InterprocessConnection.h; sourceTree = SOURCE_ROOT; }; 843A7B398E9411F0AF28D65D = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = juce_InterprocessConnectionServer.cpp; path = ../../src/events/juce_InterprocessConnectionServer.cpp; sourceTree = SOURCE_ROOT; }; @@ -1293,8 +1290,6 @@ B80F8CD026033ACCCE11A1A4, 5F454A6B5A82ECE2396C5716, B2D08C8EEE3E22026533D2EA, - F978BD0E708FA56FD1EAE238, - 4D15D2E39EAC0DDFCFC2FCE6, AE68ECB6E063BD8D4984C0B3, 4B935D7360C9F166C80A158D, 843A7B398E9411F0AF28D65D, @@ -2016,7 +2011,6 @@ 5BE4BAA99FDC6F1B3177096F, 55737E2F1817DE642AA7DA05, 6D2C50B0A69855A7F8C062E7, - 769227C780221EE89081BDFF, 70EE7A1273945B62B013DB43, 9DF800566462E24A14246EAE, 89F0DA39878F8A41E60B8C67, diff --git a/Juce.jucer b/Juce.jucer index 17ed25708a..050e81d2fa 100644 --- a/Juce.jucer +++ b/Juce.jucer @@ -507,10 +507,6 @@ file="src/events/juce_ChangeBroadcaster.h"/> - - setAttribute ("StringPooling", "true"); } - compiler->setAttribute ("AdditionalIncludeDirectories", getHeaderSearchPaths (config).joinIntoString (";")); + compiler->setAttribute ("AdditionalIncludeDirectories", replacePreprocessorTokens (config, getHeaderSearchPaths (config).joinIntoString (";"))); compiler->setAttribute ("PreprocessorDefinitions", getPreprocessorDefs (config, ";")); compiler->setAttribute ("RuntimeLibrary", isRTAS() ? (isDebug ? 3 : 2) // MT DLL : (isDebug ? 1 : 0)); // MT static @@ -988,7 +988,7 @@ private: << "# ADD BASE CPP /nologo /W3 /GX /" << optimisationFlag << " /D " << defines << " /YX /FD /c " << extraDebugFlags << " /Zm1024" << newLine << "# ADD CPP /nologo " << (isDebug ? "/MTd" : "/MT") << " /W3 /GR /GX /" << optimisationFlag - << " /I " << getHeaderSearchPaths (config).joinIntoString (" /I ") + << " /I " << replacePreprocessorTokens (config, getHeaderSearchPaths (config).joinIntoString (" /I ")) << " /D " << defines << " /D \"_UNICODE\" /D \"UNICODE\" /FD /c /Zm1024 " << extraDebugFlags << " " << replacePreprocessorTokens (config, getExtraCompilerFlags().toString()).trim() << newLine; diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h index 1fe3956ac9..65ceb84427 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_Make.h @@ -167,7 +167,7 @@ private: headerPaths.insert (0, juceWrapperFolder.toUnixStyle()); for (int i = 0; i < headerPaths.size(); ++i) - out << " -I " << FileHelpers::unixStylePath (headerPaths[i]).quoted(); + out << " -I " << FileHelpers::unixStylePath (replacePreprocessorTokens (config, headerPaths[i])).quoted(); } void writeCppFlags (OutputStream& out, const Project::BuildConfiguration& config) diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h index e5a5375b9d..f2b4dd38d2 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h @@ -518,7 +518,7 @@ private: StringArray s; s.add ("ARCHS = \"$(ARCHS_STANDARD_32_BIT)\""); s.add ("PREBINDING = NO"); - s.add ("HEADER_SEARCH_PATHS = \"" + getHeaderSearchPaths (config).joinIntoString (" ") + " $(inherited)\""); + s.add ("HEADER_SEARCH_PATHS = \"" + replacePreprocessorTokens (config, getHeaderSearchPaths (config).joinIntoString (" ")) + " $(inherited)\""); s.add ("GCC_OPTIMIZATION_LEVEL = " + config.getGCCOptimisationFlag()); s.add ("INFOPLIST_FILE = " + infoPlistFile.getFileName()); diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp index 5d53a9d811..5011cfb2e6 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp @@ -127,7 +127,7 @@ ProjectInformationComponent::ProjectInformationComponent (Project& project_) #if JUCE_MAC || JUCE_WINDOWS openProjectButton.setCommandToTrigger (commandManager, CommandIDs::openInIDE, true); openProjectButton.setButtonText (commandManager->getNameOfCommand (CommandIDs::openInIDE)); - + saveAndOpenButton.setCommandToTrigger (commandManager, CommandIDs::saveAndOpenInIDE, true); saveAndOpenButton.setButtonText (commandManager->getNameOfCommand (CommandIDs::saveAndOpenInIDE)); #else @@ -341,7 +341,7 @@ void ProjectInformationComponent::showExporterMenu() project.addNewExporter (r - 10000); } -void ProjectInformationComponent::changeListenerCallback (void*) +void ProjectInformationComponent::changeListenerCallback (ChangeBroadcaster*) { updateConfigTabs(); } diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h index ed062c25aa..ab040ef048 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.h @@ -42,7 +42,7 @@ public: //============================================================================== //[UserMethods] -- You can add your own custom methods in this section. - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void rebuildConfigTabs(); //[/UserMethods] diff --git a/extras/audio plugin host/Source/FilterGraph.h b/extras/audio plugin host/Source/FilterGraph.h index 38bc7c217a..424d1f6c14 100644 --- a/extras/audio plugin host/Source/FilterGraph.h +++ b/extras/audio plugin host/Source/FilterGraph.h @@ -235,7 +235,7 @@ public: void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); //============================================================================== static int compareElements (FilterInGraph* const first, FilterInGraph* const second) throw(); diff --git a/extras/audio plugin host/Source/GraphEditorPanel.cpp b/extras/audio plugin host/Source/GraphEditorPanel.cpp index 94348d94a1..c2c9237e10 100644 --- a/extras/audio plugin host/Source/GraphEditorPanel.cpp +++ b/extras/audio plugin host/Source/GraphEditorPanel.cpp @@ -811,7 +811,7 @@ void GraphEditorPanel::resized() updateComponents(); } -void GraphEditorPanel::changeListenerCallback (void*) +void GraphEditorPanel::changeListenerCallback (ChangeBroadcaster*) { updateComponents(); } diff --git a/extras/audio plugin host/Source/GraphEditorPanel.h b/extras/audio plugin host/Source/GraphEditorPanel.h index eefbaf9362..e47e9eba3e 100644 --- a/extras/audio plugin host/Source/GraphEditorPanel.h +++ b/extras/audio plugin host/Source/GraphEditorPanel.h @@ -54,7 +54,7 @@ public: PinComponent* findPinAt (const int x, const int y) const; void resized(); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void updateComponents(); //============================================================================== diff --git a/extras/audio plugin host/Source/MainHostWindow.cpp b/extras/audio plugin host/Source/MainHostWindow.cpp index 203f068f1e..26e59aa8f6 100644 --- a/extras/audio plugin host/Source/MainHostWindow.cpp +++ b/extras/audio plugin host/Source/MainHostWindow.cpp @@ -158,7 +158,7 @@ bool MainHostWindow::tryToQuitApplication() return false; } -void MainHostWindow::changeListenerCallback (void*) +void MainHostWindow::changeListenerCallback (ChangeBroadcaster*) { menuItemsChanged(); diff --git a/extras/audio plugin host/Source/MainHostWindow.h b/extras/audio plugin host/Source/MainHostWindow.h index 4afd1a6fa1..e2e3dd6d66 100644 --- a/extras/audio plugin host/Source/MainHostWindow.h +++ b/extras/audio plugin host/Source/MainHostWindow.h @@ -60,7 +60,7 @@ public: //============================================================================== void closeButtonPressed(); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); bool isInterestedInFileDrag (const StringArray& files); void fileDragEnter (const StringArray& files, int, int); diff --git a/extras/juce demo/Builds/MacOSX/Icon.icns b/extras/juce demo/Builds/MacOSX/Icon.icns index fea3a04779..397a57cec2 100644 Binary files a/extras/juce demo/Builds/MacOSX/Icon.icns and b/extras/juce demo/Builds/MacOSX/Icon.icns differ diff --git a/extras/juce demo/Builds/VisualStudio2005/icon.ico b/extras/juce demo/Builds/VisualStudio2005/icon.ico index 9dfea84c64..f95f8be2b7 100644 Binary files a/extras/juce demo/Builds/VisualStudio2005/icon.ico and b/extras/juce demo/Builds/VisualStudio2005/icon.ico differ diff --git a/extras/juce demo/Builds/VisualStudio2008/icon.ico b/extras/juce demo/Builds/VisualStudio2008/icon.ico index 9dfea84c64..f95f8be2b7 100644 Binary files a/extras/juce demo/Builds/VisualStudio2008/icon.ico and b/extras/juce demo/Builds/VisualStudio2008/icon.ico differ diff --git a/extras/juce demo/Builds/VisualStudio2010/icon.ico b/extras/juce demo/Builds/VisualStudio2010/icon.ico index 9dfea84c64..f95f8be2b7 100644 Binary files a/extras/juce demo/Builds/VisualStudio2010/icon.ico and b/extras/juce demo/Builds/VisualStudio2010/icon.ico differ diff --git a/extras/juce demo/Builds/iPhone/Icon.icns b/extras/juce demo/Builds/iPhone/Icon.icns index fea3a04779..397a57cec2 100644 Binary files a/extras/juce demo/Builds/iPhone/Icon.icns and b/extras/juce demo/Builds/iPhone/Icon.icns differ diff --git a/extras/juce demo/Source/demos/AudioDemoPlaybackPage.cpp b/extras/juce demo/Source/demos/AudioDemoPlaybackPage.cpp index 1e57f6049c..50dcd12f61 100644 --- a/extras/juce demo/Source/demos/AudioDemoPlaybackPage.cpp +++ b/extras/juce demo/Source/demos/AudioDemoPlaybackPage.cpp @@ -99,7 +99,7 @@ public: } } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { // this method is called by the thumbnail when it has changed, so we should repaint it.. repaint(); diff --git a/extras/juce demo/Source/demos/WidgetsDemo.cpp b/extras/juce demo/Source/demos/WidgetsDemo.cpp index 9a3bebd020..8c647b178c 100644 --- a/extras/juce demo/Source/demos/WidgetsDemo.cpp +++ b/extras/juce demo/Source/demos/WidgetsDemo.cpp @@ -271,14 +271,11 @@ public: callOut.runModalLoop(); } - void changeListenerCallback (void* source) + void changeListenerCallback (ChangeBroadcaster* source) { - ColourSelector* cs = static_cast (source); + ColourSelector* cs = dynamic_cast (source); - if (cs->getName() == "text") - setColour (TextButton::textColourOffId, cs->getCurrentColour()); - else - setColour (TextButton::buttonColourId, cs->getCurrentColour()); + setColour (TextButton::buttonColourId, cs->getCurrentColour()); } }; diff --git a/extras/the jucer/src/model/components/jucer_GroupComponentHandler.h b/extras/the jucer/src/model/components/jucer_GroupComponentHandler.h index a3210abdb2..f4adfcfec1 100644 --- a/extras/the jucer/src/model/components/jucer_GroupComponentHandler.h +++ b/extras/the jucer/src/model/components/jucer_GroupComponentHandler.h @@ -201,7 +201,7 @@ private: return group->getTextLabelPosition(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: GroupComponent* const group; diff --git a/extras/the jucer/src/model/components/jucer_ImageButtonHandler.h b/extras/the jucer/src/model/components/jucer_ImageButtonHandler.h index 3ed7ba0fc3..ff301b8335 100644 --- a/extras/the jucer/src/model/components/jucer_ImageButtonHandler.h +++ b/extras/the jucer/src/model/components/jucer_ImageButtonHandler.h @@ -508,7 +508,7 @@ public: void resetToDefault() {} - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/components/jucer_JucerComponentHandler.h b/extras/the jucer/src/model/components/jucer_JucerComponentHandler.h index 1147bc35fe..be5752375d 100644 --- a/extras/the jucer/src/model/components/jucer_JucerComponentHandler.h +++ b/extras/the jucer/src/model/components/jucer_JucerComponentHandler.h @@ -192,7 +192,7 @@ private: return component->findFile(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/components/jucer_LabelHandler.h b/extras/the jucer/src/model/components/jucer_LabelHandler.h index 528890a85e..a62adfeef3 100644 --- a/extras/the jucer/src/model/components/jucer_LabelHandler.h +++ b/extras/the jucer/src/model/components/jucer_LabelHandler.h @@ -400,7 +400,7 @@ private: return label->getJustificationType(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: Label* const label; @@ -466,7 +466,7 @@ private: return label->getProperties().getWithDefault ("typefaceName", FontPropertyComponent::defaultFont); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: Label* const label; @@ -535,7 +535,7 @@ private: return label->getFont().getHeight(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: Label* const label; @@ -621,7 +621,7 @@ private: return 0; } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: Label* const label; diff --git a/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h b/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h index 7e084cb3e7..9e182d8d9c 100644 --- a/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h +++ b/extras/the jucer/src/model/components/jucer_TabbedComponentHandler.h @@ -601,7 +601,7 @@ private: return component->getTabBarDepth(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -868,7 +868,7 @@ private: jassertfalse // shouldn't get called } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: TabbedComponent* component; @@ -1002,7 +1002,7 @@ private: return document.getFile().getSiblingFile (getTabJucerFile (component, tabIndex)); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: TabbedComponent* const component; diff --git a/extras/the jucer/src/model/components/jucer_ViewportHandler.h b/extras/the jucer/src/model/components/jucer_ViewportHandler.h index 1f08d19a99..d03babc977 100644 --- a/extras/the jucer/src/model/components/jucer_ViewportHandler.h +++ b/extras/the jucer/src/model/components/jucer_ViewportHandler.h @@ -400,7 +400,7 @@ private: return component->getScrollBarThickness(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -533,7 +533,7 @@ private: return document.getFile().getSiblingFile (filename); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/documents/jucer_ButtonDocument.cpp b/extras/the jucer/src/model/documents/jucer_ButtonDocument.cpp index c991823196..2762f64be5 100644 --- a/extras/the jucer/src/model/documents/jucer_ButtonDocument.cpp +++ b/extras/the jucer/src/model/documents/jucer_ButtonDocument.cpp @@ -270,7 +270,7 @@ public: } private: - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/paintelements/jucer_ColouredElement.cpp b/extras/the jucer/src/model/paintelements/jucer_ColouredElement.cpp index b4633a9fb5..4e451cf826 100644 --- a/extras/the jucer/src/model/paintelements/jucer_ColouredElement.cpp +++ b/extras/the jucer/src/model/paintelements/jucer_ColouredElement.cpp @@ -108,7 +108,7 @@ public: return 0; } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -211,7 +211,7 @@ public: jassertfalse // option shouldn't be visible } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -297,7 +297,7 @@ public: void setState (bool newState) { owner->enableStroke (newState, true); } bool getState() const { return owner->isStrokeEnabled(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: ColouredElement* const owner; @@ -332,7 +332,7 @@ public: double getValue() const { return owner->getStrokeType().stroke.getStrokeThickness(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: ColouredElement* const owner; @@ -391,7 +391,7 @@ public: return 0; } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: ColouredElement* const owner; @@ -450,7 +450,7 @@ public: return 0; } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: ColouredElement* const owner; @@ -594,7 +594,7 @@ public: return element->getFillType().imageOpacity; } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/paintelements/jucer_ElementSiblingComponent.h b/extras/the jucer/src/model/paintelements/jucer_ElementSiblingComponent.h index f7e1a429c7..d4c33c0ae1 100644 --- a/extras/the jucer/src/model/paintelements/jucer_ElementSiblingComponent.h +++ b/extras/the jucer/src/model/paintelements/jucer_ElementSiblingComponent.h @@ -52,7 +52,7 @@ public: //============================================================================== - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { updatePosition(); } diff --git a/extras/the jucer/src/model/paintelements/jucer_ImageResourceProperty.h b/extras/the jucer/src/model/paintelements/jucer_ImageResourceProperty.h index 4b832dfcaf..48bdf797d8 100644 --- a/extras/the jucer/src/model/paintelements/jucer_ImageResourceProperty.h +++ b/extras/the jucer/src/model/paintelements/jucer_ImageResourceProperty.h @@ -114,7 +114,7 @@ public: return choices.indexOf (getResource()); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp b/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp index 929f8afd37..05ee536b9d 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElement.cpp @@ -422,7 +422,7 @@ void PaintElement::getCurrentAbsoluteBoundsDouble (double& x, double& y, double& position.getRectangleDouble (x, y, w, h, area, getDocument()->getComponentLayout()); } -void PaintElement::changeListenerCallback (void*) +void PaintElement::changeListenerCallback (ChangeBroadcaster*) { const bool nowSelected = owner != 0 && owner->getSelectedElements().isSelected (this); @@ -449,7 +449,7 @@ void PaintElement::createSiblingComponents() void PaintElement::siblingComponentsChanged() { siblingComponents.clear(); - selfChangeListenerList.sendChangeMessage (0); + selfChangeListenerList.sendChangeMessage(); } void PaintElement::updateSiblingComps() diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElement.h b/extras/the jucer/src/model/paintelements/jucer_PaintElement.h index d4d5ecd105..d28aca5192 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElement.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElement.h @@ -90,7 +90,7 @@ public: void mouseDown (const MouseEvent& e); void mouseDrag (const MouseEvent& e); void mouseUp (const MouseEvent& e); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void parentHierarchyChanged(); int borderThickness; @@ -130,7 +130,7 @@ private: String typeName; bool selected, dragging, mouseDownSelectStatus; double originalAspectRatio; - ChangeListenerList selfChangeListenerList; + ChangeBroadcaster selfChangeListenerList; }; diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h index cbf0936da6..a86a4b3038 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h @@ -455,7 +455,7 @@ private: return element->getOpacity(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -494,7 +494,7 @@ private: return (int) element->getStretchMode(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp b/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp index 5f4a9f7d8a..b40e9eee2c 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.cpp @@ -120,7 +120,7 @@ public: void setIndex (int newIndex) { owner->setNonZeroWinding (newIndex == 0, true); } int getIndex() const { return owner->isNonZeroWinding() ? 0 : 1; } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementPath* const owner; @@ -1276,7 +1276,7 @@ public: return 0; } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -1345,7 +1345,7 @@ public: owner->getDocument()->removeChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -1671,7 +1671,7 @@ void PathPointComponent::mouseUp (const MouseEvent& e) mouseDownSelectStatus); } -void PathPointComponent::changeListenerCallback (void* source) +void PathPointComponent::changeListenerCallback (ChangeBroadcaster* source) { ElementSiblingComponent::changeListenerCallback (source); diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.h index 15782aa47e..56ce0d3cf5 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementPath.h @@ -183,7 +183,7 @@ public: void mouseDrag (const MouseEvent& e); void mouseUp (const MouseEvent& e); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); //============================================================================== juce_UseDebuggingNewOperator diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementRoundedRectangle.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementRoundedRectangle.h index 6e88725b54..04014b271b 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementRoundedRectangle.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementRoundedRectangle.h @@ -229,7 +229,7 @@ private: double getValue() const { return owner->getCornerSize(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementRoundedRectangle* const owner; diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h index f5c5418133..a4129f7ead 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementText.h @@ -387,7 +387,7 @@ private: void setText (const String& newText) { element->setText (newText, true); } const String getText() const { return element->getText(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementText* const element; @@ -413,7 +413,7 @@ private: void setTypefaceName (const String& newFontName) { element->setTypefaceName (newFontName, true); } const String getTypefaceName() const { return element->getTypefaceName(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementText* const element; @@ -463,7 +463,7 @@ private: return 0; } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementText* const element; @@ -501,7 +501,7 @@ private: return element->getFont().getHeight(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementText* const element; @@ -534,7 +534,7 @@ private: return element->getJustification(); } - void changeListenerCallback (void*) { refresh(); } + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } private: PaintElementText* const element; diff --git a/extras/the jucer/src/properties/jucer_ComponentBooleanProperty.h b/extras/the jucer/src/properties/jucer_ComponentBooleanProperty.h index 60f1864623..f05e63726d 100644 --- a/extras/the jucer/src/properties/jucer_ComponentBooleanProperty.h +++ b/extras/the jucer/src/properties/jucer_ComponentBooleanProperty.h @@ -52,7 +52,7 @@ public: document.removeChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/properties/jucer_ComponentChoiceProperty.h b/extras/the jucer/src/properties/jucer_ComponentChoiceProperty.h index d1880ae85e..087ad9cb58 100644 --- a/extras/the jucer/src/properties/jucer_ComponentChoiceProperty.h +++ b/extras/the jucer/src/properties/jucer_ComponentChoiceProperty.h @@ -50,7 +50,7 @@ public: document.removeChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/properties/jucer_ComponentColourProperty.h b/extras/the jucer/src/properties/jucer_ComponentColourProperty.h index 8457ec04bd..405ab0322c 100644 --- a/extras/the jucer/src/properties/jucer_ComponentColourProperty.h +++ b/extras/the jucer/src/properties/jucer_ComponentColourProperty.h @@ -53,7 +53,7 @@ public: document.removeChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/properties/jucer_ComponentTextProperty.h b/extras/the jucer/src/properties/jucer_ComponentTextProperty.h index e9911a9bca..aa95a2cd83 100644 --- a/extras/the jucer/src/properties/jucer_ComponentTextProperty.h +++ b/extras/the jucer/src/properties/jucer_ComponentTextProperty.h @@ -52,7 +52,7 @@ public: document.removeChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/properties/jucer_PositionPropertyBase.h b/extras/the jucer/src/properties/jucer_PositionPropertyBase.h index ec44ce7302..cab0eaef32 100644 --- a/extras/the jucer/src/properties/jucer_PositionPropertyBase.h +++ b/extras/the jucer/src/properties/jucer_PositionPropertyBase.h @@ -169,7 +169,7 @@ public: } } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } diff --git a/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.cpp b/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.cpp index 824077d80f..0c842a0090 100644 --- a/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.cpp +++ b/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.cpp @@ -146,7 +146,7 @@ void ComponentLayoutEditor::visibilityChanged() } } -void ComponentLayoutEditor::changeListenerCallback (void*) +void ComponentLayoutEditor::changeListenerCallback (ChangeBroadcaster*) { refreshAllComponents(); } diff --git a/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.h b/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.h index 4950baa3d3..388ab3e69b 100644 --- a/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.h +++ b/extras/the jucer/src/ui/jucer_ComponentLayoutEditor.h @@ -48,7 +48,7 @@ public: void paint (Graphics& g); void resized(); void visibilityChanged(); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void mouseDown (const MouseEvent& e); void mouseDrag (const MouseEvent& e); diff --git a/extras/the jucer/src/ui/jucer_ComponentLayoutPanel.cpp b/extras/the jucer/src/ui/jucer_ComponentLayoutPanel.cpp index 0858d46340..e9db4773c0 100644 --- a/extras/the jucer/src/ui/jucer_ComponentLayoutPanel.cpp +++ b/extras/the jucer/src/ui/jucer_ComponentLayoutPanel.cpp @@ -56,7 +56,7 @@ public: propsPanel->setBounds (4, 4, getWidth() - 8, getHeight() - 8); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { updateList(); } diff --git a/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp b/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp index 3aecccd561..3d3b0fc0c8 100644 --- a/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp +++ b/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.cpp @@ -63,7 +63,7 @@ ComponentOverlayComponent::~ComponentOverlayComponent() delete border; } -void ComponentOverlayComponent::changeListenerCallback (void*) +void ComponentOverlayComponent::changeListenerCallback (ChangeBroadcaster*) { const bool nowSelected = layout.getSelectedSet().isSelected (target); diff --git a/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.h b/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.h index 2328b81725..74886f7a22 100644 --- a/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.h +++ b/extras/the jucer/src/ui/jucer_ComponentOverlayComponent.h @@ -57,7 +57,7 @@ public: void componentMovedOrResized (Component& component, bool wasMoved, bool wasResized); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void resizeStart(); void resizeEnd(); diff --git a/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp b/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp index 0bcb134ffc..831fc0c776 100644 --- a/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp +++ b/extras/the jucer/src/ui/jucer_JucerDocumentHolder.cpp @@ -112,7 +112,7 @@ public: listBox->repaint(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -173,7 +173,7 @@ public: panel2->setBounds (panel1->getRight() + 20, panel1->getY(), pw, panel1->getHeight()); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { panel1->refreshAll(); panel2->refreshAll(); @@ -505,7 +505,7 @@ void JucerDocumentHolder::resized() tabbedComponent->setBounds (0, 0, getWidth(), getHeight()); } -void JucerDocumentHolder::changeListenerCallback (void*) +void JucerDocumentHolder::changeListenerCallback (ChangeBroadcaster*) { setName (document->getClassName()); updateTabs(); diff --git a/extras/the jucer/src/ui/jucer_JucerDocumentHolder.h b/extras/the jucer/src/ui/jucer_JucerDocumentHolder.h index af67e7e13c..d59759eb12 100644 --- a/extras/the jucer/src/ui/jucer_JucerDocumentHolder.h +++ b/extras/the jucer/src/ui/jucer_JucerDocumentHolder.h @@ -62,7 +62,7 @@ public: //============================================================================== void paint (Graphics& g); void resized(); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); //============================================================================== ApplicationCommandTarget* getNextCommandTarget(); diff --git a/extras/the jucer/src/ui/jucer_PaintRoutineEditor.cpp b/extras/the jucer/src/ui/jucer_PaintRoutineEditor.cpp index 3f7411d107..096154b8cd 100644 --- a/extras/the jucer/src/ui/jucer_PaintRoutineEditor.cpp +++ b/extras/the jucer/src/ui/jucer_PaintRoutineEditor.cpp @@ -213,7 +213,7 @@ void PaintRoutineEditor::refreshAllElements() } } -void PaintRoutineEditor::changeListenerCallback (void* source) +void PaintRoutineEditor::changeListenerCallback (ChangeBroadcaster* source) { refreshAllElements(); } diff --git a/extras/the jucer/src/ui/jucer_PaintRoutineEditor.h b/extras/the jucer/src/ui/jucer_PaintRoutineEditor.h index cee752d3cd..7d46f81261 100644 --- a/extras/the jucer/src/ui/jucer_PaintRoutineEditor.h +++ b/extras/the jucer/src/ui/jucer_PaintRoutineEditor.h @@ -51,7 +51,7 @@ public: void paint (Graphics& g); void paintOverChildren (Graphics& g); void resized(); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void mouseDown (const MouseEvent& e); void mouseDrag (const MouseEvent& e); diff --git a/extras/the jucer/src/ui/jucer_PaintRoutinePanel.cpp b/extras/the jucer/src/ui/jucer_PaintRoutinePanel.cpp index a5b19bbf11..86d592bbd7 100644 --- a/extras/the jucer/src/ui/jucer_PaintRoutinePanel.cpp +++ b/extras/the jucer/src/ui/jucer_PaintRoutinePanel.cpp @@ -48,7 +48,7 @@ public: document.removeChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { refresh(); } @@ -99,7 +99,7 @@ public: propsPanel->setBounds (4, 4, getWidth() - 8, getHeight() - 8); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { updateList(); } diff --git a/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp b/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp index 878eeade19..2d8c27c2ad 100644 --- a/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp +++ b/extras/the jucer/src/ui/jucer_ResourceEditorPanel.cpp @@ -245,7 +245,7 @@ void ResourceEditorPanel::visibilityChanged() listBox->updateContent(); } -void ResourceEditorPanel::changeListenerCallback (void*) +void ResourceEditorPanel::changeListenerCallback (ChangeBroadcaster*) { if (isVisible()) listBox->updateContent(); diff --git a/extras/the jucer/src/ui/jucer_ResourceEditorPanel.h b/extras/the jucer/src/ui/jucer_ResourceEditorPanel.h index 0e6e33cb41..f2092e7f6a 100644 --- a/extras/the jucer/src/ui/jucer_ResourceEditorPanel.h +++ b/extras/the jucer/src/ui/jucer_ResourceEditorPanel.h @@ -45,7 +45,7 @@ public: void resized(); void visibilityChanged(); - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); void buttonClicked (Button*); int getNumRows(); diff --git a/extras/the jucer/src/utility/jucer_ColourEditorComponent.h b/extras/the jucer/src/utility/jucer_ColourEditorComponent.h index 60ac07799f..5a0e39e029 100644 --- a/extras/the jucer/src/utility/jucer_ColourEditorComponent.h +++ b/extras/the jucer/src/utility/jucer_ColourEditorComponent.h @@ -85,7 +85,7 @@ public: m.showAt (this); } - void changeListenerCallback (void* source) + void changeListenerCallback (ChangeBroadcaster* source) { const ColourSelector* const cs = (const ColourSelector*) source; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 37034f0d83..8933b02fbb 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -20140,7 +20140,7 @@ void PropertiesFile::timerCallback() void PropertiesFile::propertyChanged() { - sendChangeMessage (this); + sendChangeMessage(); needsWriting = true; @@ -20237,14 +20237,14 @@ void FileBasedDocument::setChangedFlag (const bool hasChanged) if (changedSinceSave != hasChanged) { changedSinceSave = hasChanged; - sendChangeMessage (this); + sendChangeMessage(); } } void FileBasedDocument::changed() { changedSinceSave = true; - sendChangeMessage (this); + sendChangeMessage(); } void FileBasedDocument::setFile (const File& newFile) @@ -20610,7 +20610,7 @@ void UndoManager::clearUndoHistory() transactionNames.clear(); totalUnitsStored = 0; nextIndex = 0; - sendChangeMessage (this); + sendChangeMessage(); } int UndoManager::getNumberOfUnitsTakenUpByStoredCommands() const @@ -20700,7 +20700,7 @@ bool UndoManager::perform (UndoableAction* const command_, const String& actionN --nextIndex; } - sendChangeMessage (this); + sendChangeMessage(); return true; } @@ -20769,7 +20769,7 @@ bool UndoManager::undo() beginNewTransaction(); - sendChangeMessage (this); + sendChangeMessage(); return true; } @@ -20802,7 +20802,7 @@ bool UndoManager::redo() beginNewTransaction(); - sendChangeMessage (this); + sendChangeMessage(); return true; } @@ -22153,7 +22153,7 @@ void AudioThumbnail::setSource (InputSource* const newSource) } } - sendChangeMessage (this); + sendChangeMessage(); } bool AudioThumbnail::useTimeSlice() @@ -22177,7 +22177,7 @@ bool AudioThumbnail::useTimeSlice() readNextBlockFromAudioFile (*reader); stopTimer(); - sendChangeMessage (this); + sendChangeMessage(); const bool justFinished = isFullyLoaded(); @@ -24123,7 +24123,7 @@ void AudioTransportSource::start() inputStreamEOF = false; } - sendChangeMessage (this); + sendChangeMessage(); } } @@ -24140,7 +24140,7 @@ void AudioTransportSource::stop() while (--n >= 0 && ! stopped) Thread::sleep (2); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -24260,7 +24260,7 @@ void AudioTransportSource::getNextAudioBlock (const AudioSourceChannelInfo& info { playing = false; inputStreamEOF = true; - sendChangeMessage (this); + sendChangeMessage(); } stopped = ! playing; @@ -25589,7 +25589,7 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, setAudioDeviceSetup (s, treatAsChosenDevice); - sendChangeMessage (this); + sendChangeMessage(); break; } } @@ -25613,7 +25613,7 @@ const String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& ne return String::empty; if (! (newSetup == currentSetup)) - sendChangeMessage (this); + sendChangeMessage(); stopDevice(); @@ -25978,14 +25978,14 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device callbacks.getUnchecked(i)->audioDeviceAboutToStart (device); } - sendChangeMessage (this); + sendChangeMessage(); } void AudioDeviceManager::audioDeviceStoppedInt() { cpuUsageMs = 0; timeToCpuScale = 0; - sendChangeMessage (this); + sendChangeMessage(); const ScopedLock sl (audioCallbackLock); for (int i = callbacks.size(); --i >= 0;) @@ -26025,7 +26025,7 @@ void AudioDeviceManager::setMidiInputEnabled (const String& name, } updateXml(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -26134,7 +26134,7 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName) } updateXml(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -30411,7 +30411,7 @@ void KnownPluginList::clear() if (types.size() > 0) { types.clear(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -30449,14 +30449,14 @@ bool KnownPluginList::addType (const PluginDescription& type) } types.add (new PluginDescription (type)); - sendChangeMessage (this); + sendChangeMessage(); return true; } void KnownPluginList::removeType (const int index) { types.remove (index); - sendChangeMessage (this); + sendChangeMessage(); } namespace @@ -30614,7 +30614,7 @@ void KnownPluginList::sort (const SortMethod method) sorter.method = method; types.sort (sorter, true); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -31062,7 +31062,7 @@ void PluginListComponent::resized() optionsButton.setTopLeftPosition (8, getHeight() - 28); } -void PluginListComponent::changeListenerCallback (void*) +void PluginListComponent::changeListenerCallback (ChangeBroadcaster*) { listBox.updateContent(); listBox.repaint(); @@ -38452,6 +38452,23 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_ChangeBroadcaster.cpp ***/ BEGIN_JUCE_NAMESPACE +class ChangeBroadcaster::ChangeBroadcasterMessage : public CallbackMessage +{ +public: + ChangeBroadcasterMessage (ChangeBroadcaster* const owner_) + : owner (owner_) + { + } + + void messageCallback() + { + if (owner != 0 && owner->pendingMessage.value == this) + owner->sendSynchronousChangeMessage(); + } + + ChangeBroadcaster* owner; +}; + ChangeBroadcaster::ChangeBroadcaster() throw() { // are you trying to create this object before or after juce has been intialised?? @@ -38462,123 +38479,69 @@ ChangeBroadcaster::~ChangeBroadcaster() { // all event-based objects must be deleted BEFORE juce is shut down! jassert (MessageManager::instance != 0); + + invalidatePendingMessage(); } void ChangeBroadcaster::addChangeListener (ChangeListener* const listener) { - changeListenerList.addChangeListener (listener); + // Listeners can only be safely added when the event thread is locked... + jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); + + changeListeners.add (listener); } void ChangeBroadcaster::removeChangeListener (ChangeListener* const listener) { - jassert (changeListenerList.isValidMessageListener()); + // Listeners can only be safely added when the event thread is locked... + jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); - if (changeListenerList.isValidMessageListener()) - changeListenerList.removeChangeListener (listener); + changeListeners.remove (listener); } void ChangeBroadcaster::removeAllChangeListeners() { - changeListenerList.removeAllChangeListeners(); -} - -void ChangeBroadcaster::sendChangeMessage (void* objectThatHasChanged) -{ - changeListenerList.sendChangeMessage (objectThatHasChanged); -} - -void ChangeBroadcaster::sendSynchronousChangeMessage (void* objectThatHasChanged) -{ - changeListenerList.sendSynchronousChangeMessage (objectThatHasChanged); -} - -void ChangeBroadcaster::dispatchPendingMessages() -{ - changeListenerList.dispatchPendingMessages(); -} - -END_JUCE_NAMESPACE -/*** End of inlined file: juce_ChangeBroadcaster.cpp ***/ - - -/*** Start of inlined file: juce_ChangeListenerList.cpp ***/ -BEGIN_JUCE_NAMESPACE - -ChangeListenerList::ChangeListenerList() - : lastChangedObject (0), - messagePending (false) -{ -} - -ChangeListenerList::~ChangeListenerList() -{ -} - -void ChangeListenerList::addChangeListener (ChangeListener* const listener) -{ - const ScopedLock sl (lock); - - jassert (listener != 0); - - if (listener != 0) - listeners.add (listener); -} + // Listeners can only be safely added when the event thread is locked... + jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); -void ChangeListenerList::removeChangeListener (ChangeListener* const listener) -{ - const ScopedLock sl (lock); - listeners.removeValue (listener); + changeListeners.clear(); } -void ChangeListenerList::removeAllChangeListeners() +void ChangeBroadcaster::invalidatePendingMessage() { - const ScopedLock sl (lock); - listeners.clear(); + ChangeBroadcasterMessage* const oldMessage = pendingMessage.exchange (0); + if (oldMessage != 0) + oldMessage->owner = 0; } -void ChangeListenerList::sendChangeMessage (void* const objectThatHasChanged) +void ChangeBroadcaster::sendChangeMessage() { - const ScopedLock sl (lock); - - if ((! messagePending) && (listeners.size() > 0)) + if (pendingMessage.value == 0 && changeListeners.size() > 0) { - lastChangedObject = objectThatHasChanged; - postMessage (new Message (0, 0, 0, objectThatHasChanged)); - messagePending = true; - } -} + ScopedPointer pending (new ChangeBroadcasterMessage (this)); -void ChangeListenerList::handleMessage (const Message& message) -{ - sendSynchronousChangeMessage (message.pointerParameter); + if (pendingMessage.compareAndSetBool (pending, 0)) + pending.release()->post(); + } } -void ChangeListenerList::sendSynchronousChangeMessage (void* const objectThatHasChanged) +void ChangeBroadcaster::sendSynchronousChangeMessage() { - const ScopedLock sl (lock); - messagePending = false; - - for (int i = listeners.size(); --i >= 0;) - { - ChangeListener* const l = static_cast (listeners.getUnchecked (i)); - - { - const ScopedUnlock tempUnlocker (lock); - l->changeListenerCallback (objectThatHasChanged); - } + // This can only be called by the event thread. + jassert (MessageManager::getInstance()->isThisTheMessageThread()); - i = jmin (i, listeners.size()); - } + invalidatePendingMessage(); + changeListeners.call (&ChangeListener::changeListenerCallback, this); } -void ChangeListenerList::dispatchPendingMessages() +void ChangeBroadcaster::dispatchPendingMessages() { - if (messagePending) - sendSynchronousChangeMessage (lastChangedObject); + if (pendingMessage.get() != 0) + sendSynchronousChangeMessage(); } END_JUCE_NAMESPACE -/*** End of inlined file: juce_ChangeListenerList.cpp ***/ +/*** End of inlined file: juce_ChangeBroadcaster.cpp ***/ /*** Start of inlined file: juce_InterprocessConnection.cpp ***/ @@ -40033,6 +39996,178 @@ namespace } #endif +class Component::ComponentHelpers +{ +public: + + static void* runModalLoopCallback (void* userData) + { + return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); + } + + static const Identifier getColourPropertyId (const int colourId) + { + String s; + s.preallocateStorage (18); + s << "jcclr_" << String::toHexString (colourId); + return s; + } + + static inline bool hitTest (Component& comp, const Point& localPoint) + { + return ((unsigned int) localPoint.getX()) < (unsigned int) comp.getWidth() + && ((unsigned int) localPoint.getY()) < (unsigned int) comp.getHeight() + && comp.hitTest (localPoint.getX(), localPoint.getY()); + } + + static const Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) + { + return pointInParentSpace - comp.getPosition(); + } + + static const Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) + { + return areaInParentSpace - comp.getPosition(); + } + + static const Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) + { + return pointInLocalSpace + comp.getPosition(); + } + + static const Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) + { + return areaInLocalSpace + comp.getPosition(); + } + + template + static const Type convertFromDistantParentSpace (const Component* parent, const Component& target, Type coordInParent) + { + const Component* const directParent = target.getParentComponent(); + jassert (directParent != 0); + + if (directParent == parent) + return convertFromParentSpace (target, coordInParent); + + return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); + } + + template + static const Type convertCoordinate (const Component* target, const Component* source, Type p) + { + while (source != 0) + { + if (source == target) + return p; + + if (source->isParentOf (target)) + return convertFromDistantParentSpace (source, *target, p); + + if (source->isOnDesktop()) + { + p = source->getPeer()->localToGlobal (p); + source = 0; + } + else + { + p = convertToParentSpace (*source, p); + source = source->getParentComponent(); + } + } + + jassert (source == 0); + if (target == 0) + return p; + + const Component* const topLevelComp = target->getTopLevelComponent(); + + if (topLevelComp->isOnDesktop()) + p = topLevelComp->getPeer()->globalToLocal (p); + else + p = convertFromParentSpace (*topLevelComp, p); + + if (topLevelComp == target) + return p; + + return convertFromDistantParentSpace (topLevelComp, *target, p); + } + + static const Rectangle getUnclippedArea (const Component& comp) + { + Rectangle r (comp.getLocalBounds()); + + Component* const p = comp.getParentComponent(); + + if (p != 0) + r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p))); + + return r; + } + + static void clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle& clipRect, const Point& delta) + { + for (int i = comp.childComponentList_.size(); --i >= 0;) + { + const Component& child = *comp.childComponentList_.getUnchecked(i); + +//xxx if (child.isVisible() && ! child.isTransformed()) + if (child.isVisible()) + { + const Rectangle newClip (clipRect.getIntersection (child.bounds_)); + + if (! newClip.isEmpty()) + { + if (child.isOpaque()) + { + g.excludeClipRegion (newClip + delta); + } + else + { + const Point childPos (child.getPosition()); + clipObscuredRegions (child, g, newClip - childPos, childPos + delta); + } + } + } + } + } + + static void subtractObscuredRegions (const Component& comp, RectangleList& result, + const Point& delta, + const Rectangle& clipRect, + const Component* const compToAvoid) + { + for (int i = comp.childComponentList_.size(); --i >= 0;) + { + const Component* const c = comp.childComponentList_.getUnchecked(i); + + if (c != compToAvoid && c->isVisible()) + { + if (c->isOpaque()) + { + Rectangle childBounds (c->bounds_.getIntersection (clipRect)); + childBounds.translate (delta.getX(), delta.getY()); + + result.subtract (childBounds); + } + else + { + Rectangle newClip (clipRect.getIntersection (c->bounds_)); + newClip.translate (-c->getX(), -c->getY()); + + subtractObscuredRegions (*c, result, c->getPosition() + delta, + newClip, compToAvoid); + } + } + } + } + + static const Rectangle getParentOrMainMonitorBounds (const Component& comp) + { + return comp.getParentComponent() != 0 ? comp.getParentComponent()->getLocalBounds() + : Desktop::getInstance().getMainMonitorArea(); + } +}; + Component::Component() : parentComponent_ (0), lookAndFeel_ (0), @@ -40569,138 +40704,30 @@ int Component::getParentHeight() const throw() : getParentMonitorArea().getHeight(); } -int Component::getScreenX() const -{ - return getScreenPosition().getX(); -} - -int Component::getScreenY() const -{ - return getScreenPosition().getY(); -} - -const Point Component::getScreenPosition() const -{ - return localPointToGlobal (Point()); -} - -const Rectangle Component::getScreenBounds() const -{ - return bounds_.withPosition (getScreenPosition()); -} - -namespace CoordinateHelpers -{ - inline bool hitTest (Component& comp, const Point& localPoint) - { - return ((unsigned int) localPoint.getX()) < (unsigned int) comp.getWidth() - && ((unsigned int) localPoint.getY()) < (unsigned int) comp.getHeight() - && comp.hitTest (localPoint.getX(), localPoint.getY()); - } - - const Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) - { - return pointInParentSpace - comp.getPosition(); - } - - const Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) - { - return areaInParentSpace - comp.getPosition(); - } - - const Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) - { - return pointInLocalSpace + comp.getPosition(); - } - - const Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) - { - return areaInLocalSpace + comp.getPosition(); - } - - template - const Type convertFromDistantParentSpace (const Component* parent, const Component& target, Type coordInParent) - { - const Component* const directParent = target.getParentComponent(); - jassert (directParent != 0); - - if (directParent == parent) - return convertFromParentSpace (target, coordInParent); - - return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); - } +int Component::getScreenX() const { return getScreenPosition().getX(); } +int Component::getScreenY() const { return getScreenPosition().getY(); } - template - const Type convertCoordinate (const Component* target, const Component* source, Type p) - { - while (source != 0) - { - if (source == target) - return p; - - if (source->isParentOf (target)) - return convertFromDistantParentSpace (source, *target, p); - - if (source->isOnDesktop()) - { - p = source->getPeer()->localToGlobal (p); - source = 0; - } - else - { - p = convertToParentSpace (*source, p); - source = source->getParentComponent(); - } - } - - jassert (source == 0); - if (target == 0) - return p; - - const Component* const topLevelComp = target->getTopLevelComponent(); - - if (topLevelComp->isOnDesktop()) - p = topLevelComp->getPeer()->globalToLocal (p); - else - p = convertFromParentSpace (*topLevelComp, p); - - if (topLevelComp == target) - return p; - - return convertFromDistantParentSpace (topLevelComp, *target, p); - } - - const Rectangle getUnclippedArea (const Component& comp) - { - Rectangle r (comp.getLocalBounds()); - - Component* const p = comp.getParentComponent(); - - if (p != 0) - r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p))); - - return r; - } -} +const Point Component::getScreenPosition() const { return localPointToGlobal (Point()); } +const Rectangle Component::getScreenBounds() const { return localAreaToGlobal (getLocalBounds()); } const Point Component::getLocalPoint (const Component* source, const Point& point) const { - return CoordinateHelpers::convertCoordinate (this, source, point); + return ComponentHelpers::convertCoordinate (this, source, point); } const Rectangle Component::getLocalArea (const Component* source, const Rectangle& area) const { - return CoordinateHelpers::convertCoordinate (this, source, area); + return ComponentHelpers::convertCoordinate (this, source, area); } const Point Component::localPointToGlobal (const Point& point) const { - return CoordinateHelpers::convertCoordinate (0, this, point); + return ComponentHelpers::convertCoordinate (0, this, point); } const Rectangle Component::localAreaToGlobal (const Rectangle& area) const { - return CoordinateHelpers::convertCoordinate (0, this, area); + return ComponentHelpers::convertCoordinate (0, this, area); } /* Deprecated methods... */ @@ -40854,7 +40881,7 @@ void Component::setCentreRelative (const float x, const float y) void Component::centreWithSize (const int width, const int height) { - const Rectangle parentArea (getParentOrMainMonitorBounds()); + const Rectangle parentArea (ComponentHelpers::getParentOrMainMonitorBounds (*this)); setBounds (parentArea.getCentreX() - width / 2, parentArea.getCentreY() - height / 2, @@ -40863,7 +40890,7 @@ void Component::centreWithSize (const int width, const int height) void Component::setBoundsInset (const BorderSize& borders) { - setBounds (borders.subtractedFrom (getParentOrMainMonitorBounds())); + setBounds (borders.subtractedFrom (ComponentHelpers::getParentOrMainMonitorBounds (*this))); } void Component::setBoundsToFit (int x, int y, int width, int height, @@ -40924,7 +40951,7 @@ bool Component::hitTest (int x, int y) Component& child = *getChildComponent (i); if (child.isVisible() - && CoordinateHelpers::hitTest (child, CoordinateHelpers::convertFromParentSpace (child, Point (x, y)))) + && ComponentHelpers::hitTest (child, ComponentHelpers::convertFromParentSpace (child, Point (x, y)))) return true; } } @@ -40948,11 +40975,11 @@ void Component::getInterceptsMouseClicks (bool& allowsClicksOnThisComponent, bool Component::contains (const Point& point) { - if (CoordinateHelpers::hitTest (*this, point)) + if (ComponentHelpers::hitTest (*this, point)) { if (parentComponent_ != 0) { - return parentComponent_->contains (CoordinateHelpers::convertToParentSpace (*this, point)); + return parentComponent_->contains (ComponentHelpers::convertToParentSpace (*this, point)); } else if (flags.hasHeavyweightPeerFlag) { @@ -40981,12 +41008,12 @@ bool Component::reallyContains (const int x, const int y, const bool returnTrueI Component* Component::getComponentAt (const Point& position) { - if (flags.visibleFlag && CoordinateHelpers::hitTest (*this, position)) + if (flags.visibleFlag && ComponentHelpers::hitTest (*this, position)) { for (int i = childComponentList_.size(); --i >= 0;) { Component* child = childComponentList_.getUnchecked(i); - child = child->getComponentAt (CoordinateHelpers::convertFromParentSpace (*child, position)); + child = child->getComponentAt (ComponentHelpers::convertFromParentSpace (*child, position)); if (child != 0) return child; @@ -41209,14 +41236,6 @@ void Component::internalHierarchyChanged() } } -namespace ComponentHelpers -{ - void* runModalLoopCallback (void* userData) - { - return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); - } -} - int Component::runModalLoop() { if (! MessageManager::getInstance()->isThisTheMessageThread()) @@ -41479,7 +41498,7 @@ void Component::paintComponentAndChildren (Graphics& g) else { g.saveState(); - clipObscuredRegions (g, clipBounds, 0, 0); + ComponentHelpers::clipObscuredRegions (*this, g, clipBounds, Point()); if (! g.isClipEmpty()) paintComponent (g); @@ -41666,17 +41685,6 @@ void Component::sendLookAndFeelChange() } } -namespace ComponentHelpers -{ - const Identifier getColourPropertyId (const int colourId) - { - String s; - s.preallocateStorage (18); - s << "jcclr_" << String::toHexString (colourId); - return s; - } -} - const Colour Component::findColour (const int colourId, const bool inheritFromParent) const { var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)); @@ -41733,44 +41741,10 @@ const Rectangle Component::getLocalBounds() const throw() return Rectangle (getWidth(), getHeight()); } -const Rectangle Component::getParentOrMainMonitorBounds() const -{ - return parentComponent_ != 0 ? parentComponent_->getLocalBounds() - : Desktop::getInstance().getMainMonitorArea(); -} - -void Component::clipObscuredRegions (Graphics& g, const Rectangle& clipRect, - const int deltaX, const int deltaY) const -{ - for (int i = childComponentList_.size(); --i >= 0;) - { - const Component* const c = childComponentList_.getUnchecked(i); - - if (c->isVisible()) - { - const Rectangle newClip (clipRect.getIntersection (c->bounds_)); - - if (! newClip.isEmpty()) - { - if (c->isOpaque()) - { - g.excludeClipRegion (newClip.translated (deltaX, deltaY)); - } - else - { - c->clipObscuredRegions (g, newClip.translated (-c->getX(), -c->getY()), - c->getX() + deltaX, - c->getY() + deltaY); - } - } - } - } -} - void Component::getVisibleArea (RectangleList& result, const bool includeSiblings) const { result.clear(); - const Rectangle unclipped (CoordinateHelpers::getUnclippedArea (*this)); + const Rectangle unclipped (ComponentHelpers::getUnclippedArea (*this)); if (! unclipped.isEmpty()) { @@ -41780,45 +41754,15 @@ void Component::getVisibleArea (RectangleList& result, const bool includeSibling { const Component* const c = getTopLevelComponent(); - c->subtractObscuredRegions (result, getLocalPoint (c, Point()), - c->getLocalBounds(), this); + ComponentHelpers::subtractObscuredRegions (*c, result, getLocalPoint (c, Point()), + c->getLocalBounds(), this); } - subtractObscuredRegions (result, Point(), unclipped, 0); + ComponentHelpers::subtractObscuredRegions (*this, result, Point(), unclipped, 0); result.consolidate(); } } -void Component::subtractObscuredRegions (RectangleList& result, - const Point& delta, - const Rectangle& clipRect, - const Component* const compToAvoid) const -{ - for (int i = childComponentList_.size(); --i >= 0;) - { - const Component* const c = childComponentList_.getUnchecked(i); - - if (c != compToAvoid && c->isVisible()) - { - if (c->isOpaque()) - { - Rectangle childBounds (c->bounds_.getIntersection (clipRect)); - childBounds.translate (delta.getX(), delta.getY()); - - result.subtract (childBounds); - } - else - { - Rectangle newClip (clipRect.getIntersection (c->bounds_)); - newClip.translate (-c->getX(), -c->getY()); - - c->subtractObscuredRegions (result, c->getPosition() + delta, - newClip, compToAvoid); - } - } - } -} - void Component::mouseEnter (const MouseEvent&) { // base class does nothing @@ -48929,6 +48873,7 @@ void ListBox::setModel (ListBoxModel* const newModel) if (model != newModel) { model = newModel; + repaint(); updateContent(); } } @@ -58001,7 +57946,7 @@ bool DirectoryContentsList::isStillLoading() const void DirectoryContentsList::changed() { - sendChangeMessage (this); + sendChangeMessage(); } bool DirectoryContentsList::useTimeSlice() @@ -58969,7 +58914,7 @@ void FileListComponent::scrollToTop() getVerticalScrollBar()->setCurrentRangeStart (0); } -void FileListComponent::changeListenerCallback (void*) +void FileListComponent::changeListenerCallback (ChangeBroadcaster*) { updateContent(); @@ -59722,7 +59667,7 @@ public: newList->addChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { clearSubItems(); @@ -60481,7 +60426,7 @@ public: bool mightContainSubItems() { return true; } const String getUniqueName() const { return "keys"; } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { const ScopedPointer oldOpenness (owner.tree.getOpennessState (true)); @@ -60904,7 +60849,7 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID, { mappings.getUnchecked(i)->keypresses.insert (insertIndex, newKeyPress); - sendChangeMessage (this); + sendChangeMessage(); return; } } @@ -60919,7 +60864,7 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID, cm->wantsKeyUpDownCallbacks = (ci->flags & ApplicationCommandInfo::wantsKeyUpDownCallbacks) != 0; mappings.add (cm); - sendChangeMessage (this); + sendChangeMessage(); } } } @@ -60940,7 +60885,7 @@ void KeyPressMappingSet::resetToDefaultMappings() } } - sendChangeMessage (this); + sendChangeMessage(); } void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID) @@ -60960,7 +60905,7 @@ void KeyPressMappingSet::clearAllKeyPresses() { if (mappings.size() > 0) { - sendChangeMessage (this); + sendChangeMessage(); mappings.clear(); } } @@ -60972,7 +60917,7 @@ void KeyPressMappingSet::clearAllKeyPresses (const CommandID commandID) if (mappings.getUnchecked(i)->commandID == commandID) { mappings.remove (i); - sendChangeMessage (this); + sendChangeMessage(); } } } @@ -60990,7 +60935,7 @@ void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress) if (keypress == cm->keypresses [j]) { cm->keypresses.remove (j); - sendChangeMessage (this); + sendChangeMessage(); } } } @@ -61004,7 +60949,7 @@ void KeyPressMappingSet::removeKeyPress (const CommandID commandID, const int ke if (mappings.getUnchecked(i)->commandID == commandID) { mappings.getUnchecked(i)->keypresses.remove (keyPressIndex); - sendChangeMessage (this); + sendChangeMessage(); break; } } @@ -61494,7 +61439,7 @@ void ComponentAnimator::animateComponent (Component* const component, { at = new AnimationTask (component); tasks.add (at); - sendChangeMessage (this); + sendChangeMessage(); } at->reset (finalBounds, finalAlpha, millisecondsToSpendMoving, @@ -61538,7 +61483,7 @@ void ComponentAnimator::cancelAllAnimations (const bool moveComponentsToTheirFin tasks.getUnchecked(i)->moveToFinalDestination(); tasks.clear(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -61553,7 +61498,7 @@ void ComponentAnimator::cancelAnimation (Component* const component, at->moveToFinalDestination(); tasks.removeObject (at); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -61587,7 +61532,7 @@ void ComponentAnimator::timerCallback() if (! tasks.getUnchecked(i)->useTimeslice (elapsed)) { tasks.remove (i); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -64006,7 +63951,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, const bool sendChangeMes resized(); if (sendChangeMessage_) - sendChangeMessage (this); + sendChangeMessage(); currentTabChanged (newIndex, getCurrentTabName()); } @@ -67859,8 +67804,8 @@ void LookAndFeel::drawGlassLozenge (Graphics& g, } { - const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; - const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; + const float leftIndent = flatOnTop || flatOnLeft ? 0.0f : cs * 0.4f; + const float rightIndent = flatOnTop || flatOnRight ? 0.0f : cs * 0.4f; Path highlight; LookAndFeelHelpers::createRoundedPath (highlight, @@ -73125,7 +73070,7 @@ public: resized(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice(); @@ -73762,7 +73707,7 @@ void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha } } -void AudioDeviceSelectorComponent::changeListenerCallback (void*) +void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*) { if (deviceTypeDropDown != 0) { @@ -74497,7 +74442,7 @@ void ColourSelector::update() if ((flags & showColourAtTop) != 0) repaint (previewArea); - sendChangeMessage (this); + sendChangeMessage(); } void ColourSelector::paint (Graphics& g) @@ -75394,7 +75339,7 @@ void MidiKeyboardComponent::setLowestVisibleKey (int noteNumber) if (noteNumber != firstKey) { firstKey = noteNumber; - sendChangeMessage (this); + sendChangeMessage(); resized(); } } @@ -75838,7 +75783,7 @@ void MidiKeyboardComponent::resized() if (kx2 - kx1 <= w) { firstKey = rangeStart; - sendChangeMessage (this); + sendChangeMessage(); repaint(); } } @@ -75881,7 +75826,7 @@ void MidiKeyboardComponent::resized() if (lastStartKey >= 0 && firstKey > lastStartKey) { firstKey = jlimit (rangeStart, rangeEnd, lastStartKey); - sendChangeMessage (this); + sendChangeMessage(); } int newOffset = 0; @@ -82132,6 +82077,11 @@ void Graphics::setOrigin (const int newOriginX, const int newOriginY) context->setOrigin (newOriginX, newOriginY); } +void Graphics::addTransform (const AffineTransform& transform) +{ + context->addTransform (transform); +} + bool Graphics::clipRegionIntersects (const Rectangle& area) const { return context->clipRegionIntersects (area); @@ -242341,6 +242291,7 @@ public: if (taskBarIcon == 0) { taskBarIcon = new NOTIFYICONDATA(); + zeromem (taskBarIcon, sizeof (NOTIFYICONDATA)); taskBarIcon->cbSize = sizeof (NOTIFYICONDATA); taskBarIcon->hWnd = (HWND) hwnd; taskBarIcon->uID = (int) (pointer_sized_int) hwnd; @@ -242361,8 +242312,6 @@ public: DestroyIcon (oldIcon); } - - DestroyIcon (hicon); } else if (taskBarIcon != 0) { @@ -242383,6 +242332,55 @@ public: } } + void handleTaskBarEvent (const LPARAM lParam, const WPARAM wParam) + { + if (component->isCurrentlyBlockedByAnotherModalComponent()) + { + if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN + || lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) + { + Component* const current = Component::getCurrentlyModalComponent(); + + if (current != 0) + current->inputAttemptWhenModal(); + } + } + else + { + ModifierKeys eventMods (ModifierKeys::getCurrentModifiersRealtime()); + + if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) + eventMods = eventMods.withFlags (ModifierKeys::leftButtonModifier); + else if (lParam == WM_RBUTTONDOWN || lParam == WM_RBUTTONDBLCLK) + eventMods = eventMods.withFlags (ModifierKeys::rightButtonModifier); + else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) + eventMods = eventMods.withoutMouseButtons(); + + const MouseEvent e (Desktop::getInstance().getMainMouseSource(), + Point(), eventMods, component, component, getMouseEventTime(), + Point(), getMouseEventTime(), 1, false); + + if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN) + { + SetFocus (hwnd); + SetForegroundWindow (hwnd); + component->mouseDown (e); + } + else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) + { + component->mouseUp (e); + } + else if (lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) + { + component->mouseDoubleClick (e); + } + else if (lParam == WM_MOUSEMOVE) + { + component->mouseMove (e); + } + } + } + bool isInside (HWND h) const { return GetAncestor (hwnd, GA_ROOT) == h; @@ -243145,21 +243143,11 @@ private: switch (GET_APPCOMMAND_LPARAM (lParam)) { - case APPCOMMAND_MEDIA_PLAY_PAUSE: - key = KeyPress::playKey; - break; - - case APPCOMMAND_MEDIA_STOP: - key = KeyPress::stopKey; - break; - - case APPCOMMAND_MEDIA_NEXTTRACK: - key = KeyPress::fastForwardKey; - break; - - case APPCOMMAND_MEDIA_PREVIOUSTRACK: - key = KeyPress::rewindKey; - break; + case APPCOMMAND_MEDIA_PLAY_PAUSE: key = KeyPress::playKey; break; + case APPCOMMAND_MEDIA_STOP: key = KeyPress::stopKey; break; + case APPCOMMAND_MEDIA_NEXTTRACK: key = KeyPress::fastForwardKey; break; + case APPCOMMAND_MEDIA_PREVIOUSTRACK: key = KeyPress::rewindKey; break; + default: break; } if (key != 0) @@ -243176,6 +243164,83 @@ private: return false; } + LRESULT handleSizeConstraining (RECT* const r, const WPARAM wParam) + { + if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) + { + Rectangle pos (r->left, r->top, r->right - r->left, r->bottom - r->top); + + constrainer->checkBounds (pos, windowBorder.addedTo (component->getBounds()), + Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), + wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT, + wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT, + wParam == WMSZ_BOTTOM || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT, + wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT || wParam == WMSZ_BOTTOMRIGHT); + r->left = pos.getX(); + r->top = pos.getY(); + r->right = pos.getRight(); + r->bottom = pos.getBottom(); + } + + return TRUE; + } + + LRESULT handlePositionChanging (WINDOWPOS* const wp) + { + if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) + { + if ((wp->flags & (SWP_NOMOVE | SWP_NOSIZE)) != (SWP_NOMOVE | SWP_NOSIZE) + && ! Component::isMouseButtonDownAnywhere()) + { + Rectangle pos (wp->x, wp->y, wp->cx, wp->cy); + const Rectangle current (windowBorder.addedTo (component->getBounds())); + + constrainer->checkBounds (pos, current, + Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), + pos.getY() != current.getY() && pos.getBottom() == current.getBottom(), + pos.getX() != current.getX() && pos.getRight() == current.getRight(), + pos.getY() == current.getY() && pos.getBottom() != current.getBottom(), + pos.getX() == current.getX() && pos.getRight() != current.getRight()); + wp->x = pos.getX(); + wp->y = pos.getY(); + wp->cx = pos.getWidth(); + wp->cy = pos.getHeight(); + } + } + + return 0; + } + + void handleAppActivation (const WPARAM wParam) + { + modifiersAtLastCallback = -1; + updateKeyModifiers(); + + if (isMinimised()) + { + component->repaint(); + handleMovedOrResized(); + + if (! ComponentPeer::isValidPeer (this)) + return; + } + + if (LOWORD (wParam) == WA_CLICKACTIVE && component->isCurrentlyBlockedByAnotherModalComponent()) + { + Component* const underMouse = component->getComponentAt (component->getMouseXYRelative()); + + if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent()) + Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); + } + else + { + handleBroughtToFront(); + + if (component->isCurrentlyBlockedByAnotherModalComponent()) + Component::getCurrentlyModalComponent()->toFront (true); + } + } + class JuceDropTarget : public ComBaseClassHelper { public: @@ -243334,11 +243399,10 @@ private: case WM_NCHITTEST: if ((styleFlags & windowIgnoresMouseClicks) != 0) return HTTRANSPARENT; + else if (! hasTitleBar()) + return HTCLIENT; - if (hasTitleBar()) - break; - - return HTCLIENT; + break; case WM_PAINT: handlePaintMessage(); @@ -243399,48 +243463,10 @@ private: return 0; case WM_SIZING: - if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) - { - RECT* const r = (RECT*) lParam; - Rectangle pos (r->left, r->top, r->right - r->left, r->bottom - r->top); - - constrainer->checkBounds (pos, windowBorder.addedTo (component->getBounds()), - Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), - wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT, - wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT, - wParam == WMSZ_BOTTOM || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT, - wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT || wParam == WMSZ_BOTTOMRIGHT); - r->left = pos.getX(); - r->top = pos.getY(); - r->right = pos.getRight(); - r->bottom = pos.getBottom(); - } - return TRUE; + return handleSizeConstraining ((RECT*) lParam, wParam); case WM_WINDOWPOSCHANGING: - if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) - { - WINDOWPOS* const wp = (WINDOWPOS*) lParam; - - if ((wp->flags & (SWP_NOMOVE | SWP_NOSIZE)) != (SWP_NOMOVE | SWP_NOSIZE) - && ! Component::isMouseButtonDownAnywhere()) - { - Rectangle pos (wp->x, wp->y, wp->cx, wp->cy); - const Rectangle current (windowBorder.addedTo (component->getBounds())); - - constrainer->checkBounds (pos, current, - Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), - pos.getY() != current.getY() && pos.getBottom() == current.getBottom(), - pos.getX() != current.getX() && pos.getRight() == current.getRight(), - pos.getY() == current.getY() && pos.getBottom() != current.getBottom(), - pos.getX() == current.getX() && pos.getRight() != current.getRight()); - wp->x = pos.getX(); - wp->y = pos.getY(); - wp->cx = pos.getWidth(); - wp->cy = pos.getHeight(); - } - } - return 0; + return handlePositionChanging ((WINDOWPOS*) lParam); case WM_WINDOWPOSCHANGED: { @@ -243512,35 +243538,7 @@ private: case WM_ACTIVATE: if (LOWORD (wParam) == WA_ACTIVE || LOWORD (wParam) == WA_CLICKACTIVE) { - modifiersAtLastCallback = -1; - updateKeyModifiers(); - - if (isMinimised()) - { - component->repaint(); - handleMovedOrResized(); - - if (! ComponentPeer::isValidPeer (this)) - return 0; - } - - if (LOWORD (wParam) == WA_CLICKACTIVE - && component->isCurrentlyBlockedByAnotherModalComponent()) - { - const Point mousePos (component->getMouseXYRelative()); - Component* const underMouse = component->getComponentAt (mousePos.getX(), mousePos.getY()); - - if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent()) - Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); - - return 0; - } - - handleBroughtToFront(); - - if (component->isCurrentlyBlockedByAnotherModalComponent()) - Component::getCurrentlyModalComponent()->toFront (true); - + handleAppActivation (wParam); return 0; } @@ -243581,52 +243579,7 @@ private: return TRUE; case WM_TRAYNOTIFY: - if (component->isCurrentlyBlockedByAnotherModalComponent()) - { - if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN - || lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) - { - Component* const current = Component::getCurrentlyModalComponent(); - - if (current != 0) - current->inputAttemptWhenModal(); - } - } - else - { - ModifierKeys eventMods (ModifierKeys::getCurrentModifiersRealtime()); - - if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) - eventMods = eventMods.withFlags (ModifierKeys::leftButtonModifier); - else if (lParam == WM_RBUTTONDOWN || lParam == WM_RBUTTONDBLCLK) - eventMods = eventMods.withFlags (ModifierKeys::rightButtonModifier); - else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) - eventMods = eventMods.withoutMouseButtons(); - - const MouseEvent e (Desktop::getInstance().getMainMouseSource(), - Point(), eventMods, component, component, getMouseEventTime(), - Point(), getMouseEventTime(), 1, false); - - if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN) - { - SetFocus (hwnd); - SetForegroundWindow (hwnd); - component->mouseDown (e); - } - else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) - { - component->mouseUp (e); - } - else if (lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) - { - component->mouseDoubleClick (e); - } - else if (lParam == WM_MOUSEMOVE) - { - component->mouseMove (e); - } - } - + handleTaskBarEvent (lParam, wParam); break; case WM_SYNCPAINT: @@ -243674,10 +243627,8 @@ private: break; case SC_KEYMENU: - // (NB mustn't call sendInputAttemptWhenModalMessage() here because of very - // obscure situations that can arise if a modal loop is started from an alt-key - // keypress). - + // (NB mustn't call sendInputAttemptWhenModalMessage() here because of very obscure + // situations that can arise if a modal loop is started from an alt-key keypress). if (hasTitleBar() && h == GetCapture()) ReleaseCapture(); @@ -243741,6 +243692,17 @@ private: return DLGC_WANTALLKEYS; default: + if (taskBarIcon != 0) + { + static const DWORD taskbarCreatedMessage = RegisterWindowMessage (TEXT("TaskbarCreated")); + + if (message == taskbarCreatedMessage) + { + taskBarIcon->uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + Shell_NotifyIcon (NIM_ADD, taskBarIcon); + } + } + break; } } @@ -248537,7 +248499,7 @@ public: if (state != lastState) { lastState = state; - owner.sendChangeMessage (&owner); + owner.sendChangeMessage(); } } @@ -253914,7 +253876,7 @@ public: if (listeners.size() > 0) callListeners (loadingImage); - sendChangeMessage (this); + sendChangeMessage(); } void drawCurrentImage (Graphics& g, int x, int y, int w, int h) @@ -254126,7 +254088,7 @@ public: g.fillAll (Colours::black); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { const int64 now = Time::currentTimeMillis(); @@ -276265,7 +276227,7 @@ public: if (state != lastState) { lastState = state; - owner.sendChangeMessage (&owner); + owner.sendChangeMessage(); } } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 6ee4bb91e8..556c67e80d 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 92 +#define JUCE_BUILDNUMBER 93 /** Current Juce version number. @@ -798,6 +798,13 @@ /** This macro is added to all juce public function declarations. */ #define JUCE_PUBLIC_FUNCTION JUCE_API JUCE_CALLTYPE +/** This turns on some non-essential bits of code that should prevent old code from compiling + in cases where method signatures have changed, etc. +*/ +#if (! defined (JUCE_CATCH_DEPRECATED_CODE_MISUSE)) && JUCE_DEBUG && ! DOXYGEN + #define JUCE_CATCH_DEPRECATED_CODE_MISUSE 1 +#endif + // Now include some basics that are needed by most of the Juce classes... BEGIN_JUCE_NAMESPACE @@ -12585,6 +12592,12 @@ public: return listeners.size() == 0; } + /** Clears the list. */ + void clear() + { + listeners.clear(); + } + /** Returns true if the specified listener has been added to the list. */ bool contains (ListenerClass* const listener) const throw() { @@ -12993,27 +13006,24 @@ typedef Value::Listener ValueListener; #define __JUCE_CHANGEBROADCASTER_JUCEHEADER__ -/*** Start of inlined file: juce_ChangeListenerList.h ***/ -#ifndef __JUCE_CHANGELISTENERLIST_JUCEHEADER__ -#define __JUCE_CHANGELISTENERLIST_JUCEHEADER__ - - /*** Start of inlined file: juce_ChangeListener.h ***/ #ifndef __JUCE_CHANGELISTENER_JUCEHEADER__ #define __JUCE_CHANGELISTENER_JUCEHEADER__ +class ChangeBroadcaster; + /** - Receives callbacks about changes to some kind of object. + Receives change event callbacks that are sent out by a ChangeBroadcaster. - Many objects use a ChangeListenerList to keep a set of listeners which they - will inform when something changes. A subclass of ChangeListener - is used to receive these callbacks. + A ChangeBroadcaster keeps a set of listeners to which it broadcasts a message when + the ChangeBroadcaster::sendChangeMessage() method is called. A subclass of + ChangeListener is used to receive these callbacks. Note that the major difference between an ActionListener and a ChangeListener is that for a ChangeListener, multiple changes will be coalesced into fewer callbacks, but ActionListeners perform one callback for every event posted. - @see ChangeListenerList, ChangeBroadcaster, ActionListener + @see ChangeBroadcaster, ActionListener */ class JUCE_API ChangeListener { @@ -13021,238 +13031,24 @@ public: /** Destructor. */ virtual ~ChangeListener() {} - /** Overridden by your subclass to receive the callback. - - @param objectThatHasChanged the value that was passed to the - ChangeListenerList::sendChangeMessage() method + /** Your subclass should implement this method to receive the callback. + @param source the ChangeBroadcaster that triggered the callback. */ - virtual void changeListenerCallback (void* objectThatHasChanged) = 0; + virtual void changeListenerCallback (ChangeBroadcaster* source) = 0; + + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This method's signature has changed to take a ChangeBroadcaster parameter - please update your code! + private: virtual int changeListenerCallback (void*) { return 0; } + #endif }; #endif // __JUCE_CHANGELISTENER_JUCEHEADER__ /*** End of inlined file: juce_ChangeListener.h ***/ - -/*** Start of inlined file: juce_ScopedLock.h ***/ -#ifndef __JUCE_SCOPEDLOCK_JUCEHEADER__ -#define __JUCE_SCOPEDLOCK_JUCEHEADER__ - -/** - Automatically locks and unlocks a CriticalSection object. - - Use one of these as a local variable to control access to a CriticalSection. - - e.g. @code - - CriticalSection myCriticalSection; - - for (;;) - { - const ScopedLock myScopedLock (myCriticalSection); - // myCriticalSection is now locked - - ...do some stuff... - - // myCriticalSection gets unlocked here. - } - @endcode - - @see CriticalSection, ScopedUnlock -*/ -class JUCE_API ScopedLock -{ -public: - - /** Creates a ScopedLock. - - As soon as it is created, this will lock the CriticalSection, and - when the ScopedLock object is deleted, the CriticalSection will - be unlocked. - - Make sure this object is created and deleted by the same thread, - otherwise there are no guarantees what will happen! Best just to use it - as a local stack object, rather than creating one with the new() operator. - */ - inline explicit ScopedLock (const CriticalSection& lock) throw() : lock_ (lock) { lock.enter(); } - - /** Destructor. - - The CriticalSection will be unlocked when the destructor is called. - - Make sure this object is created and deleted by the same thread, - otherwise there are no guarantees what will happen! - */ - inline ~ScopedLock() throw() { lock_.exit(); } - -private: - - const CriticalSection& lock_; - - ScopedLock (const ScopedLock&); - ScopedLock& operator= (const ScopedLock&); -}; - -/** - Automatically unlocks and re-locks a CriticalSection object. - - This is the reverse of a ScopedLock object - instead of locking the critical - section for the lifetime of this object, it unlocks it. - - Make sure you don't try to unlock critical sections that aren't actually locked! - - e.g. @code - - CriticalSection myCriticalSection; - - for (;;) - { - const ScopedLock myScopedLock (myCriticalSection); - // myCriticalSection is now locked - - ... do some stuff with it locked .. - - while (xyz) - { - ... do some stuff with it locked .. - - const ScopedUnlock unlocker (myCriticalSection); - - // myCriticalSection is now unlocked for the remainder of this block, - // and re-locked at the end. - - ...do some stuff with it unlocked ... - } - - // myCriticalSection gets unlocked here. - } - @endcode - - @see CriticalSection, ScopedLock -*/ -class ScopedUnlock -{ -public: - - /** Creates a ScopedUnlock. - - As soon as it is created, this will unlock the CriticalSection, and - when the ScopedLock object is deleted, the CriticalSection will - be re-locked. - - Make sure this object is created and deleted by the same thread, - otherwise there are no guarantees what will happen! Best just to use it - as a local stack object, rather than creating one with the new() operator. - */ - inline explicit ScopedUnlock (const CriticalSection& lock) throw() : lock_ (lock) { lock.exit(); } - - /** Destructor. - - The CriticalSection will be unlocked when the destructor is called. - - Make sure this object is created and deleted by the same thread, - otherwise there are no guarantees what will happen! - */ - inline ~ScopedUnlock() throw() { lock_.enter(); } - -private: - - const CriticalSection& lock_; - - ScopedUnlock (const ScopedLock&); - ScopedUnlock& operator= (const ScopedUnlock&); -}; - -#endif // __JUCE_SCOPEDLOCK_JUCEHEADER__ -/*** End of inlined file: juce_ScopedLock.h ***/ - /** - A set of ChangeListeners. - - Listeners can be added and removed from the list, and change messages can be - broadcast to all the listeners. + Holds a list of ChangeListeners, and sends messages to them when instructed. - @see ChangeListener, ChangeBroadcaster -*/ -class JUCE_API ChangeListenerList : public MessageListener -{ -public: - - /** Creates an empty list. */ - ChangeListenerList(); - - /** Destructor. */ - ~ChangeListenerList(); - - /** Adds a listener to the list. - - (Trying to add a listener that's already on the list will have no effect). - */ - void addChangeListener (ChangeListener* listener); - - /** Removes a listener from the list. - - If the listener isn't on the list, this won't have any effect. - */ - void removeChangeListener (ChangeListener* listener); - - /** Removes all listeners from the list. */ - void removeAllChangeListeners(); - - /** Posts an asynchronous change message to all the listeners. - - If a message has already been sent and hasn't yet been delivered, this - method won't send another - in this way it coalesces multiple frequent - changes into fewer actual callbacks to the ChangeListeners. Contrast this - with the ActionListener, which posts a new event for every call to its - sendActionMessage() method. - - Only listeners which are on the list when the change event is delivered - will receive the event - and this may include listeners that weren't on - the list when the change message was sent. - - @param objectThatHasChanged this pointer is passed to the - ChangeListener::changeListenerCallback() method, - and can be any value the application needs - @see sendSynchronousChangeMessage - */ - void sendChangeMessage (void* objectThatHasChanged); - - /** This will synchronously callback all the ChangeListeners. - - Use this if you need to synchronously force a call to all the - listeners' ChangeListener::changeListenerCallback() methods. - */ - void sendSynchronousChangeMessage (void* objectThatHasChanged); - - /** If a change message has been sent but not yet dispatched, this will - use sendSynchronousChangeMessage() to make the callback immediately. - */ - void dispatchPendingMessages(); - - /** @internal */ - void handleMessage (const Message&); - - juce_UseDebuggingNewOperator - -private: - SortedSet listeners; - CriticalSection lock; - void* lastChangedObject; - bool messagePending; - - ChangeListenerList (const ChangeListenerList&); - ChangeListenerList& operator= (const ChangeListenerList&); -}; - -#endif // __JUCE_CHANGELISTENERLIST_JUCEHEADER__ -/*** End of inlined file: juce_ChangeListenerList.h ***/ - -/** Manages a list of ChangeListeners, and can send them messages. - - To quickly add methods to your class that can add/remove change - listeners and broadcast to them, you can derive from this. - - @see ChangeListenerList, ChangeListener + @see ChangeListener */ class JUCE_API ChangeBroadcaster { @@ -13264,14 +13060,12 @@ public: /** Destructor. */ virtual ~ChangeBroadcaster(); - /** Adds a listener to the list. - - (Trying to add a listener that's already on the list will have no effect). + /** Registers a listener to receive change callbacks from this broadcaster. + Trying to add a listener that's already on the list will have no effect. */ void addChangeListener (ChangeListener* listener); - /** Removes a listener from the list. - + /** Unregisters a listener from the list. If the listener isn't on the list, this won't have any effect. */ void removeChangeListener (ChangeListener* listener); @@ -13279,30 +13073,39 @@ public: /** Removes all listeners from the list. */ void removeAllChangeListeners(); - /** Broadcasts a change message to all the registered listeners. - - The message will be delivered asynchronously by the event thread, so this - method will not directly call any of the listeners. For a synchronous - message, use sendSynchronousChangeMessage(). + /** Causes an asynchronous change message to be sent to all the registered listeners. - @see ChangeListenerList::sendActionMessage + The message will be delivered asynchronously by the main message thread, so this + method will return immediately. To call the listeners synchronously use + sendSynchronousChangeMessage(). */ - void sendChangeMessage (void* objectThatHasChanged); + void sendChangeMessage(); /** Sends a synchronous change message to all the registered listeners. - @see ChangeListenerList::sendSynchronousChangeMessage + This will immediately call all the listeners that are registered. For thread-safety + reasons, you must only call this method on the main message thread. + + @see dispatchPendingMessages */ - void sendSynchronousChangeMessage (void* objectThatHasChanged); + void sendSynchronousChangeMessage(); + + /** If a change message has been sent but not yet dispatched, this will call + sendSynchronousChangeMessage() to make the callback immediately. - /** If a change message has been sent but not yet dispatched, this will - use sendSynchronousChangeMessage() to make the callback immediately. + For thread-safety reasons, you must only call this method on the main message thread. */ void dispatchPendingMessages(); private: - ChangeListenerList changeListenerList; + class ChangeBroadcasterMessage; + friend class ChangeBroadcasterMessage; + + Atomic pendingMessage; + ListenerList changeListeners; + + void invalidatePendingMessage(); ChangeBroadcaster (const ChangeBroadcaster&); ChangeBroadcaster& operator= (const ChangeBroadcaster&); @@ -14833,6 +14636,139 @@ private: #ifndef __JUCE_SINGLETON_JUCEHEADER__ #define __JUCE_SINGLETON_JUCEHEADER__ + +/*** Start of inlined file: juce_ScopedLock.h ***/ +#ifndef __JUCE_SCOPEDLOCK_JUCEHEADER__ +#define __JUCE_SCOPEDLOCK_JUCEHEADER__ + +/** + Automatically locks and unlocks a CriticalSection object. + + Use one of these as a local variable to control access to a CriticalSection. + + e.g. @code + + CriticalSection myCriticalSection; + + for (;;) + { + const ScopedLock myScopedLock (myCriticalSection); + // myCriticalSection is now locked + + ...do some stuff... + + // myCriticalSection gets unlocked here. + } + @endcode + + @see CriticalSection, ScopedUnlock +*/ +class JUCE_API ScopedLock +{ +public: + + /** Creates a ScopedLock. + + As soon as it is created, this will lock the CriticalSection, and + when the ScopedLock object is deleted, the CriticalSection will + be unlocked. + + Make sure this object is created and deleted by the same thread, + otherwise there are no guarantees what will happen! Best just to use it + as a local stack object, rather than creating one with the new() operator. + */ + inline explicit ScopedLock (const CriticalSection& lock) throw() : lock_ (lock) { lock.enter(); } + + /** Destructor. + + The CriticalSection will be unlocked when the destructor is called. + + Make sure this object is created and deleted by the same thread, + otherwise there are no guarantees what will happen! + */ + inline ~ScopedLock() throw() { lock_.exit(); } + +private: + + const CriticalSection& lock_; + + ScopedLock (const ScopedLock&); + ScopedLock& operator= (const ScopedLock&); +}; + +/** + Automatically unlocks and re-locks a CriticalSection object. + + This is the reverse of a ScopedLock object - instead of locking the critical + section for the lifetime of this object, it unlocks it. + + Make sure you don't try to unlock critical sections that aren't actually locked! + + e.g. @code + + CriticalSection myCriticalSection; + + for (;;) + { + const ScopedLock myScopedLock (myCriticalSection); + // myCriticalSection is now locked + + ... do some stuff with it locked .. + + while (xyz) + { + ... do some stuff with it locked .. + + const ScopedUnlock unlocker (myCriticalSection); + + // myCriticalSection is now unlocked for the remainder of this block, + // and re-locked at the end. + + ...do some stuff with it unlocked ... + } + + // myCriticalSection gets unlocked here. + } + @endcode + + @see CriticalSection, ScopedLock +*/ +class ScopedUnlock +{ +public: + + /** Creates a ScopedUnlock. + + As soon as it is created, this will unlock the CriticalSection, and + when the ScopedLock object is deleted, the CriticalSection will + be re-locked. + + Make sure this object is created and deleted by the same thread, + otherwise there are no guarantees what will happen! Best just to use it + as a local stack object, rather than creating one with the new() operator. + */ + inline explicit ScopedUnlock (const CriticalSection& lock) throw() : lock_ (lock) { lock.exit(); } + + /** Destructor. + + The CriticalSection will be unlocked when the destructor is called. + + Make sure this object is created and deleted by the same thread, + otherwise there are no guarantees what will happen! + */ + inline ~ScopedUnlock() throw() { lock_.enter(); } + +private: + + const CriticalSection& lock_; + + ScopedUnlock (const ScopedLock&); + ScopedUnlock& operator= (const ScopedUnlock&); +}; + +#endif // __JUCE_SCOPEDLOCK_JUCEHEADER__ +/*** End of inlined file: juce_ScopedLock.h ***/ + /** Macro to declare member variables and methods for a singleton class. @@ -25137,10 +25073,20 @@ public: So if you call setOrigin (100, 100), then the position that was previously referred to as (100, 100) will subsequently be considered to be (0, 0). - @see reduceClipRegion + @see reduceClipRegion, addTransform */ void setOrigin (int newOriginX, int newOriginY); + /** Adds a transformation which will be performed on all the graphics operations that + the context subsequently performs. + + After calling this, all the coordinates that are passed into the context will be + transformed by this matrix. + + @see setOrigin + */ + void addTransform (const AffineTransform& transform); + /** Resets the current colour, brush, and font to default settings. */ void resetToDefaultState(); @@ -28003,16 +27949,13 @@ public: }; #ifndef DOXYGEN - /** @internal - This method is deprecated - use localPointToGlobal instead. */ + /** This method is deprecated - use localPointToGlobal instead. */ const Point relativePositionToGlobal (const Point& relativePosition) const; - /** @internal - This method is deprecated - use getLocalPoint instead. */ + /** This method is deprecated - use getLocalPoint instead. */ const Point globalPositionToRelative (const Point& screenPosition) const; - /** @internal - This method is deprecated - use getLocalPoint instead. */ + /** This method is deprecated - use getLocalPoint instead. */ const Point relativePositionToOtherComponent (const Component* targetComponent, const Point& positionRelativeToThis) const; #endif @@ -28103,13 +28046,19 @@ private: void grabFocusInternal (const FocusChangeType cause, bool canTryParent = true); static void giveAwayFocus(); void sendEnablementChangeMessage(); - void subtractObscuredRegions (RectangleList& result, const Point& delta, - const Rectangle& clipRect, const Component* const compToAvoid) const; - void clipObscuredRegions (Graphics& g, const Rectangle& clipRect, int deltaX, int deltaY) const; - void sendVisibilityChangeMessage(); - const Rectangle getParentOrMainMonitorBounds() const; + class ComponentHelpers; + friend class ComponentHelpers; + + /* Components aren't allowed to have copy constructors, as this would mess up parent hierarchies. + You might need to give your subclasses a private dummy constructor like this one to avoid + compiler warnings. + */ + Component (const Component&); + Component& operator= (const Component&); + + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE // This is included here just to cause a compile error if your code is still handling // drag-and-drop with this method. If so, just update it to use the new FileDragAndDropTarget // class, which is easy (just make your class inherit from FileDragAndDropTarget, and @@ -28119,15 +28068,10 @@ private: // This is included here to cause an error if you use or overload it - it has been deprecated in // favour of contains (const Point&) void contains (int, int); - - /* Components aren't allowed to have copy constructors, as this would mess up parent hierarchies. - You might need to give your subclasses a private dummy constructor like this one to avoid - compiler warnings. - */ - Component (const Component&); - Component& operator= (const Component&); + #endif protected: + /** @internal */ virtual void internalRepaint (int x, int y, int w, int h); /** @internal */ @@ -29727,9 +29671,11 @@ private: void handleAsyncUpdate(); void globalFocusChanged (Component*); - // xxx this is just here to cause a compile error in old code that hasn't been changed to use the new + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This is just here to cause a compile error in old code that hasn't been changed to use the new // version of this method. virtual short getFirstCommandTarget() { return 0; } + #endif ApplicationCommandManager (const ApplicationCommandManager&); ApplicationCommandManager& operator= (const ApplicationCommandManager&); @@ -42087,7 +42033,7 @@ public: /** @internal */ void buttonClicked (Button* b); /** @internal */ - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); /** @internal */ void timerCallback(); @@ -43292,8 +43238,10 @@ protected: int midiNoteNumber, float velocity); - /** xxx Temporary method here to cause a compiler error - note the new parameters for this method. */ + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // Temporary method here to cause a compiler error - note the new parameters for this method. int findFreeVoice (const bool) const { return 0; } + #endif private: double sampleRate; @@ -43623,9 +43571,6 @@ private: #endif #ifndef __JUCE_CHANGELISTENER_JUCEHEADER__ -#endif -#ifndef __JUCE_CHANGELISTENERLIST_JUCEHEADER__ - #endif #ifndef __JUCE_INTERPROCESSCONNECTION_JUCEHEADER__ @@ -51954,7 +51899,7 @@ public: void scrollToTop(); /** @internal */ - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); /** @internal */ int getNumRows(); /** @internal */ @@ -56186,9 +56131,9 @@ public: void changed (const bool synchronous = false) { if (synchronous) - sendSynchronousChangeMessage (this); + sendSynchronousChangeMessage(); else - sendChangeMessage (this); + sendChangeMessage(); } juce_UseDebuggingNewOperator @@ -56981,8 +56926,6 @@ public: /** @internal */ void refresh(); /** @internal */ - void changeListenerCallback (void*); - /** @internal */ void sliderValueChanged (Slider*); juce_UseDebuggingNewOperator @@ -57249,7 +57192,7 @@ public: /** @internal */ void buttonClicked (Button*); /** @internal */ - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); /** @internal */ void childBoundsChanged (Component*); @@ -57659,10 +57602,11 @@ private: ColourSelector (const ColourSelector&); ColourSelector& operator= (const ColourSelector&); - // this constructor is here temporarily to prevent old code compiling, because the parameters + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This constructor is here temporarily to prevent old code compiling, because the parameters // have changed - if you get an error here, update your code to use the new constructor instead.. - // (xxx - note to self: remember to remove this at some point in the future) ColourSelector (bool); + #endif }; #endif // __JUCE_COLOURSELECTOR_JUCEHEADER__ diff --git a/src/application/juce_ApplicationCommandManager.h b/src/application/juce_ApplicationCommandManager.h index 00fce1ace1..840419ad15 100644 --- a/src/application/juce_ApplicationCommandManager.h +++ b/src/application/juce_ApplicationCommandManager.h @@ -327,9 +327,11 @@ private: void handleAsyncUpdate(); void globalFocusChanged (Component*); - // xxx this is just here to cause a compile error in old code that hasn't been changed to use the new + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This is just here to cause a compile error in old code that hasn't been changed to use the new // version of this method. virtual short getFirstCommandTarget() { return 0; } + #endif ApplicationCommandManager (const ApplicationCommandManager&); ApplicationCommandManager& operator= (const ApplicationCommandManager&); diff --git a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp index 618e727790..5176d05d9b 100644 --- a/src/audio/audio_file_formats/juce_AudioThumbnail.cpp +++ b/src/audio/audio_file_formats/juce_AudioThumbnail.cpp @@ -81,7 +81,7 @@ void AudioThumbnail::setSource (InputSource* const newSource) } } - sendChangeMessage (this); + sendChangeMessage(); } bool AudioThumbnail::useTimeSlice() @@ -105,7 +105,7 @@ bool AudioThumbnail::useTimeSlice() readNextBlockFromAudioFile (*reader); stopTimer(); - sendChangeMessage (this); + sendChangeMessage(); const bool justFinished = isFullyLoaded(); diff --git a/src/audio/audio_sources/juce_AudioTransportSource.cpp b/src/audio/audio_sources/juce_AudioTransportSource.cpp index c3c3f915c4..5481e47896 100644 --- a/src/audio/audio_sources/juce_AudioTransportSource.cpp +++ b/src/audio/audio_sources/juce_AudioTransportSource.cpp @@ -135,7 +135,7 @@ void AudioTransportSource::start() inputStreamEOF = false; } - sendChangeMessage (this); + sendChangeMessage(); } } @@ -152,7 +152,7 @@ void AudioTransportSource::stop() while (--n >= 0 && ! stopped) Thread::sleep (2); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -272,7 +272,7 @@ void AudioTransportSource::getNextAudioBlock (const AudioSourceChannelInfo& info { playing = false; inputStreamEOF = true; - sendChangeMessage (this); + sendChangeMessage(); } stopped = ! playing; diff --git a/src/audio/devices/juce_AudioDeviceManager.cpp b/src/audio/devices/juce_AudioDeviceManager.cpp index c935891872..6026cf9e13 100644 --- a/src/audio/devices/juce_AudioDeviceManager.cpp +++ b/src/audio/devices/juce_AudioDeviceManager.cpp @@ -339,7 +339,7 @@ void AudioDeviceManager::setCurrentAudioDeviceType (const String& type, setAudioDeviceSetup (s, treatAsChosenDevice); - sendChangeMessage (this); + sendChangeMessage(); break; } } @@ -363,7 +363,7 @@ const String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& ne return String::empty; if (! (newSetup == currentSetup)) - sendChangeMessage (this); + sendChangeMessage(); stopDevice(); @@ -729,14 +729,14 @@ void AudioDeviceManager::audioDeviceAboutToStartInt (AudioIODevice* const device callbacks.getUnchecked(i)->audioDeviceAboutToStart (device); } - sendChangeMessage (this); + sendChangeMessage(); } void AudioDeviceManager::audioDeviceStoppedInt() { cpuUsageMs = 0; timeToCpuScale = 0; - sendChangeMessage (this); + sendChangeMessage(); const ScopedLock sl (audioCallbackLock); for (int i = callbacks.size(); --i >= 0;) @@ -777,7 +777,7 @@ void AudioDeviceManager::setMidiInputEnabled (const String& name, } updateXml(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -887,7 +887,7 @@ void AudioDeviceManager::setDefaultMidiOutput (const String& deviceName) } updateXml(); - sendChangeMessage (this); + sendChangeMessage(); } } diff --git a/src/audio/plugins/juce_KnownPluginList.cpp b/src/audio/plugins/juce_KnownPluginList.cpp index 6338e2f127..c0eb3c46e0 100644 --- a/src/audio/plugins/juce_KnownPluginList.cpp +++ b/src/audio/plugins/juce_KnownPluginList.cpp @@ -45,7 +45,7 @@ void KnownPluginList::clear() if (types.size() > 0) { types.clear(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -83,14 +83,14 @@ bool KnownPluginList::addType (const PluginDescription& type) } types.add (new PluginDescription (type)); - sendChangeMessage (this); + sendChangeMessage(); return true; } void KnownPluginList::removeType (const int index) { types.remove (index); - sendChangeMessage (this); + sendChangeMessage(); } namespace @@ -249,7 +249,7 @@ void KnownPluginList::sort (const SortMethod method) sorter.method = method; types.sort (sorter, true); - sendChangeMessage (this); + sendChangeMessage(); } } diff --git a/src/audio/plugins/juce_PluginListComponent.cpp b/src/audio/plugins/juce_PluginListComponent.cpp index 2a07f5d791..7671d12bd4 100644 --- a/src/audio/plugins/juce_PluginListComponent.cpp +++ b/src/audio/plugins/juce_PluginListComponent.cpp @@ -70,7 +70,7 @@ void PluginListComponent::resized() optionsButton.setTopLeftPosition (8, getHeight() - 28); } -void PluginListComponent::changeListenerCallback (void*) +void PluginListComponent::changeListenerCallback (ChangeBroadcaster*) { listBox.updateContent(); listBox.repaint(); diff --git a/src/audio/plugins/juce_PluginListComponent.h b/src/audio/plugins/juce_PluginListComponent.h index 3674231c65..f9ececa9a6 100644 --- a/src/audio/plugins/juce_PluginListComponent.h +++ b/src/audio/plugins/juce_PluginListComponent.h @@ -76,7 +76,7 @@ public: /** @internal */ void buttonClicked (Button* b); /** @internal */ - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); /** @internal */ void timerCallback(); diff --git a/src/audio/synthesisers/juce_Synthesiser.h b/src/audio/synthesisers/juce_Synthesiser.h index 777d4b8d62..f265b57aaf 100644 --- a/src/audio/synthesisers/juce_Synthesiser.h +++ b/src/audio/synthesisers/juce_Synthesiser.h @@ -468,8 +468,10 @@ protected: int midiNoteNumber, float velocity); - /** xxx Temporary method here to cause a compiler error - note the new parameters for this method. */ + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // Temporary method here to cause a compiler error - note the new parameters for this method. int findFreeVoice (const bool) const { return 0; } + #endif private: double sampleRate; diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 97869a0d17..d6debc3325 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 52 -#define JUCE_BUILDNUMBER 92 +#define JUCE_BUILDNUMBER 93 /** Current Juce version number. @@ -154,6 +154,12 @@ /** This macro is added to all juce public function declarations. */ #define JUCE_PUBLIC_FUNCTION JUCE_API JUCE_CALLTYPE +/** This turns on some non-essential bits of code that should prevent old code from compiling + in cases where method signatures have changed, etc. +*/ +#if (! defined (JUCE_CATCH_DEPRECATED_CODE_MISUSE)) && JUCE_DEBUG && ! DOXYGEN + #define JUCE_CATCH_DEPRECATED_CODE_MISUSE 1 +#endif //============================================================================== // Now include some basics that are needed by most of the Juce classes... diff --git a/src/events/juce_ChangeBroadcaster.cpp b/src/events/juce_ChangeBroadcaster.cpp index d99068c828..551919ac33 100644 --- a/src/events/juce_ChangeBroadcaster.cpp +++ b/src/events/juce_ChangeBroadcaster.cpp @@ -31,6 +31,24 @@ BEGIN_JUCE_NAMESPACE #include "juce_MessageManager.h" +//============================================================================== +class ChangeBroadcaster::ChangeBroadcasterMessage : public CallbackMessage +{ +public: + ChangeBroadcasterMessage (ChangeBroadcaster* const owner_) + : owner (owner_) + { + } + + void messageCallback() + { + if (owner != 0 && owner->pendingMessage.value == this) + owner->sendSynchronousChangeMessage(); + } + + ChangeBroadcaster* owner; +}; + //============================================================================== ChangeBroadcaster::ChangeBroadcaster() throw() { @@ -42,39 +60,65 @@ ChangeBroadcaster::~ChangeBroadcaster() { // all event-based objects must be deleted BEFORE juce is shut down! jassert (MessageManager::instance != 0); + + invalidatePendingMessage(); } void ChangeBroadcaster::addChangeListener (ChangeListener* const listener) { - changeListenerList.addChangeListener (listener); + // Listeners can only be safely added when the event thread is locked... + jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); + + changeListeners.add (listener); } void ChangeBroadcaster::removeChangeListener (ChangeListener* const listener) { - jassert (changeListenerList.isValidMessageListener()); + // Listeners can only be safely added when the event thread is locked... + jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); - if (changeListenerList.isValidMessageListener()) - changeListenerList.removeChangeListener (listener); + changeListeners.remove (listener); } void ChangeBroadcaster::removeAllChangeListeners() { - changeListenerList.removeAllChangeListeners(); + // Listeners can only be safely added when the event thread is locked... + jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); + + changeListeners.clear(); +} + +void ChangeBroadcaster::invalidatePendingMessage() +{ + ChangeBroadcasterMessage* const oldMessage = pendingMessage.exchange (0); + if (oldMessage != 0) + oldMessage->owner = 0; } -void ChangeBroadcaster::sendChangeMessage (void* objectThatHasChanged) +void ChangeBroadcaster::sendChangeMessage() { - changeListenerList.sendChangeMessage (objectThatHasChanged); + if (pendingMessage.value == 0 && changeListeners.size() > 0) + { + ScopedPointer pending (new ChangeBroadcasterMessage (this)); + + if (pendingMessage.compareAndSetBool (pending, 0)) + pending.release()->post(); + } } -void ChangeBroadcaster::sendSynchronousChangeMessage (void* objectThatHasChanged) +void ChangeBroadcaster::sendSynchronousChangeMessage() { - changeListenerList.sendSynchronousChangeMessage (objectThatHasChanged); + // This can only be called by the event thread. + jassert (MessageManager::getInstance()->isThisTheMessageThread()); + + invalidatePendingMessage(); + changeListeners.call (&ChangeListener::changeListenerCallback, this); } void ChangeBroadcaster::dispatchPendingMessages() { - changeListenerList.dispatchPendingMessages(); + if (pendingMessage.get() != 0) + sendSynchronousChangeMessage(); } diff --git a/src/events/juce_ChangeBroadcaster.h b/src/events/juce_ChangeBroadcaster.h index a12b856fd7..72333874d8 100644 --- a/src/events/juce_ChangeBroadcaster.h +++ b/src/events/juce_ChangeBroadcaster.h @@ -26,16 +26,16 @@ #ifndef __JUCE_CHANGEBROADCASTER_JUCEHEADER__ #define __JUCE_CHANGEBROADCASTER_JUCEHEADER__ -#include "juce_ChangeListenerList.h" +#include "juce_ChangeListener.h" +#include "juce_ListenerList.h" +#include "../core/juce_Atomic.h" //============================================================================== -/** Manages a list of ChangeListeners, and can send them messages. +/** + Holds a list of ChangeListeners, and sends messages to them when instructed. - To quickly add methods to your class that can add/remove change - listeners and broadcast to them, you can derive from this. - - @see ChangeListenerList, ChangeListener + @see ChangeListener */ class JUCE_API ChangeBroadcaster { @@ -48,14 +48,12 @@ public: virtual ~ChangeBroadcaster(); //============================================================================== - /** Adds a listener to the list. - - (Trying to add a listener that's already on the list will have no effect). + /** Registers a listener to receive change callbacks from this broadcaster. + Trying to add a listener that's already on the list will have no effect. */ void addChangeListener (ChangeListener* listener); - /** Removes a listener from the list. - + /** Unregisters a listener from the list. If the listener isn't on the list, this won't have any effect. */ void removeChangeListener (ChangeListener* listener); @@ -64,31 +62,39 @@ public: void removeAllChangeListeners(); //============================================================================== - /** Broadcasts a change message to all the registered listeners. + /** Causes an asynchronous change message to be sent to all the registered listeners. - The message will be delivered asynchronously by the event thread, so this - method will not directly call any of the listeners. For a synchronous - message, use sendSynchronousChangeMessage(). - - @see ChangeListenerList::sendActionMessage + The message will be delivered asynchronously by the main message thread, so this + method will return immediately. To call the listeners synchronously use + sendSynchronousChangeMessage(). */ - void sendChangeMessage (void* objectThatHasChanged); + void sendChangeMessage(); /** Sends a synchronous change message to all the registered listeners. - @see ChangeListenerList::sendSynchronousChangeMessage + This will immediately call all the listeners that are registered. For thread-safety + reasons, you must only call this method on the main message thread. + + @see dispatchPendingMessages */ - void sendSynchronousChangeMessage (void* objectThatHasChanged); + void sendSynchronousChangeMessage(); - /** If a change message has been sent but not yet dispatched, this will - use sendSynchronousChangeMessage() to make the callback immediately. + /** If a change message has been sent but not yet dispatched, this will call + sendSynchronousChangeMessage() to make the callback immediately. + + For thread-safety reasons, you must only call this method on the main message thread. */ void dispatchPendingMessages(); - private: //============================================================================== - ChangeListenerList changeListenerList; + class ChangeBroadcasterMessage; + friend class ChangeBroadcasterMessage; + + Atomic pendingMessage; + ListenerList changeListeners; + + void invalidatePendingMessage(); ChangeBroadcaster (const ChangeBroadcaster&); ChangeBroadcaster& operator= (const ChangeBroadcaster&); diff --git a/src/events/juce_ChangeListener.h b/src/events/juce_ChangeListener.h index 662d15bb96..b4ffaae577 100644 --- a/src/events/juce_ChangeListener.h +++ b/src/events/juce_ChangeListener.h @@ -26,20 +26,21 @@ #ifndef __JUCE_CHANGELISTENER_JUCEHEADER__ #define __JUCE_CHANGELISTENER_JUCEHEADER__ +class ChangeBroadcaster; //============================================================================== /** - Receives callbacks about changes to some kind of object. + Receives change event callbacks that are sent out by a ChangeBroadcaster. - Many objects use a ChangeListenerList to keep a set of listeners which they - will inform when something changes. A subclass of ChangeListener - is used to receive these callbacks. + A ChangeBroadcaster keeps a set of listeners to which it broadcasts a message when + the ChangeBroadcaster::sendChangeMessage() method is called. A subclass of + ChangeListener is used to receive these callbacks. Note that the major difference between an ActionListener and a ChangeListener is that for a ChangeListener, multiple changes will be coalesced into fewer callbacks, but ActionListeners perform one callback for every event posted. - @see ChangeListenerList, ChangeBroadcaster, ActionListener + @see ChangeBroadcaster, ActionListener */ class JUCE_API ChangeListener { @@ -47,12 +48,17 @@ public: /** Destructor. */ virtual ~ChangeListener() {} - /** Overridden by your subclass to receive the callback. - - @param objectThatHasChanged the value that was passed to the - ChangeListenerList::sendChangeMessage() method + /** Your subclass should implement this method to receive the callback. + @param source the ChangeBroadcaster that triggered the callback. */ - virtual void changeListenerCallback (void* objectThatHasChanged) = 0; + virtual void changeListenerCallback (ChangeBroadcaster* source) = 0; + + + //============================================================================== + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This method's signature has changed to take a ChangeBroadcaster parameter - please update your code! + private: virtual int changeListenerCallback (void*) { return 0; } + #endif }; diff --git a/src/events/juce_ChangeListenerList.cpp b/src/events/juce_ChangeListenerList.cpp deleted file mode 100644 index ac61a2da43..0000000000 --- a/src/events/juce_ChangeListenerList.cpp +++ /dev/null @@ -1,107 +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_ChangeListenerList.h" - - -//============================================================================== -ChangeListenerList::ChangeListenerList() - : lastChangedObject (0), - messagePending (false) -{ -} - -ChangeListenerList::~ChangeListenerList() -{ -} - -void ChangeListenerList::addChangeListener (ChangeListener* const listener) -{ - const ScopedLock sl (lock); - - jassert (listener != 0); - - if (listener != 0) - listeners.add (listener); -} - -void ChangeListenerList::removeChangeListener (ChangeListener* const listener) -{ - const ScopedLock sl (lock); - listeners.removeValue (listener); -} - -void ChangeListenerList::removeAllChangeListeners() -{ - const ScopedLock sl (lock); - listeners.clear(); -} - -void ChangeListenerList::sendChangeMessage (void* const objectThatHasChanged) -{ - const ScopedLock sl (lock); - - if ((! messagePending) && (listeners.size() > 0)) - { - lastChangedObject = objectThatHasChanged; - postMessage (new Message (0, 0, 0, objectThatHasChanged)); - messagePending = true; - } -} - -void ChangeListenerList::handleMessage (const Message& message) -{ - sendSynchronousChangeMessage (message.pointerParameter); -} - -void ChangeListenerList::sendSynchronousChangeMessage (void* const objectThatHasChanged) -{ - const ScopedLock sl (lock); - messagePending = false; - - for (int i = listeners.size(); --i >= 0;) - { - ChangeListener* const l = static_cast (listeners.getUnchecked (i)); - - { - const ScopedUnlock tempUnlocker (lock); - l->changeListenerCallback (objectThatHasChanged); - } - - i = jmin (i, listeners.size()); - } -} - -void ChangeListenerList::dispatchPendingMessages() -{ - if (messagePending) - sendSynchronousChangeMessage (lastChangedObject); -} - -END_JUCE_NAMESPACE diff --git a/src/events/juce_ChangeListenerList.h b/src/events/juce_ChangeListenerList.h deleted file mode 100644 index 24ad8fb298..0000000000 --- a/src/events/juce_ChangeListenerList.h +++ /dev/null @@ -1,119 +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_CHANGELISTENERLIST_JUCEHEADER__ -#define __JUCE_CHANGELISTENERLIST_JUCEHEADER__ - -#include "juce_ChangeListener.h" -#include "juce_MessageListener.h" -#include "../containers/juce_SortedSet.h" -#include "../threads/juce_ScopedLock.h" - - -//============================================================================== -/** - A set of ChangeListeners. - - Listeners can be added and removed from the list, and change messages can be - broadcast to all the listeners. - - @see ChangeListener, ChangeBroadcaster -*/ -class JUCE_API ChangeListenerList : public MessageListener -{ -public: - //============================================================================== - /** Creates an empty list. */ - ChangeListenerList(); - - /** Destructor. */ - ~ChangeListenerList(); - - //============================================================================== - /** Adds a listener to the list. - - (Trying to add a listener that's already on the list will have no effect). - */ - void addChangeListener (ChangeListener* listener); - - /** Removes a listener from the list. - - If the listener isn't on the list, this won't have any effect. - */ - void removeChangeListener (ChangeListener* listener); - - /** Removes all listeners from the list. */ - void removeAllChangeListeners(); - - //============================================================================== - /** Posts an asynchronous change message to all the listeners. - - If a message has already been sent and hasn't yet been delivered, this - method won't send another - in this way it coalesces multiple frequent - changes into fewer actual callbacks to the ChangeListeners. Contrast this - with the ActionListener, which posts a new event for every call to its - sendActionMessage() method. - - Only listeners which are on the list when the change event is delivered - will receive the event - and this may include listeners that weren't on - the list when the change message was sent. - - @param objectThatHasChanged this pointer is passed to the - ChangeListener::changeListenerCallback() method, - and can be any value the application needs - @see sendSynchronousChangeMessage - */ - void sendChangeMessage (void* objectThatHasChanged); - - /** This will synchronously callback all the ChangeListeners. - - Use this if you need to synchronously force a call to all the - listeners' ChangeListener::changeListenerCallback() methods. - */ - void sendSynchronousChangeMessage (void* objectThatHasChanged); - - /** If a change message has been sent but not yet dispatched, this will - use sendSynchronousChangeMessage() to make the callback immediately. - */ - void dispatchPendingMessages(); - - //============================================================================== - /** @internal */ - void handleMessage (const Message&); - - juce_UseDebuggingNewOperator - -private: - SortedSet listeners; - CriticalSection lock; - void* lastChangedObject; - bool messagePending; - - ChangeListenerList (const ChangeListenerList&); - ChangeListenerList& operator= (const ChangeListenerList&); -}; - - -#endif // __JUCE_CHANGELISTENERLIST_JUCEHEADER__ diff --git a/src/events/juce_ListenerList.h b/src/events/juce_ListenerList.h index 659008007d..a8c32f4a93 100644 --- a/src/events/juce_ListenerList.h +++ b/src/events/juce_ListenerList.h @@ -130,6 +130,12 @@ public: return listeners.size() == 0; } + /** Clears the list. */ + void clear() + { + listeners.clear(); + } + /** Returns true if the specified listener has been added to the list. */ bool contains (ListenerClass* const listener) const throw() { diff --git a/src/gui/components/controls/juce_ListBox.cpp b/src/gui/components/controls/juce_ListBox.cpp index 67933a9be8..217b1b79b9 100644 --- a/src/gui/components/controls/juce_ListBox.cpp +++ b/src/gui/components/controls/juce_ListBox.cpp @@ -381,6 +381,7 @@ void ListBox::setModel (ListBoxModel* const newModel) if (model != newModel) { model = newModel; + repaint(); updateContent(); } } diff --git a/src/gui/components/filebrowser/juce_DirectoryContentsList.cpp b/src/gui/components/filebrowser/juce_DirectoryContentsList.cpp index 83c467b66e..e33cda78ee 100644 --- a/src/gui/components/filebrowser/juce_DirectoryContentsList.cpp +++ b/src/gui/components/filebrowser/juce_DirectoryContentsList.cpp @@ -29,6 +29,7 @@ BEGIN_JUCE_NAMESPACE #include "juce_DirectoryContentsList.h" #include "../../graphics/imaging/juce_ImageCache.h" +#include "../../../threads/juce_ScopedLock.h" //============================================================================== @@ -160,7 +161,7 @@ bool DirectoryContentsList::isStillLoading() const void DirectoryContentsList::changed() { - sendChangeMessage (this); + sendChangeMessage(); } //============================================================================== diff --git a/src/gui/components/filebrowser/juce_FileListComponent.cpp b/src/gui/components/filebrowser/juce_FileListComponent.cpp index 580710ece9..511fd42dfb 100644 --- a/src/gui/components/filebrowser/juce_FileListComponent.cpp +++ b/src/gui/components/filebrowser/juce_FileListComponent.cpp @@ -70,7 +70,7 @@ void FileListComponent::scrollToTop() } //============================================================================== -void FileListComponent::changeListenerCallback (void*) +void FileListComponent::changeListenerCallback (ChangeBroadcaster*) { updateContent(); diff --git a/src/gui/components/filebrowser/juce_FileListComponent.h b/src/gui/components/filebrowser/juce_FileListComponent.h index dd58e4c5e9..743ef86dda 100644 --- a/src/gui/components/filebrowser/juce_FileListComponent.h +++ b/src/gui/components/filebrowser/juce_FileListComponent.h @@ -78,7 +78,7 @@ public: //============================================================================== /** @internal */ - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); /** @internal */ int getNumRows(); /** @internal */ diff --git a/src/gui/components/filebrowser/juce_FileTreeComponent.cpp b/src/gui/components/filebrowser/juce_FileTreeComponent.cpp index 2202675dd2..9742c9b472 100644 --- a/src/gui/components/filebrowser/juce_FileTreeComponent.cpp +++ b/src/gui/components/filebrowser/juce_FileTreeComponent.cpp @@ -122,7 +122,7 @@ public: newList->addChangeListener (this); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { clearSubItems(); diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index b723d2fedf..de11d28ccc 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -221,6 +221,181 @@ namespace } #endif +//============================================================================== +class Component::ComponentHelpers +{ +public: + //============================================================================== + static void* runModalLoopCallback (void* userData) + { + return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); + } + + static const Identifier getColourPropertyId (const int colourId) + { + String s; + s.preallocateStorage (18); + s << "jcclr_" << String::toHexString (colourId); + return s; + } + + //============================================================================== + static inline bool hitTest (Component& comp, const Point& localPoint) + { + return ((unsigned int) localPoint.getX()) < (unsigned int) comp.getWidth() + && ((unsigned int) localPoint.getY()) < (unsigned int) comp.getHeight() + && comp.hitTest (localPoint.getX(), localPoint.getY()); + } + + static const Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) + { + return pointInParentSpace - comp.getPosition(); + } + + static const Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) + { + return areaInParentSpace - comp.getPosition(); + } + + static const Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) + { + return pointInLocalSpace + comp.getPosition(); + } + + static const Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) + { + return areaInLocalSpace + comp.getPosition(); + } + + template + static const Type convertFromDistantParentSpace (const Component* parent, const Component& target, Type coordInParent) + { + const Component* const directParent = target.getParentComponent(); + jassert (directParent != 0); + + if (directParent == parent) + return convertFromParentSpace (target, coordInParent); + + return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); + } + + template + static const Type convertCoordinate (const Component* target, const Component* source, Type p) + { + while (source != 0) + { + if (source == target) + return p; + + if (source->isParentOf (target)) + return convertFromDistantParentSpace (source, *target, p); + + if (source->isOnDesktop()) + { + p = source->getPeer()->localToGlobal (p); + source = 0; + } + else + { + p = convertToParentSpace (*source, p); + source = source->getParentComponent(); + } + } + + jassert (source == 0); + if (target == 0) + return p; + + const Component* const topLevelComp = target->getTopLevelComponent(); + + if (topLevelComp->isOnDesktop()) + p = topLevelComp->getPeer()->globalToLocal (p); + else + p = convertFromParentSpace (*topLevelComp, p); + + if (topLevelComp == target) + return p; + + return convertFromDistantParentSpace (topLevelComp, *target, p); + } + + static const Rectangle getUnclippedArea (const Component& comp) + { + Rectangle r (comp.getLocalBounds()); + + Component* const p = comp.getParentComponent(); + + if (p != 0) + r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p))); + + return r; + } + + static void clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle& clipRect, const Point& delta) + { + for (int i = comp.childComponentList_.size(); --i >= 0;) + { + const Component& child = *comp.childComponentList_.getUnchecked(i); + +//xxx if (child.isVisible() && ! child.isTransformed()) + if (child.isVisible()) + { + const Rectangle newClip (clipRect.getIntersection (child.bounds_)); + + if (! newClip.isEmpty()) + { + if (child.isOpaque()) + { + g.excludeClipRegion (newClip + delta); + } + else + { + const Point childPos (child.getPosition()); + clipObscuredRegions (child, g, newClip - childPos, childPos + delta); + } + } + } + } + } + + static void subtractObscuredRegions (const Component& comp, RectangleList& result, + const Point& delta, + const Rectangle& clipRect, + const Component* const compToAvoid) + { + for (int i = comp.childComponentList_.size(); --i >= 0;) + { + const Component* const c = comp.childComponentList_.getUnchecked(i); + + if (c != compToAvoid && c->isVisible()) + { + if (c->isOpaque()) + { + Rectangle childBounds (c->bounds_.getIntersection (clipRect)); + childBounds.translate (delta.getX(), delta.getY()); + + result.subtract (childBounds); + } + else + { + Rectangle newClip (clipRect.getIntersection (c->bounds_)); + newClip.translate (-c->getX(), -c->getY()); + + subtractObscuredRegions (*c, result, c->getPosition() + delta, + newClip, compToAvoid); + } + } + } + } + + static const Rectangle getParentOrMainMonitorBounds (const Component& comp) + { + return comp.getParentComponent() != 0 ? comp.getParentComponent()->getLocalBounds() + : Desktop::getInstance().getMainMonitorArea(); + } +}; + + //============================================================================== Component::Component() : parentComponent_ (0), @@ -766,138 +941,30 @@ int Component::getParentHeight() const throw() : getParentMonitorArea().getHeight(); } -int Component::getScreenX() const -{ - return getScreenPosition().getX(); -} - -int Component::getScreenY() const -{ - return getScreenPosition().getY(); -} - -const Point Component::getScreenPosition() const -{ - return localPointToGlobal (Point()); -} - -const Rectangle Component::getScreenBounds() const -{ - return bounds_.withPosition (getScreenPosition()); -} - -namespace CoordinateHelpers -{ - inline bool hitTest (Component& comp, const Point& localPoint) - { - return ((unsigned int) localPoint.getX()) < (unsigned int) comp.getWidth() - && ((unsigned int) localPoint.getY()) < (unsigned int) comp.getHeight() - && comp.hitTest (localPoint.getX(), localPoint.getY()); - } - - const Point convertFromParentSpace (const Component& comp, const Point& pointInParentSpace) - { - return pointInParentSpace - comp.getPosition(); - } - - const Rectangle convertFromParentSpace (const Component& comp, const Rectangle& areaInParentSpace) - { - return areaInParentSpace - comp.getPosition(); - } - - const Point convertToParentSpace (const Component& comp, const Point& pointInLocalSpace) - { - return pointInLocalSpace + comp.getPosition(); - } - - const Rectangle convertToParentSpace (const Component& comp, const Rectangle& areaInLocalSpace) - { - return areaInLocalSpace + comp.getPosition(); - } - - template - const Type convertFromDistantParentSpace (const Component* parent, const Component& target, Type coordInParent) - { - const Component* const directParent = target.getParentComponent(); - jassert (directParent != 0); - - if (directParent == parent) - return convertFromParentSpace (target, coordInParent); - - return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); - } - - template - const Type convertCoordinate (const Component* target, const Component* source, Type p) - { - while (source != 0) - { - if (source == target) - return p; - - if (source->isParentOf (target)) - return convertFromDistantParentSpace (source, *target, p); - - if (source->isOnDesktop()) - { - p = source->getPeer()->localToGlobal (p); - source = 0; - } - else - { - p = convertToParentSpace (*source, p); - source = source->getParentComponent(); - } - } - - jassert (source == 0); - if (target == 0) - return p; - - const Component* const topLevelComp = target->getTopLevelComponent(); - - if (topLevelComp->isOnDesktop()) - p = topLevelComp->getPeer()->globalToLocal (p); - else - p = convertFromParentSpace (*topLevelComp, p); - - if (topLevelComp == target) - return p; - - return convertFromDistantParentSpace (topLevelComp, *target, p); - } - - const Rectangle getUnclippedArea (const Component& comp) - { - Rectangle r (comp.getLocalBounds()); - - Component* const p = comp.getParentComponent(); +int Component::getScreenX() const { return getScreenPosition().getX(); } +int Component::getScreenY() const { return getScreenPosition().getY(); } - if (p != 0) - r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p))); - - return r; - } -} +const Point Component::getScreenPosition() const { return localPointToGlobal (Point()); } +const Rectangle Component::getScreenBounds() const { return localAreaToGlobal (getLocalBounds()); } const Point Component::getLocalPoint (const Component* source, const Point& point) const { - return CoordinateHelpers::convertCoordinate (this, source, point); + return ComponentHelpers::convertCoordinate (this, source, point); } const Rectangle Component::getLocalArea (const Component* source, const Rectangle& area) const { - return CoordinateHelpers::convertCoordinate (this, source, area); + return ComponentHelpers::convertCoordinate (this, source, area); } const Point Component::localPointToGlobal (const Point& point) const { - return CoordinateHelpers::convertCoordinate (0, this, point); + return ComponentHelpers::convertCoordinate (0, this, point); } const Rectangle Component::localAreaToGlobal (const Rectangle& area) const { - return CoordinateHelpers::convertCoordinate (0, this, area); + return ComponentHelpers::convertCoordinate (0, this, area); } /* Deprecated methods... */ @@ -1053,7 +1120,7 @@ void Component::setCentreRelative (const float x, const float y) void Component::centreWithSize (const int width, const int height) { - const Rectangle parentArea (getParentOrMainMonitorBounds()); + const Rectangle parentArea (ComponentHelpers::getParentOrMainMonitorBounds (*this)); setBounds (parentArea.getCentreX() - width / 2, parentArea.getCentreY() - height / 2, @@ -1062,7 +1129,7 @@ void Component::centreWithSize (const int width, const int height) void Component::setBoundsInset (const BorderSize& borders) { - setBounds (borders.subtractedFrom (getParentOrMainMonitorBounds())); + setBounds (borders.subtractedFrom (ComponentHelpers::getParentOrMainMonitorBounds (*this))); } void Component::setBoundsToFit (int x, int y, int width, int height, @@ -1124,7 +1191,7 @@ bool Component::hitTest (int x, int y) Component& child = *getChildComponent (i); if (child.isVisible() - && CoordinateHelpers::hitTest (child, CoordinateHelpers::convertFromParentSpace (child, Point (x, y)))) + && ComponentHelpers::hitTest (child, ComponentHelpers::convertFromParentSpace (child, Point (x, y)))) return true; } } @@ -1148,11 +1215,11 @@ void Component::getInterceptsMouseClicks (bool& allowsClicksOnThisComponent, bool Component::contains (const Point& point) { - if (CoordinateHelpers::hitTest (*this, point)) + if (ComponentHelpers::hitTest (*this, point)) { if (parentComponent_ != 0) { - return parentComponent_->contains (CoordinateHelpers::convertToParentSpace (*this, point)); + return parentComponent_->contains (ComponentHelpers::convertToParentSpace (*this, point)); } else if (flags.hasHeavyweightPeerFlag) { @@ -1181,12 +1248,12 @@ bool Component::reallyContains (const int x, const int y, const bool returnTrueI Component* Component::getComponentAt (const Point& position) { - if (flags.visibleFlag && CoordinateHelpers::hitTest (*this, position)) + if (flags.visibleFlag && ComponentHelpers::hitTest (*this, position)) { for (int i = childComponentList_.size(); --i >= 0;) { Component* child = childComponentList_.getUnchecked(i); - child = child->getComponentAt (CoordinateHelpers::convertFromParentSpace (*child, position)); + child = child->getComponentAt (ComponentHelpers::convertFromParentSpace (*child, position)); if (child != 0) return child; @@ -1414,14 +1481,6 @@ void Component::internalHierarchyChanged() } //============================================================================== -namespace ComponentHelpers -{ - void* runModalLoopCallback (void* userData) - { - return (void*) (pointer_sized_int) static_cast (userData)->runModalLoop(); - } -} - int Component::runModalLoop() { if (! MessageManager::getInstance()->isThisTheMessageThread()) @@ -1689,7 +1748,7 @@ void Component::paintComponentAndChildren (Graphics& g) else { g.saveState(); - clipObscuredRegions (g, clipBounds, 0, 0); + ComponentHelpers::clipObscuredRegions (*this, g, clipBounds, Point()); if (! g.isClipEmpty()) paintComponent (g); @@ -1878,17 +1937,6 @@ void Component::sendLookAndFeelChange() } } -namespace ComponentHelpers -{ - const Identifier getColourPropertyId (const int colourId) - { - String s; - s.preallocateStorage (18); - s << "jcclr_" << String::toHexString (colourId); - return s; - } -} - const Colour Component::findColour (const int colourId, const bool inheritFromParent) const { var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)); @@ -1946,44 +1994,10 @@ const Rectangle Component::getLocalBounds() const throw() return Rectangle (getWidth(), getHeight()); } -const Rectangle Component::getParentOrMainMonitorBounds() const -{ - return parentComponent_ != 0 ? parentComponent_->getLocalBounds() - : Desktop::getInstance().getMainMonitorArea(); -} - -void Component::clipObscuredRegions (Graphics& g, const Rectangle& clipRect, - const int deltaX, const int deltaY) const -{ - for (int i = childComponentList_.size(); --i >= 0;) - { - const Component* const c = childComponentList_.getUnchecked(i); - - if (c->isVisible()) - { - const Rectangle newClip (clipRect.getIntersection (c->bounds_)); - - if (! newClip.isEmpty()) - { - if (c->isOpaque()) - { - g.excludeClipRegion (newClip.translated (deltaX, deltaY)); - } - else - { - c->clipObscuredRegions (g, newClip.translated (-c->getX(), -c->getY()), - c->getX() + deltaX, - c->getY() + deltaY); - } - } - } - } -} - void Component::getVisibleArea (RectangleList& result, const bool includeSiblings) const { result.clear(); - const Rectangle unclipped (CoordinateHelpers::getUnclippedArea (*this)); + const Rectangle unclipped (ComponentHelpers::getUnclippedArea (*this)); if (! unclipped.isEmpty()) { @@ -1993,45 +2007,15 @@ void Component::getVisibleArea (RectangleList& result, const bool includeSibling { const Component* const c = getTopLevelComponent(); - c->subtractObscuredRegions (result, getLocalPoint (c, Point()), - c->getLocalBounds(), this); + ComponentHelpers::subtractObscuredRegions (*c, result, getLocalPoint (c, Point()), + c->getLocalBounds(), this); } - subtractObscuredRegions (result, Point(), unclipped, 0); + ComponentHelpers::subtractObscuredRegions (*this, result, Point(), unclipped, 0); result.consolidate(); } } -void Component::subtractObscuredRegions (RectangleList& result, - const Point& delta, - const Rectangle& clipRect, - const Component* const compToAvoid) const -{ - for (int i = childComponentList_.size(); --i >= 0;) - { - const Component* const c = childComponentList_.getUnchecked(i); - - if (c != compToAvoid && c->isVisible()) - { - if (c->isOpaque()) - { - Rectangle childBounds (c->bounds_.getIntersection (clipRect)); - childBounds.translate (delta.getX(), delta.getY()); - - result.subtract (childBounds); - } - else - { - Rectangle newClip (clipRect.getIntersection (c->bounds_)); - newClip.translate (-c->getX(), -c->getY()); - - c->subtractObscuredRegions (result, c->getPosition() + delta, - newClip, compToAvoid); - } - } - } -} - //============================================================================== void Component::mouseEnter (const MouseEvent&) { diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 1e8a499b07..948cbcb025 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -2006,16 +2006,13 @@ public: //============================================================================== #ifndef DOXYGEN - /** @internal - This method is deprecated - use localPointToGlobal instead. */ + /** This method is deprecated - use localPointToGlobal instead. */ const Point relativePositionToGlobal (const Point& relativePosition) const; - /** @internal - This method is deprecated - use getLocalPoint instead. */ + /** This method is deprecated - use getLocalPoint instead. */ const Point globalPositionToRelative (const Point& screenPosition) const; - /** @internal - This method is deprecated - use getLocalPoint instead. */ + /** This method is deprecated - use getLocalPoint instead. */ const Point relativePositionToOtherComponent (const Component* targetComponent, const Point& positionRelativeToThis) const; #endif @@ -2109,14 +2106,20 @@ private: void grabFocusInternal (const FocusChangeType cause, bool canTryParent = true); static void giveAwayFocus(); void sendEnablementChangeMessage(); - void subtractObscuredRegions (RectangleList& result, const Point& delta, - const Rectangle& clipRect, const Component* const compToAvoid) const; - void clipObscuredRegions (Graphics& g, const Rectangle& clipRect, int deltaX, int deltaY) const; - void sendVisibilityChangeMessage(); - const Rectangle getParentOrMainMonitorBounds() const; + + class ComponentHelpers; + friend class ComponentHelpers; + + /* Components aren't allowed to have copy constructors, as this would mess up parent hierarchies. + You might need to give your subclasses a private dummy constructor like this one to avoid + compiler warnings. + */ + Component (const Component&); + Component& operator= (const Component&); //============================================================================== + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE // This is included here just to cause a compile error if your code is still handling // drag-and-drop with this method. If so, just update it to use the new FileDragAndDropTarget // class, which is easy (just make your class inherit from FileDragAndDropTarget, and @@ -2126,15 +2129,10 @@ private: // This is included here to cause an error if you use or overload it - it has been deprecated in // favour of contains (const Point&) void contains (int, int); - - /* Components aren't allowed to have copy constructors, as this would mess up parent hierarchies. - You might need to give your subclasses a private dummy constructor like this one to avoid - compiler warnings. - */ - Component (const Component&); - Component& operator= (const Component&); + #endif protected: + //============================================================================== /** @internal */ virtual void internalRepaint (int x, int y, int w, int h); /** @internal */ diff --git a/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp b/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp index 34644cf1b0..bcb76db4fc 100644 --- a/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp +++ b/src/gui/components/keyboard/juce_KeyMappingEditorComponent.cpp @@ -364,7 +364,7 @@ public: bool mightContainSubItems() { return true; } const String getUniqueName() const { return "keys"; } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { const ScopedPointer oldOpenness (owner.tree.getOpennessState (true)); diff --git a/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp b/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp index 4a38696f4a..ac5cc168e2 100644 --- a/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp +++ b/src/gui/components/keyboard/juce_KeyPressMappingSet.cpp @@ -86,7 +86,7 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID, { mappings.getUnchecked(i)->keypresses.insert (insertIndex, newKeyPress); - sendChangeMessage (this); + sendChangeMessage(); return; } } @@ -101,7 +101,7 @@ void KeyPressMappingSet::addKeyPress (const CommandID commandID, cm->wantsKeyUpDownCallbacks = (ci->flags & ApplicationCommandInfo::wantsKeyUpDownCallbacks) != 0; mappings.add (cm); - sendChangeMessage (this); + sendChangeMessage(); } } } @@ -122,7 +122,7 @@ void KeyPressMappingSet::resetToDefaultMappings() } } - sendChangeMessage (this); + sendChangeMessage(); } void KeyPressMappingSet::resetToDefaultMapping (const CommandID commandID) @@ -142,7 +142,7 @@ void KeyPressMappingSet::clearAllKeyPresses() { if (mappings.size() > 0) { - sendChangeMessage (this); + sendChangeMessage(); mappings.clear(); } } @@ -154,7 +154,7 @@ void KeyPressMappingSet::clearAllKeyPresses (const CommandID commandID) if (mappings.getUnchecked(i)->commandID == commandID) { mappings.remove (i); - sendChangeMessage (this); + sendChangeMessage(); } } } @@ -172,7 +172,7 @@ void KeyPressMappingSet::removeKeyPress (const KeyPress& keypress) if (keypress == cm->keypresses [j]) { cm->keypresses.remove (j); - sendChangeMessage (this); + sendChangeMessage(); } } } @@ -186,7 +186,7 @@ void KeyPressMappingSet::removeKeyPress (const CommandID commandID, const int ke if (mappings.getUnchecked(i)->commandID == commandID) { mappings.getUnchecked(i)->keypresses.remove (keyPressIndex); - sendChangeMessage (this); + sendChangeMessage(); break; } } diff --git a/src/gui/components/layout/juce_ComponentAnimator.cpp b/src/gui/components/layout/juce_ComponentAnimator.cpp index c39fc3c5b7..f22037d90f 100644 --- a/src/gui/components/layout/juce_ComponentAnimator.cpp +++ b/src/gui/components/layout/juce_ComponentAnimator.cpp @@ -240,7 +240,7 @@ void ComponentAnimator::animateComponent (Component* const component, { at = new AnimationTask (component); tasks.add (at); - sendChangeMessage (this); + sendChangeMessage(); } at->reset (finalBounds, finalAlpha, millisecondsToSpendMoving, @@ -284,7 +284,7 @@ void ComponentAnimator::cancelAllAnimations (const bool moveComponentsToTheirFin tasks.getUnchecked(i)->moveToFinalDestination(); tasks.clear(); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -299,7 +299,7 @@ void ComponentAnimator::cancelAnimation (Component* const component, at->moveToFinalDestination(); tasks.removeObject (at); - sendChangeMessage (this); + sendChangeMessage(); } } @@ -333,7 +333,7 @@ void ComponentAnimator::timerCallback() if (! tasks.getUnchecked(i)->useTimeslice (elapsed)) { tasks.remove (i); - sendChangeMessage (this); + sendChangeMessage(); } } diff --git a/src/gui/components/layout/juce_TabbedButtonBar.cpp b/src/gui/components/layout/juce_TabbedButtonBar.cpp index a7c99915ad..b83ef28f4d 100644 --- a/src/gui/components/layout/juce_TabbedButtonBar.cpp +++ b/src/gui/components/layout/juce_TabbedButtonBar.cpp @@ -307,7 +307,7 @@ void TabbedButtonBar::setCurrentTabIndex (int newIndex, const bool sendChangeMes resized(); if (sendChangeMessage_) - sendChangeMessage (this); + sendChangeMessage(); currentTabChanged (newIndex, getCurrentTabName()); } diff --git a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp index 73a1872f27..2fd6b0a16d 100644 --- a/src/gui/components/lookandfeel/juce_LookAndFeel.cpp +++ b/src/gui/components/lookandfeel/juce_LookAndFeel.cpp @@ -3097,8 +3097,8 @@ void LookAndFeel::drawGlassLozenge (Graphics& g, } { - const float leftIndent = flatOnLeft ? 0.0f : cs * 0.4f; - const float rightIndent = flatOnRight ? 0.0f : cs * 0.4f; + const float leftIndent = flatOnTop || flatOnLeft ? 0.0f : cs * 0.4f; + const float rightIndent = flatOnTop || flatOnRight ? 0.0f : cs * 0.4f; Path highlight; LookAndFeelHelpers::createRoundedPath (highlight, diff --git a/src/gui/components/properties/juce_SliderPropertyComponent.h b/src/gui/components/properties/juce_SliderPropertyComponent.h index 906e6e20c2..3b58a64612 100644 --- a/src/gui/components/properties/juce_SliderPropertyComponent.h +++ b/src/gui/components/properties/juce_SliderPropertyComponent.h @@ -90,8 +90,6 @@ public: /** @internal */ void refresh(); /** @internal */ - void changeListenerCallback (void*); - /** @internal */ void sliderValueChanged (Slider*); juce_UseDebuggingNewOperator diff --git a/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp b/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp index 05e88fb73f..b15252f8b0 100644 --- a/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp +++ b/src/gui/components/special/juce_AudioDeviceSelectorComponent.cpp @@ -418,7 +418,7 @@ public: resized(); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { AudioIODevice* const currentDevice = setup.manager->getCurrentAudioDevice(); @@ -1059,7 +1059,7 @@ void AudioDeviceSelectorComponent::comboBoxChanged (ComboBox* comboBoxThatHasCha } } -void AudioDeviceSelectorComponent::changeListenerCallback (void*) +void AudioDeviceSelectorComponent::changeListenerCallback (ChangeBroadcaster*) { if (deviceTypeDropDown != 0) { diff --git a/src/gui/components/special/juce_AudioDeviceSelectorComponent.h b/src/gui/components/special/juce_AudioDeviceSelectorComponent.h index 185a9f0cdd..ec89ee865f 100644 --- a/src/gui/components/special/juce_AudioDeviceSelectorComponent.h +++ b/src/gui/components/special/juce_AudioDeviceSelectorComponent.h @@ -86,7 +86,7 @@ public: /** @internal */ void buttonClicked (Button*); /** @internal */ - void changeListenerCallback (void*); + void changeListenerCallback (ChangeBroadcaster*); /** @internal */ void childBoundsChanged (Component*); diff --git a/src/gui/components/special/juce_ColourSelector.cpp b/src/gui/components/special/juce_ColourSelector.cpp index b8ac12adbe..725a10609c 100644 --- a/src/gui/components/special/juce_ColourSelector.cpp +++ b/src/gui/components/special/juce_ColourSelector.cpp @@ -430,7 +430,7 @@ void ColourSelector::update() if ((flags & showColourAtTop) != 0) repaint (previewArea); - sendChangeMessage (this); + sendChangeMessage(); } //============================================================================== diff --git a/src/gui/components/special/juce_ColourSelector.h b/src/gui/components/special/juce_ColourSelector.h index abc3ce84d0..fad4b446b7 100644 --- a/src/gui/components/special/juce_ColourSelector.h +++ b/src/gui/components/special/juce_ColourSelector.h @@ -165,10 +165,11 @@ private: ColourSelector (const ColourSelector&); ColourSelector& operator= (const ColourSelector&); - // this constructor is here temporarily to prevent old code compiling, because the parameters + #if JUCE_CATCH_DEPRECATED_CODE_MISUSE + // This constructor is here temporarily to prevent old code compiling, because the parameters // have changed - if you get an error here, update your code to use the new constructor instead.. - // (xxx - note to self: remember to remove this at some point in the future) ColourSelector (bool); + #endif }; diff --git a/src/gui/components/special/juce_MidiKeyboardComponent.cpp b/src/gui/components/special/juce_MidiKeyboardComponent.cpp index 99b9e8bb31..8020fb2cd2 100644 --- a/src/gui/components/special/juce_MidiKeyboardComponent.cpp +++ b/src/gui/components/special/juce_MidiKeyboardComponent.cpp @@ -151,7 +151,7 @@ void MidiKeyboardComponent::setLowestVisibleKey (int noteNumber) if (noteNumber != firstKey) { firstKey = noteNumber; - sendChangeMessage (this); + sendChangeMessage(); resized(); } } @@ -598,7 +598,7 @@ void MidiKeyboardComponent::resized() if (kx2 - kx1 <= w) { firstKey = rangeStart; - sendChangeMessage (this); + sendChangeMessage(); repaint(); } } @@ -641,7 +641,7 @@ void MidiKeyboardComponent::resized() if (lastStartKey >= 0 && firstKey > lastStartKey) { firstKey = jlimit (rangeStart, rangeEnd, lastStartKey); - sendChangeMessage (this); + sendChangeMessage(); } int newOffset = 0; diff --git a/src/gui/graphics/contexts/juce_Graphics.cpp b/src/gui/graphics/contexts/juce_Graphics.cpp index 6b882a13f1..6af9706b81 100644 --- a/src/gui/graphics/contexts/juce_Graphics.cpp +++ b/src/gui/graphics/contexts/juce_Graphics.cpp @@ -165,6 +165,11 @@ void Graphics::setOrigin (const int newOriginX, const int newOriginY) context->setOrigin (newOriginX, newOriginY); } +void Graphics::addTransform (const AffineTransform& transform) +{ + context->addTransform (transform); +} + bool Graphics::clipRegionIntersects (const Rectangle& area) const { return context->clipRegionIntersects (area); diff --git a/src/gui/graphics/contexts/juce_Graphics.h b/src/gui/graphics/contexts/juce_Graphics.h index 9cf00bd4c9..d71fa6ad8a 100644 --- a/src/gui/graphics/contexts/juce_Graphics.h +++ b/src/gui/graphics/contexts/juce_Graphics.h @@ -621,10 +621,20 @@ public: So if you call setOrigin (100, 100), then the position that was previously referred to as (100, 100) will subsequently be considered to be (0, 0). - @see reduceClipRegion + @see reduceClipRegion, addTransform */ void setOrigin (int newOriginX, int newOriginY); + /** Adds a transformation which will be performed on all the graphics operations that + the context subsequently performs. + + After calling this, all the coordinates that are passed into the context will be + transformed by this matrix. + + @see setOrigin + */ + void addTransform (const AffineTransform& transform); + /** Resets the current colour, brush, and font to default settings. */ void resetToDefaultState(); diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index e7efe91341..0fa9760d7f 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -245,9 +245,6 @@ #ifndef __JUCE_CHANGELISTENER_JUCEHEADER__ #include "events/juce_ChangeListener.h" #endif -#ifndef __JUCE_CHANGELISTENERLIST_JUCEHEADER__ - #include "events/juce_ChangeListenerList.h" -#endif #ifndef __JUCE_INTERPROCESSCONNECTION_JUCEHEADER__ #include "events/juce_InterprocessConnection.h" #endif diff --git a/src/native/mac/juce_mac_AudioCDBurner.mm b/src/native/mac/juce_mac_AudioCDBurner.mm index bf0be2b6ba..9587e1c99c 100644 --- a/src/native/mac/juce_mac_AudioCDBurner.mm +++ b/src/native/mac/juce_mac_AudioCDBurner.mm @@ -352,7 +352,7 @@ public: if (state != lastState) { lastState = state; - owner.sendChangeMessage (&owner); + owner.sendChangeMessage(); } } diff --git a/src/native/windows/juce_win32_AudioCDReader.cpp b/src/native/windows/juce_win32_AudioCDReader.cpp index 8b4df80e5a..652519b93a 100644 --- a/src/native/windows/juce_win32_AudioCDReader.cpp +++ b/src/native/windows/juce_win32_AudioCDReader.cpp @@ -2201,7 +2201,7 @@ public: if (state != lastState) { lastState = state; - owner.sendChangeMessage (&owner); + owner.sendChangeMessage(); } } diff --git a/src/native/windows/juce_win32_CameraDevice.cpp b/src/native/windows/juce_win32_CameraDevice.cpp index 2e66ff7264..cc0dc32a6c 100644 --- a/src/native/windows/juce_win32_CameraDevice.cpp +++ b/src/native/windows/juce_win32_CameraDevice.cpp @@ -226,7 +226,7 @@ public: if (listeners.size() > 0) callListeners (loadingImage); - sendChangeMessage (this); + sendChangeMessage(); } void drawCurrentImage (Graphics& g, int x, int y, int w, int h) @@ -441,7 +441,7 @@ public: g.fillAll (Colours::black); } - void changeListenerCallback (void*) + void changeListenerCallback (ChangeBroadcaster*) { const int64 now = Time::currentTimeMillis(); diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index cc5143cf8e..4c2ea2ea68 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -885,6 +885,7 @@ public: if (taskBarIcon == 0) { taskBarIcon = new NOTIFYICONDATA(); + zeromem (taskBarIcon, sizeof (NOTIFYICONDATA)); taskBarIcon->cbSize = sizeof (NOTIFYICONDATA); taskBarIcon->hWnd = (HWND) hwnd; taskBarIcon->uID = (int) (pointer_sized_int) hwnd; @@ -905,8 +906,6 @@ public: DestroyIcon (oldIcon); } - - DestroyIcon (hicon); } else if (taskBarIcon != 0) { @@ -927,6 +926,56 @@ public: } } + void handleTaskBarEvent (const LPARAM lParam, const WPARAM wParam) + { + if (component->isCurrentlyBlockedByAnotherModalComponent()) + { + if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN + || lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) + { + Component* const current = Component::getCurrentlyModalComponent(); + + if (current != 0) + current->inputAttemptWhenModal(); + } + } + else + { + ModifierKeys eventMods (ModifierKeys::getCurrentModifiersRealtime()); + + if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) + eventMods = eventMods.withFlags (ModifierKeys::leftButtonModifier); + else if (lParam == WM_RBUTTONDOWN || lParam == WM_RBUTTONDBLCLK) + eventMods = eventMods.withFlags (ModifierKeys::rightButtonModifier); + else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) + eventMods = eventMods.withoutMouseButtons(); + + const MouseEvent e (Desktop::getInstance().getMainMouseSource(), + Point(), eventMods, component, component, getMouseEventTime(), + Point(), getMouseEventTime(), 1, false); + + if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN) + { + SetFocus (hwnd); + SetForegroundWindow (hwnd); + component->mouseDown (e); + } + else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) + { + component->mouseUp (e); + } + else if (lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) + { + component->mouseDoubleClick (e); + } + else if (lParam == WM_MOUSEMOVE) + { + component->mouseMove (e); + } + } + } + + //============================================================================== bool isInside (HWND h) const { return GetAncestor (hwnd, GA_ROOT) == h; @@ -1700,21 +1749,11 @@ private: switch (GET_APPCOMMAND_LPARAM (lParam)) { - case APPCOMMAND_MEDIA_PLAY_PAUSE: - key = KeyPress::playKey; - break; - - case APPCOMMAND_MEDIA_STOP: - key = KeyPress::stopKey; - break; - - case APPCOMMAND_MEDIA_NEXTTRACK: - key = KeyPress::fastForwardKey; - break; - - case APPCOMMAND_MEDIA_PREVIOUSTRACK: - key = KeyPress::rewindKey; - break; + case APPCOMMAND_MEDIA_PLAY_PAUSE: key = KeyPress::playKey; break; + case APPCOMMAND_MEDIA_STOP: key = KeyPress::stopKey; break; + case APPCOMMAND_MEDIA_NEXTTRACK: key = KeyPress::fastForwardKey; break; + case APPCOMMAND_MEDIA_PREVIOUSTRACK: key = KeyPress::rewindKey; break; + default: break; } if (key != 0) @@ -1731,6 +1770,83 @@ private: return false; } + LRESULT handleSizeConstraining (RECT* const r, const WPARAM wParam) + { + if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) + { + Rectangle pos (r->left, r->top, r->right - r->left, r->bottom - r->top); + + constrainer->checkBounds (pos, windowBorder.addedTo (component->getBounds()), + Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), + wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT, + wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT, + wParam == WMSZ_BOTTOM || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT, + wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT || wParam == WMSZ_BOTTOMRIGHT); + r->left = pos.getX(); + r->top = pos.getY(); + r->right = pos.getRight(); + r->bottom = pos.getBottom(); + } + + return TRUE; + } + + LRESULT handlePositionChanging (WINDOWPOS* const wp) + { + if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) + { + if ((wp->flags & (SWP_NOMOVE | SWP_NOSIZE)) != (SWP_NOMOVE | SWP_NOSIZE) + && ! Component::isMouseButtonDownAnywhere()) + { + Rectangle pos (wp->x, wp->y, wp->cx, wp->cy); + const Rectangle current (windowBorder.addedTo (component->getBounds())); + + constrainer->checkBounds (pos, current, + Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), + pos.getY() != current.getY() && pos.getBottom() == current.getBottom(), + pos.getX() != current.getX() && pos.getRight() == current.getRight(), + pos.getY() == current.getY() && pos.getBottom() != current.getBottom(), + pos.getX() == current.getX() && pos.getRight() != current.getRight()); + wp->x = pos.getX(); + wp->y = pos.getY(); + wp->cx = pos.getWidth(); + wp->cy = pos.getHeight(); + } + } + + return 0; + } + + void handleAppActivation (const WPARAM wParam) + { + modifiersAtLastCallback = -1; + updateKeyModifiers(); + + if (isMinimised()) + { + component->repaint(); + handleMovedOrResized(); + + if (! ComponentPeer::isValidPeer (this)) + return; + } + + if (LOWORD (wParam) == WA_CLICKACTIVE && component->isCurrentlyBlockedByAnotherModalComponent()) + { + Component* const underMouse = component->getComponentAt (component->getMouseXYRelative()); + + if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent()) + Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); + } + else + { + handleBroughtToFront(); + + if (component->isCurrentlyBlockedByAnotherModalComponent()) + Component::getCurrentlyModalComponent()->toFront (true); + } + } + //============================================================================== class JuceDropTarget : public ComBaseClassHelper { @@ -1891,11 +2007,10 @@ private: case WM_NCHITTEST: if ((styleFlags & windowIgnoresMouseClicks) != 0) return HTTRANSPARENT; + else if (! hasTitleBar()) + return HTCLIENT; - if (hasTitleBar()) - break; - - return HTCLIENT; + break; //============================================================================== case WM_PAINT: @@ -1959,48 +2074,10 @@ private: //============================================================================== case WM_SIZING: - if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) - { - RECT* const r = (RECT*) lParam; - Rectangle pos (r->left, r->top, r->right - r->left, r->bottom - r->top); - - constrainer->checkBounds (pos, windowBorder.addedTo (component->getBounds()), - Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), - wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT, - wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT, - wParam == WMSZ_BOTTOM || wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_BOTTOMRIGHT, - wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT || wParam == WMSZ_BOTTOMRIGHT); - r->left = pos.getX(); - r->top = pos.getY(); - r->right = pos.getRight(); - r->bottom = pos.getBottom(); - } - return TRUE; + return handleSizeConstraining ((RECT*) lParam, wParam); case WM_WINDOWPOSCHANGING: - if (constrainer != 0 && (styleFlags & (windowHasTitleBar | windowIsResizable)) == (windowHasTitleBar | windowIsResizable)) - { - WINDOWPOS* const wp = (WINDOWPOS*) lParam; - - if ((wp->flags & (SWP_NOMOVE | SWP_NOSIZE)) != (SWP_NOMOVE | SWP_NOSIZE) - && ! Component::isMouseButtonDownAnywhere()) - { - Rectangle pos (wp->x, wp->y, wp->cx, wp->cy); - const Rectangle current (windowBorder.addedTo (component->getBounds())); - - constrainer->checkBounds (pos, current, - Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), - pos.getY() != current.getY() && pos.getBottom() == current.getBottom(), - pos.getX() != current.getX() && pos.getRight() == current.getRight(), - pos.getY() == current.getY() && pos.getBottom() != current.getBottom(), - pos.getX() == current.getX() && pos.getRight() != current.getRight()); - wp->x = pos.getX(); - wp->y = pos.getY(); - wp->cx = pos.getWidth(); - wp->cy = pos.getHeight(); - } - } - return 0; + return handlePositionChanging ((WINDOWPOS*) lParam); case WM_WINDOWPOSCHANGED: { @@ -2074,35 +2151,7 @@ private: case WM_ACTIVATE: if (LOWORD (wParam) == WA_ACTIVE || LOWORD (wParam) == WA_CLICKACTIVE) { - modifiersAtLastCallback = -1; - updateKeyModifiers(); - - if (isMinimised()) - { - component->repaint(); - handleMovedOrResized(); - - if (! ComponentPeer::isValidPeer (this)) - return 0; - } - - if (LOWORD (wParam) == WA_CLICKACTIVE - && component->isCurrentlyBlockedByAnotherModalComponent()) - { - const Point mousePos (component->getMouseXYRelative()); - Component* const underMouse = component->getComponentAt (mousePos.getX(), mousePos.getY()); - - if (underMouse != 0 && underMouse->isCurrentlyBlockedByAnotherModalComponent()) - Component::getCurrentlyModalComponent()->inputAttemptWhenModal(); - - return 0; - } - - handleBroughtToFront(); - - if (component->isCurrentlyBlockedByAnotherModalComponent()) - Component::getCurrentlyModalComponent()->toFront (true); - + handleAppActivation (wParam); return 0; } @@ -2142,57 +2191,10 @@ private: } return TRUE; - //============================================================================== case WM_TRAYNOTIFY: - if (component->isCurrentlyBlockedByAnotherModalComponent()) - { - if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN - || lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) - { - Component* const current = Component::getCurrentlyModalComponent(); - - if (current != 0) - current->inputAttemptWhenModal(); - } - } - else - { - ModifierKeys eventMods (ModifierKeys::getCurrentModifiersRealtime()); - - if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) - eventMods = eventMods.withFlags (ModifierKeys::leftButtonModifier); - else if (lParam == WM_RBUTTONDOWN || lParam == WM_RBUTTONDBLCLK) - eventMods = eventMods.withFlags (ModifierKeys::rightButtonModifier); - else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) - eventMods = eventMods.withoutMouseButtons(); - - const MouseEvent e (Desktop::getInstance().getMainMouseSource(), - Point(), eventMods, component, component, getMouseEventTime(), - Point(), getMouseEventTime(), 1, false); - - if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN) - { - SetFocus (hwnd); - SetForegroundWindow (hwnd); - component->mouseDown (e); - } - else if (lParam == WM_LBUTTONUP || lParam == WM_RBUTTONUP) - { - component->mouseUp (e); - } - else if (lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) - { - component->mouseDoubleClick (e); - } - else if (lParam == WM_MOUSEMOVE) - { - component->mouseMove (e); - } - } - + handleTaskBarEvent (lParam, wParam); break; - //============================================================================== case WM_SYNCPAINT: return 0; @@ -2238,10 +2240,8 @@ private: break; case SC_KEYMENU: - // (NB mustn't call sendInputAttemptWhenModalMessage() here because of very - // obscure situations that can arise if a modal loop is started from an alt-key - // keypress). - + // (NB mustn't call sendInputAttemptWhenModalMessage() here because of very obscure + // situations that can arise if a modal loop is started from an alt-key keypress). if (hasTitleBar() && h == GetCapture()) ReleaseCapture(); @@ -2305,6 +2305,17 @@ private: return DLGC_WANTALLKEYS; default: + if (taskBarIcon != 0) + { + static const DWORD taskbarCreatedMessage = RegisterWindowMessage (TEXT("TaskbarCreated")); + + if (message == taskbarCreatedMessage) + { + taskBarIcon->uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + Shell_NotifyIcon (NIM_ADD, taskBarIcon); + } + } + break; } } diff --git a/src/utilities/juce_FileBasedDocument.cpp b/src/utilities/juce_FileBasedDocument.cpp index 23b641d189..75c7cef080 100644 --- a/src/utilities/juce_FileBasedDocument.cpp +++ b/src/utilities/juce_FileBasedDocument.cpp @@ -57,14 +57,14 @@ void FileBasedDocument::setChangedFlag (const bool hasChanged) if (changedSinceSave != hasChanged) { changedSinceSave = hasChanged; - sendChangeMessage (this); + sendChangeMessage(); } } void FileBasedDocument::changed() { changedSinceSave = true; - sendChangeMessage (this); + sendChangeMessage(); } //============================================================================== diff --git a/src/utilities/juce_PropertiesFile.cpp b/src/utilities/juce_PropertiesFile.cpp index 29f914f2fb..1b31ebfb2e 100644 --- a/src/utilities/juce_PropertiesFile.cpp +++ b/src/utilities/juce_PropertiesFile.cpp @@ -38,6 +38,7 @@ BEGIN_JUCE_NAMESPACE #include "../containers/juce_ScopedPointer.h" #include "../core/juce_SystemStats.h" #include "../threads/juce_InterProcessLock.h" +#include "../threads/juce_ScopedLock.h" #include "../text/juce_XmlDocument.h" @@ -275,7 +276,7 @@ void PropertiesFile::timerCallback() void PropertiesFile::propertyChanged() { - sendChangeMessage (this); + sendChangeMessage(); needsWriting = true; diff --git a/src/utilities/juce_SelectedItemSet.h b/src/utilities/juce_SelectedItemSet.h index 771939b1c9..d4d4ca2e90 100644 --- a/src/utilities/juce_SelectedItemSet.h +++ b/src/utilities/juce_SelectedItemSet.h @@ -306,9 +306,9 @@ public: void changed (const bool synchronous = false) { if (synchronous) - sendSynchronousChangeMessage (this); + sendSynchronousChangeMessage(); else - sendChangeMessage (this); + sendChangeMessage(); } //============================================================================== diff --git a/src/utilities/juce_UndoManager.cpp b/src/utilities/juce_UndoManager.cpp index fa6f76c10a..294c12dc25 100644 --- a/src/utilities/juce_UndoManager.cpp +++ b/src/utilities/juce_UndoManager.cpp @@ -55,7 +55,7 @@ void UndoManager::clearUndoHistory() transactionNames.clear(); totalUnitsStored = 0; nextIndex = 0; - sendChangeMessage (this); + sendChangeMessage(); } int UndoManager::getNumberOfUnitsTakenUpByStoredCommands() const @@ -146,7 +146,7 @@ bool UndoManager::perform (UndoableAction* const command_, const String& actionN --nextIndex; } - sendChangeMessage (this); + sendChangeMessage(); return true; } @@ -216,7 +216,7 @@ bool UndoManager::undo() beginNewTransaction(); - sendChangeMessage (this); + sendChangeMessage(); return true; } @@ -249,7 +249,7 @@ bool UndoManager::redo() beginNewTransaction(); - sendChangeMessage (this); + sendChangeMessage(); return true; }