Old 12-28-2016, 10:44 AM   #81
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 1,714
Default

no no , the problem is much more complicated ,the context is the folder behavior in my script.now I need to make uuid for all item chunks in order to not get mixed up with other item chunks (which happens when standalone track item chunks get deleted). When that happens that chunk in norm_val2 get removed with table.remove so everything is still ok,but then item chunk AFTER that deleted one gets is key,so when calling folder items the new one gets mixed up with deleted one (i get item that is not stored in folder). So it crossed my mind just to nil the key instead using table.remove so the next value will stil have same key. But that obviously does not work with current implementation of this script that is the core of mine (I'm talking about classes here). If this would work then I dont need UUID-s for every chunk (need to re-code everything). This would act as an uuid because if chunk is on key[4] then 4 is his UUID. To help explain little better (i think this above does not make any sence ) here is the pic of my table what it looks like when I delete one chunk:
Before delete I have norm_val2 1-2-3

After delete I only have 1-3 but norm_val is calculated as #norm_val2 which is 2 which is correct because table consist only 2 keys, but key[2] does not exist

but here script breaks because when selecting 2 norm_val it looks for [2] but on that possition there is nothing.Even the box 3 is not drawed (only 1 )because it expects it to be [2] but it is really [3]
__________________
https://github.com/GoranKovac - I absolutely don't get it
Sexan is offline   Reply With Quote
Old 12-28-2016, 11:03 AM   #82
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,179
Default

- Setting a key to nil is the same as removing it with table.remove

- It's not typically a good idea to remove items from a table while you're in the middle of looping through it; Lua can start getting confused.

- When it gives you a length of 2 after removing that chunk, it's by accident. Lua doesn't have a way of calculating the length of a table if there are values missing, unless you want to write a function for it yourself. If you had a separate variable that stores the highest key number in the table, you could always do:
Code:
 for i = 1, table_length do
   if table[i] then
      -- do stuff
   end
end
That way it'll check to see if value 2 exists before processing it.

- Could you make a placeholder chunk and then, rather than removing x.norm_val2.2, setting x.norm_val2.2 = empty_chunk? Give it a blank name, have your functions check against that name so they don't try to process it, etc?

Last edited by Lokasenna; 12-28-2016 at 11:11 AM.
Lokasenna is offline   Reply With Quote
Old 12-28-2016, 11:22 AM   #83
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 1,714
Default

The best way to see this what happens is add this line to your script:
Code:
radio2.onRightClick = function()
radio2.norm_val2[radio2.norm_val] = nil
end
add 3 buttons and remove the middle one

yeah I think it is the best to just make it "empty_chunk" rather than this black magic I'm doing thank you for your help
__________________
https://github.com/GoranKovac - I absolutely don't get it
Sexan is offline   Reply With Quote
Old 12-28-2016, 11:56 AM   #84
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,179
Default

Actually, you might be okay just doing this:
Code:
x.norm_val2[2] = {}
Rather than setting it to nil, you're just leaving an empty table there. Your other functions will still have to check if it's empty though, which you can easily do by checking for a value that every chunk has to have:
Code:
if x.norm_val2[i].name then
Lokasenna is offline   Reply With Quote
Old 12-28-2016, 03:07 PM   #85
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 1,714
Default

well this for now works MUCH better,but only thing that refuses to cooperate right now is norm_val for some reason,it still switches between two values (1 and 2) even the norm_val2 is 3
__________________
https://github.com/GoranKovac - I absolutely don't get it

Last edited by Sexan; 12-28-2016 at 03:16 PM.
Sexan is offline   Reply With Quote
Old 12-28-2016, 03:39 PM   #86
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,179
Default

Don't forget that norm_val and norm_val2 are completely separate; if you insert or remove something from 2, you need the adjust the string of names for 1 yourself.
Lokasenna is offline   Reply With Quote
Old 06-06-2017, 01:13 PM   #87
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,297
Default

@eugen2777,

Do you still plan on releasing the GUI designer version shown here?
http://forum.cockos.com/showpost.php...67&postcount=7

I really hope so because it would really speed up and simplify the design/layout process.

Thank you
Anton9 is offline   Reply With Quote
Old 06-06-2017, 01:25 PM   #88
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,297
Default

@Lokasenna,

If you still have your version found here ↓↓↓ could you please repost it?
http://forum.cockos.com/showpost.php...1&postcount=66

Also if you have the time, could you possibly add a txt edit box object with a simple example function like maybe changing the master BPM or something?

Than you
Anton9 is offline   Reply With Quote
Old 06-06-2017, 01:33 PM   #89
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,297
Default

@eugen2777 or Lokasenna,

Is it possible to add triggering of the GUI buttons via MIDI?
If so, would one of you be willing to add an example?

Thanks!
Anton9 is offline   Reply With Quote
Old 06-06-2017, 03:21 PM   #90
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 524
Default

Quote:
Originally Posted by Anton9 View Post
@Lokasenna,

If you still have your version found here ↓↓↓ could you please repost it?
http://forum.cockos.com/showpost.php...1&postcount=66

Also if you have the time, could you possibly add a txt edit box object with a simple example function like maybe changing the master BPM or something?

Than you
Hi - you can find my mod of Eugene's script here - the file is called eGUI.lua

It has Lokasenna's changes and some extra stuff I added (layers, vertical range sliders, reworked knobs, reworked check boxes and radio buttons, and text boxes although they don't accept text, just display it, I also changed the zoom to discrete steps), it's modularised for import to other scripts. If you need help getting it working, the Midi ex Machina script has many examples... Or, you can PM me if you get stuck.

