Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
Other
9.16k stars 550 forks source link

Is it feasible to implement a MIDI sequencer in Nuklear? #438

Closed mavavilj closed 2 years ago

mavavilj commented 2 years ago

For example of this kind:

https://static.kvraudio.com/i/b/poly-step-seq-2.jpg

I was struggling to find suitable pre-made components.

dumblob commented 2 years ago

There are currently no pre-made MIDI components as far as I know. But look at how other canvas-like components are implemented (e.g. charts) in Nuklear and you should be ready to make your own.

mavavilj commented 2 years ago

Okay, but I did not find a good reference for explaining charts.

dumblob commented 2 years ago

As we discussed in https://github.com/Immediate-Mode-UI/Nuklear/issues/424 , Nuklear is built around the idea that one'll read the relevant parts of the source code.

In this case it's the implementation of chart functions and other canvas-related functions. It's quite well commented and written in a very readable way. That everything together is the best reference you can even imagine.

mavavilj commented 2 years ago

I've progressed a bit with charts, but now I'm confused about how am I supposed to customize the chart to this need I had. I have been reading the code, such as the part around:

https://github.com/vurtun/nuklear/blob/6b9f937475db9280d966f44f469bc80191b5092a/src/nuklear_chart.c#L214

which shows something related to capturing mouse clicks, which I would need in order to modify the slots or something via mouse clicks.

However, I've been confused as to whether I need to modify:

https://github.com/Immediate-Mode-UI/Nuklear/blob/6e80e2a646f35be4afc157a932f2936392ec8f74/src/nuklear_chart.c

or whether I should, as I thought first (with my limited experience), capture mouse clicks in the main.c (like https://github.com/Immediate-Mode-UI/Nuklear/blob/master/demo/x11/main.c#L170) and redraw the chart.

Based on this https://github.com/vurtun/nuklear/blob/6b9f937475db9280d966f44f469bc80191b5092a/src/nuklear_button.c#L63 the library seems to expect that input handling is done in the respective object's .c file?

Then I also became confused about what the /src/ is for since the same stuff is in nuklear.h:

https://github.com/Immediate-Mode-UI/Nuklear/issues/441

dumblob commented 2 years ago

However, I've been confused as to whether I need to modify:

https://github.com/Immediate-Mode-UI/Nuklear/blob/6e80e2a646f35be4afc157a932f2936392ec8f74/src/nuklear_chart.c

No, no modification to Nuklear sources is necessary nor recommended.

or whether I should, as I thought first (with my limited experience), capture mouse clicks in the main.c (like https://github.com/Immediate-Mode-UI/Nuklear/blob/master/demo/x11/main.c#L170) and redraw the chart.

Yes, this is the correct way. Capture them yourself and conditionally (based on the keys you've captured) call appropriate Nuklear functions - e.g. a button :wink: (which will add all the needed commands for you to the Nuklear command queue which your backend of choice will then render).

Based on this https://github.com/vurtun/nuklear/blob/6b9f937475db9280d966f44f469bc80191b5092a/src/nuklear_button.c#L63 the library seems to expect that input handling is done in the respective object's .c file?

Please don't read old sources. Read only the content of this repository. Nuklear was kind of rewritten several times in the past by @vurtun and thus we really consider only the latest code from this repository from the master branch.

Then I also became confused about what the /src/ is for since the same stuff is in nuklear.h:

441

/src/ is a source for "amalgamation" (i.e. simple joining of all the files into the final nuklear.h by build scripts) - please refer to #441 for answers and further discussion if needed.