New programmer need help (onNanoDisplay and onMouse)

Programming applications for making music on Linux.

Moderators: khz, MattKingUSA

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

New programmer need help (onNanoDisplay and onMouse)

Postby marbangens » Tue Aug 13, 2019 8:17 pm

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)

Postby marbangens » Wed Aug 14, 2019 8:19 am

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: 920
Joined: Mon May 12, 2014 7:11 am

Re: New programmer need help (onNanoDisplay and onMouse)

Postby rghvdberg » Wed Aug 14, 2019 12:34 pm

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)

Postby jpcima » Wed Aug 14, 2019 12:39 pm

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

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

Re: New programmer need help (onNanoDisplay and onMouse)

Postby rghvdberg » Wed Aug 14, 2019 2:51 pm

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: 920
Joined: Mon May 12, 2014 7:11 am

Re: New programmer need help (onNanoDisplay and onMouse)

Postby rghvdberg » Wed Aug 14, 2019 2:52 pm

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/#clearlybroken:matrix.org?action=chat

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

Re: New programmer need help (onNanoDisplay and onMouse)

Postby marbangens » Wed Aug 14, 2019 4:05 pm

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)

Postby marbangens » Wed Aug 14, 2019 4:35 pm

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


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 2 guests