Not sure about adding incoming midi support....

Cheers
Rob
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen

Last edited by RobU; 06-06-2017 at 03:32 PM.
RobU is offline   Reply With Quote
Old 06-07-2017, 12:53 AM   #91
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,297
Default

RobU,

Thank you, I will check out your version. ...oh by the way your MIDI Ex Machina is a pretty fun little tool, so thanks for that as well.

Cheers!
Anton9 is offline   Reply With Quote
Old 06-09-2017, 11:11 AM   #92
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,179
Default

Quote:
Originally Posted by Anton9 View Post
@Lokasenna,

If you still have your version found here ↓↓↓ could you please repost it?
http://forum.cockos.com/showpost.php...1&postcount=66

Also if you have the time, could you possibly add a txt edit box object with a simple example function like maybe changing the master BPM or something?

Than you
Dropbox killed all public links a while back.

Here: https://www.dropbox.com/s/hk02ph9ld3...0mods.lua?dl=1

As for further additions, I'll have to say no - I have my own GUI library with way more elements, tools, etc than this template so it would be a little silly to just keep porting things over. I'll upload the newest version to my thread for it later, maybe.
Lokasenna is offline   Reply With Quote
Old 06-10-2017, 02:17 PM   #93
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,297
Default

Thank you Lokasenna, I'll have a look at your library as well.
Anton9 is offline   Reply With Quote
Old 06-18-2017, 04:00 PM   #94
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 6,881
Default

Thank you Eugen.

Question: I'm trying to use this to draw a persistent text when a button is clicked, but currently it immediately disappears. How can I prevent this ?



The (simple example) code I have:

Code:
  btn1.onClick = 
    function()   
    
      gfx.setfont(1,"Arial", 24) 
      gfx.x, gfx.y = 20, 60
      gfx.drawstr("clicked")
  
    end 
   btn2.onClick = 
    function() 
      gfx.setfont(1,"Arial", 24) 
      gfx.x, gfx.y = 80,60
      gfx.drawstr("clicked")
    end

Last edited by nofish; 06-18-2017 at 04:14 PM.
nofish is offline   Reply With Quote
Old 06-19-2017, 12:53 AM   #95
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 524
Default

Quote:
Originally Posted by nofish View Post
Thank you Eugen.

Question: I'm trying to use this to draw a persistent text when a button is clicked, but currently it immediately disappears. How can I prevent this ?



The (simple example) code I have:

Code:
  btn1.onClick = 
    function()   
    
      gfx.setfont(1,"Arial", 24) 
      gfx.x, gfx.y = 20, 60
      gfx.drawstr("clicked")
  
    end 
   btn2.onClick = 
    function() 
      gfx.setfont(1,"Arial", 24) 
      gfx.x, gfx.y = 80,60
      gfx.drawstr("clicked")
    end
