Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30a8140
commit c61759f
Showing
6 changed files
with
2,519 additions
and
2,410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1271,13 +1271,15 @@ String ScriptingApi::Engine::getPreloadMessage() | |
|
||
var ScriptingApi::Engine::getZoomLevel() const | ||
{ | ||
logSettingWarning("getZoomLevel"); | ||
This comment has been minimized.
Sorry, something went wrong.
christoph-hart
Author
Collaborator
|
||
auto gm = dynamic_cast<const GlobalSettingManager*>(getScriptProcessor()->getMainController_()); | ||
|
||
return gm->getGlobalScaleFactor(); | ||
} | ||
|
||
void ScriptingApi::Engine::setZoomLevel(double newLevel) | ||
{ | ||
logSettingWarning("setZoomLevel"); | ||
newLevel = jlimit(0.25, 2.0, newLevel); | ||
|
||
auto gm = dynamic_cast<GlobalSettingManager*>(getScriptProcessor()->getMainController_()); | ||
|
@@ -1286,6 +1288,8 @@ void ScriptingApi::Engine::setZoomLevel(double newLevel) | |
|
||
void ScriptingApi::Engine::setDiskMode(int mode) | ||
{ | ||
logSettingWarning("setDiskMode"); | ||
|
||
auto mc = dynamic_cast<MainController*>(getScriptProcessor()->getMainController_()); | ||
|
||
AudioProcessorDriver* driver = dynamic_cast<AudioProcessorDriver*>(mc); | ||
|
@@ -1608,6 +1612,45 @@ void ScriptingApi::Engine::saveUserPreset(var presetName) | |
} | ||
} | ||
|
||
struct ScriptingApi::Settings::Wrapper | ||
{ | ||
API_METHOD_WRAPPER_0(Settings, getZoomLevel); | ||
API_VOID_METHOD_WRAPPER_1(Settings, setZoomLevel); | ||
API_VOID_METHOD_WRAPPER_1(Settings, setDiskMode); | ||
}; | ||
|
||
ScriptingApi::Settings::Settings(ProcessorWithScriptingContent* s) : | ||
ScriptingObject(s), | ||
ApiClass(0) | ||
This comment has been minimized.
Sorry, something went wrong.
christoph-hart
Author
Collaborator
|
||
{ | ||
// Gonna save you some typing... | ||
mc = dynamic_cast<MainController*>(getScriptProcessor()->getMainController_()); | ||
gm = dynamic_cast<GlobalSettingManager*>(mc); | ||
driver = dynamic_cast<AudioProcessorDriver*>(mc); | ||
|
||
ADD_API_METHOD_0(getZoomLevel); | ||
ADD_API_METHOD_1(setZoomLevel); | ||
ADD_API_METHOD_1(setDiskMode); | ||
} | ||
|
||
|
||
double ScriptingApi::Settings::getZoomLevel() const | ||
{ | ||
return gm->getGlobalScaleFactor(); | ||
} | ||
|
||
void ScriptingApi::Settings::setZoomLevel(double newLevel) | ||
{ | ||
newLevel = jlimit(0.25, 2.0, newLevel); | ||
gm->setGlobalScaleFactor(newLevel, sendNotificationAsync); | ||
} | ||
|
||
void ScriptingApi::Settings::setDiskMode(int mode) | ||
{ | ||
driver->diskMode = mode; | ||
mc->getSampleManager().setDiskMode((MainController::SampleManager::DiskMode)mode); | ||
} | ||
|
||
struct DynamicArrayComparator | ||
{ | ||
DynamicArrayComparator(HiseJavascriptEngine* engine_, var sortFunction_, var arrayToSort_): | ||
|
@@ -2049,6 +2092,17 @@ String ScriptingApi::Engine::getSystemTime(bool includeDividerCharacters) | |
return Time::getCurrentTime().toISO8601(includeDividerCharacters); | ||
}; | ||
|
||
void ScriptingApi::Engine::logSettingWarning(const String& methodName) const | ||
{ | ||
auto p = dynamic_cast<const Processor*>(getScriptProcessor()); | ||
|
||
auto unconst = const_cast<Processor*>(p); | ||
|
||
String s; | ||
s << "Engine." << methodName << "() is deprecated. Use Settings." << methodName << "() instead."; | ||
debugToConsole(unconst, s); | ||
} | ||
|
||
// ====================================================================================================== Sampler functions | ||
|
||
struct ScriptingApi::Sampler::Wrapper | ||
|
@@ -4871,4 +4925,6 @@ void ScriptingApi::Server::setServerCallback(var callback) | |
|
||
|
||
|
||
|
||
|
||
} // namespace hise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,13 +494,48 @@ class ScriptingApi | |
|
||
// ============================================================================================================ | ||
|
||
/** This warning will show up in the console so people can migrate in the next years... */ | ||
void logSettingWarning(const String& methodName) const; | ||
|
||
struct Wrapper; | ||
|
||
ScriptBaseMidiProcessor* parentMidiProcessor; | ||
|
||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Engine); | ||
}; | ||
|
||
/** This class takes over a few of the Engine methods in order to break down this gigantomanic object. */ | ||
class Settings : public ApiClass, | ||
This comment has been minimized.
Sorry, something went wrong.
christoph-hart
Author
Collaborator
|
||
public ScriptingObject | ||
{ | ||
public: | ||
|
||
Settings(ProcessorWithScriptingContent* s);; | ||
|
||
Identifier getObjectName() const override { RETURN_STATIC_IDENTIFIER("Settings"); } | ||
|
||
// ================================================================================================== API Calls | ||
|
||
/** Returns the UI Zoom factor. */ | ||
double getZoomLevel() const; | ||
|
||
/** Changes the UI zoom (1.0 = 100%). */ | ||
void setZoomLevel(double newLevel); | ||
|
||
/** Sets the Streaming Mode (0 -> Fast-SSD, 1 -> Slow-HDD) */ | ||
void setDiskMode(int mode); | ||
|
||
// ============================================================================================================ | ||
|
||
private: | ||
|
||
GlobalSettingManager* gm; | ||
AudioProcessorDriver* driver; | ||
MainController* mc; | ||
|
||
struct Wrapper; | ||
This comment has been minimized.
Sorry, something went wrong.
christoph-hart
Author
Collaborator
|
||
}; | ||
|
||
/** All scripting functions for sampler specific functionality. */ | ||
class Sampler : public ConstScriptingObject | ||
{ | ||
|
Oops, something went wrong.
Add the api class here. This makes it available in all script MIDI processors. If you want it to be available on the other module types, add it there too.