Add support of background image

This commit is contained in:
Jean Pierre Cimalando 2021-04-03 23:58:46 +02:00
parent bbac05281d
commit 06ae5d2f52
4 changed files with 19 additions and 4 deletions

View file

@ -44,6 +44,8 @@ enum class EditId : int {
UINumActiveVoices,
UIActivePanel,
//
BackgroundImage,
//
#undef KEY_RANGE
#undef CC_RANGE
};

View file

@ -443,6 +443,12 @@ void Editor::Impl::uiReceiveValue(EditId id, const EditValue& v)
setActivePanel(value);
}
break;
case EditId::BackgroundImage:
{
const std::string& value = v.to_string();
updateBackgroundImage(value.c_str());
}
break;
default:
if (editIdIsKey(id)) {
const int key = keyForEditId(id);
@ -1541,10 +1547,7 @@ void Editor::Impl::updateSWLastLabel(unsigned sw, const char* label)
void Editor::Impl::updateBackgroundImage(const char* filepath)
{
const fs::path sfzFilePath = fs::u8path(currentSfzFile_);
const fs::path sfzDirPath = sfzFilePath.parent_path();
const fs::path imagePath = sfzDirPath / fs::u8path(filepath);
SharedPointer<CBitmap> bitmap = loadAnyFormatImage(imagePath);
SharedPointer<CBitmap> bitmap = loadAnyFormatImage(filepath);
if (!bitmap)
bitmap = owned(new CBitmap("background.png"));

View file

@ -46,6 +46,7 @@
#include <lv2/patch/patch.h>
#include <lv2/urid/urid.h>
#include <lv2/instance-access/instance-access.h>
#include <ghc/fs_std.hpp>
#include <string>
#include <memory>
#include <cstring>
@ -379,6 +380,10 @@ sfizz_ui_update_description(sfizz_ui_t *self, const InstrumentDescription& desc)
self->uiReceiveValue(EditId::UINumRegions, desc.numRegions);
self->uiReceiveValue(EditId::UINumPreloadedSamples, desc.numSamples);
const fs::path rootPath = fs::u8path(desc.rootPath);
const fs::path imagePath = rootPath / fs::u8path(desc.image);
self->uiReceiveValue(EditId::BackgroundImage, imagePath.u8string());
for (unsigned key = 0; key < 128; ++key) {
bool keyUsed = desc.keyUsed.test(key);
bool keyswitchUsed = desc.keyswitchUsed.test(key);

View file

@ -16,6 +16,7 @@
#if !defined(__APPLE__) && !defined(_WIN32)
#include "X11RunLoop.h"
#endif
#include <ghc/fs_std.hpp>
using namespace VSTGUI;
@ -203,6 +204,10 @@ void PLUGIN_API SfizzVstEditor::update(FUnknown* changedUnknown, int32 message)
uiReceiveValue(EditId::UINumRegions, desc.numRegions);
uiReceiveValue(EditId::UINumPreloadedSamples, desc.numSamples);
const fs::path rootPath = fs::u8path(desc.rootPath);
const fs::path imagePath = rootPath / fs::u8path(desc.image);
uiReceiveValue(EditId::BackgroundImage, imagePath.u8string());
for (unsigned key = 0; key < 128; ++key) {
bool keyUsed = desc.keyUsed.test(key);
bool keyswitchUsed = desc.keyswitchUsed.test(key);