New programmer need help (onNanoDisplay and onMouse)

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
User avatar
marbangens
Established Member
Posts: 21
Joined: Fri Nov 16, 2018 8:39 pm

New programmer need help (onNanoDisplay and onMouse)

Post 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

User avatar
marbangens
Established Member
Posts: 21
Joined: Fri Nov 16, 2018 8:39 pm

Re: New programmer need help (onNanoDisplay and onMouse)

Post 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};

rghvdberg
Established Member
Posts: 959
Joined: Mon May 12, 2014 7:11 am

Re: New programmer need help (onNanoDisplay and onMouse)

Post by rghvdberg »

You'll need to add the idleCallback.
I'll have a look at your code later.

jpcima
Established Member
Posts: 5
Joined: Tue Aug 13, 2019 6:18 am

Re: New programmer need help (onNanoDisplay and onMouse)

Post by jpcima »

Hi. I think you should update your value, and then call repaint() on the UI.

rghvdberg
Established Member
Posts: 959
Joined: Mon May 12, 2014 7:11 am

Re: New programmer need help (onNanoDisplay and onMouse)

Post 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.

rghvdberg
Established Member
Posts: 959
Joined: Mon May 12, 2014 7:11 am

Re: New programmer need help (onNanoDisplay and onMouse)

Post 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

User avatar
marbangens
Established Member
Posts: 21
Joined: Fri Nov 16, 2018 8:39 pm

Re: New programmer need help (onNanoDisplay and onMouse)

Post 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?

User avatar
marbangens
Established Member
Posts: 21
Joined: Fri Nov 16, 2018 8:39 pm

Re: New programmer need help (onNanoDisplay and onMouse)

Post by marbangens »

I't Works!! I dide't see it at first, cus I thought my circles where another size :roll: :lol: :oops:

Post Reply