Old 04-06-2016, 07:07 AM   #1
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default Simple gui template for Scripts


Ctrl+left drag - fine tune.
Mouswheel in element supported.
------
For link function to element use use onClick,onMove etc - add onMove etc in elm draw.

Link
__________________
ReaScripts

Last edited by eugen2777; 05-24-2016 at 03:25 AM.
eugen2777 is offline   Reply With Quote
Old 04-06-2016, 10:20 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

Beautiful thanks for sharing !

Maybe a bit more doc about the function parameter could be useful
X-Raym is offline   Reply With Quote
Old 04-06-2016, 11:05 AM   #3
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Any function can be assigned.
As values for the sliders and knobs should be used sldr.norm_val and knb.norm_val.
For very simple example - add string - to sldr.draw
Code:
if self:mouseDown() then a=a+0.2 
           self:set_norm_val()
           if self.onMove then self:onMove() end --Add this string -!!!
        end
its actual for all sliders - but each slider can have self functions
---------------------------------------------------------------------
----------------------------------------------------------------------
--Add this line anywhere after the definition
--Set slider values - x,y,w,h, etc -- ! 
local sldr1 = H_Slider:new(20,20,180,30, 0.7,0.3,0.3,0.5, "Slider1","Arial",17, 0.5 )
  ---Its very simple example!---------------
-- Add function for slider(sldr1) --
 sldr1.onMove = function() Track = reaper.GetSelectedTrack(0,0)
     if Track then reaper.SetMediaTrackInfo_Value( Track , "D_VOL", sldr1.norm_val )    end
 end

Last edited by eugen2777; 04-06-2016 at 11:44 AM.
eugen2777 is offline   Reply With Quote
Old 04-06-2016, 12:17 PM   #4
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,444
Default

Very tidy implementation! If you don't mind, can I borrow your knob code to add a knob to my GUI stuff?
snooks is offline   Reply With Quote
Old 04-06-2016, 12:25 PM   #5
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Sure, no problem.
eugen2777 is offline   Reply With Quote
Old 04-06-2016, 02:42 PM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

@eugen2777
Another type of slider that you could consider is a range slider



This can be handy in some case where you want things to be between x and y

EDIT : also, toggle buttons could be interesting.

Just ideas !)
X-Raym is offline   Reply With Quote
Old 04-06-2016, 03:01 PM   #7
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Yes, this is a good option. I'll do it as soon as the time. In addition, there is an option with mouse configurable elements - change the size, position, add, delete. While it is not quite ready to use.
Some other features


Last edited by eugen2777; 04-06-2016 at 03:25 PM.
eugen2777 is offline   Reply With Quote
Old 04-06-2016, 03:22 PM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

Thanks !

The Interface Creator with muse input is quite impressive !

Would it then be able to export it as code to create a script from it ? or does it commit the code right in the script ? In other words.. could be build script GUI just like that ?
X-Raym is offline   Reply With Quote
Old 04-06-2016, 03:33 PM   #9
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Yes. It's just part of the graphic.
Of course, it is not suitable for complex scripts.
But for simple scripts fit
eugen2777 is offline   Reply With Quote
Old 04-06-2016, 03:42 PM   #10
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

This looks cool!
WyattRice is offline   Reply With Quote
Old 04-06-2016, 06:12 PM   #11
snooks
Human being with feelings
 
Join Date: Sep 2015
Posts: 1,444
Default

Quote:
Originally Posted by eugen2777 View Post
Sure, no problem.
Thanks!
snooks is offline   Reply With Quote
Old 04-06-2016, 08:49 PM   #12
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

I'm a complete noob at lua, but I thought I would ask here of what the possibility would be be to create a listbox?

Thanks, Wyatt
WyattRice is offline   Reply With Quote
Old 04-17-2016, 08:44 AM   #13
noise_construct
Human being with feelings
 
Join Date: Nov 2015
Posts: 1,560
Default

This looks great!
noise_construct is offline   Reply With Quote
Old 04-17-2016, 08:46 AM   #14
memyselfandus
Human being with feelings
 
memyselfandus's Avatar
 
Join Date: Oct 2008
Posts: 1,594
Default

This is great!!
memyselfandus is offline   Reply With Quote
Old 04-17-2016, 10:17 AM   #15
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

