Add ability in the editor to change the user directory
This commit is contained in:
parent
0cb1b67bfa
commit
ccdba9d6c7
6 changed files with 94 additions and 9 deletions
|
|
@ -11,7 +11,7 @@ widget_class mainView {open
|
|||
class Background
|
||||
}
|
||||
Fl_Group {} {
|
||||
comment {theme=darkTheme} open
|
||||
comment {theme=darkTheme}
|
||||
xywh {0 0 800 110}
|
||||
class LogicalGroup
|
||||
} {
|
||||
|
|
@ -138,7 +138,7 @@ widget_class mainView {open
|
|||
}
|
||||
}
|
||||
Fl_Group {subPanels_[kPanelGeneral]} {
|
||||
xywh {5 110 791 285}
|
||||
xywh {5 110 791 285} hide
|
||||
class LogicalGroup
|
||||
} {
|
||||
Fl_Group {} {open
|
||||
|
|
@ -213,7 +213,7 @@ widget_class mainView {open
|
|||
}
|
||||
}
|
||||
Fl_Group {subPanels_[kPanelSettings]} {open
|
||||
xywh {5 109 790 286} hide
|
||||
xywh {5 109 790 316}
|
||||
class LogicalGroup
|
||||
} {
|
||||
Fl_Group {} {
|
||||
|
|
@ -304,8 +304,25 @@ widget_class mainView {open
|
|||
class ValueMenu
|
||||
}
|
||||
}
|
||||
Fl_Group userFilesGroup_ {
|
||||
label Files open selected
|
||||
xywh {620 270 139 100} box ROUNDED_BOX labelsize 12 align 17
|
||||
class TitleGroup
|
||||
} {
|
||||
Fl_Box {} {
|
||||
label {User SFZ folder}
|
||||
xywh {640 290 100 25} labelsize 12
|
||||
class ValueLabel
|
||||
}
|
||||
Fl_Button userFilesDirButton_ {
|
||||
label DefaultPath
|
||||
comment {tag=kTagChooseUserFilesDir}
|
||||
xywh {640 330 100 25} labelsize 12
|
||||
class ValueButton
|
||||
}
|
||||
}
|
||||
}
|
||||
Fl_Box piano_ {selected
|
||||
Fl_Box piano_ {
|
||||
xywh {5 400 790 70} labelsize 12
|
||||
class Piano
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ enum class EditId : int {
|
|||
ScalaRootKey,
|
||||
TuningFrequency,
|
||||
StretchTuning,
|
||||
CanEditUserFilesDir,
|
||||
UserFilesDir,
|
||||
UINumCurves,
|
||||
UINumMasters,
|
||||
UINumGroups,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
|
|||
kTagSetScalaRootKey,
|
||||
kTagSetTuningFrequency,
|
||||
kTagSetStretchedTuning,
|
||||
kTagChooseUserFilesDir,
|
||||
kTagFirstChangePanel,
|
||||
kTagLastChangePanel = kTagFirstChangePanel + kNumPanels - 1,
|
||||
};
|
||||
|
|
@ -86,6 +87,9 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
|
|||
CControl *stretchedTuningSlider_ = nullptr;
|
||||
CTextLabel* stretchedTuningLabel_ = nullptr;
|
||||
|
||||
STitleContainer* userFilesGroup_ = nullptr;
|
||||
STextButton* userFilesDirButton_ = nullptr;
|
||||
|
||||
CTextLabel* infoCurvesLabel_ = nullptr;
|
||||
CTextLabel* infoMastersLabel_ = nullptr;
|
||||
CTextLabel* infoGroupsLabel_ = nullptr;
|
||||
|
|
@ -118,6 +122,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
|
|||
void changeToNextSfzFile(long offset);
|
||||
void chooseScalaFile();
|
||||
void changeScalaFile(const std::string& filePath);
|
||||
void chooseUserFilesDir();
|
||||
|
||||
static bool scanDirectoryFiles(const fs::path& dirPath, std::function<bool(const fs::path&)> filter, std::vector<fs::path>& fileNames);
|
||||
|
||||
|
|
@ -125,6 +130,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
|
|||
|
||||
void updateSfzFileLabel(const std::string& filePath);
|
||||
void updateScalaFileLabel(const std::string& filePath);
|
||||
void updateUserFilesDirLabel(const std::string& filePath);
|
||||
static void updateLabelWithFileName(CTextLabel* label, const std::string& filePath, absl::string_view removedSuffix);
|
||||
static void updateButtonWithFileName(STextButton* button, const std::string& filePath, absl::string_view removedSuffix);
|
||||
static void updateSButtonWithFileName(STextButton* button, const std::string& filePath, absl::string_view removedSuffix);
|
||||
|
|
@ -268,6 +274,17 @@ void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v)
|
|||
updateStretchedTuningLabel(value);
|
||||
}
|
||||
break;
|
||||
case EditId::CanEditUserFilesDir:
|
||||
{
|
||||
if (STitleContainer* group = userFilesGroup_)
|
||||
group->setVisible(v.to_float());
|
||||
break;
|
||||
}
|
||||
case EditId::UserFilesDir:
|
||||
{
|
||||
updateUserFilesDirLabel(v.to_string());
|
||||
break;
|
||||
}
|
||||
case EditId::UINumCurves:
|
||||
{
|
||||
const int value = static_cast<int>(v.to_float());
|
||||
|
|
@ -836,6 +853,22 @@ void Editor::Impl::changeScalaFile(const std::string& filePath)
|
|||
updateScalaFileLabel(filePath);
|
||||
}
|
||||
|
||||
void Editor::Impl::chooseUserFilesDir()
|
||||
{
|
||||
SharedPointer<CNewFileSelector> fs = owned(
|
||||
CNewFileSelector::create(frame_, CNewFileSelector::kSelectDirectory));
|
||||
|
||||
fs->setTitle("Set user files directory");
|
||||
|
||||
if (fs->runModal()) {
|
||||
UTF8StringPtr dir = fs->getSelectedFile(0);
|
||||
if (dir) {
|
||||
updateUserFilesDirLabel(dir);
|
||||
ctrl_->uiSendValue(EditId::UserFilesDir, std::string(dir));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Editor::Impl::scanDirectoryFiles(const fs::path& dirPath, std::function<bool(const fs::path&)> filter, std::vector<fs::path>& fileNames)
|
||||
{
|
||||
std::error_code ec;
|
||||
|
|
@ -898,6 +931,11 @@ void Editor::Impl::updateScalaFileLabel(const std::string& filePath)
|
|||
updateButtonWithFileName(scalaFileButton_, filePath, ".scl");
|
||||
}
|
||||
|
||||
void Editor::Impl::updateUserFilesDirLabel(const std::string& filePath)
|
||||
{
|
||||
updateButtonWithFileName(userFilesDirButton_, filePath, {});
|
||||
}
|
||||
|
||||
void Editor::Impl::updateLabelWithFileName(CTextLabel* label, const std::string& filePath, absl::string_view removedSuffix)
|
||||
{
|
||||
if (!label)
|
||||
|
|
@ -1137,6 +1175,13 @@ void Editor::Impl::valueChanged(CControl* ctl)
|
|||
updateStretchedTuningLabel(value);
|
||||
break;
|
||||
|
||||
case kTagChooseUserFilesDir:
|
||||
if (value != 1)
|
||||
break;
|
||||
|
||||
Call::later([this]() { chooseUserFilesDir(); });
|
||||
break;
|
||||
|
||||
default:
|
||||
if (tag >= kTagFirstChangePanel && tag <= kTagLastChangePanel) {
|
||||
int panelId = tag - kTagFirstChangePanel;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ enterTheme(defaultTheme);
|
|||
LogicalGroup* const view__28 = createLogicalGroup(CRect(5, 110, 796, 395), -1, "", kCenterText, 14);
|
||||
subPanels_[kPanelGeneral] = view__28;
|
||||
view__0->addView(view__28);
|
||||
view__28->setVisible(false);
|
||||
RoundedGroup* const view__29 = createRoundedGroup(CRect(0, 0, 175, 280), -1, "", kCenterText, 14);
|
||||
view__28->addView(view__29);
|
||||
Label* const view__30 = createLabel(CRect(15, 10, 75, 35), -1, "Curves:", kLeftText, 14);
|
||||
|
|
@ -104,10 +105,9 @@ RoundedGroup* const view__41 = createRoundedGroup(CRect(0, 0, 790, 285), -1, "",
|
|||
view__40->addView(view__41);
|
||||
Label* const view__42 = createLabel(CRect(0, 0, 790, 285), -1, "Controls not available", kCenterText, 40);
|
||||
view__41->addView(view__42);
|
||||
LogicalGroup* const view__43 = createLogicalGroup(CRect(5, 109, 795, 395), -1, "", kCenterText, 14);
|
||||
LogicalGroup* const view__43 = createLogicalGroup(CRect(5, 109, 795, 425), -1, "", kCenterText, 14);
|
||||
subPanels_[kPanelSettings] = view__43;
|
||||
view__0->addView(view__43);
|
||||
view__43->setVisible(false);
|
||||
TitleGroup* const view__44 = createTitleGroup(CRect(255, 26, 535, 126), -1, "Engine", kCenterText, 12);
|
||||
view__43->addView(view__44);
|
||||
ValueMenu* const view__45 = createValueMenu(CRect(25, 60, 85, 85), kTagSetNumVoices, "", kCenterText, 12);
|
||||
|
|
@ -150,6 +150,14 @@ view__51->addView(view__59);
|
|||
ValueMenu* const view__60 = createValueMenu(CRect(170, 60, 200, 85), kTagSetScalaRootKey, "", kCenterText, 12);
|
||||
scalaRootOctaveSlider_ = view__60;
|
||||
view__51->addView(view__60);
|
||||
Piano* const view__61 = createPiano(CRect(5, 400, 795, 470), -1, "", kCenterText, 12);
|
||||
piano_ = view__61;
|
||||
view__0->addView(view__61);
|
||||
TitleGroup* const view__61 = createTitleGroup(CRect(615, 161, 754, 261), -1, "Files", kCenterText, 12);
|
||||
userFilesGroup_ = view__61;
|
||||
view__43->addView(view__61);
|
||||
ValueLabel* const view__62 = createValueLabel(CRect(20, 20, 120, 45), -1, "User SFZ folder", kCenterText, 12);
|
||||
view__61->addView(view__62);
|
||||
ValueButton* const view__63 = createValueButton(CRect(20, 60, 120, 85), kTagChooseUserFilesDir, "DefaultPath", kCenterText, 12);
|
||||
userFilesDirButton_ = view__63;
|
||||
view__61->addView(view__63);
|
||||
Piano* const view__64 = createPiano(CRect(5, 400, 795, 470), -1, "", kCenterText, 12);
|
||||
piano_ = view__64;
|
||||
view__0->addView(view__64);
|
||||
|
|
|
|||
|
|
@ -239,6 +239,10 @@ instantiate(const LV2UI_Descriptor *descriptor,
|
|||
self->editor.reset(editor);
|
||||
editor->open(*uiFrame);
|
||||
|
||||
// user files dir is not relevant to LV2 (not yet?)
|
||||
// LV2 has its own path management mechanism
|
||||
self->uiReceiveValue(EditId::CanEditUserFilesDir, 0);
|
||||
|
||||
*widget = reinterpret_cast<LV2UI_Widget>(uiFrame->getPlatformFrame()->getPlatformRepresentation());
|
||||
|
||||
if (self->resize)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "SfizzVstEditor.h"
|
||||
#include "SfizzVstState.h"
|
||||
#include "SfizzFileScan.h"
|
||||
#include "editor/Editor.h"
|
||||
#include "editor/EditIds.h"
|
||||
#if !defined(__APPLE__) && !defined(_WIN32)
|
||||
|
|
@ -73,6 +74,10 @@ bool PLUGIN_API SfizzVstEditor::open(void* parent, const VSTGUI::PlatformType& p
|
|||
|
||||
editor->open(*frame);
|
||||
|
||||
absl::optional<fs::path> userFilesDir = SfizzPaths::getSfzConfigDefaultPath();
|
||||
uiReceiveValue(EditId::CanEditUserFilesDir, 1);
|
||||
uiReceiveValue(EditId::UserFilesDir, userFilesDir.value_or(fs::path()).u8string());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -242,6 +247,10 @@ void SfizzVstEditor::uiSendValue(EditId id, const EditValue& v)
|
|||
normalizeAndSet(kPidStretchedTuning, kParamStretchedTuningRange, v.to_float());
|
||||
break;
|
||||
|
||||
case EditId::UserFilesDir:
|
||||
SfizzPaths::setSfzConfigDefaultPath(fs::u8path(v.to_string()));
|
||||
break;
|
||||
|
||||
case EditId::UIActivePanel:
|
||||
uiState_.activePanel = static_cast<int32>(v.to_float());
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue