DPF icon indicating copy to clipboard operation
DPF copied to clipboard

Add SVG support + basic MidiKeyboard example

Open pdesaulniers opened this issue 7 years ago • 6 comments

This PR adds the ability to load and display SVGs in DGL UIs. It also adds an example that demonstrates this feature, along with sendNote.

The loading and rastering is done using NanoSVG. For now, I've added an SVG class, along with a loadFromSVG(const SVG& svg) method in the Image class. Later, there should also be some way to display an SVG as a NanoImage or a Cairo image.

There is something important to consider: right now, SVGs are converted to RGBA arrays. This means that we need to recreate a new image every time we want to change the scale of the image, otherwise it won't look crisp. This is not really compatible with the current 'scaling' feature of DGL, which will make the SVG look blurry after scaling, like a standard image.

As for the MidiKeyboard example, it's a really bare-bones keyboard that sends notes from C4 to C6. 2019-04-29-20:03:55

pdesaulniers avatar Apr 30 '19 00:04 pdesaulniers

@falkTX I've polished a few things, and added some way to play the piano using the computer keyboard (very rudimentary for now, will be improved in another PR).

I guess you can start merging the PR piece by piece. At least, the keyboard widget seems to behave as expected, and I'm not aware of any terrible issue in the code.

pdesaulniers avatar May 01 '19 03:05 pdesaulniers

Hold on, it seems like I broke SVG scaling. I'll need to investigate this tomorrow.

pdesaulniers avatar May 01 '19 03:05 pdesaulniers

Nevermind, seems like it's working fine. Scaling would make the keyboard bigger than the UI, and the keyboard would end up outside of the UI due to a uint underflow.

pdesaulniers avatar May 01 '19 22:05 pdesaulniers

After some thought I decided that it is best to place these sorta widgets into a new repo, like DPF-Widgets or similar in name. So DPF remains small, but we can have the community bring some useful stuff in there.

No time for this now, just letting you know. I welcome proposals for the repo name :)

falkTX avatar Jul 12 '19 10:07 falkTX

Good. Perhaps it would make sense to create a "DISTRHO-Community" organization, and add the repo there.

I guess the repo could contain more than just widgets (utility classes, DSP stuff, etc). In that case, the name "DPF-Widgets" would be too specific.

As for the piano widget: even if it ends up in a different repo, it would still benefit from key-codes support in pugl. I'll try to create a PR for this soon.

pdesaulniers avatar Jul 28 '19 18:07 pdesaulniers

For demonstration purposes, I have updated the piano widget to use keycodes instead of hard-coded QWERTY notes.

pdesaulniers avatar Jul 29 '19 19:07 pdesaulniers