|
Krotos Modules 3
|
Helper class for saving and loading presets. More...
#include <PresetManager.h>
Classes | |
| struct | Preset |
Public Member Functions | |
| PresetManager () | |
| const Preset & | getCurrentPreset () const |
| void | setCurrentPreset (const File &presetFile) |
| PopupMenu | getCurrentPopupMenu () |
Static Public Member Functions | |
| static bool | checkPresetVersion (const File &presetFile, const String &pluginVersion, const bool showAlertWindow) |
| static String | getPresetVersion (const ValueTree &state) |
| static String | getPresetVersion (const File &presetFile) |
| static void | writePresetVersion (ValueTree &state, const String &versionNumber) |
| static File | getFactoryTemplateDirectory () |
| static File | getUserTemplateDirectory () |
| static File | getFactoryPresetDirectory () |
| static File | getUserPresetDirectory () |
| static ValueTree | getValueTreeFromFile (const File &presetFile) |
| static void | writeValueTreeToFile (const ValueTree &valueTree, const File &outputFile) |
| static Preset | getPresetFromFile (const File &file) |
| static File | getInitPresetFile () |
| static void | checkReformerVersion (ValueTree &state) |
| Checks the Reformer version within a ValueTree. | |
| static void | checkReformerVersion (File &preset) |
| Checks the Reformer version within a File. | |
| static void | writeReformerVersion (ValueTree &state) |
| Writes the Reformer version to a ValueTree. | |
| static String | getReformerVersion (ValueTree &state) |
| Retrieves the Reformer version from a ValueTree. | |
Public Attributes | |
| std::function< void(const ValueTree &)> | presetChanged {nullptr} |
Private Member Functions | |
| PopupMenu | getPopupMenuFromDirectory (const File &presetDirectory) |
| void | initializePresetDirectories () |
Static Private Member Functions | |
| static void | checkReformerVersionInternal (ValueTree &state) |
Private Attributes | |
| Preset | m_currentPreset |
Static Private Attributes | |
| static const String | m_cutoffVersion |
| static const String | m_factoryPresetFolderName = "Factory" |
| static const String | m_userPresetFolderName = "User" |
| static const String | m_presetFileExtension = "ksp" |
| static const String | m_initFileName = "init" |
Helper class for saving and loading presets.
This class contains functions for saving and loading ValueTree objects as presets.
A single lambda can be registered with this class to perform the necessary actions after a change in preset.
This class can also export a PopupMenu containing a list of all the presets, which can then be used by a ComboBox to create a preset selection menu.
| krotos::PresetManager::PresetManager | ( | ) |
Constructor.
|
static |
Check plugin version number from a Preset. Returns true if version number is compatible with the current version
|
static |
Checks the Reformer version within a File.
This function reads a ValueTree from a File, checks if it contains a Reformer Kwidget, and compares its version to the current Reformer version. If the version is different or not present, it writes the Reformer version to the ValueTree.
| preset | The File containing the ValueTree to check and potentially update. |
|
static |
Checks the Reformer version within a ValueTree.
This function checks if a ValueTree contains a Reformer Kwidget and compares its version to the current Reformer version. If the version is different or not present, it writes the Reformer version to the ValueTree.
| state | The ValueTree to check and potentially update. |
|
staticprivate |
| PopupMenu krotos::PresetManager::getCurrentPopupMenu | ( | ) |
Get a PopupMenu that can be added to a ComboBox & contains the entire preset list, with each PopupMenu::Item owning a function that will cause the preset to change when the menu item is selected.
Basically, just use this menu for your ComboBox, and no other message setup is needed.
| const PresetManager::Preset & krotos::PresetManager::getCurrentPreset | ( | ) | const |
Returns the current Preset.
|
static |
Get the system-specific factory preset directory.
|
static |
Get the system-specific factory template directory.
|
static |
Getter for the init.ksp preset file
|
private |
|
static |
Get a Preset struct containing the name and file for a particular preset file.
|
static |
Get the plugin version number from a preset file
|
static |
Get the plugin version number from a ValueTree
|
static |
Retrieves the Reformer version from a ValueTree.
This function retrieves the Reformer version from a given ValueTree.
| state | The ValueTree from which the Reformer version will be retrieved. |
|
static |
Get the system-specific user preset directory.
|
static |
Get the system-specific user template directory.
|
static |
Get the ValueTree contained in a preset file.
|
private |
| void krotos::PresetManager::setCurrentPreset | ( | const File & | presetFile | ) |
Set the preset, triggering a message that updates the whole plugin state.
|
static |
Write the current plugin version number to an incoming ValueTree, designed to be used when preset is saved
|
static |
Writes the Reformer version to a ValueTree.
This function writes the current Reformer version to a given ValueTree.
| state | The ValueTree to which the Reformer version will be written. |
|
static |
Save a preset file from an existing ValueTree.
|
private |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
| std::function<void(const ValueTree&)> krotos::PresetManager::presetChanged {nullptr} |
Register a function here to be called when the preset changes.