Page 1 of 1

New programmer need help (onNanoDisplay and onMouse)

Posted: Tue Aug 13, 2019 8:17 pm
by marbangens
I try to make Nano draw "dotts" on the screen while the mouse is clicked, hold down and moving.
I want to paint on the UI screen whit the mouse, simple.

How do I connect the functions inside my class to do this? I tried for 3 days 100 different things.

code is not long you only need to look at 2 small files. DistoTVUI.cpp and .hpp
https://github.com/martinbangens/DistoTV

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 8:19 am
by marbangens
It seem to me that the problem is that the screen wont get updated or re-drawn after I change the value of the array for the line with the mouse. onNanoDisplay get executed 2 times when the program starts. Then it wont update the screen, even if I call onNanoDisplay again after it wont re-draw.

I see that its possible to change the "position of dots"(the visual line) by defining values
from the start like this.

Code: Select all

int line[190] = {1,2,3,4,5,6,7,8};

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 12:34 pm
by rghvdberg
You'll need to add the idleCallback.
I'll have a look at your code later.

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 12:39 pm
by jpcima
Hi. I think you should update your value, and then call repaint() on the UI.

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 2:51 pm
by rghvdberg
bit of pseudo code

Code: Select all

onMouse() 
    if (mousePress and UI.contains(x.y)
         bool mouseDown is true

onMotion() 
    if (mouseDown and UI.contains(x,y))
        get new x,y
        repaint(); // 
repaint() is real code :wink:
https://distrho.github.io/DPF/classWindow.html
if the repaint is too stuttery then you need idleCallback(), but we'll cross that bridge when we get there.

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 2:52 pm
by rghvdberg
Also, why do you need nanovg ?
if you are using image widgets :?:

for drawing you can use DGL code or plain old opengl
zam audio has some good examples
https://github.com/zamaudio/zam-plugins ... ynthUI.cpp

if you want, hop on irc freenode #lad, I'm often there.
or join my matrix room
http://riot.im/app/#/room/#clearlybroke ... ction=chat

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 4:05 pm
by marbangens
Hey all, wow thanks for the replies and the support <3
repaint() did it kind of.. Now I got 2 lines one strait and one whit curves :lol:
I though NanoVG was gonna be easy for this stuff, that's why :D . idel callback what is that?
In the documentation I saw something about NanoVG use "states" to redraw the screen?

Re: New programmer need help (onNanoDisplay and onMouse)

Posted: Wed Aug 14, 2019 4:35 pm
by marbangens
I't Works!! I dide't see it at first, cus I thought my circles where another size :roll: :lol: :oops: