From 39bbc0b4f480956c767efa90acad701cc334ae6d Mon Sep 17 00:00:00 2001 From: jmechnich Date: Wed, 13 Oct 2021 12:12:04 +0200 Subject: [PATCH 01/19] fix: updated MacOS build files generated by Projucer - added vst2sdk to header search path - use standard AU type 'aumi' --- Builds/MacOSX/Ctrlr.xcodeproj/project.pbxproj | 36 ++++++++++++------- Builds/MacOSX/Info-AU.plist | 2 +- Builds/MacOSX/Info-AUv3_AppExtension.plist | 2 +- Ctrlr.jucer | 6 ++-- JuceLibraryCode/JucePluginDefines.h | 2 +- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Builds/MacOSX/Ctrlr.xcodeproj/project.pbxproj b/Builds/MacOSX/Ctrlr.xcodeproj/project.pbxproj index 7cfedc7e5..3d10b8278 100644 --- a/Builds/MacOSX/Ctrlr.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/Ctrlr.xcodeproj/project.pbxproj @@ -2859,6 +2859,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -2874,7 +2875,7 @@ LIBRARY_STYLE = Bundle; LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-bundle -lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; @@ -2928,6 +2929,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -2943,7 +2945,7 @@ LIBRARY_STYLE = Bundle; LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-bundle -lCtrlr"; OTHER_REZFLAGS = "-d ppc_$ppc -d i386_$i386 -d ppc64_$ppc64 -d x86_64_$x86_64 -I /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers -I \"$(DEVELOPER_DIR)/Extras/CoreAudio/AudioUnits/AUPublic/AUBase\" -I \"$(DEVELOPER_DIR)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioUnit.framework/Headers\""; @@ -2996,6 +2998,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3009,7 +3012,7 @@ INFOPLIST_PREPROCESS = NO; LIBRARY_STYLE = Bundle; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-bundle -lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; @@ -3061,6 +3064,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3074,7 +3078,7 @@ INFOPLIST_PREPROCESS = NO; LIBRARY_STYLE = Bundle; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-bundle -lCtrlr"; OTHER_REZFLAGS = "-d ppc_$ppc -d i386_$i386 -d ppc64_$ppc64 -d x86_64_$x86_64 -I /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers -I \"$(DEVELOPER_DIR)/Extras/CoreAudio/AudioUnits/AUPublic/AUBase\" -I \"$(DEVELOPER_DIR)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioUnit.framework/Headers\""; @@ -3126,6 +3130,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3139,7 +3144,7 @@ INFOPLIST_PREPROCESS = NO; LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; @@ -3192,6 +3197,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3207,7 +3213,7 @@ LIBRARY_STYLE = Bundle; LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-bundle -lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; @@ -3260,6 +3266,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3273,7 +3280,7 @@ INFOPLIST_PREPROCESS = NO; LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr.CtrlrAUv3; @@ -3323,6 +3330,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3335,7 +3343,7 @@ INFOPLIST_FILE = Info-Standalone_Plugin.plist; INFOPLIST_PREPROCESS = NO; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; @@ -3436,6 +3444,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3448,7 +3457,7 @@ INFOPLIST_FILE = Info-AUv3_AppExtension.plist; INFOPLIST_PREPROCESS = NO; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr.CtrlrAUv3; @@ -3499,6 +3508,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3511,7 +3521,7 @@ INSTALL_PATH = "@executable_path/../Frameworks"; LLVM_LTO = YES; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; PRODUCT_NAME = "Ctrlr"; @@ -3562,6 +3572,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3573,7 +3584,7 @@ ); INSTALL_PATH = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; PRODUCT_NAME = "Ctrlr"; @@ -3688,6 +3699,7 @@ "$(SRCROOT)/../../Source/Misc/luabind", "$(SRCROOT)/../../Source/Misc/libusb/include", "$(SRCROOT)/../../Source/Misc/boost", + "$(SRCROOT)/../../Source/Misc/vst2sdk", "$(SRCROOT)/../../Source/MIDI", "$(SRCROOT)/../../Source/Core", "$(SRCROOT)/../../Source/Native", @@ -3701,7 +3713,7 @@ INFOPLIST_PREPROCESS = NO; LIBRARY_STYLE = Bundle; MACOSX_DEPLOYMENT_TARGET = 10.11; - MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; + MTL_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../JUCE/modules/juce_audio_processors/format_types/VST3_SDK $(SRCROOT)/../../JuceLibraryCode $(SRCROOT)/../../JUCE/modules $(SRCROOT)/../../Source $(SRCROOT)/../../Source/Misc $(SRCROOT)/../../Source/Misc/include $(SRCROOT)/../../Source/Misc/lua/include $(SRCROOT)/../../Source/Misc/luabind $(SRCROOT)/../../Source/Misc/libusb/include $(SRCROOT)/../../Source/Misc/boost $(SRCROOT)/../../Source/Misc/vst2sdk $(SRCROOT)/../../Source/MIDI $(SRCROOT)/../../Source/Core $(SRCROOT)/../../Source/Native $(SRCROOT)/../../Source/Plugin $(SRCROOT)/../../Source/UIComponents $(SRCROOT)/../../Source/Lua $(SRCROOT)/../../JUCE/modules/juce_audio_plugin_client"; OTHER_CPLUSPLUSFLAGS = "-w"; OTHER_LDFLAGS = "-bundle -lCtrlr"; PRODUCT_BUNDLE_IDENTIFIER = com.instigator.Ctrlr; diff --git a/Builds/MacOSX/Info-AU.plist b/Builds/MacOSX/Info-AU.plist index 316d97615..5ae69a0f7 100644 --- a/Builds/MacOSX/Info-AU.plist +++ b/Builds/MacOSX/Info-AU.plist @@ -37,7 +37,7 @@ manufacturer inSt type - CtrlrAU + aumi subtype cTrl version diff --git a/Builds/MacOSX/Info-AUv3_AppExtension.plist b/Builds/MacOSX/Info-AUv3_AppExtension.plist index 7be04defe..14c58867f 100644 --- a/Builds/MacOSX/Info-AUv3_AppExtension.plist +++ b/Builds/MacOSX/Info-AUv3_AppExtension.plist @@ -45,7 +45,7 @@ manufacturer inSt type - CtrlrAU + aumi subtype cTrl version diff --git a/Ctrlr.jucer b/Ctrlr.jucer index 3fa104bb3..351dcce9e 100644 --- a/Ctrlr.jucer +++ b/Ctrlr.jucer @@ -10,7 +10,7 @@ pluginIsSynth="1" pluginWantsMidiIn="1" pluginProducesMidiOut="1" pluginIsMidiEffectPlugin="1" pluginEditorRequiresKeys="1" pluginAUExportPrefix="CtrlrAU" pluginRTASCategory="" aaxIdentifier="com.instigator.Ctrlr" pluginAAXCategory="2" - companyName="Instigator" pluginAUMainType="CtrlrAU" pluginFormats="buildVST,buildVST3,buildAU,buildAUv3,buildStandalone" + companyName="Instigator" pluginFormats="buildVST,buildVST3,buildAU,buildAUv3,buildStandalone" pluginCharacteristicsValue="pluginIsSynth,pluginWantsMidiIn,pluginProducesMidiOut,pluginIsMidiEffectPlugin,pluginEditorRequiresKeys" jucerFormatVersion="1"> @@ -1060,9 +1060,9 @@ enableGNUExtensions="0" extraCompilerFlags="-w"> + headerPath="../../Source ../../Source/Misc ../../Source/Misc/include ../../Source/Misc/lua/include ../../Source/Misc/luabind ../../Source/Misc/libusb/include ../../Source/Misc/boost ../../Source/Misc/vst2sdk ../../Source/MIDI ../../Source/Core ../../Source/Native ../../Source/Plugin ../../Source/UIComponents ../../Source/Lua"/> diff --git a/JuceLibraryCode/JucePluginDefines.h b/JuceLibraryCode/JucePluginDefines.h index 80dea9e83..c891730d6 100644 --- a/JuceLibraryCode/JucePluginDefines.h +++ b/JuceLibraryCode/JucePluginDefines.h @@ -92,7 +92,7 @@ #define JucePlugin_Vst3Category "Instrument|Synth" #endif #ifndef JucePlugin_AUMainType - #define JucePlugin_AUMainType CtrlrAU + #define JucePlugin_AUMainType 'aumi' #endif #ifndef JucePlugin_AUSubType #define JucePlugin_AUSubType JucePlugin_PluginCode From 496a389045d60a7376c949f8e09cd9bf0313b3ce Mon Sep 17 00:00:00 2001 From: jmechnich Date: Wed, 13 Oct 2021 12:15:31 +0200 Subject: [PATCH 02/19] fix: compilation fails on MacOS 11.3 with JUCE 6.0.8 --- Source/Native/CtrlrMac.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Native/CtrlrMac.cpp b/Source/Native/CtrlrMac.cpp index 4f4dfeb0a..1fe229170 100644 --- a/Source/Native/CtrlrMac.cpp +++ b/Source/Native/CtrlrMac.cpp @@ -2,6 +2,7 @@ #include "stdafx_luabind.h" static const int zero=0; #ifdef __APPLE__ +#include #include "CtrlrPanel/CtrlrPanel.h" #include "CtrlrMac.h" #include "CtrlrMacros.h" @@ -126,7 +127,7 @@ const Result CtrlrMac::setBundleInfo (CtrlrPanel *sourceInfo, const File &bundle if (plist.existsAsFile() && plist.hasWriteAccess()) { - ScopedPointer plistXml (XmlDocument::parse(plist)); + std::unique_ptr plistXml (XmlDocument::parse(plist)); if (plistXml == nullptr) { return (Result::fail("MAC native, can't parse Info.plist as a XML document")); From 3211836e0c0e4b081f6949b7cdca5c016320d4a0 Mon Sep 17 00:00:00 2001 From: jmechnich Date: Wed, 13 Oct 2021 12:18:15 +0200 Subject: [PATCH 03/19] README.md: updated macOS build instructions --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 572cab356..c15710a51 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ Control any MIDI enabled hardware: synthesizers, drum machines, samplers, effect Cross Platform ============== -Works on Windows (XP and up, both 64 and 32bit binaries are available), MAC OSX (10.5 and up), Linux (any modern distro should run it). +Works on Windows (XP and up, both 64 and 32bit binaries are available), macOS (10.5 and up), Linux (any modern distro should run it). Host in your DAW -Each platform has a VST build of Ctrlr so you can host your panels as normal VST plugins, for the OSX a special AU build is available. +Each platform has a VST build of Ctrlr so you can host your panels as normal VST plugins, for macOS a special AU build is available. Customize ========= @@ -71,15 +71,17 @@ The post-commit script takes an argument "clean" if you wish to clean all the in files before building. If you want to ignore any package errors that it reports (i assume you know your system better then my script) then just add -f as an option when building. -OSX -=== -You need the CoreAudio developer files for the build to work. +macOS +===== +Unzip boost or link your own boost library e.g. from [Homebrew](https://brew.sh): -First you need to build the AU_wrapper library that simplifies the build a lot, it's located in -Builds/Generated/Mac/AU_Wrapper, it will create a .a library and try to put it in /usr/local/lib -if it fails, do that manualy (permission problems) +``` +# use packaged boost library +cd Source/Misc/boost && unzip boost.zip +# alternatively, link your own +ln -s /opt/homebrew/Cellar/boost/BOOST_VERSION/include/boost Source/Misc/boost/boost +``` -Open the corresponding Xcode project in Builds/Generated/Mac, after that just build it, in case of -errors you are on your own, the amount of changes between Xcode versions and OSX versions is impossible -for me to track, you can post an issue and i'll try to solve it. +Open the Xcode project `Builds/MacOSX/Ctrlr.xcodeproj` and build it. +In case of errors it might help to refresh the project files using Projuicer. From 27f3ed56e568ca1496091949c519e268c88f26e0 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 19 Jun 2021 21:39:36 +0200 Subject: [PATCH 04/19] Avoid some JUCE assertions. This patch circumvents program aborts when - The window is too small so that the text width may get negative - uiImageSlider is fully initialised, so that the slider range contains invalid data --- .../lookandfeel/juce_LookAndFeel_V4.cpp | 2 +- .../CtrlrComponents/Sliders/CtrlrImageSlider.cpp | 13 ++++++++++++- .../CtrlrPropertyEditors/CtrlrPropertyComponent.cpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/JUCE/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp b/JUCE/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp index 21042d0b2..580d62319 100644 --- a/JUCE/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp +++ b/JUCE/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V4.cpp @@ -1246,7 +1246,7 @@ void LookAndFeel_V4::drawPropertyPanelSectionHeader (Graphics& g, const String& g.setColour (findColour (PropertyComponent::labelTextColourId)); g.setFont ({ (float) height * 0.7f, Font::bold }); - g.drawText (name, textX, 0, width - textX - 4, height, Justification::centredLeft, true); + g.drawText (name, textX, 0, std::max(width - textX - 4,1), height, Justification::centredLeft, true); } void LookAndFeel_V4::drawPropertyComponentBackground (Graphics& g, int width, int height, PropertyComponent& component) diff --git a/Source/UIComponents/CtrlrComponents/Sliders/CtrlrImageSlider.cpp b/Source/UIComponents/CtrlrComponents/Sliders/CtrlrImageSlider.cpp index 50cfd8715..b217e54f5 100644 --- a/Source/UIComponents/CtrlrComponents/Sliders/CtrlrImageSlider.cpp +++ b/Source/UIComponents/CtrlrComponents/Sliders/CtrlrImageSlider.cpp @@ -162,7 +162,18 @@ void CtrlrImageSlider::valueTreePropertyChanged (ValueTree &treeWhosePropertyHas } else if (property == Ids::uiSliderInterval || property == Ids::uiSliderMax || property == Ids::uiSliderMin) { - ctrlrSlider->setRange ( getProperty (Ids::uiSliderMin), getProperty (Ids::uiSliderMax), getProperty (Ids::uiSliderInterval) ); + double max = getProperty (Ids::uiSliderMax); + const double min = getProperty (Ids::uiSliderMin); + double interval = getProperty (Ids::uiSliderInterval); + if (interval == 0) + interval = std::abs(max-min) + 1; + // For JUCE MAX must be >= min + if (max <= min) { + // samething between 0.5 and 1 times the interval + // to avoid rounding errors + max = min + interval * 0.66; + } + ctrlrSlider->setRange ( min, max, interval ); owner.setProperty (Ids::modulatorMax, ctrlrSlider->getMaximum()); owner.setProperty (Ids::modulatorMin, ctrlrSlider->getMinimum()); } diff --git a/Source/UIComponents/CtrlrPropertyEditors/CtrlrPropertyComponent.cpp b/Source/UIComponents/CtrlrPropertyEditors/CtrlrPropertyComponent.cpp index 51c7d7f1e..375f6c5d5 100644 --- a/Source/UIComponents/CtrlrPropertyEditors/CtrlrPropertyComponent.cpp +++ b/Source/UIComponents/CtrlrPropertyEditors/CtrlrPropertyComponent.cpp @@ -58,7 +58,7 @@ void CtrlrPropertyComponent::paint (Graphics &g) g.setFont (currentFont); g.setColour(findColour(PropertyComponent::labelTextColourId)); - g.drawFittedText (visibleText, 3, 0, getLookAndFeel().getPropertyComponentContentPosition (*this).getX()-5, getHeight(), Justification::centredLeft, 2); + g.drawFittedText (visibleText, 3, 0, std::max( getLookAndFeel().getPropertyComponentContentPosition (*this).getX()-5,0), getHeight(), Justification::centredLeft, 2); } void CtrlrPropertyComponent::resized() From 9050927c9f412586ec771e207589921333906cbf Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 19 Jun 2021 21:42:38 +0200 Subject: [PATCH 05/19] Don't set the title of owner's editor if that is nullptr. --- Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp b/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp index 90bc3bf0a..e82002821 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp @@ -978,7 +978,8 @@ void CtrlrPanel::updatePanelWindowTitle() { editor->setName(newName); // Trigger editor window title update - owner.getEditor()->activeCtrlrChanged(); + auto editor = owner.getEditor(); + if (editor) editor->activeCtrlrChanged(); } } } From e608f0fd70befef2013ad3ed71c4b37be7c535e7 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 19 Jun 2021 22:24:08 +0200 Subject: [PATCH 06/19] Fix crashes when a Lua chunk does not contain a function of the same name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a Lua chank has a name, after the compilation an extended type of the variable with the chunk's name is stored in the CtrlrLuaMethod object. Errors are defined as additional types. This complies to the fact that a Lua chunk can contain everything, not only a single functions. The function isValid() changed its semantics from “running fine, so far” to “no probable error has been detected, so far“. In this sense a named Lua chunk that does not define a variable with the chunk's name is considered to probably contain an error. The function isValid() is mainly used to inform the Ctrlr user/programmer that a certain chunk is problematic in some way, which meens colouring its name red if isValid() returns false. In order to invalid calls to the Lua variable a function isCallable() has been introduced. It returns true iff the Lua chunk defines a function with the chunk's name that compiles fine and did not raise any Lua error so far. So, isCallable() covers most of the cases where isValid() had been called until this patch. In order to avoid unnecessary confusion “json4lua“ has been renamed to “json” and “debugger.lua” has been renamed to “debugger”. --- JuceLibraryCode/BinaryData.cpp | 4 +- .../CtrlrModulatorProcessor.cpp | 6 +- Source/Core/CtrlrPanel/CtrlrPanel.cpp | 24 ++--- .../CtrlrPanel/CtrlrPanelMIDISnapshot.cpp | 4 +- .../Core/CtrlrPanel/CtrlrPanelProcessor.cpp | 2 +- Source/Lua/CtrlrLuaManager.cpp | 75 ++++++++++++++-- Source/Lua/CtrlrLuaManager.h | 2 +- Source/Lua/Methods/CtrlrLuaMethod.cpp | 66 +++++++------- Source/Lua/Methods/CtrlrLuaMethod.h | 74 ++++++++++++++- .../Methods/CtrlrLuaMethodManagerCalls.cpp | 90 +++++++++---------- .../Resources/XML/CtrlrLuaMethodTemplates.xml | 4 +- .../CtrlrComponents/CtrlrComponent.cpp | 8 +- .../CtrlrComponents/CtrlrCustomComponent.cpp | 46 +++++----- .../Groups/CtrlrTabsComponent.cpp | 2 +- .../CtrlrComponents/Labels/CtrlrLCDLabel.cpp | 2 +- .../CtrlrComponents/Labels/CtrlrLabel.cpp | 2 +- .../Specials/CtrlrFileListBox.cpp | 8 +- .../CtrlrComponents/Specials/CtrlrListBox.cpp | 8 +- .../Specials/CtrlrWaveform.cpp | 8 +- .../CtrlrPanel/CtrlrPanelCanvas.cpp | 10 +-- 20 files changed, 291 insertions(+), 154 deletions(-) diff --git a/JuceLibraryCode/BinaryData.cpp b/JuceLibraryCode/BinaryData.cpp index e9be2126d..278154268 100644 --- a/JuceLibraryCode/BinaryData.cpp +++ b/JuceLibraryCode/BinaryData.cpp @@ -18778,8 +18778,8 @@ static const unsigned char temp_binary_data_81[] = "end\r\n" " \r\n" "\r\n" -" \r\n" -" \r\n" +" \r\n" +" \r\n" " \r\n" " \r\n" "\r\n"; diff --git a/Source/Core/CtrlrModulator/CtrlrModulatorProcessor.cpp b/Source/Core/CtrlrModulator/CtrlrModulatorProcessor.cpp index 2caaf3f69..e4c909960 100644 --- a/Source/Core/CtrlrModulator/CtrlrModulatorProcessor.cpp +++ b/Source/Core/CtrlrModulator/CtrlrModulatorProcessor.cpp @@ -49,7 +49,7 @@ void CtrlrModulatorProcessor::handleAsyncUpdate() if (valueChangedCbk.get() && !owner.getRestoreState()) { CtrlrPanel &ownerPanel = owner.getOwnerPanel(); - if (!ownerPanel.getRestoreState() && !ownerPanel.getBootstrapState() && valueChangedCbk->isValid()) + if (!ownerPanel.getRestoreState() && !ownerPanel.getBootstrapState() && valueChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (valueChangedCbk, &owner, @@ -324,7 +324,7 @@ int CtrlrModulatorProcessor::getValueFromMidiMessage(const CtrlrMIDIDeviceType s if (getValueFromMidiCbk) { - if (!getValueFromMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isValid()) + if (!getValueFromMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isCallable()) { evaluationResult = owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRet (getValueFromMidiCbk, &owner, getMidiMessage(source), evaluationResult); } @@ -477,7 +477,7 @@ int CtrlrModulatorProcessor::getValueForMidiMessage(const int value) if (getValueForMidiCbk) { - if (!getValueForMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isValid()) + if (!getValueForMidiCbk.wasObjectDeleted() && getValueForMidiCbk->isCallable()) { evaluationResult = owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRet (getValueForMidiCbk, &owner, evaluationResult); } diff --git a/Source/Core/CtrlrPanel/CtrlrPanel.cpp b/Source/Core/CtrlrPanel/CtrlrPanel.cpp index 5548f5b17..934210a2a 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanel.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanel.cpp @@ -278,7 +278,7 @@ Result CtrlrPanel::restoreState (const ValueTree &savedState) if (luaPanelBeforeLoadCbk && !luaPanelBeforeLoadCbk.wasObjectDeleted()) { - if (luaPanelBeforeLoadCbk->isValid()) + if (luaPanelBeforeLoadCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelBeforeLoadCbk); } @@ -342,7 +342,7 @@ void CtrlrPanel::bootstrapPanel(const bool setInitialProgram) if (luaPanelLoadedCbk.get()) { - if (luaPanelLoadedCbk->isValid()) + if (luaPanelLoadedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelLoadedCbk, (uint8)owner.getInstanceMode()); } @@ -829,7 +829,7 @@ ValueTree CtrlrPanel::getCustomData() if (luaPanelSaveStateCbk && !luaPanelSaveStateCbk.wasObjectDeleted()) { - if (luaPanelSaveStateCbk->isValid()) + if (luaPanelSaveStateCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelSaveStateCbk, customData); } @@ -852,7 +852,7 @@ void CtrlrPanel::setCustomData (const ValueTree &customData) { if (luaPanelRestoreStateCbk && !luaPanelRestoreStateCbk.wasObjectDeleted()) { - if (luaPanelRestoreStateCbk->isValid()) + if (luaPanelRestoreStateCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelRestoreStateCbk, customData); } @@ -912,7 +912,7 @@ void CtrlrPanel::setProgram(ValueTree programTree, const bool sendSnapshotNow) if (luaPanelProgramChangedCbk && !luaPanelProgramChangedCbk.wasObjectDeleted()) { - if (luaPanelProgramChangedCbk->isValid()) + if (luaPanelProgramChangedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelProgramChangedCbk); } @@ -1088,7 +1088,7 @@ void CtrlrPanel::handleAsyncUpdate() bool luaValid = false; if (luaPanelMidiReceivedCbk) - luaValid = luaPanelMidiReceivedCbk->isValid(); + luaValid = luaPanelMidiReceivedCbk->isCallable(); while (i.getNextEvent(m,time)) { @@ -1181,7 +1181,7 @@ void CtrlrPanel::setMidiChannel(const CtrlrPanelMidiChannel optionToSet, const u if (luaPanelMidiChannelChangedCbk && !luaPanelMidiChannelChangedCbk.wasObjectDeleted()) { - if (luaPanelMidiChannelChangedCbk->isValid()) + if (luaPanelMidiChannelChangedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelMidiChannelChangedCbk, (int)optionToSet, (int)value); } @@ -1275,7 +1275,7 @@ void CtrlrPanel::modulatorValueChanged(CtrlrModulator *m) if (luaPanelModulatorValueChangedCbk && !luaPanelModulatorValueChangedCbk.wasObjectDeleted()) { - if (luaPanelModulatorValueChangedCbk->isValid()) + if (luaPanelModulatorValueChangedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelModulatorValueChangedCbk, m, m->getValueNonMapped()); } @@ -1461,7 +1461,7 @@ void CtrlrPanel::luaSavePanel(const CtrlrPanelFileType fileType, const File &fil { if (luaPanelSavedCbk && !luaPanelSavedCbk.wasObjectDeleted()) { - if (luaPanelSavedCbk->isValid()) + if (luaPanelSavedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelSavedCbk, (int)fileType, file); } @@ -1497,7 +1497,7 @@ void CtrlrPanel::sendMidiProgramChange() if (luaPanelProgramChangedCbk && !luaPanelProgramChangedCbk.wasObjectDeleted()) { - if (luaPanelProgramChangedCbk->isValid()) + if (luaPanelProgramChangedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelProgramChangedCbk, program, bankLsb, bankMsb); } @@ -1665,7 +1665,7 @@ void CtrlrPanel::notify (const String ¬ification, CtrlrNotificationCallback * { if (luaPanelMessageHandlerCbk && !luaPanelMessageHandlerCbk.wasObjectDeleted()) { - if (luaPanelMessageHandlerCbk->isValid()) + if (luaPanelMessageHandlerCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelMessageHandlerCbk, notification, ctrlrNotificationType); } @@ -1765,7 +1765,7 @@ void CtrlrPanel::resourceImportFinished() if (luaPanelResourcesLoadedCbk && !luaPanelResourcesLoadedCbk.wasObjectDeleted()) { - if (luaPanelResourcesLoadedCbk->isValid()) + if (luaPanelResourcesLoadedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelResourcesLoadedCbk); } diff --git a/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp b/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp index d7353f90e..3e11648a1 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp @@ -89,7 +89,7 @@ void CtrlrPanelMIDISnapshot::gatherSnapshotData() if (luaPanelMidiSnapshotPreCbk && !luaPanelMidiSnapshotPreCbk.wasObjectDeleted()) { - if (luaPanelMidiSnapshotPreCbk->isValid()) + if (luaPanelMidiSnapshotPreCbk->isCallable()) { owner.getCtrlrLuaManager().getMethodManager().call (luaPanelMidiSnapshotPreCbk, &buffer); } @@ -141,7 +141,7 @@ void CtrlrPanelMIDISnapshot::timerCallback() if (luaPanelMidiSnapshotPostCbk && !luaPanelMidiSnapshotPostCbk.wasObjectDeleted()) { - if (luaPanelMidiSnapshotPostCbk->isValid()) + if (luaPanelMidiSnapshotPostCbk->isCallable()) { owner.getCtrlrLuaManager().getMethodManager().call (luaPanelMidiSnapshotPostCbk, &buffer); } diff --git a/Source/Core/CtrlrPanel/CtrlrPanelProcessor.cpp b/Source/Core/CtrlrPanel/CtrlrPanelProcessor.cpp index 19285734e..40388030f 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelProcessor.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelProcessor.cpp @@ -91,7 +91,7 @@ CtrlrPanel &CtrlrPanelProcessor::getOwner() void CtrlrPanelProcessor::processLua(MidiBuffer &midiMessages, const AudioPlayHead::CurrentPositionInfo &info) { - if (luaAudioProcessBlockCbk && luaAudioProcessBlockCbk->isValid()) + if (luaAudioProcessBlockCbk && luaAudioProcessBlockCbk->isCallable()) { owner.getCtrlrLuaManager().getMethodManager().callAudio(luaAudioProcessBlockCbk, midiMessages, info); } diff --git a/Source/Lua/CtrlrLuaManager.cpp b/Source/Lua/CtrlrLuaManager.cpp index b8dfda592..934856150 100644 --- a/Source/Lua/CtrlrLuaManager.cpp +++ b/Source/Lua/CtrlrLuaManager.cpp @@ -276,11 +276,47 @@ int func_panic(lua_State *L) lua_getglobal(L, "ERROR"); return(0); } +/* + * dump_stack(ls); + */ +static void dump_stack(lua_State *L) +{ + int i; + int top = lua_gettop(L); + printf("\n#### BOS ####\n"); + for(i = top; i >= 1; i--) + { + int t = lua_type(L, i); + switch(t) + { + case LUA_TSTRING: + printf("%i (%i) = `%s'", i, i - (top + 1), lua_tostring(L, i)); + break; + + case LUA_TBOOLEAN: + printf("%i (%i) = %s", i, i - (top + 1), lua_toboolean(L, i) ? "true" : "false"); + break; + + case LUA_TNUMBER: + printf("%i (%i) = %g", i, i - (top + 1), lua_tonumber(L, i)); + break; + + default: + printf("%i (%i) = %s", i, i - (top + 1), lua_typename(L, t)); + break; + } + printf("\n"); + } + printf("#### EOS ####\n"); + printf("\n"); +} -bool CtrlrLuaManager::runCode (const String &code, const String name) +CtrlrLuaMethod::Type CtrlrLuaManager::runCode (const String &code, const String name) { if (luaState && !isLuaDisabled()) { + //std::clog << "Executing Lua code " << (const char *) name.toUTF8() << std::endl; + if (luaL_loadbuffer(luaState, code.toUTF8(), std::strlen(code.toUTF8()), name.isEmpty() ? "_runtime" : name.toUTF8()) || lua_pcall(luaState, 0, 0, 0)) { @@ -288,14 +324,43 @@ bool CtrlrLuaManager::runCode (const String &code, const String name) _LERR("ERROR: " + String(a)); lastError = "ERROR: " + String(a); lua_pop(luaState, 1); - return (false); + return (CtrlrLuaMethod::ERROR); + } else if (!name.isEmpty()) { + //std::clog << code << std::endl; + lua_getglobal(luaState,name.toUTF8()); + //dump_stack(luaState); + int type = lua_type(luaState,1); + lua_pop(luaState,1); + switch (type) { + case CtrlrLuaMethod::NONE: + case CtrlrLuaMethod::NIL: + { + String errstring = "ERROR: The code for function or variable " + name + + " does not define " + name + "."; + _LERR(errstring); + lastError = std::move(errstring); + break; + } + case CtrlrLuaMethod::BOOLEAN: + case CtrlrLuaMethod::LIGHTUSERDATA: + case CtrlrLuaMethod::NUMBER: + case CtrlrLuaMethod::STRING: + case CtrlrLuaMethod::TABLE: + case CtrlrLuaMethod::USERDATA: + case CtrlrLuaMethod::THREAD: + case CtrlrLuaMethod::FUNCTION: + break; + default: + type = CtrlrLuaMethod::UNKNOWN; + } + return ((CtrlrLuaMethod::Type)type); } - return (true); + return (CtrlrLuaMethod::SCRIPT); } else { - return (false); + return (CtrlrLuaMethod::DISABLED); } } @@ -388,7 +453,7 @@ void CtrlrPanel::setGlobalVariable(const int index, const int value) if (luaPanelGlobalChangedCbk && !luaPanelGlobalChangedCbk.wasObjectDeleted()) { - if (luaPanelGlobalChangedCbk->isValid()) + if (luaPanelGlobalChangedCbk->isCallable()) { getCtrlrLuaManager().getMethodManager().call (luaPanelGlobalChangedCbk, index, value); } diff --git a/Source/Lua/CtrlrLuaManager.h b/Source/Lua/CtrlrLuaManager.h index b1dffa545..3f5df4eec 100644 --- a/Source/Lua/CtrlrLuaManager.h +++ b/Source/Lua/CtrlrLuaManager.h @@ -28,7 +28,7 @@ class CtrlrLuaManager : public ValueTree::Listener void wrapJuceCoreClasses(lua_State *L); void wrapConverters(lua_State* L); void wrapUtilities(lua_State* L); - bool runCode (const String &code, const String name=""); + CtrlrLuaMethod::Type runCode (const String &code, const String name=""); void setProperty (const Identifier& name, const var &newValue, const bool isUndoable=false); const var &getProperty (const Identifier& name) const { return luaManagerTree.getProperty (name); } diff --git a/Source/Lua/Methods/CtrlrLuaMethod.cpp b/Source/Lua/Methods/CtrlrLuaMethod.cpp index caa03b047..c624c869c 100644 --- a/Source/Lua/Methods/CtrlrLuaMethod.cpp +++ b/Source/Lua/Methods/CtrlrLuaMethod.cpp @@ -10,7 +10,7 @@ #include "CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.h" CtrlrLuaMethod::CtrlrLuaMethod(CtrlrLuaMethodManager &_owner) - : methodIsValid(false), + : type(UNKNOWN), methodTree(Ids::luaMethod), owner(_owner), methodCodeEditor(nullptr), @@ -24,7 +24,7 @@ CtrlrLuaMethod::CtrlrLuaMethod(CtrlrLuaMethodManager &_owner) } CtrlrLuaMethod::CtrlrLuaMethod(CtrlrLuaMethodManager &_owner, ValueTree &_methodTree) - : methodIsValid(false), + : type(UNKNOWN), methodTree(_methodTree), owner(_owner), methodCodeEditor(nullptr), @@ -49,7 +49,7 @@ CtrlrLuaMethod::~CtrlrLuaMethod() void CtrlrLuaMethod::remove() // this is called by the manager to remove us permanently, cleanup and stuff { - setValid (false); + setType (DISABLED); if (luaObject && luaObject->getObject()) { @@ -105,7 +105,9 @@ void CtrlrLuaMethod::valueTreePropertyChanged (ValueTree &treeWhosePropertyHasCh { if (property == Ids::luaMethodValid) { - methodIsValid = (bool)treeWhosePropertyHasChanged.getProperty(property); + if (!(bool)treeWhosePropertyHasChanged.getProperty(property)) { + setType(DISABLED); + } } else if (property == Ids::luaMethodName) { @@ -150,7 +152,7 @@ const String CtrlrLuaMethod::getCode() } } -bool CtrlrLuaMethod::setCodeInternal(const String &newMethodCode) +CtrlrLuaMethod::Type CtrlrLuaMethod::setCodeInternal(const String &newMethodCode) { errorString.clear(); errorString.append ("Compile: "+getName()+" - ", out, Colours::black); @@ -158,54 +160,56 @@ bool CtrlrLuaMethod::setCodeInternal(const String &newMethodCode) if (owner.isLuaDisabled()) { errorString.append("FAILED lua is disabled\n", out.withStyle(Font::bold), Colours::darkred); - return (false); + return (DISABLED); } - bool compileRet = owner.getOwner().runCode(newMethodCode, getName()); + Type compileRet = owner.getOwner().runCode(newMethodCode, getName()); String error; - if (compileRet && getName() != "") - { - try - { - setObject ( (luabind::object)luabind::globals (getLuaState()) [(const char *)getName().toUTF8()] ); - } - catch (const luabind::error &e) - { - error = String(e.what()); - } - } - else if (compileRet == false) - { + switch (compileRet) { + case ERROR: error = owner.getOwner().getLastError(); - } - - if (compileRet) - { - errorString.append ("OK\n", out.withStyle(Font::bold), Colours::black); - } - else - { errorString.append ("FAILED\n", out.withStyle(Font::bold), Colours::darkred); errorString.append (error + "\n" , out, Colours::darkred); + break; + default: + if (getName() != "") + { + try + { + setObject ( (luabind::object)luabind::globals (getLuaState()) [(const char *)getName().toUTF8()] ); + } + catch (const luabind::error &e) + { + error = String(e.what()); + } + errorString.append ("OK\n", out.withStyle(Font::bold), Colours::black); + } } - - setValid(compileRet); + setType(compileRet); return (compileRet); } +void CtrlrLuaMethod::setType(Type t) { + type = t; + methodTree.setProperty (Ids::luaMethodValid, + isValid(), + nullptr); +} +#if 0 void CtrlrLuaMethod::setValid (const bool _methodIsValid) { methodIsValid = _methodIsValid; methodTree.setProperty (Ids::luaMethodValid, methodIsValid, nullptr); } -bool CtrlrLuaMethod::isValid () const +Bool CtrlrLuaMethod::isValid () const { return (methodIsValid); } +#endif void CtrlrLuaMethod::setCodeEditor (CtrlrLuaMethodCodeEditor *_methodCodeEditor) { diff --git a/Source/Lua/Methods/CtrlrLuaMethod.h b/Source/Lua/Methods/CtrlrLuaMethod.h index 257193c72..33756e149 100644 --- a/Source/Lua/Methods/CtrlrLuaMethod.h +++ b/Source/Lua/Methods/CtrlrLuaMethod.h @@ -33,14 +33,37 @@ class CtrlrLuaMethod : public ValueTree::Listener codeInFile }; + enum Type + { + NONE = LUA_TNONE, + NIL = LUA_TNIL, + BOOLEAN = LUA_TBOOLEAN, + LIGHTUSERDATA = LUA_TLIGHTUSERDATA, + NUMBER = LUA_TNUMBER, + STRING = LUA_TSTRING, + TABLE = LUA_TTABLE, + FUNCTION = LUA_TFUNCTION, + USERDATA = LUA_TUSERDATA, + THREAD = LUA_TTHREAD, + NUMTAGS = LUA_NUMTAGS, + SCRIPT = LUA_NUMTAGS, + ERROR, + UNKNOWN, + DISABLED + }; + + void setCodeEditor (CtrlrLuaMethodCodeEditor *_methodCodeEditor); CtrlrLuaMethodCodeEditor *getCodeEditor(); void setObject (CtrlrLuaObjectWrapper _luaObject); const String getName() const; CtrlrLuaObjectWrapper &getObject(); + Type getType() const { return type ; } + void setType(Type t); bool isValid() const; - void setValid (const bool _methodIsValid); + // void setValid (const bool _methodIsValid); + bool isCallable() const; void remove(); ValueTree &getMethodTree() { return (methodTree); } Uuid getUuid(); @@ -64,11 +87,11 @@ class CtrlrLuaMethod : public ValueTree::Listener private: Font out; - bool setCodeInternal (const String &newMethodCode); + Type setCodeInternal (const String &newMethodCode); WeakReference::Master masterReference; friend class WeakReference; CtrlrLuaObjectWrapper *luaObject; - bool methodIsValid; + Type type; ValueTree methodTree; String methodName; CtrlrLuaMethodManager &owner; @@ -77,4 +100,49 @@ class CtrlrLuaMethod : public ValueTree::Listener bool audioThreadMethod; }; +inline bool CtrlrLuaMethod::isValid() const { + switch (getType()) { + case BOOLEAN: + case LIGHTUSERDATA: + case NUMBER: + case STRING: + case TABLE: + case FUNCTION: + case USERDATA: + case THREAD: + case SCRIPT: + return true; + case NONE: + case NIL: + case ERROR: + case UNKNOWN: + case DISABLED: + default: + return false; + } +} + +inline bool CtrlrLuaMethod::isCallable() const { + switch (getType()) { + case FUNCTION: + return true; + case NONE: + case NIL: + case BOOLEAN: + case LIGHTUSERDATA: + case USERDATA: + case THREAD: + case SCRIPT: + case NUMBER: + case STRING: + case TABLE: + case ERROR: + case UNKNOWN: + case DISABLED: + default: + return false; + } +} + + #endif diff --git a/Source/Lua/Methods/CtrlrLuaMethodManagerCalls.cpp b/Source/Lua/Methods/CtrlrLuaMethodManagerCalls.cpp index f2d2e1ce5..9c8623f15 100644 --- a/Source/Lua/Methods/CtrlrLuaMethodManagerCalls.cpp +++ b/Source/Lua/Methods/CtrlrLuaMethodManagerCalls.cpp @@ -16,7 +16,7 @@ #define CATCH_METHOD_EXCEPTION \ catch (luabind::error &e)\ {\ - o->setValid(false);\ + o->setType(CtrlrLuaMethod::ERROR); \ const char* a = lua_tostring(e.state(), -1);\ lastExecutionError = String(a);\ AlertWindow::showMessageBox (AlertWindow::WarningIcon,\ @@ -32,7 +32,7 @@ catch (luabind::error &e)\ #define CATCH_METHOD_EXCEPTION_STR \ catch (luabind::error &e)\ {\ - o->setValid(false);\ + o->setType(CtrlrLuaMethod::ERROR);\ const char* a = lua_tostring(e.state(), -1);\ lastExecutionError = String(a);\ AlertWindow::showMessageBox (AlertWindow::WarningIcon, "Callback error: " + o->getName(), String(luabind::object_cast (luabind::object(luabind::from_stack(e.state(), -1)))) + "\n\nMethod disabled");\ @@ -45,7 +45,7 @@ catch (luabind::error &e)\ #define CATCH_METHOD_EXCEPTION_DAD \ catch (luabind::error &e)\ {\ - o->setValid(false);\ + o->setType(CtrlrLuaMethod::ERROR);\ const char* a = lua_tostring(e.state(), -1);\ lastExecutionError = String(a);\ AlertWindow::showMessageBox (AlertWindow::WarningIcon, "Callback error: " + o->getName(), String(luabind::object_cast (luabind::object(luabind::from_stack(e.state(), -1)))) + "\n\nMethod disabled");\ @@ -57,7 +57,7 @@ catch (luabind::error &e)\ #define CATCH_METHOD_EXCEPTION_NO_DIALOG \ catch (luabind::error &e)\ {\ - o->setValid(false);\ + o->setType(CtrlrLuaMethod::ERROR); \ lastExecutionError = String(luabind::object_cast (luabind::object(luabind::from_stack(e.state(), -1))));\ _LERR("Callback error: [" + o->getName() + "]\n" + lastExecutionError.fromLastOccurrenceOf("Error message:\n",false,false) + ".\nMethod disabled");\ if (currentMethodEditor)\ @@ -78,7 +78,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o) try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject()); } CATCH_METHOD_EXCEPTION @@ -97,7 +97,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrModulator *param1 try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2); } @@ -118,7 +118,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrModulator *param1 try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2, param3); } @@ -139,7 +139,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrModulator *param1 try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2.toUTF8().getAddress()); } @@ -160,7 +160,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrComponent *param1 try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2.toUTF8().getAddress()); } @@ -182,7 +182,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrComponent *param1 try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2); } @@ -203,7 +203,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const MidiMessage &par try { - if (o->isValid()) + if (o->isCallable()) { CtrlrMidiMessage mm(param1); const luabind::object &obj = o->getObject().getLuabindObject(); @@ -231,7 +231,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const CtrlrMidiMessage try { - if (o->isValid()) + if (o->isCallable()) { const luabind::object &obj = o->getObject().getLuabindObject(); if (obj.is_valid()) @@ -256,7 +256,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1); } CATCH_METHOD_EXCEPTION @@ -275,7 +275,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, boost::ref(param2)); } CATCH_METHOD_EXCEPTION_NO_DIALOG @@ -294,7 +294,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrPanelCanvas *para try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, boost::reference_wrapper(param2)); } @@ -315,7 +315,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrPanel *param1) try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1); } CATCH_METHOD_EXCEPTION_NO_DIALOG @@ -334,7 +334,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, boost::ref(param2)); } CATCH_METHOD_EXCEPTION @@ -353,7 +353,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, boost::ref(param2), param3, param4); } CATCH_METHOD_EXCEPTION @@ -372,7 +372,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const int param1, cons try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, param2, param3); } CATCH_METHOD_EXCEPTION @@ -391,7 +391,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const int param1, cons try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, param2); } CATCH_METHOD_EXCEPTION @@ -410,7 +410,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const int param1, cons try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, param2, param3, param4); } CATCH_METHOD_EXCEPTION @@ -429,7 +429,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const int param1, cons try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, param2); } CATCH_METHOD_EXCEPTION @@ -448,7 +448,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrModulator *param1 try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1, param2); } CATCH_METHOD_EXCEPTION @@ -467,7 +467,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrWaveform *param1) try { - if (o->isValid()) + if (o->isCallable()) luabind::call_function(o->getObject().getObject(), param1); } CATCH_METHOD_EXCEPTION @@ -488,7 +488,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const ValueTree ¶m try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2); } @@ -509,7 +509,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const String ¶m1, try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2); } @@ -531,7 +531,7 @@ int CtrlrLuaMethodManager::callWithRet(CtrlrLuaMethod *o, CtrlrModulator *param1 try { - if (o->isValid()) + if (o->isCallable()) { return (luabind::call_function(o->getObject().getObject(), param1, param2)); } @@ -552,7 +552,7 @@ int CtrlrLuaMethodManager::callWithRet(CtrlrLuaMethod *o, CtrlrModulator *param1 try { - if (o->isValid()) + if (o->isCallable()) { return (luabind::call_function(o->getObject().getObject(), param1, param2, param3)); } @@ -573,7 +573,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const StringArray &par try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2, param3); } @@ -595,7 +595,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const StringArray &par try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1); } @@ -617,7 +617,7 @@ int CtrlrLuaMethodManager::callWithRet(CtrlrLuaMethod *o, ValueTree valueTree1, try { - if (o->isValid()) + if (o->isCallable()) { return (luabind::call_function(o->getObject().getObject(), valueTree1, valueTree2)); } @@ -638,7 +638,7 @@ String CtrlrLuaMethodManager::callWithRetString(CtrlrLuaMethod *o, CtrlrCustomCo try { - if (o->isValid()) + if (o->isCallable()) { return (luabind::call_function(o->getObject().getObject(), param1)); } @@ -659,7 +659,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2, param3); } @@ -681,7 +681,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2, param3); } @@ -703,7 +703,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2, param3); } @@ -725,7 +725,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2); } @@ -747,7 +747,7 @@ int CtrlrLuaMethodManager::callWithRet(CtrlrLuaMethod *o, CtrlrCustomComponent * try { - if (o->isValid()) + if (o->isCallable()) { return (luabind::call_function(o->getObject().getObject(), param1, param2)); } @@ -768,7 +768,7 @@ DragAndDropSourceDetails CtrlrLuaMethodManager::callWithRet (CtrlrLuaMethod *o, try { - if (o->isValid()) + if (o->isCallable()) { return (luabind::call_function(o->getObject().getObject(), param1, param2)); } @@ -789,7 +789,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, LMemoryBlock *param1) try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1); } @@ -811,7 +811,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, ValueTree ¶m1) try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1); } @@ -833,7 +833,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, MidiBuffer *param1) try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1); } @@ -855,7 +855,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const ValueTree ¶m try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1); } @@ -877,7 +877,7 @@ const bool CtrlrLuaMethodManager::callAudio(CtrlrLuaMethod *o, MidiBuffer ¶m try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2); } @@ -899,7 +899,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const String ¶m1, try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1, param2, param3); } @@ -921,7 +921,7 @@ const bool CtrlrLuaMethodManager::call(CtrlrLuaMethod *o, const uint8 param1) try { - if (o->isValid()) + if (o->isCallable()) { luabind::call_function(o->getObject().getObject(), param1); } diff --git a/Source/Resources/XML/CtrlrLuaMethodTemplates.xml b/Source/Resources/XML/CtrlrLuaMethodTemplates.xml index 86ea8fb67..d655d16eb 100644 --- a/Source/Resources/XML/CtrlrLuaMethodTemplates.xml +++ b/Source/Resources/XML/CtrlrLuaMethodTemplates.xml @@ -702,8 +702,8 @@ function how() end - - + + diff --git a/Source/UIComponents/CtrlrComponents/CtrlrComponent.cpp b/Source/UIComponents/CtrlrComponents/CtrlrComponent.cpp index 47ac0de48..f64395ff2 100644 --- a/Source/UIComponents/CtrlrComponents/CtrlrComponent.cpp +++ b/Source/UIComponents/CtrlrComponents/CtrlrComponent.cpp @@ -177,7 +177,7 @@ void CtrlrComponent::mouseDoubleClick(const MouseEvent &e) { if (mouseDoubleClickCbk && !mouseDoubleClickCbk.wasObjectDeleted()) { - if (mouseDoubleClickCbk->isValid()) + if (mouseDoubleClickCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseDoubleClickCbk, this, e); } @@ -188,7 +188,7 @@ void CtrlrComponent::mouseDown(const MouseEvent &e) { if (mouseDownCbk && !mouseDownCbk.wasObjectDeleted()) { - if (mouseDownCbk->isValid()) + if (mouseDownCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseDownCbk, this, e); } @@ -216,7 +216,7 @@ void CtrlrComponent::mouseMove (const MouseEvent &e) { if (mouseMoveCbk && !mouseMoveCbk.wasObjectDeleted()) { - if (mouseMoveCbk->isValid()) + if (mouseMoveCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseMoveCbk, this, e); } @@ -227,7 +227,7 @@ void CtrlrComponent::mouseDrag (const MouseEvent &e) { if (mouseDragCbk && !mouseDragCbk.wasObjectDeleted()) { - if (mouseDragCbk->isValid()) + if (mouseDragCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseDragCbk, this, e); } diff --git a/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp b/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp index 66a47ef45..89530a070 100644 --- a/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp +++ b/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp @@ -46,7 +46,7 @@ void CtrlrCustomComponent::paint (Graphics &g) { if (paintCbk && !paintCbk.wasObjectDeleted()) { - if (paintCbk->isValid()) + if (paintCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (paintCbk, this, g); } @@ -57,7 +57,7 @@ bool CtrlrCustomComponent::keyPressed (const KeyPress &key, Component *originati { if (keyPressedCbk.get()) { - if (keyPressedCbk->isValid()) + if (keyPressedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (keyPressedCbk, this, key, originatingComponent); } @@ -69,7 +69,7 @@ bool CtrlrCustomComponent::keyStateChanged (bool isKeyDown, Component *originati { if (keyStateChangedCbk && !keyStateChangedCbk.wasObjectDeleted()) { - if (keyStateChangedCbk->isValid()) + if (keyStateChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (keyStateChangedCbk, this, isKeyDown, originatingComponent); } @@ -81,7 +81,7 @@ void CtrlrCustomComponent::paintOverChildren(Graphics &g) { if (paintOverChildrenCbk && !paintOverChildrenCbk.wasObjectDeleted()) { - if (paintOverChildrenCbk->isValid()) + if (paintOverChildrenCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (paintOverChildrenCbk, this, g); } @@ -92,7 +92,7 @@ void CtrlrCustomComponent::resized() { if (resizedCbk && !resizedCbk.wasObjectDeleted()) { - if (resizedCbk->isValid()) + if (resizedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (resizedCbk, this); } @@ -104,7 +104,7 @@ void CtrlrCustomComponent::mouseMove (const MouseEvent &e) { if (mouseMoveCbk && !mouseMoveCbk.wasObjectDeleted()) { - if (mouseMoveCbk->isValid()) + if (mouseMoveCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseMoveCbk, this, e); } @@ -115,7 +115,7 @@ void CtrlrCustomComponent::mouseDown (const MouseEvent &e) { if (mouseDownCbk && !mouseDownCbk.wasObjectDeleted()) { - if (mouseDownCbk->isValid()) + if (mouseDownCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseDownCbk, this, e); } @@ -126,7 +126,7 @@ void CtrlrCustomComponent::mouseUp (const MouseEvent &e) { if (mouseUpCbk && !mouseUpCbk.wasObjectDeleted()) { - if (mouseUpCbk->isValid()) + if (mouseUpCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseUpCbk, this, e); } @@ -140,7 +140,7 @@ void CtrlrCustomComponent::mouseDrag (const MouseEvent &e) { if (dadStartCbk && !dadStartCbk.wasObjectDeleted()) { - if (dadStartCbk->isValid()) + if (dadStartCbk->isCallable()) { DragAndDropContainer* const dragContainer = DragAndDropContainer::findParentDragContainerFor (this); if (dragContainer) @@ -155,7 +155,7 @@ void CtrlrCustomComponent::mouseDrag (const MouseEvent &e) if (mouseDragCbk && !mouseDragCbk.wasObjectDeleted()) { - if (mouseDragCbk->isValid()) + if (mouseDragCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseDragCbk, this, e); } @@ -167,7 +167,7 @@ void CtrlrCustomComponent::mouseEnter (const MouseEvent &e) _DBG("CtrlrCustomComponent::mouseEnter"); if (mouseEnterCbk && !mouseEnterCbk.wasObjectDeleted()) { - if (mouseEnterCbk->isValid()) + if (mouseEnterCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseEnterCbk, this, e); } @@ -178,7 +178,7 @@ void CtrlrCustomComponent::mouseExit (const MouseEvent &e) { if (mouseExitCbk && !mouseExitCbk.wasObjectDeleted()) { - if (mouseExitCbk->isValid()) + if (mouseExitCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseExitCbk, this, e); } @@ -194,7 +194,7 @@ const String CtrlrCustomComponent::getComponentText() { if (getTextCbk && !getTextCbk.wasObjectDeleted()) { - if (getTextCbk->isValid()) + if (getTextCbk->isCallable()) { return (owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRetString (getTextCbk, this)); } @@ -207,7 +207,7 @@ void CtrlrCustomComponent::setComponentText (const String &componentText) { if (setTextCbk && !setTextCbk.wasObjectDeleted()) { - if (setTextCbk->isValid()) + if (setTextCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (setTextCbk, this, componentText); } @@ -218,7 +218,7 @@ void CtrlrCustomComponent::setComponentValue (const double newValue, const bool { if (setValueCbk && !setValueCbk.wasObjectDeleted()) { - if (setValueCbk->isValid()) + if (setValueCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (setValueCbk, this, newValue, sendChangeMessage); } @@ -229,7 +229,7 @@ double CtrlrCustomComponent::getComponentValue() { if (getValueCbk && !getValueCbk.wasObjectDeleted()) { - if (getValueCbk->isValid()) + if (getValueCbk->isCallable()) { return (owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (getValueCbk, this)); } @@ -436,7 +436,7 @@ void CtrlrCustomComponent::mouseDoubleClick (const MouseEvent &e) { if (mouseDoubleClickCbk && !mouseDoubleClickCbk.wasObjectDeleted()) { - if (mouseDoubleClickCbk->isValid()) + if (mouseDoubleClickCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseDoubleClickCbk, this, e); } @@ -447,7 +447,7 @@ void CtrlrCustomComponent::mouseWheelMove (const MouseEvent &e, const MouseWheel { if (mouseWheelMoveCbk && !mouseWheelMoveCbk.wasObjectDeleted()) { - if (mouseWheelMoveCbk->isValid()) + if (mouseWheelMoveCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (mouseWheelMoveCbk, this, e, wheel.deltaX, wheel.deltaY); } @@ -458,7 +458,7 @@ bool CtrlrCustomComponent::isInterestedInDragSource (const SourceDetails& dragSo { if (dadIsInterestedCbk && !dadIsInterestedCbk.wasObjectDeleted()) { - if (dadIsInterestedCbk->isValid()) + if (dadIsInterestedCbk->isCallable()) { return (owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRet (dadIsInterestedCbk, this, DragAndDropSourceDetails (dragSourceDetails)) ? true : false); } @@ -470,7 +470,7 @@ void CtrlrCustomComponent::itemDragEnter (const SourceDetails &dragSourceDetails { if (dadEnterCbk && !dadEnterCbk.wasObjectDeleted()) { - if (dadEnterCbk->isValid()) + if (dadEnterCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (dadEnterCbk, this, DragAndDropSourceDetails (dragSourceDetails)); } @@ -482,7 +482,7 @@ void CtrlrCustomComponent::itemDragMove (const SourceDetails &dragSourceDetails) _DBG("CtrlrCustomComponent::itemDragMove"); if (dadMoveCbk && !dadMoveCbk.wasObjectDeleted()) { - if (dadMoveCbk->isValid()) + if (dadMoveCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (dadMoveCbk, this, DragAndDropSourceDetails (dragSourceDetails)); } @@ -493,7 +493,7 @@ void CtrlrCustomComponent::itemDragExit (const SourceDetails &dragSourceDetails) { if (dadExitCbk && !dadExitCbk.wasObjectDeleted()) { - if (dadExitCbk->isValid()) + if (dadExitCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (dadExitCbk, this, DragAndDropSourceDetails (dragSourceDetails)); } @@ -504,7 +504,7 @@ void CtrlrCustomComponent::itemDropped (const SourceDetails& dragSourceDetails) { if (dadDroppedCbk && !dadDroppedCbk.wasObjectDeleted()) { - if (dadDroppedCbk->isValid()) + if (dadDroppedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (dadDroppedCbk, this, DragAndDropSourceDetails (dragSourceDetails)); } diff --git a/Source/UIComponents/CtrlrComponents/Groups/CtrlrTabsComponent.cpp b/Source/UIComponents/CtrlrComponents/Groups/CtrlrTabsComponent.cpp index efafe0cce..9893e3d62 100644 --- a/Source/UIComponents/CtrlrComponents/Groups/CtrlrTabsComponent.cpp +++ b/Source/UIComponents/CtrlrComponents/Groups/CtrlrTabsComponent.cpp @@ -322,7 +322,7 @@ void CtrlrTabsComponent::valueTreePropertyChanged (ValueTree &treeWhosePropertyH if (tabChangedCbk && !tabChangedCbk.wasObjectDeleted()) { - if (tabChangedCbk->isValid()) + if (tabChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (tabChangedCbk, &owner, (int)getProperty(property)); } diff --git a/Source/UIComponents/CtrlrComponents/Labels/CtrlrLCDLabel.cpp b/Source/UIComponents/CtrlrComponents/Labels/CtrlrLCDLabel.cpp index 87d637c34..045ede912 100644 --- a/Source/UIComponents/CtrlrComponents/Labels/CtrlrLCDLabel.cpp +++ b/Source/UIComponents/CtrlrComponents/Labels/CtrlrLCDLabel.cpp @@ -225,7 +225,7 @@ void CtrlrLCDLabel::labelTextChanged (Label* labelThatHasChanged) if (labelChangedCbk && !labelChangedCbk.wasObjectDeleted()) { - if (labelChangedCbk->isValid()) + if (labelChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (labelChangedCbk, dynamic_cast(this), labelThatHasChanged->getText()); } diff --git a/Source/UIComponents/CtrlrComponents/Labels/CtrlrLabel.cpp b/Source/UIComponents/CtrlrComponents/Labels/CtrlrLabel.cpp index d45d5af81..7438a09d5 100644 --- a/Source/UIComponents/CtrlrComponents/Labels/CtrlrLabel.cpp +++ b/Source/UIComponents/CtrlrComponents/Labels/CtrlrLabel.cpp @@ -263,7 +263,7 @@ void CtrlrLabel::labelTextChanged (Label* labelThatHasChanged) if (labelChangedCbk && !labelChangedCbk.wasObjectDeleted()) { - if (labelChangedCbk->isValid()) + if (labelChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (labelChangedCbk, dynamic_cast(this), labelThatHasChanged->getText()); } diff --git a/Source/UIComponents/CtrlrComponents/Specials/CtrlrFileListBox.cpp b/Source/UIComponents/CtrlrComponents/Specials/CtrlrFileListBox.cpp index 4f8112694..6cdc706b0 100644 --- a/Source/UIComponents/CtrlrComponents/Specials/CtrlrFileListBox.cpp +++ b/Source/UIComponents/CtrlrComponents/Specials/CtrlrFileListBox.cpp @@ -324,7 +324,7 @@ void CtrlrFileListBox::fileClicked (const File &file, const MouseEvent &e) { if (fileClickedCbk && !fileClickedCbk.wasObjectDeleted()) { - if (fileClickedCbk->isValid()) + if (fileClickedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (fileClickedCbk, &owner, file); } @@ -335,7 +335,7 @@ void CtrlrFileListBox::fileDoubleClicked (const File &file) { if (fileDoubleClickedCbk && !fileDoubleClickedCbk.wasObjectDeleted()) { - if (fileDoubleClickedCbk->isValid()) + if (fileDoubleClickedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (fileDoubleClickedCbk, &owner, file); } @@ -347,7 +347,7 @@ void CtrlrFileListBox::deleteKeyPressed (const int value) { if (itemDeleteKeyPressedCbk && !itemDeleteKeyPressedCbk.wasObjectDeleted()) { - if (itemDeleteKeyPressedCbk->isValid()) + if (itemDeleteKeyPressedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (itemDeleteKeyPressedCbk, &owner, value); } @@ -358,7 +358,7 @@ void CtrlrFileListBox::returnKeyPressed (const int value) { if (itemReturnKeyPressedCbk && !itemReturnKeyPressedCbk.wasObjectDeleted()) { - if (itemReturnKeyPressedCbk->isValid()) + if (itemReturnKeyPressedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (itemReturnKeyPressedCbk, &owner, value); } diff --git a/Source/UIComponents/CtrlrComponents/Specials/CtrlrListBox.cpp b/Source/UIComponents/CtrlrComponents/Specials/CtrlrListBox.cpp index 3b24340c9..78c184a29 100644 --- a/Source/UIComponents/CtrlrComponents/Specials/CtrlrListBox.cpp +++ b/Source/UIComponents/CtrlrComponents/Specials/CtrlrListBox.cpp @@ -226,7 +226,7 @@ void CtrlrListBox::listBoxItemClicked (int value, const MouseEvent &e) { if (itemClickedCbk && !itemClickedCbk.wasObjectDeleted()) { - if (itemClickedCbk->isValid()) + if (itemClickedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (itemClickedCbk, &owner, value); } @@ -237,7 +237,7 @@ void CtrlrListBox::listBoxItemDoubleClicked (int value, const MouseEvent &e) { if (itemDoubleClickedCbk && !itemDoubleClickedCbk.wasObjectDeleted()) { - if (itemDoubleClickedCbk->isValid()) + if (itemDoubleClickedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (itemDoubleClickedCbk, &owner, value); } @@ -248,7 +248,7 @@ void CtrlrListBox::deleteKeyPressed (int value) { if (itemDeleteKeyPressedCbk && !itemDeleteKeyPressedCbk.wasObjectDeleted()) { - if (itemDeleteKeyPressedCbk->isValid()) + if (itemDeleteKeyPressedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (itemDeleteKeyPressedCbk, &owner, value); } @@ -259,7 +259,7 @@ void CtrlrListBox::returnKeyPressed (int value) { if (itemReturnKeyPressedCbk && !itemReturnKeyPressedCbk.wasObjectDeleted()) { - if (itemReturnKeyPressedCbk->isValid()) + if (itemReturnKeyPressedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (itemReturnKeyPressedCbk, &owner, value); } diff --git a/Source/UIComponents/CtrlrComponents/Specials/CtrlrWaveform.cpp b/Source/UIComponents/CtrlrComponents/Specials/CtrlrWaveform.cpp index ef29a0c41..dd48faca6 100644 --- a/Source/UIComponents/CtrlrComponents/Specials/CtrlrWaveform.cpp +++ b/Source/UIComponents/CtrlrComponents/Specials/CtrlrWaveform.cpp @@ -247,7 +247,7 @@ void CtrlrWaveform::changeListenerCallback (ChangeBroadcaster* source) { if (thumbnailChangedCbk && !thumbnailChangedCbk.wasObjectDeleted()) { - if (thumbnailChangedCbk->isValid()) + if (thumbnailChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (thumbnailChangedCbk, this); } @@ -307,7 +307,7 @@ void CtrlrWaveform::reset (int numChannels, double sampleRate, double totalSampl if (sourceChangedCbk && !sourceChangedCbk.wasObjectDeleted()) { - if (sourceChangedCbk->isValid()) + if (sourceChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (sourceChangedCbk, this); } @@ -322,7 +322,7 @@ const bool CtrlrWaveform::loadFromFile (const File &fileToLoadFrom) if (sourceChangedCbk && !sourceChangedCbk.wasObjectDeleted()) { - if (sourceChangedCbk->isValid()) + if (sourceChangedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (sourceChangedCbk, this); } @@ -431,7 +431,7 @@ void CtrlrWaveform::filesDropped (const StringArray &files, int x, int y) { if (fileDroppedCbk && !fileDroppedCbk.wasObjectDeleted()) { - if (fileDroppedCbk->isValid()) + if (fileDroppedCbk->isCallable()) { owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().call (fileDroppedCbk, files, x, y); } diff --git a/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp b/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp index 87cfb83c2..f62ae4dcb 100644 --- a/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp +++ b/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp @@ -54,7 +54,7 @@ void CtrlrPanelCanvas::paint (Graphics& g) { if (paintCbk && !paintCbk.wasObjectDeleted()) { - if (paintCbk->isValid()) + if (paintCbk->isCallable()) { owner.getOwner().getCtrlrLuaManager().getMethodManager().call (paintCbk, this, g); @@ -130,7 +130,7 @@ void CtrlrPanelCanvas::resized() if (resizedCbk && !resizedCbk.wasObjectDeleted()) { - if (resizedCbk->isValid()) + if (resizedCbk->isCallable()) { owner.getOwner().getCtrlrLuaManager().getMethodManager().call (resizedCbk, &owner.getOwner()); } @@ -1030,7 +1030,7 @@ void CtrlrPanelCanvas::fileDragEnter (const StringArray &files, int x, int y) { if (luaPanelFileDragEnterHandlerCbk && !luaPanelFileDragEnterHandlerCbk.wasObjectDeleted()) { - if (luaPanelFileDragEnterHandlerCbk->isValid()) + if (luaPanelFileDragEnterHandlerCbk->isCallable()) { owner.getOwner().getCtrlrLuaManager().getMethodManager().call (luaPanelFileDragEnterHandlerCbk, files, x, y); @@ -1043,7 +1043,7 @@ void CtrlrPanelCanvas::fileDragExit (const StringArray &files) { if (luaPanelFileDragExitHandlerCbk && !luaPanelFileDragExitHandlerCbk.wasObjectDeleted()) { - if (luaPanelFileDragExitHandlerCbk->isValid()) + if (luaPanelFileDragExitHandlerCbk->isCallable()) { owner.getOwner().getCtrlrLuaManager().getMethodManager().call (luaPanelFileDragExitHandlerCbk, files); @@ -1080,7 +1080,7 @@ void CtrlrPanelCanvas::filesDropped (const StringArray &files, int x, int y) if (luaPanelFileDragDropHandlerCbk && !luaPanelFileDragDropHandlerCbk.wasObjectDeleted()) { - if (luaPanelFileDragDropHandlerCbk->isValid()) + if (luaPanelFileDragDropHandlerCbk->isCallable()) { owner.getOwner().getCtrlrLuaManager().getMethodManager().call (luaPanelFileDragDropHandlerCbk, files, x, y); From 354b38a126a4c0256e64dd875abd1672627ff4f2 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 19 Jun 2021 22:24:54 +0200 Subject: [PATCH 07/19] Allow UTF-8 characters in lua defiened JUCE Strings. --- Source/Core/stdafx_luabind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/stdafx_luabind.h b/Source/Core/stdafx_luabind.h index 77599826a..5d88b75d0 100644 --- a/Source/Core/stdafx_luabind.h +++ b/Source/Core/stdafx_luabind.h @@ -159,7 +159,7 @@ namespace luabind String* wp = object_cast(obj); return String(*wp); } - return String(lua_tostring(L, index)); + return String(CharPointer_UTF8 (lua_tostring(L, index))); } void to(lua_State* L, String const &value) From 09a53705fbb890b79b10784fb0144fbe0eeb6c6c Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 19 Jun 2021 22:27:28 +0200 Subject: [PATCH 08/19] Output the panel path name on the console. This helps to find out to which panel an error message belongs to. Especially on startup, when many panels are loaded at once. --- Source/Core/CtrlrPanel/CtrlrPanel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/CtrlrPanel/CtrlrPanel.cpp b/Source/Core/CtrlrPanel/CtrlrPanel.cpp index 934210a2a..dc1fc9edd 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanel.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanel.cpp @@ -230,6 +230,7 @@ Result CtrlrPanel::restoreState (const ValueTree &savedState) File panelFile = userDocsDir.getNonexistentChildFile("CtrlrPanel", ".panel"); filePath = panelFile.getFullPathName(); } + _DBG(filePath); panelTree.setProperty(Ids::panelFilePath, filePath, nullptr); ctrlrLuaManager->restoreState(savedState.getChildWithName(Ids::luaManager)); From abbcc0a21ee1c8ac6919156755525e1a991f2cba Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Fri, 25 Jun 2021 20:48:21 +0200 Subject: [PATCH 09/19] Fix assertion during Drag and Drop --- .../CtrlrComponents/CtrlrCustomComponent.cpp | 7 ++++++- .../UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp | 15 +++++++++++---- Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.h | 4 +++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp b/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp index 89530a070..7efc5c4e9 100644 --- a/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp +++ b/Source/UIComponents/CtrlrComponents/CtrlrCustomComponent.cpp @@ -147,7 +147,12 @@ void CtrlrCustomComponent::mouseDrag (const MouseEvent &e) { DragAndDropSourceDetails details = owner.getOwnerPanel().getCtrlrLuaManager().getMethodManager().callWithRet (dadStartCbk, this, e); Point offset(details.getImageOffsetX(), details.getImageOffsetY()); - dragContainer->startDragging (details.getDescription(), this, details.getDragImage(), true, &offset); + dragContainer->startDragging (details.getDescription(), + this, + details.getDragImage(), + true, + &offset, + &e.source); } } } diff --git a/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp b/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp index f62ae4dcb..927240450 100644 --- a/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp +++ b/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.cpp @@ -217,7 +217,7 @@ void CtrlrPanelCanvas::mouseDown (const MouseEvent& e) { getOwner().getSelection()->selectOnly (c); getOwner().getSelection()->dispatchPendingMessages(); - startDraggingSelection(); + startDraggingSelection(e.source); } } } @@ -228,7 +228,7 @@ void CtrlrPanelCanvas::mouseDown (const MouseEvent& e) } if (!isLayer(e.eventComponent) && editMode && e.mods.isShiftDown()) { - startDraggingSelection(); + startDraggingSelection(e.source); } } @@ -503,6 +503,7 @@ int CtrlrPanelCanvas::snapPosition (int pos, int snapSize, const bool allowSnap) return pos; } +#if 0 void CtrlrPanelCanvas::moveSelectedComps (int dx, int dy, bool snap) { if ((bool)owner.getProperty (Ids::uiPanelLock)) @@ -512,6 +513,7 @@ void CtrlrPanelCanvas::moveSelectedComps (int dx, int dy, bool snap) dragSelectedComps (dx, dy, snap); endDraggingSelection(); } +#endif void CtrlrPanelCanvas::dragSelectedComps (int dx, int dy, const bool allowSnap) { @@ -562,7 +564,7 @@ void CtrlrPanelCanvas::endDraggingSelection() } } -void CtrlrPanelCanvas::startDraggingSelection() +void CtrlrPanelCanvas::startDraggingSelection(const MouseInputSource& inputSource) { if (getOwner().getSelection() == nullptr) return; @@ -574,7 +576,12 @@ void CtrlrPanelCanvas::startDraggingSelection() c->getProperties().set ("yDragStart", c->getY()); c->toBack(); } - startDragging ("__ctrlr_component_selection", this, Image (Image::ARGB,1,1,true)); + startDragging ("__ctrlr_component_selection", + this, + Image (Image::ARGB,1,1,true), + false, + nullptr, + &inputSource); if (getOwner().getSelection()->getNumSelected() > 1) getPanel().getUndoManager()->beginNewTransaction ("Move multiple"); diff --git a/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.h b/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.h index b191bd29d..8e62e1cda 100644 --- a/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.h +++ b/Source/UIComponents/CtrlrPanel/CtrlrPanelCanvas.h @@ -119,9 +119,11 @@ class CtrlrPanelCanvas : public CtrlrChildWindowContent, void copyWithChildren(CtrlrComponent *c); void deleteWithChildren(CtrlrComponent *c); int snapPosition (int pos, int snapSize, const bool allowSnap); +#if 0 void moveSelectedComps (int dx, int dy, bool snap); +#endif void dragSelectedComps (int dx, int dy, const bool allowSnap); - void startDraggingSelection(); + void startDraggingSelection(const MouseInputSource& inputSource); void endDraggingSelection(); void restoreState (const ValueTree &savedState); void canvasStateRestored(); From 8ace1348991e8a5884ebed656b9fcc18733e906a Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Fri, 25 Jun 2021 21:02:59 +0200 Subject: [PATCH 10/19] Whitespace fixes (mostly line endings) --- .../CtrlrPanel/CtrlrPanelMIDISnapshot.cpp | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp b/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp index 3e11648a1..1976c123d 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp @@ -3,26 +3,26 @@ #include "CtrlrLog.h" #include "CtrlrPanel/CtrlrPanel.h" #include "CtrlrPanelMIDISnapshot.h" -#include "CtrlrLuaManager.h" +#include "CtrlrLuaManager.h" CtrlrPanelMIDISnapshot::CtrlrPanelMIDISnapshot(CtrlrPanel &_owner) : owner(_owner), Thread("MIDI Snapshot"), - snapshotDelay(50), - showDialog(false), - alertWindow(nullptr), - wasCancelledByUser(false), - luaPanelMidiSnapshotPreCbk(nullptr), + snapshotDelay(50), + showDialog(false), + alertWindow(nullptr), + wasCancelledByUser(false), + luaPanelMidiSnapshotPreCbk(nullptr), luaPanelMidiSnapshotPostCbk(nullptr) { buffer.ensureSize(8192); } CtrlrPanelMIDISnapshot::~CtrlrPanelMIDISnapshot() -{ - if (alertWindow) - deleteAndZero (alertWindow); - +{ + if (alertWindow) + deleteAndZero (alertWindow); + stopThread (500); } @@ -34,13 +34,13 @@ void CtrlrPanelMIDISnapshot::sendSnapshot() void CtrlrPanelMIDISnapshot::handleAsyncUpdate() { gatherSnapshotData(); - startThread(); - + startThread(); + startTimer (100); - if (alertWindow) + if (alertWindow) { const ScopedLock sl (messageLock); - alertWindow->setMessage (message); + alertWindow->setMessage (message); alertWindow->enterModalState(); } } @@ -69,24 +69,24 @@ void CtrlrPanelMIDISnapshot::gatherSnapshotData() } } } - } - - showDialog = owner.getProperty(Ids::panelMidiSnapshotShowProgress); - - if (showDialog) - { - if (alertWindow == nullptr) - { + } + + showDialog = owner.getProperty(Ids::panelMidiSnapshotShowProgress); + + if (showDialog) + { + if (alertWindow == nullptr) + { alertWindow = LookAndFeel::getDefaultLookAndFeel().createAlertWindow ("MIDI Snapshot", String(), "Stop", String(), String(), AlertWindow::NoIcon, 1, nullptr); alertWindow->setEscapeKeyCancels (false); - alertWindow->addProgressBarComponent (progress); - } - } - else - { - alertWindow = nullptr; - } - + alertWindow->addProgressBarComponent (progress); + } + } + else + { + alertWindow = nullptr; + } + if (luaPanelMidiSnapshotPreCbk && !luaPanelMidiSnapshotPreCbk.wasObjectDeleted()) { if (luaPanelMidiSnapshotPreCbk->isCallable()) @@ -94,20 +94,20 @@ void CtrlrPanelMIDISnapshot::gatherSnapshotData() owner.getCtrlrLuaManager().getMethodManager().call (luaPanelMidiSnapshotPreCbk, &buffer); } } -} - +} + void CtrlrPanelMIDISnapshot::setStatusMessage (const String& newStatusMessage) { const ScopedLock sl (messageLock); message = newStatusMessage; -} +} void CtrlrPanelMIDISnapshot::run() { MidiBuffer::Iterator i(buffer); MidiMessage m; int t; int k=0; while (i.getNextEvent(m,t)) - { + { progress = k / (double) buffer.getNumEvents(); owner.sendMidi(m); k++; @@ -118,51 +118,51 @@ void CtrlrPanelMIDISnapshot::run() void CtrlrPanelMIDISnapshot::setDelay(const int _snapshotDelay) { snapshotDelay = _snapshotDelay; -} - -void CtrlrPanelMIDISnapshot::timerCallback() -{ +} + +void CtrlrPanelMIDISnapshot::timerCallback() +{ bool threadStillRunning = isThreadRunning(); if (! threadStillRunning) { stopTimer(); stopThread (500); - - if (alertWindow) - { + + if (alertWindow) + { if (alertWindow->isCurrentlyModal()) - alertWindow->exitModalState (1); + alertWindow->exitModalState (1); - alertWindow->setVisible (false); + alertWindow->setVisible (false); } - wasCancelledByUser = threadStillRunning; - + wasCancelledByUser = threadStillRunning; + if (luaPanelMidiSnapshotPostCbk && !luaPanelMidiSnapshotPostCbk.wasObjectDeleted()) { if (luaPanelMidiSnapshotPostCbk->isCallable()) { owner.getCtrlrLuaManager().getMethodManager().call (luaPanelMidiSnapshotPostCbk, &buffer); } - } + } return; // (this may be deleted now) } - - if (alertWindow) + + if (alertWindow) { const ScopedLock sl (messageLock); - alertWindow->setMessage (message); - } -} - -void CtrlrPanelMIDISnapshot::setPreLuaCallback(CtrlrLuaMethod *method) -{ - luaPanelMidiSnapshotPreCbk = method; -} - -void CtrlrPanelMIDISnapshot::setPostLuaCallback(CtrlrLuaMethod *method) -{ - luaPanelMidiSnapshotPostCbk = method; -} + alertWindow->setMessage (message); + } +} + +void CtrlrPanelMIDISnapshot::setPreLuaCallback(CtrlrLuaMethod *method) +{ + luaPanelMidiSnapshotPreCbk = method; +} + +void CtrlrPanelMIDISnapshot::setPostLuaCallback(CtrlrLuaMethod *method) +{ + luaPanelMidiSnapshotPostCbk = method; +} From 0e2f51b45d77c0b5839ed6c4bd2146a8b16cb195 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Fri, 25 Jun 2021 21:31:24 +0200 Subject: [PATCH 11/19] Fix deletion of the MIDI snapshot thread. A thread should be running either as detached thread or as joinable thread. JUCE blurres this nomenclature with their own words. In general creating and deleting a system thread is expensive. So it should be deleted when it is save (i.e. not in realtime functions). This patch solves several issues with the thread: - the thread should exit if it gets signalled by setting a special variable. This variable is handled by JUCE. - The main program should signal the thread to end its action. This is done by stopThread() by setting the status variable and waking up the thread. - When the thread ends before the main program allows it to end, it must wait indefinitely. Otherwise an undefined state with a race condition is created, which may cause additional trouble. --- Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp b/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp index 1976c123d..31e263ea1 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelMIDISnapshot.cpp @@ -106,13 +106,16 @@ void CtrlrPanelMIDISnapshot::run() { MidiBuffer::Iterator i(buffer); MidiMessage m; int t; int k=0; - while (i.getNextEvent(m,t)) + while (!threadShouldExit() && i.getNextEvent(m,t)) { progress = k / (double) buffer.getNumEvents(); owner.sendMidi(m); k++; wait(snapshotDelay); } + while (!threadShouldExit()) { + wait(-1); + } } void CtrlrPanelMIDISnapshot::setDelay(const int _snapshotDelay) @@ -127,7 +130,6 @@ void CtrlrPanelMIDISnapshot::timerCallback() if (! threadStillRunning) { stopTimer(); - stopThread (500); if (alertWindow) { From fc25af23240811c0799420bb3592fad8ef9e264e Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 17 Jul 2021 21:19:34 +0200 Subject: [PATCH 12/19] convert CtrlrLuaMethodEditor::menuItemSelected to swtich () {} --- .../MethodEditor/CtrlrLuaMethodEditor.cpp | 106 ++++++++---------- 1 file changed, 44 insertions(+), 62 deletions(-) diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp index 4aec9ea88..5de768679 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp @@ -1067,70 +1067,52 @@ PopupMenu CtrlrLuaMethodEditor::getMenuForIndex(int topLevelMenuIndex, const Str void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuIndex) { - if (menuItemID == 1 && topLevelMenuIndex == 0) - { - if (isCurrentlyModal()) - exitModalState(-1); - - if (canCloseWindow()) - { - owner.getWindowManager().toggle(CtrlrPanelWindowManager::LuaMethodEditor, false); - } - } - if (menuItemID == 2 && topLevelMenuIndex == 0) - { - if (getCurrentEditor()) - { - getCurrentEditor()->saveDocument(); - } - } - else if (menuItemID == 3 && topLevelMenuIndex == 0) - { - if (getCurrentEditor()) - { - getCurrentEditor()->saveAndCompileDocument(); + switch (topLevelMenuIndex) { + case 0: + switch (menuItemId) { + case 1: + if (isCurrentlyModal()) + exitModalState(-1); + + if (canCloseWindow()) { + owner.getWindowManager().toggle(CtrlrPanelWindowManager::LuaMethodEditor, false); + } + case 2: + if (getCurrentEditor()) + getCurrentEditor()->saveDocument(); + case 3: + if (getCurrentEditor()) + getCurrentEditor()->saveAndCompileDocument(); + case 4: + saveAndCompilAllMethods(); + case 5: + closeCurrentTab(); + case 6: + closeAllTabs(); + case 7: + convertToFiles(); + }; + case 1: + switch (menuItemId) { + case 4: + methodEditArea->showFindDialog(); + case 5: + methodEditArea->clearOutputText(); + case 6: + CtrlrLuaMethodCodeEditorSettings s(*this); + CtrlrDialogWindow::showModalDialog ("Code editor settings", &s, false, this); + + componentTree.setProperty (Ids::luaMethodEditorFont, + owner.getCtrlrManagerOwner().getFontManager().getStringFromFont (s.getFont()), + nullptr); + componentTree.setProperty (Ids::luaMethodEditorBgColour, + COLOUR2STR (s.getColour()), nullptr); + case 7: + methodEditArea->showDebuggerTab(); + case 8: + methodEditArea->showConsoleTab(); } } - else if (menuItemID == 4 && topLevelMenuIndex == 0) - { - saveAndCompilAllMethods(); - } - else if (menuItemID == 5 && topLevelMenuIndex == 0) - { - closeCurrentTab(); - } - else if (menuItemID == 6 && topLevelMenuIndex == 0) - { - closeAllTabs(); - } - else if (menuItemID == 7 && topLevelMenuIndex == 0) - { - convertToFiles(); - } - else if (menuItemID == 4 && topLevelMenuIndex == 1) - { - methodEditArea->showFindDialog(); - } - else if (menuItemID == 5 && topLevelMenuIndex == 1) - { - methodEditArea->clearOutputText(); - } - else if (menuItemID == 6 && topLevelMenuIndex == 1) - { - CtrlrLuaMethodCodeEditorSettings s(*this); - CtrlrDialogWindow::showModalDialog ("Code editor settings", &s, false, this); - - componentTree.setProperty (Ids::luaMethodEditorFont, owner.getCtrlrManagerOwner().getFontManager().getStringFromFont (s.getFont()), nullptr); - componentTree.setProperty (Ids::luaMethodEditorBgColour, COLOUR2STR (s.getColour()), nullptr); - } - else if (menuItemID == 7 && topLevelMenuIndex == 1) - { - methodEditArea->showDebuggerTab(); - } - else if (menuItemID == 8 && topLevelMenuIndex == 1) - { - methodEditArea->showConsoleTab(); - } } void CtrlrLuaMethodEditor::saveAndCompilAllMethods() From 2f33e73d99567d09bafd9fcf6a71a72eb7965a76 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 17 Jul 2021 21:24:50 +0200 Subject: [PATCH 13/19] Fix spelling of saveAndCompileAllMethods --- .../CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.cpp | 2 +- .../CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp | 6 +++--- .../CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.cpp index 6628c58f8..ca70a4f34 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.cpp @@ -154,7 +154,7 @@ bool CtrlrLuaMethodCodeEditor::keyPressed (const KeyPress &key, Component *origi if (key.getKeyCode() == KeyPress::F8Key) { - owner.saveAndCompilAllMethods(); + owner.saveAndCompileAllMethods(); return (true); } diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp index 5de768679..ca36e9935 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp @@ -503,7 +503,7 @@ bool CtrlrLuaMethodEditor::canCloseWindow() } else if (ret == 1) { // Save all - saveAndCompilAllMethods(); + saveAndCompileAllMethods(); return true; } else @@ -1084,7 +1084,7 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde if (getCurrentEditor()) getCurrentEditor()->saveAndCompileDocument(); case 4: - saveAndCompilAllMethods(); + saveAndCompileAllMethods(); case 5: closeCurrentTab(); case 6: @@ -1115,7 +1115,7 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde } } -void CtrlrLuaMethodEditor::saveAndCompilAllMethods() +void CtrlrLuaMethodEditor::saveAndCompileAllMethods() { for (int i=0; igetNumTabs(); i++) { diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h index 2d655d237..62165f933 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h @@ -108,7 +108,7 @@ class CtrlrLuaMethodEditor : public CtrlrChildWindowContent, PopupMenu getMenuForIndex(int topLevelMenuIndex, const String &menuName); void menuItemSelected(int menuItemID, int topLevelMenuIndex); void searchResultClicked (const String &methodName, const int lineNumber, const int resultPositionStart, const int resultPositionEnd); - void saveAndCompilAllMethods(); + void saveAndCompileAllMethods(); void convertToFiles(); /* Debugger stuff */ From 6059eed30f941a8019b660f41b52dfcaa16c6920 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Sat, 17 Jul 2021 21:55:02 +0200 Subject: [PATCH 14/19] Add missing breaks --- .../Core/CtrlrPanel/CtrlrPanelFileOperations.cpp | 4 ++-- .../MethodEditor/CtrlrLuaMethodEditor.cpp | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp b/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp index e82002821..2b321bc44 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp @@ -978,7 +978,7 @@ void CtrlrPanel::updatePanelWindowTitle() { editor->setName(newName); // Trigger editor window title update - auto editor = owner.getEditor(); + auto editor = owner.getEditor(); if (editor) editor->activeCtrlrChanged(); } } @@ -1039,4 +1039,4 @@ bool CtrlrPanel::canClose(const bool closePanel) } } return result; -} +} diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp index ca36e9935..0a4b94301 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp @@ -1069,7 +1069,7 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde { switch (topLevelMenuIndex) { case 0: - switch (menuItemId) { + switch (menuItemID) { case 1: if (isCurrentlyModal()) exitModalState(-1); @@ -1077,27 +1077,37 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde if (canCloseWindow()) { owner.getWindowManager().toggle(CtrlrPanelWindowManager::LuaMethodEditor, false); } + break; case 2: if (getCurrentEditor()) getCurrentEditor()->saveDocument(); + break; case 3: if (getCurrentEditor()) getCurrentEditor()->saveAndCompileDocument(); + break; case 4: saveAndCompileAllMethods(); + break; case 5: closeCurrentTab(); + break; case 6: closeAllTabs(); + break; case 7: convertToFiles(); + break; }; + break; case 1: - switch (menuItemId) { + switch (menuItemID) { case 4: methodEditArea->showFindDialog(); + break; case 5: methodEditArea->clearOutputText(); + break; case 6: CtrlrLuaMethodCodeEditorSettings s(*this); CtrlrDialogWindow::showModalDialog ("Code editor settings", &s, false, this); @@ -1107,8 +1117,10 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde nullptr); componentTree.setProperty (Ids::luaMethodEditorBgColour, COLOUR2STR (s.getColour()), nullptr); + break; case 7: methodEditArea->showDebuggerTab(); + break; case 8: methodEditArea->showConsoleTab(); } From f106f4006df859940ff6cf481f363d545111eb96 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Fri, 23 Jul 2021 21:00:44 +0200 Subject: [PATCH 15/19] Use enum and switch for lua method context menu --- .../MethodEditor/CtrlrLuaMethodEditor.cpp | 164 ++++++++++-------- 1 file changed, 88 insertions(+), 76 deletions(-) diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp index 0a4b94301..f24e3b4cf 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp @@ -792,72 +792,47 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) { if (e.mods.isPopupMenu()) { + enum popupItems { + NOP = 0, + ADD_METHOD, + ADD_FILES, + ADD_GROUP, + REMOVE_METHOD, + REMOVE_GROUP, + RENAME_GROUP, + CONVERT_TO_FILLES, + CONVERT_TO_FILE, + LOCATE_FILE, + SORT_BY_NAME, + SORT_BY_SIZE + } result; if ( item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup) ) { PopupMenu m; + m.addSectionHeader ("Group operations"); - m.addItem (1, "Add method"); - m.addItem (2, "Add files"); - m.addItem (3, "Add group"); + m.addItem (ADD_METHOD, "Add method"); + m.addItem (ADD_FILES , "Add files"); + m.addItem (ADD_GROUP , "Add group"); m.addSeparator(); bool isMethodGroup = item.hasType(Ids::luaMethodGroup); if (isMethodGroup) { - m.addItem (4, "Remove group"); - m.addItem (5, "Rename group"); + m.addItem (REMOVE_GROUP, "Remove group"); + m.addItem (RENAME_GROUP, "Rename group"); } else { // Root element => add a menu to convert method to filesto files - m.addItem(4, "Convert to files..."); + m.addItem(CONVERT_TO_FILE , "Convert to file..."); + m.addItem(CONVERT_TO_FILES, "Convert all to files..."); } m.addSeparator(); - m.addItem (6, "Sort by name"); - m.addItem (7, "Sort by size"); - - const int ret = m.show(); - - if (ret == 1) - { - addNewMethod (item); - } - else if (ret == 2) - { - addMethodFromFile (item); - } - else if (ret == 3) - { - addNewGroup (item); - } - else if (ret == 4) - { - if (isMethodGroup) - { // Case of a method group => remove group - removeGroup(item); - } - else - { // Case of to root element => export to files - convertToFiles(); - } - } - else if (ret == 5) - { - renameGroup (item); - } - else if (ret == 6) - { - ChildSorter sorter(true,*this); - getMethodManager().getManagerTree().sort (sorter, nullptr, false); + m.addItem (SORT_BY_NAME, "Sort by name"); + m.addItem (SORT_BY_SIZE, "Sort by size"); - triggerAsyncUpdate(); - } - else if (ret == 7) - { - ChildSorter sorter(false,*this); - getMethodManager().getManagerTree().sort (sorter, nullptr, false); + result = m.show(); - triggerAsyncUpdate(); - } } else if (item.hasType(Ids::luaMethod)) { @@ -867,40 +842,77 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) { if (!owner.getLuaMethodSourceFile(&item).existsAsFile()) { - m.addItem (12, "Locate file on disk"); + m.addItem (LOCATE_FILE, "Locate file on disk"); } } m.addSeparator(); - m.addItem (2,"Remove method"); + m.addItem (REMOVE_METHOD,"Remove method"); const int ret = m.show(); - if (ret == 11) - { - /* convert a in-memory method to a file based one */ - } - else if (ret == 12) - { - /* locate a missing file on disk */ - } - else if (ret == 10) - { - /* convert a method from a file to a in-memory property */ - } - else if (ret == 2) - { - /* remove a method */ - if (SURE("Delete the selected method?", this)) - { - { - methodEditArea->closeTabWithMethod (item); - getMethodManager().removeMethod (item.getProperty(Ids::uuid).toString()); - } - - triggerAsyncUpdate(); - } + } + switch (ret) { + case ADD_METHOD: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + addNewMethod (item); + break; + case ADD_FILES: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + addMethodFromFile (item); + break; + case ADD_GROUP: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + addNewGroup (item); + break; + case REMOVE_GROUP: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + jassert(isMethodGroup); + removeGroup(item); + break; + case RENAME_GROUP: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + jassert(isMethodGroup); + renameGroup (item); + break; + case CONVERT_TO_FILE: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + jassert(!isMethodGroup); + break; + case CONVERT_TO_FILES: + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + jassert(!isMethodGroup); + // Case of to root element => export to files + convertToFiles(); + break; + case SORT_BY_NAME: { + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + ChildSorter sorter(true,*this); + getMethodManager().getManagerTree().sort (sorter, nullptr, false); + triggerAsyncUpdate(); + break; + } + case SORT_BY_SIZE: { + jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); + ChildSorter sorter(false,*this); + getMethodManager().getManagerTree().sort (sorter, nullptr, false); + triggerAsyncUpdate(); + break; + } + case LOCATE_FILE: { + jassert(item.hasType(Ids::luaMethod)); + jassert((int)item.getProperty(Ids::luaMethodSource) == CtrlrLuaMethod::codeInFile); + /* TODO: implement */ + break; + } + case REMOVE_METHOD: { +1 jassert(item.hasType(Ids::luaMethod)); + /* remove a method */ + if (SURE("Delete the selected method?", this)) { + methodEditArea->closeTabWithMethod (item); + getMethodManager().removeMethod (item.getProperty(Ids::uuid).toString()); } + triggerAsyncUpdate(); } } } From 5a86460c4c66bedb8df57d1400356853f8491b65 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Fri, 23 Jul 2021 21:25:41 +0200 Subject: [PATCH 16/19] Use enum for submenu ids in CtrlrLuaMethodEditor This allows the compiler to warn about unimplemented values. --- .../MethodEditor/CtrlrLuaMethodEditor.cpp | 173 ++++++++++-------- 1 file changed, 98 insertions(+), 75 deletions(-) diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp index f24e3b4cf..de6088776 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp @@ -1042,100 +1042,123 @@ int ChildSorter::compareElements (ValueTree first, ValueTree second) } } +enum MainMenus { + MAIN_FILE, + MAIN_EDIT +}; + +enum SubMenuIds { + MENU_SAVE, + MENU_COMPILE, + MENU_COMPILE_ALL, + MENU_CLOSE, + MENU_CLOSE_TAB, + MENU_CLOSE_ALL_TABS, + MENU_CONVERT_TO_FILE, + MENU_CONVERT_TO_FILES, + MENU_FIND_REPLACE, + MENU_DEBUGGER, + MENU_CONSOLE, + MENU_CLEAR_OUTPUT, + MENU_SETTINGS +}; + +static const char* const menuNames[] = { "File", "Edit", nullptr }; + + + StringArray CtrlrLuaMethodEditor::getMenuBarNames() { - const char* const names[] = { "File", "Edit", nullptr }; - return StringArray (names); + return StringArray (menuNames); } PopupMenu CtrlrLuaMethodEditor::getMenuForIndex(int topLevelMenuIndex, const String &menuName) { PopupMenu menu; - if (topLevelMenuIndex == 0) - { - menu.addItem (2, "Save"); - menu.addItem (3, "Save and compile"); - menu.addItem (4, "Save and compile all"); + switch (topLevelMenuIndex) { + case MAIN_FILE: + menu.addItem (MENU_SAVE , "Save"); + menu.addItem (MENU_COMPILE , "Save and compile"); + menu.addItem (MENU_cOMPILE_ALL , "Save and compile all"); menu.addSeparator(); - menu.addItem(5, "Close current tab"); - menu.addItem(6, "Close all tabs"); + menu.addItem (MENU_CLOSE_TAB , "Close current tab"); + menu.addItem (MENU_CLOSE_ALL_TABS , "Close all tabs"); menu.addSeparator (); - menu.addItem(7, "Convert to files..."); + menu.addItem (MENU_CONVERT_TO_FILE , "Convert to file..."); + menu.addItem (MENU_CONVERT_TO_FILES, "Convert to files..."); menu.addSeparator(); - menu.addItem (1, "Close"); - } - else if (topLevelMenuIndex == 1) - { - menu.addItem (4, "Find and replace"); - menu.addItem (7, "Debugger"); - menu.addItem (8, "Console"); + menu.addItem (MENU_CLOSE , "Close"); + break; + case MAIN_EDIT: + menu.addItem (MENU_FIND_REPLACE , "Find and replace"); + menu.addItem (MENU_DEBUGGER , "Debugger"); + menu.addItem (MENU_CONSOLE , "Console"); - menu.addItem (5, "Clear Output"); + menu.addItem (MENU_CLEAR_OUTPUT , "Clear Output"); menu.addSeparator(); - menu.addItem (6, "Settings"); + menu.addItem (MENU_SETTINGS , "Settings"); + break; + default: + jassert(topMenuIndex < MAIN_FILE || topMenuIndex > MAIN_EDIT); } return (menu); } void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuIndex) { - switch (topLevelMenuIndex) { - case 0: - switch (menuItemID) { - case 1: - if (isCurrentlyModal()) - exitModalState(-1); - - if (canCloseWindow()) { - owner.getWindowManager().toggle(CtrlrPanelWindowManager::LuaMethodEditor, false); - } - break; - case 2: - if (getCurrentEditor()) - getCurrentEditor()->saveDocument(); - break; - case 3: - if (getCurrentEditor()) - getCurrentEditor()->saveAndCompileDocument(); - break; - case 4: - saveAndCompileAllMethods(); - break; - case 5: - closeCurrentTab(); - break; - case 6: - closeAllTabs(); - break; - case 7: - convertToFiles(); - break; - }; - break; - case 1: - switch (menuItemID) { - case 4: - methodEditArea->showFindDialog(); - break; - case 5: - methodEditArea->clearOutputText(); - break; - case 6: - CtrlrLuaMethodCodeEditorSettings s(*this); - CtrlrDialogWindow::showModalDialog ("Code editor settings", &s, false, this); - - componentTree.setProperty (Ids::luaMethodEditorFont, - owner.getCtrlrManagerOwner().getFontManager().getStringFromFont (s.getFont()), - nullptr); - componentTree.setProperty (Ids::luaMethodEditorBgColour, - COLOUR2STR (s.getColour()), nullptr); - break; - case 7: - methodEditArea->showDebuggerTab(); - break; - case 8: - methodEditArea->showConsoleTab(); + switch ((SubMenuIds)menuItemID) { + case MENU_CLOSE: + if (isCurrentlyModal()) + exitModalState(-1); + if (canCloseWindow()) { + owner.getWindowManager().toggle(CtrlrPanelWindowManager::LuaMethodEditor, false); } + break; + case MENU_SAVE: + if (getCurrentEditor()) + getCurrentEditor()->saveDocument(); + break; + case MENU_COMPILE: + if (getCurrentEditor()) + getCurrentEditor()->saveAndCompileDocument(); + break; + case MENU_COMPILE_ALL: + saveAndCompileAllMethods(); + break; + case MENU_CLOSE_TAB: + closeCurrentTab(); + break; + case MENU_CLOSE_ALL_TABS: + closeAllTabs(); + break; + case MENU_CONVERT_TO_FILE: + convertToFile(); + break; + case MENU_CONVERT_TO_FILES: + convertToFiles(); + break; + case MENU_FIND_REPLACE: + methodEditArea->showFindDialog(); + break; + case MENU_DEBUGGER: + methodEditArea->showDebuggerTab(); + break; + case MENU_CONSOLE: + methodEditArea->showConsoleTab(); + break + case MENU_CLEAR_OUTPUT: + methodEditArea->clearOutputText(); + break; + case MENU_SETTINGS: { + CtrlrLuaMethodCodeEditorSettings s(*this); + CtrlrDialogWindow::showModalDialog ("Code editor settings", &s, false, this); + + componentTree.setProperty (Ids::luaMethodEditorFont, + owner.getCtrlrManagerOwner().getFontManager().getStringFromFont (s.getFont()), + nullptr); + componentTree.setProperty (Ids::luaMethodEditorBgColour, + COLOUR2STR (s.getColour()), nullptr); + break; } } From f11c29f98d14b7e7b9b8e64cc795195c7326c350 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Wed, 8 Sep 2021 21:22:25 +0200 Subject: [PATCH 17/19] Fix a coding issue with JUCE --- .../AU/CoreAudioUtilityClasses/AUCarbonViewBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JUCE/modules/juce_audio_plugin_client/AU/CoreAudioUtilityClasses/AUCarbonViewBase.cpp b/JUCE/modules/juce_audio_plugin_client/AU/CoreAudioUtilityClasses/AUCarbonViewBase.cpp index 4b9525b1b..7de90afec 100644 --- a/JUCE/modules/juce_audio_plugin_client/AU/CoreAudioUtilityClasses/AUCarbonViewBase.cpp +++ b/JUCE/modules/juce_audio_plugin_client/AU/CoreAudioUtilityClasses/AUCarbonViewBase.cpp @@ -285,7 +285,7 @@ bool AUCarbonViewBase::HandleEvent(EventHandlerCallRef inHandlerRef, EventRef ev // [4/4] /* <-- kEventParamOrigin (out, typeHIPoint) - * On exit, contains the scrollable views current origin (the + * On exit, contains the scrollable view's current origin (the * view-relative coordinate that is drawn at the top left * corner of its frame). These coordinates should always be * greater than or equal to zero. They should be less than or From cc9fc138b84100fa4d69484eb03aaaceb291d337 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Wed, 8 Sep 2021 21:22:57 +0200 Subject: [PATCH 18/19] Implement NotificationType values in Lua --- Source/Lua/JuceClasses/LComponents.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/Lua/JuceClasses/LComponents.cpp b/Source/Lua/JuceClasses/LComponents.cpp index 7be9927c6..077d1daf2 100644 --- a/Source/Lua/JuceClasses/LComponents.cpp +++ b/Source/Lua/JuceClasses/LComponents.cpp @@ -1596,9 +1596,16 @@ void LSlider::wrapForLua (lua_State *L) module(L) [ - class_("NotificationType") - , - class_ >("Slider") + class_("NotificationType") + .enum_("NotificationType") + [ + value("dontSendNotification",dontSendNotification), + value("sendNotification",sendNotification), + value("sendNotificationSync",sendNotificationSync), + value("sendNotificationAsync",sendNotificationAsync) + ] + , + class_ >("Slider") .def("setSliderStyle", &Slider::setSliderStyle) .def("getSliderStyle", &Slider::getSliderStyle) .def("setRotaryParameters", (void(Slider::*)(float, float, bool))&Slider::setRotaryParameters) From 1534dde4ce719ea727ce85d1f92d2110a2604177 Mon Sep 17 00:00:00 2001 From: Tobias Schlemmer Date: Wed, 17 Nov 2021 15:03:04 +0100 Subject: [PATCH 19/19] Convert a single Lua method to a file. * using menu of the file editor * from the method tree context menu --- Source/Core/CtrlrPanel/CtrlrPanel.h | 4 +- .../CtrlrPanel/CtrlrPanelFileOperations.cpp | 77 ++++++++++++++----- Source/Lua/CtrlrLuaManager.cpp | 1 + Source/Lua/Methods/CtrlrLuaMethod.cpp | 1 + .../MethodEditor/CtrlrLuaMethodCodeEditor.h | 4 +- .../MethodEditor/CtrlrLuaMethodEditor.cpp | 74 ++++++++++++++---- .../MethodEditor/CtrlrLuaMethodEditor.h | 4 +- 7 files changed, 126 insertions(+), 39 deletions(-) diff --git a/Source/Core/CtrlrPanel/CtrlrPanel.h b/Source/Core/CtrlrPanel/CtrlrPanel.h index a544ae4c3..2e122bd69 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanel.h +++ b/Source/Core/CtrlrPanel/CtrlrPanel.h @@ -145,6 +145,7 @@ class CtrlrPanel: public ValueTree::Listener, File getPanelContentDir(); File getPanelLuaDir(); File getPanelResourcesDir(); + Result convertLuaMethodToFile(ValueTree & item); Result convertLuaMethodsToFiles(const String dirPath); File getLuaMethodGroupDir(const ValueTree &methodGroup); @@ -183,7 +184,8 @@ class CtrlrPanel: public ValueTree::Listener, static void writePanelXml(OutputStream &outputStream, CtrlrPanel *panel, const bool compressPanel); Result writeLuaMethod(const File &parentDir, ValueTree *method); Result writeLuaMethodGroup(const File &parentDir, ValueTree *methodGroup); - Result writeLuaChildren(const File &parentDir, ValueTree *parentElement); + Result writeLuaChild(const File &parentDir, ValueTree *child); + Result writeLuaChildren(const File &parentDir, ValueTree *parentElement); File getLuaMethodSourceFile(const ValueTree *method); static void convertLuaMethodsToPropeties(const File &panelLuaDir, ValueTree &panelTree); static void convertLuaMethodToProperty(const File &panelLuaDir, ValueTree *method); diff --git a/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp b/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp index 2b321bc44..5bec2524b 100644 --- a/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp +++ b/Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp @@ -92,6 +92,36 @@ File CtrlrPanel::getLuaMethodGroupDir(const ValueTree &methodGroup) return result; } +Result CtrlrPanel::convertLuaMethodToFile(ValueTree & item) +{ + Result res = Result::ok(); + if (!item.isValid() || !item.hasType(Ids::luaMethod)) + { + res = Result::fail("Internal error: Ony Lua methods can be converted to files."); + } + File methodLuaDirectory(getLuaMethodGroupDir(item.getParent())); + if (methodLuaDirectory.existsAsFile()) + { // A directory with that name already exists + res = Result::fail("Convert to file can't create directory (a file with that name already exists): " + methodLuaDirectory.getFullPathName()); + } + else if (!methodLuaDirectory.exists()) + { + res = methodLuaDirectory.createDirectory(); + } + if (res.ok()) + { + if (methodLuaDirectory.hasWriteAccess()) + { // Save lua code + res = writeLuaChild(methodLuaDirectory, &item); + } + else + { + res = Result::fail("Convert to XML can't write in panel directory: " + methodLuaDirectory.getFullPathName()); + } + } + return res; +} + Result CtrlrPanel::convertLuaMethodsToFiles(const String dirPath) { Result res = Result::ok(); @@ -680,35 +710,46 @@ Result CtrlrPanel::writeLuaMethodGroup(const File &parentDir, ValueTree *methodG return res; } -Result CtrlrPanel::writeLuaChildren(const File &parentDir, ValueTree *parentElement) +Result CtrlrPanel::writeLuaChild(const File &parentDir, ValueTree *child) { - if (parentElement == nullptr) - return Result::fail("Parent element is missing"); + if (child == nullptr) + return Result::fail("Child element is missing"); Result res = Result::ok(); - for (int i = 0; igetNumChildren(); i++) + if (child->hasType(Ids::luaMethod)) { - ValueTree child = parentElement->getChild(i); - if (child.hasType(Ids::luaMethod)) - { - if ((int)child.getProperty(Ids::luaMethodSource) != CtrlrLuaMethod::codeInFile) - { // Only process methods that are not already saved in files - res = CtrlrPanel::writeLuaMethod(parentDir, &child); - if (res.failed()) - { // Break on first error - return res; - } - } - } - else if (child.hasType(Ids::luaMethodGroup)) + if ((int)child->getProperty(Ids::luaMethodSource) != CtrlrLuaMethod::codeInFile) { - res = CtrlrPanel::writeLuaMethodGroup(parentDir, &child); + // Only process methods that are not already saved in files + res = CtrlrPanel::writeLuaMethod(parentDir, child); if (res.failed()) { // Break on first error return res; } } } + else if (child->hasType(Ids::luaMethodGroup)) + { + res = CtrlrPanel::writeLuaMethodGroup(parentDir, child); + if (res.failed()) + { // Break on first error + return res; + } + } + return res; +} + +Result CtrlrPanel::writeLuaChildren(const File &parentDir, ValueTree *parentElement) +{ + if (parentElement == nullptr) + return Result::fail("Parent element is missing"); + + Result res = Result::ok(); + for (int i = 0; igetNumChildren(); i++) + { + ValueTree child = parentElement->getChild(i); + writeLuaChild(parentDir, &child); + } return res; } diff --git a/Source/Lua/CtrlrLuaManager.cpp b/Source/Lua/CtrlrLuaManager.cpp index 934856150..a97ca8f18 100644 --- a/Source/Lua/CtrlrLuaManager.cpp +++ b/Source/Lua/CtrlrLuaManager.cpp @@ -203,6 +203,7 @@ void CtrlrLuaManager::wrapCore (lua_State* L) void CtrlrLuaManager::wrapCtrlrClasses(lua_State* L) { + _DBG("CtrlrLuaManager::wrapCtrlrClasses"); CtrlrValueMap::wrapForLua (L); CtrlrModulator::wrapForLua (L); CtrlrPanel::wrapForLua (L); diff --git a/Source/Lua/Methods/CtrlrLuaMethod.cpp b/Source/Lua/Methods/CtrlrLuaMethod.cpp index c624c869c..4f1fd3df4 100644 --- a/Source/Lua/Methods/CtrlrLuaMethod.cpp +++ b/Source/Lua/Methods/CtrlrLuaMethod.cpp @@ -93,6 +93,7 @@ Uuid CtrlrLuaMethod::getUuid() const File CtrlrLuaMethod::getSourceFile() { + // TODO: there should be a better way to get the owning panel return (owner.getOwner().getOwner().getLuaMethodSourceFile(&methodTree)); } diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.h b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.h index fa49ff0a1..c8d2e6b45 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.h +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodCodeEditor.h @@ -9,7 +9,7 @@ class CtrlrLuaMethodEditor; class GenericCodeEditorComponent; -class CtrlrLuaDebugger; +class CtrlrLuaDebugger; class CtrlrLuaMethodCodeEditor : public Component, public KeyListener, public CodeDocument::Listener, public AsyncUpdater { @@ -100,4 +100,4 @@ class GenericCodeEditorComponent : public CodeEditorComponent JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GenericCodeEditorComponent) }; //============================================================================== -#endif +#endif diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp index de6088776..a865ec865 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.cpp @@ -800,12 +800,14 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) REMOVE_METHOD, REMOVE_GROUP, RENAME_GROUP, - CONVERT_TO_FILLES, + CONVERT_TO_FILES, CONVERT_TO_FILE, LOCATE_FILE, SORT_BY_NAME, SORT_BY_SIZE - } result; + }; + int result; + bool isMethodGroup = item.hasType(Ids::luaMethodGroup); if ( item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup) ) { PopupMenu m; @@ -815,7 +817,6 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) m.addItem (ADD_FILES , "Add files"); m.addItem (ADD_GROUP , "Add group"); m.addSeparator(); - bool isMethodGroup = item.hasType(Ids::luaMethodGroup); if (isMethodGroup) { m.addItem (REMOVE_GROUP, "Remove group"); @@ -823,7 +824,6 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) } else { // Root element => add a menu to convert method to filesto files - m.addItem(CONVERT_TO_FILE , "Convert to file..."); m.addItem(CONVERT_TO_FILES, "Convert all to files..."); } @@ -844,15 +844,17 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) { m.addItem (LOCATE_FILE, "Locate file on disk"); } + } else { + m.addItem(CONVERT_TO_FILE , "Convert to file..."); } m.addSeparator(); m.addItem (REMOVE_METHOD,"Remove method"); - const int ret = m.show(); + result = m.show(); } - switch (ret) { + switch (result) { case ADD_METHOD: jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); addNewMethod (item); @@ -875,10 +877,6 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) jassert(isMethodGroup); renameGroup (item); break; - case CONVERT_TO_FILE: - jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); - jassert(!isMethodGroup); - break; case CONVERT_TO_FILES: jassert(item.hasType (Ids::luaManagerMethods) || item.hasType (Ids::luaMethodGroup)); jassert(!isMethodGroup); @@ -905,8 +903,12 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) /* TODO: implement */ break; } + case CONVERT_TO_FILE: + jassert(item.hasType(Ids::luaMethod)); + jassert((int)item.getProperty(Ids::luaMethodSource) == CtrlrLuaMethod::codeInFile); + convertToFile(item); + break; case REMOVE_METHOD: { -1 jassert(item.hasType(Ids::luaMethod)); /* remove a method */ if (SURE("Delete the selected method?", this)) { methodEditArea->closeTabWithMethod (item); @@ -914,6 +916,7 @@ void CtrlrLuaMethodEditor::itemClicked (const MouseEvent &e, ValueTree &item) } triggerAsyncUpdate(); } + } } } @@ -1048,18 +1051,22 @@ enum MainMenus { }; enum SubMenuIds { - MENU_SAVE, + MENU_SAVE=1, MENU_COMPILE, MENU_COMPILE_ALL, + MENU_CLOSE, MENU_CLOSE_TAB, MENU_CLOSE_ALL_TABS, + MENU_CONVERT_TO_FILE, MENU_CONVERT_TO_FILES, + MENU_FIND_REPLACE, MENU_DEBUGGER, MENU_CONSOLE, MENU_CLEAR_OUTPUT, + MENU_SETTINGS }; @@ -1079,7 +1086,7 @@ PopupMenu CtrlrLuaMethodEditor::getMenuForIndex(int topLevelMenuIndex, const Str case MAIN_FILE: menu.addItem (MENU_SAVE , "Save"); menu.addItem (MENU_COMPILE , "Save and compile"); - menu.addItem (MENU_cOMPILE_ALL , "Save and compile all"); + menu.addItem (MENU_COMPILE_ALL , "Save and compile all"); menu.addSeparator(); menu.addItem (MENU_CLOSE_TAB , "Close current tab"); menu.addItem (MENU_CLOSE_ALL_TABS , "Close all tabs"); @@ -1099,7 +1106,7 @@ PopupMenu CtrlrLuaMethodEditor::getMenuForIndex(int topLevelMenuIndex, const Str menu.addItem (MENU_SETTINGS , "Settings"); break; default: - jassert(topMenuIndex < MAIN_FILE || topMenuIndex > MAIN_EDIT); + jassert(topLevelMenuIndex < MAIN_FILE || topLevelMenuIndex > MAIN_EDIT); } return (menu); } @@ -1110,6 +1117,7 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde case MENU_CLOSE: if (isCurrentlyModal()) exitModalState(-1); + if (canCloseWindow()) { owner.getWindowManager().toggle(CtrlrPanelWindowManager::LuaMethodEditor, false); } @@ -1132,12 +1140,12 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde closeAllTabs(); break; case MENU_CONVERT_TO_FILE: - convertToFile(); + convertToFile(getCurrentEditor()); break; case MENU_CONVERT_TO_FILES: convertToFiles(); break; - case MENU_FIND_REPLACE: + case MENU_FIND_REPLACE: methodEditArea->showFindDialog(); break; case MENU_DEBUGGER: @@ -1145,7 +1153,7 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde break; case MENU_CONSOLE: methodEditArea->showConsoleTab(); - break + break; case MENU_CLEAR_OUTPUT: methodEditArea->clearOutputText(); break; @@ -1160,6 +1168,7 @@ void CtrlrLuaMethodEditor::menuItemSelected(int menuItemID, int topLevelMenuInde COLOUR2STR (s.getColour()), nullptr); break; } + } } void CtrlrLuaMethodEditor::saveAndCompileAllMethods() @@ -1175,6 +1184,37 @@ void CtrlrLuaMethodEditor::saveAndCompileAllMethods() } } +void CtrlrLuaMethodEditor::convertToFile(WeakReference editor) +{ + if (!editor) + return; + auto method = editor -> getMethod(); + if (method) + convertToFile(method->getMethodTree()); +} + + +void CtrlrLuaMethodEditor::convertToFile(ValueTree &item) +{ + /* TODO: implement */ + // Show confirmation dialog + const String base_path = owner.getPanelLuaDirPath(); + const int confirm = AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, "Convert to files", "Do you want to convert the Lua method to file (base path=" + base_path + ")?", "Yes", "No"); + if (confirm == 1) + { + Result res = owner.convertLuaMethodToFile(item); + if (res.wasOk()) + { + owner.luaManagerChanged(); + triggerAsyncUpdate(); + } + else + { + AlertWindow::showMessageBox(AlertWindow::WarningIcon, "Convert to file", "Failed to convert Lua method to file.\n" + res.getErrorMessage()); + } + } +} + void CtrlrLuaMethodEditor::convertToFiles() { // Show confirmation dialog diff --git a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h index 62165f933..b14cd8510 100644 --- a/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h +++ b/Source/UIComponents/CtrlrLua/MethodEditor/CtrlrLuaMethodEditor.h @@ -109,6 +109,8 @@ class CtrlrLuaMethodEditor : public CtrlrChildWindowContent, void menuItemSelected(int menuItemID, int topLevelMenuIndex); void searchResultClicked (const String &methodName, const int lineNumber, const int resultPositionStart, const int resultPositionEnd); void saveAndCompileAllMethods(); + void convertToFile(WeakReference codeEditor); + void convertToFile(ValueTree &item); void convertToFiles(); /* Debugger stuff */ @@ -123,7 +125,7 @@ class CtrlrLuaMethodEditor : public CtrlrChildWindowContent, bool caseCansitive, findDialogActive; String lookInString, searchInString, currentSearchString; - private: +private: WeakReference::Master masterReference; friend class WeakReference; File lastBrowsedSourceDir;