Update Fundamental and Rack

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-12-18 20:05:40 +00:00
parent 3943e4c1e9
commit fd1de47874
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
6 changed files with 45 additions and 32 deletions

@ -1 +1 @@
Subproject commit 9ef61963db2c7a03053aa5ff613e35d79335a83c Subproject commit e7c2fe6d54531fd2fd25014dc722a18546393207

View file

@ -30,6 +30,7 @@
#include "AsyncDialog.hpp" #include "AsyncDialog.hpp"
#include "PluginContext.hpp" #include "PluginContext.hpp"
#include <asset.hpp>
#include <context.hpp> #include <context.hpp>
#include <history.hpp> #include <history.hpp>
#include <patch.hpp> #include <patch.hpp>
@ -117,6 +118,30 @@ void loadPathDialog(const std::string& path)
#endif #endif
} }
void loadSelectionDialog()
{
app::RackWidget* const w = APP->scene->rack;
std::string selectionDir = asset::user("selections");
system::createDirectories(selectionDir);
async_dialog_filebrowser(false, selectionDir.c_str(), "Import selection", [w](char* pathC) {
if (!pathC) {
// No path selected
return;
}
try {
w->loadSelection(pathC);
}
catch (Exception& e) {
async_dialog_message(e.what());
}
std::free(pathC);
});
}
void loadTemplateDialog() void loadTemplateDialog()
{ {
#ifndef HEADLESS #ifndef HEADLESS

View file

@ -31,6 +31,7 @@ namespace patchUtils
void loadDialog(); void loadDialog();
void loadPathDialog(const std::string& path); void loadPathDialog(const std::string& path);
void loadSelectionDialog();
void loadTemplateDialog(); void loadTemplateDialog();
void revertDialog(); void revertDialog();
void saveDialog(const std::string& path); void saveDialog(const std::string& path);

View file

@ -239,28 +239,6 @@ static void CardinalModuleWidget__createContextMenu(ModuleWidget* const w,
w->appendContextMenu(menu); w->appendContextMenu(menu);
} }
static void CardinalModuleWidget__loadSelectionDialog(RackWidget* const w)
{
std::string selectionDir = asset::user("selections");
system::createDirectories(selectionDir);
async_dialog_filebrowser(false, selectionDir.c_str(), "Import selection", [w](char* pathC) {
if (!pathC) {
// No path selected
return;
}
try {
w->loadSelection(pathC);
}
catch (Exception& e) {
async_dialog_message(e.what());
}
std::free(pathC);
});
}
static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w) static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w)
{ {
std::string selectionDir = asset::user("selections"); std::string selectionDir = asset::user("selections");
@ -355,11 +333,6 @@ void appendSelectionContextMenu(ui::Menu* const menu)
w->pasteClipboardAction(); w->pasteClipboardAction();
}, false, true)); }, false, true));
// Load
menu->addChild(createMenuItem("Import selection", "", [w]() {
CardinalModuleWidget__loadSelectionDialog(w);
}, false, true));
// Save // Save
menu->addChild(createMenuItem("Save selection as", "", [w]() { menu->addChild(createMenuItem("Save selection as", "", [w]() {
CardinalModuleWidget__saveSelectionDialog(w); CardinalModuleWidget__saveSelectionDialog(w);

@ -1 +1 @@
Subproject commit 704590eb6e462860ae6187ec8bc754af476c1a4e Subproject commit 9ad53329fff74989daf3365600f9fccc0b6f5266

View file

@ -174,6 +174,14 @@ struct FileButton : MenuButton {
patchUtils::revertDialog(); patchUtils::revertDialog();
}, APP->patch->path.empty())); }, APP->patch->path.empty()));
menu->addChild(new ui::MenuSeparator);
// Load selection
menu->addChild(createMenuItem("Import selection", "", [=]() {
// APP->scene->rack->loadSelectionDialog();
patchUtils::loadSelectionDialog();
}, false, true));
if (isStandalone) { if (isStandalone) {
menu->addChild(new ui::MenuSeparator); menu->addChild(new ui::MenuSeparator);
@ -325,13 +333,19 @@ struct CableTensionQuantity : Quantity {
return settings::cableTension; return settings::cableTension;
} }
float getDefaultValue() override { float getDefaultValue() override {
return 0.5; return 0.75;
}
float getDisplayValue() override {
return getValue() * 100;
}
void setDisplayValue(float displayValue) override {
setValue(displayValue / 100);
} }
std::string getLabel() override { std::string getLabel() override {
return "Cable tension"; return "Cable tension";
} }
int getDisplayPrecision() override { std::string getUnit() override {
return 2; return "%";
} }
}; };
struct CableTensionSlider : ui::Slider { struct CableTensionSlider : ui::Slider {