Hi,

The screen is refreshed every 1/30th sec (approx), and your call to draw string happens only once when the button is click and so is drawn only on the next screen update. To have something appear persistently, it needs to be redrawn every cycle.

I don't have an easy example to hand, but the link I posted for Anton earlier contains my fork/mod of Eugen's script with an example script. The Info tab displays some text persistently, but it's stored in a Textbox element which is drawn every cycle with the rest of the GUI.

I also added a method element:getSetLabel(string) - which does what it says on the tin..

Code:
    btn1.onClick = function()   
        someTextbox:getSetLabel("clicked")
    end
If you didn't want to create an extra text box, you could update the button label itself, or the button colour if you don't want the text to change...

Code:
    btn1.onClick = function()   
        btn1:getSetColour(col_table)
    end
Alternatively, you could store the text to be drawn in a variable, and toggle some other state variable to have it displayed or not when you click the button.



Does that help?
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen

Last edited by RobU; 06-19-2017 at 12:59 AM.
RobU is offline   Reply With Quote
Old 06-19-2017, 08:44 AM   #96
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 6,881
Default

Quote:
Originally Posted by RobU View Post
Alternatively, you could store the text to be drawn in a variable, and toggle some other state variable to have it displayed or not when you click the button.
This worked fine for the purpose. Thanks.
nofish is offline   Reply With Quote
Old 06-19-2017, 10:16 AM   #97
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 2
Default

Hi all,

I resuming this old thread to ask to you these (maybe) basic options.
First of all, you are genes!

I would like to return the value of another component by pressing the btn1 key (for example in ShowConsoleMsg).
For example the values of sliders, or the number of "Select Track" or "Mode" value.
The values of Radio1 and Check
I tried with ch_box1.val, ch_box1.lbl, ch_box1.value...
AHHHHhh, don't work!
Can you help me, please.

Thx
lollo is offline   Reply With Quote
Old 06-19-2017, 11:01 PM   #98
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 524
Default

Quote:
Originally Posted by lollo View Post
Hi all,

I resuming this old thread to ask to you these (maybe) basic options.
First of all, you are genes!

I would like to return the value of another component by pressing the btn1 key (for example in ShowConsoleMsg).
For example the values of sliders, or the number of "Select Track" or "Mode" value.
The values of Radio1 and Check
I tried with ch_box1.val, ch_box1.lbl, ch_box1.value...
AHHHHhh, don't work!
Can you help me, please.

Thx
Hi, lollo

What happens when you try to access the element variable? Does it stop the script and give an error, or do you get a nil value?


Rob
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen
RobU is offline   Reply With Quote
Old 06-20-2017, 02:10 AM   #99
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 2
Default

Quote:
Originally Posted by RobU View Post
Hi, lollo

What happens when you try to access the element variable? Does it stop the script and give an error, or do you get a nil value?


Rob
Hi Robu,

thank'you for your answer. I just solved the problem. There was an error in my code.
The solution was move the code "onclick" down in the script. :-)

Another thing: how is possible to add a textfiled form in this interface?

Thx

Last edited by lollo; 06-20-2017 at 04:58 AM.
lollo is offline   Reply With Quote
Old 06-21-2017, 05:02 AM   #100
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 524
Default

Quote:
Originally Posted by lollo View Post
Hi Robu,

thank'you for your answer. I just solved the problem. There was an error in my code.
The solution was move the code "onclick" down in the script. :-)

Another thing: how is possible to add a textfiled form in this interface?

Thx
Ok, glad you got it sorted

Do you mean a text entry box? Currently no, there is only a text display element - however, Schwa posted some code for text entry and it should be /reasonably/ easy to port over, however I don't have a lot of free time at the moment, but I will take a look when I get a chance.

If you really need one before I get around to it, then Lokasenna's GUI template has one, and a lot more besides - and it looks pretty cool too

http://forum.cockos.com/showthread.php?t=177772

There's a tutorial thread for that too somewhere in the forum...


Cheers
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen
RobU 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 03:22 AM.


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