@WyattRice
Recently asked here :
LUA: Checkboxes in scripts - Cockos Confederated Forums
X-Raym is offline   Reply With Quote
Old 04-17-2016, 11:15 AM   #16
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: City
Posts: 9,623
Default

Spectacular for amateur coders like me. Knocking out a simple no-gfx button panel would be much easier with a creator like this.

I hope you release that GUI creator in whatever form you can. The libraries are already great.
__________________
Dialogue/FX Editor & Re-Recording Mixer
Using Latch Preview
"My ego comes pre-shrunk" - Randy Thom
airon is online now   Reply With Quote
Old 04-18-2016, 07:40 PM   #17
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,196
Default

This is pretty rad.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 04-19-2016, 01:34 AM   #18
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,584
Default

Quote:
Originally Posted by WyattRice View Post
I'm a complete noob at lua, but I thought I would ask here of what the possibility would be be to create a listbox?

Thanks, Wyatt
Do you mean radio-buttons or a dropdown menubox?
__________________
Dax Liniere
Not dead, building a studio complex in London. (videos)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 04-19-2016, 04:15 PM   #19
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,196
Default

"Listbox" usually means the kind you get from gfx.showmenu.

However, both that and checkboxes/radio buttons would be pretty cool.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 04-19-2016, 06:22 PM   #20
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

Quote:
Originally Posted by daxliniere View Post
Do you mean radio-buttons or a dropdown menubox?
A listbox for an example, in Reaper would be like view track manager, or like sws marker list window.

It has columns and text fields.

The list holds items, you can change text, click on items, then do actions, etc for each item.

This would probably be difficult and time consuming to do in lua, I think?
WyattRice is offline   Reply With Quote
Old 04-20-2016, 01:32 AM   #21
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,584
Default

Quote:
Originally Posted by WyattRice View Post
A listbox for an example, in Reaper would be like...sws marker list window.
Ahhhh, I know it well.
__________________
Dax Liniere
Not dead, building a studio complex in London. (videos)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 05-04-2016, 05:44 PM   #22
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

@Eugen2777
Feature request : ability to increment knobs and slider on mousewheel scroll button when the mouse is over the element

Also, what could be good is knob with steps

And finally, the knobs should be able to update a global value :P

Last edited by X-Raym; 05-05-2016 at 06:19 AM.
X-Raym is offline   Reply With Quote
Old 05-08-2016, 02:26 PM   #23
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

X-Raym,
updated,mousewheel is now supported.
============
For step-knob you can simply override the method for a specific knob.
And this will not affect all other knobs!
For example:
Code:
....
local knb3 = Knob:new(20,140,50,50,  0.7,0.7,0.3,0.4, "K3","Arial",14, 0.5 )
local knb4 = Knob:new(80,140,50,50,  0.3,0.7,0.7,0.4, "K4","Arial",14, 0.5 )
  -- For knb4 Only !!! ------
  function knb4:set_norm_val()
      local x,y,w,h  = self.x,self.y,self.w,self.h
      local step = 0.25
      local VAL = (h-(gfx.mouse_y-y))/h
      if VAL<0 then VAL=0 elseif VAL>1 then VAL=1 end
      self.norm_val = math.floor(VAL/step+0.5)*step
  end
local Knob_TB = {knb1,knb2,knb3,knb4}
....
===========

===========
Quote:
the knobs should be able to update a global value
Values are available at any part of the code, for example, we can simply use the value knb4.norm_val
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-10-2016, 12:01 PM   #24
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,766
Default

eugen2777,
I have a request if possible.
Would it be possible for you to add an editbox element to your template?
http://forum.cockos.com/showpost.php...&postcount=103

Many Thanks,
Wyatt
WyattRice is offline   Reply With Quote
Old 05-11-2016, 08:18 AM   #25
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

WyattRice,Sorry, soon I do not plan to do it, maybe in the future. You could use a script from Schwa. It's ready to use script.
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-11-2016, 09:01 AM   #26
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

@eugen
Thanks !
I am instensively using your btn library on a script I am coding, can't wait to show you :P

I mod it a bit to fit more my needs,
Here are some mods I made
  • No auto update size function, size is deifnitely from the source scripts
  • added optional ID, Function1, Funct2 and Tooltip as element property
  • When btn is pressed, func1 is trigger with ID, 1 as parameter. If it is right click, it is ID, -1 which is return, which allows to set a different thing on right click acion.
  • Funct2 is triggered at mouse hover
