Search in sources :

Example 1 with SettableEnumValue

use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.

the class SettingsUIImpl method getActionSetting.

/**
 * {@inheritDoc}
 */
@Override
public IActionSetting getActionSetting(final String label, final String category) {
    // Has to be here since it must be executed in the initialize method!
    this.prepareActions();
    final String cat = category + " - " + label;
    final SettableEnumValue categorySetting = this.preferences.getEnumSetting(label + ": Category", cat, this.categoryNames, this.categoryNames[0]);
    final Map<String, SettableEnumValue> categoryActionsSettings = new TreeMap<>();
    for (final String categoryName : this.categoryNames) {
        final String[] actionNames = this.categoriesActionIDs.get(categoryName);
        categoryActionsSettings.put(categoryName, this.preferences.getEnumSetting(label + ": " + categoryName + " Actions", cat, actionNames, actionNames[0]));
    }
    return new ActionSettingImpl(categorySetting, categoryActionsSettings, this.actionIDsNames, this.actionCategories);
}
Also used : SettableEnumValue(com.bitwig.extension.controller.api.SettableEnumValue) TreeMap(java.util.TreeMap)

Example 2 with SettableEnumValue

use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.

the class ActionSettingImpl method set.

/**
 * {@inheritDoc}
 */
@Override
public void set(final String actionID) {
    final String category = this.actionCategories.get(actionID);
    final String actionName = this.actionsMap.get(actionID);
    // Could only happen if actions would be removed
    if (category == null || actionName == null)
        return;
    // Select the category of the action
    this.categorySetting.set(category);
    final SettableEnumValue categoryActionsSetting = this.categoryActionsSettings.get(category);
    if (categoryActionsSetting == null)
        return;
    // Only show the actions list of the category
    for (final SettableEnumValue setting : this.categoryActionsSettings.values()) {
        if (setting == categoryActionsSetting)
            ((Setting) setting).show();
        else
            ((Setting) setting).hide();
    }
    // Finally select the action
    categoryActionsSetting.set(actionName);
}
Also used : SettableEnumValue(com.bitwig.extension.controller.api.SettableEnumValue)

Example 3 with SettableEnumValue

use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.

the class ActionSettingImpl method addValueObserver.

/**
 * {@inheritDoc}
 */
@Override
public void addValueObserver(final IValueObserver<String> observer) {
    this.observer = observer;
    this.categorySetting.addValueObserver(value -> this.notifyOberserver());
    for (final SettableEnumValue setting : this.categoryActionsSettings.values()) setting.addValueObserver(value -> this.notifyOberserver());
    // Directly fire the current value
    observer.update(this.get());
}
Also used : Setting(com.bitwig.extension.controller.api.Setting) IActionSetting(de.mossgrabers.framework.configuration.IActionSetting) SettableEnumValue(com.bitwig.extension.controller.api.SettableEnumValue) Map(java.util.Map) IValueObserver(de.mossgrabers.framework.observer.IValueObserver) SettableEnumValue(com.bitwig.extension.controller.api.SettableEnumValue)

Example 4 with SettableEnumValue

use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.

the class ActionSettingImpl method get.

/**
 * {@inheritDoc}
 */
@Override
public String get() {
    // Get the setting for the selected category
    final String selectedCategory = this.categorySetting.get();
    final SettableEnumValue setting = this.categoryActionsSettings.get(selectedCategory);
    if (setting == null)
        return this.actionsMap.keySet().iterator().next();
    // Get and return the ID of the selected action
    final String actionName = setting.get();
    for (final Map.Entry<String, String> e : this.actionsMap.entrySet()) {
        if (e.getValue().equals(actionName))
            return e.getKey();
    }
    return this.actionsMap.keySet().iterator().next();
}
Also used : SettableEnumValue(com.bitwig.extension.controller.api.SettableEnumValue) Map(java.util.Map)

Aggregations

SettableEnumValue (com.bitwig.extension.controller.api.SettableEnumValue)4 Map (java.util.Map)2 Setting (com.bitwig.extension.controller.api.Setting)1 IActionSetting (de.mossgrabers.framework.configuration.IActionSetting)1 IValueObserver (de.mossgrabers.framework.observer.IValueObserver)1 TreeMap (java.util.TreeMap)1