@d-healey
Thank you for taking the time to review the code below. You do a lot for the HISE community. You've helped me so much on this project. I really appreciate it!
This is the oninit code:
Content.makeFrontInterface(960, 600);
include("PresetBrowser.js");
// load all Audio Files from the AudioFiles Folder into the Pool
Engine.loadAudioFilesIntoPool();
//Sampler
const var Sampler1 = Synth.getChildSynth("Sampler1");
//Sample maps array
const var sampleMaps = Sampler.getSampleMapList();
//ComboBox
const var cmbSampleBox = Content.getComponent("cmbSampleBox");
cmbSampleBox.set ("items", sampleMaps.join("\n"));
inline function oncmbSampleBoxControl(component, value)
{
Sampler1.asSampler().loadSampleMap(sampleMaps[value-1]);
};
Content.getComponent("cmbSampleBox").setControlCallback(oncmbSampleBoxControl);
This is the PresetBrowser.js
namespace PresetBrowser
{
const NUM_BANKS = 5;
Engine.loadImageIntoPool("*");
const laf = Content.createLocalLookAndFeel();
for (i = 0; i < NUM_BANKS; i++)
laf.loadImage("{PROJECT_FOLDER}bank" + (i + 1) + ".png", "bank" + (i + 1));
laf.registerFunction("drawPresetBrowserBackground", function(g, obj)
{
g.fillAll(0xff0e0e0e);
});
laf.registerFunction("drawPresetBrowserColumnBackground", function(g, obj)
{
var a = obj.area;
switch (obj.columnIndex)
{
case 0: // Bank
g.fillAll(0xff0e0e0e);
break;
case 1: // Category
g.fillAll(0xff0e0e0e);
break;
case 2: // Preset
g.fillAll(0xff0e0e0e);
break;
}
});
laf.registerFunction("drawPresetBrowserListItem", function(g, obj)
{
var a = obj.area;
g.setColour(Colours.withAlpha(0xffffffff, obj.selected ? 0.9 + (obj.hover * 0.2): 0.3 + (obj.hover * 0.2)));
if (obj.columnIndex == 0) // Bank
{
var imgName = "bank" + (obj.rowIndex + 1);
g.drawImage(imgName, a, 0, 0);
}
else // Category and Preset
{
g.setFont("Arial", 14);
g.drawAlignedText(obj.text.toUpperCase(), a, "centred");
}
});
const fltPresetBrowser = Content.getComponent("fltPresetBrowser");
fltPresetBrowser.setLocalLookAndFeel(laf);
const SCROLLBAR_PADDING = 10;
laf.registerFunction('drawScrollbar', function(g, obj) {
var a = obj.handle;
var pa = [
a[0] + SCROLLBAR_PADDING,
a[1] + SCROLLBAR_PADDING,
a[2] - SCROLLBAR_PADDING,
a[3] - SCROLLBAR_PADDING,
];
g.setColour(0xff141414);
g.fillRoundedRectangle(pa, 5);
});
}