Anyway, this library is really cool and easy to implement in a script.

I don't understand all of its core, it quite advanced, but it is very good.
X-Raym is offline   Reply With Quote
Old 05-11-2016, 09:28 AM   #27
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

I can do it, it is not difficult, but it's still a simple template... Minimum. Gui functions should not clutter up the code.
The main(no gui) part should be separate.
By the way, as I have a bit of time doing a range slider and a toggle button


For "No auto update size" - to do this, simply comment out the line
Code:
 --[[ 
    Z_w, Z_h = gfx.w/Wnd_W, gfx.h/Wnd_H
    if Z_w<0.6 then Z_w = 0.6 elseif Z_w>2 then Z_w = 2 end
    if Z_h<0.6 then Z_h = 0.6 elseif Z_h>2 then Z_h = 2 end 
    --]]
__________________
ReaScripts

Last edited by eugen2777; 05-11-2016 at 10:11 AM.
eugen2777 is offline   Reply With Quote
Old 05-11-2016, 10:05 AM   #28
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

@eugen2777
Very COOL !
I'll stay with my custom mod for the script I am coding as it works as expected for me
but I am sure your next class you will be very great !!

Indeed, separating what is GUI and what is the first thing I considered for starting moding :P
X-Raym is offline   Reply With Quote
Old 05-11-2016, 11:22 AM   #29
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Range Slider added.
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-11-2016, 11:13 PM   #30
Spacemen Tree
Human being with feelings
 
Spacemen Tree's Avatar
 
Join Date: Mar 2013
Posts: 484
Default

Man this is huge!!!! Very cool!

Have to check it out as soon as I have more time. Kudos eugen!
__________________
"After silence, that which comes nearest to expressing the inexpressible is music", Aldous Huxley
Spacemen Tree is offline   Reply With Quote
Old 05-12-2016, 04:19 AM   #31
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,196
Default

Curse you for making a range slider before I could get around to it. CURSE YOU I SAY!!!
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 05-12-2016, 05:44 AM   #32
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

Thanks for it !!
X-Raym is offline   Reply With Quote
Old 05-13-2016, 10:07 AM   #33
Aleksandr_Oleynik
Human being with feelings
 
Join Date: Jan 2013
Location: Kiev, Ukraine
Posts: 42
Default

Thanks Eugen
Aleksandr_Oleynik is offline   Reply With Quote
Old 05-13-2016, 12:46 PM   #34
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Well, I would add step-sliders and step-knobs.
Maybe range-knobs.
__________________
ReaScripts
eugen2777 is offline   Reply With Quote
Old 05-13-2016, 02:41 PM   #35
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,196
Default

In the GUI template I'm working on I just included a "steps" parameter for sliders and knobs, and then as you drag it the element snaps to that number of values. For a pan knob you just specify 200 steps- it works really well.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 05-13-2016, 03:58 PM   #36
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

Steps would be very cool indeed !
X-Raym is offline   Reply With Quote
Old 05-14-2016, 07:42 AM   #37
Aleksandr_Oleynik
Human being with feelings
 
Join Date: Jan 2013
Location: Kiev, Ukraine
Posts: 42
Default

It would be cool to make a checkbox
Aleksandr_Oleynik is offline   Reply With Quote
Old 05-16-2016, 10:47 AM   #38
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

Simple checkbox added.

Probably need to change the appearance of the elements( sliders,buttons, etc). Now they look really ugly.
__________________
ReaScripts

Last edited by eugen2777; 05-16-2016 at 10:59 AM.
eugen2777 is offline   Reply With Quote
Old 05-25-2016, 04:49 PM   #39
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,006
Default

@eugen2777

Is this normal ? or did I ake a mistake ? ^^

X-Raym is offline   Reply With Quote
Old 05-25-2016, 05:35 PM   #40
eugen2777
Human being with feelings
 
eugen2777's Avatar
 
Join Date: Aug 2012
Posts: 211
Default

This is normal. You can use the local table = {} etc, for example, to hide its.
Look metatable and metamethods
__________________
ReaScripts

Last edited by eugen2777; 05-25-2016 at 05:40 PM.
eugen2777 is offline   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 01:45 AM.


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