Old 09-01-2019, 08:45 AM   #1
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,335
Default lua gfx help

Hey Guys,

I have the following code which opens a graphic of a vertical MIDI keyboard.
What I'd like to do now is when the mouse is over specific keys other graphics should open/close automatically.

Each key is aprox. 30 x 120, black keys are a little shorter. Detection zone does'nt have to be exact, just a few pix in each direction should work.

So when mouse is over key 1, "mygraphic001.png" should auto-open aprox. 100 pix to the right of the cursor, when mouse is over key 2, "mygraphic001.png" should close and "mygraphic002.png" should open.., etc.

Any help whould be greatly appreciated.

Code:
function Init()
  --- Init window ---
  gfx.clear = 0xF0F0F0
  gui = {w = 364, h = 975 , dock = 0, x = 1920, y = 3}
  gfx.loadimg(0,"C:\\Pictures\\kybd.png")         
  gfx.init("Keyboard", gui.w, gui.h, gui.dock, gui.x, gui.y)
  gfx.blit(0,1.0,0.0)
end

function  loop()
  char = gfx.getchar()
  if char~=-1 then reaper.defer(loop) end 
  gfx.update()
end

Init()
loop()
Anton9 is offline   Reply With Quote
Old 09-01-2019, 01:20 PM   #2
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,688
Default

What is the current behavior and what did you try already?
And do you mean hovering or clicking a midi-note?
Where shall the other graphics appear?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is online now   Reply With Quote
Old 09-01-2019, 11:48 PM   #3
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,335
Default

So basically what I'm using this for is a reference aid that shows me what scripts/actions I have mapped to a MIDI controller. When the script is executed it displays a MIDI kybd and on each key is written what is assigned. For example I have one that shows various playrates that I have mapped to MIDI notes, another shows grid divisions that are mapped.
This is meant to be just a visual aid, so I don't have to remember hundreds of assignments.

This one I would like to pop open various graphics when each key is hovered over. The graphics should open aprox. 100 pixels to the right of the kybd graphic. As I hover over each key a different graphic should pop open and the previous one should close.

I just don't know how to program the mouse hover and pop open/close code.

For anyone trying the code I posted.., two things to take note of;
1) Change this line, gfx.loadimg(0,"C:\\Pictures\\kybd.png") to point to whatever graphic you would like displayed.
2) This is being used on a dual monitor system so you may also need to change "x = 1920" to whatever is suitable for your setup.

Cheers

Last edited by Anton9; 09-01-2019 at 11:54 PM.
Anton9 is offline   Reply With Quote
Old 09-02-2019, 04:40 AM   #4
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,688
Default

Ok. I could attempt an example which would show you how to do hovering and displaying but could write that only at the end of the week.
Unless someone else can do it faster
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is online now   Reply With Quote
Old 09-02-2019, 06:44 AM   #5
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,335
Default

That would be awesome.., thanks mespotine.
Anton9 is offline   Reply With Quote
Old 09-02-2019, 07:04 AM   #6
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,439
Default

I think the quickest and least headache-inducing solution would be to use my GUI library. You can still draw the keyboard image yourself with the code you've got above, although you'd have to redraw it on each graphics update.

PM me if you're interested and I can help you get started.
Lokasenna is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.