Old 12-28-2016, 10:44 AM   #81
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,585
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]
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: Calgary, AB, Canada
Posts: 6,551
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?
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate

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: 4,585
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
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: Calgary, AB, Canada
Posts: 6,551
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
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
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: 4,585
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

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: Calgary, AB, Canada
Posts: 6,551
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.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
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,340
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,340
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,340
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
Posts: 863
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
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1

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,340
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: Calgary, AB, Canada
Posts: 6,551
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.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
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,340
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: 12,096
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
Posts: 863
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?
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1

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: 12,096
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: 54
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
Posts: 863
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
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1
RobU is offline   Reply With Quote
Old 06-20-2017, 02:10 AM   #99
lollo
Human being with feelings
 
Join Date: Jun 2017
Posts: 54
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
Posts: 863
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
__________________
Return of the Dub Cadet - https://open.spotify.com/album/2t98A...lQ&dl_branch=1
RobU is offline   Reply With Quote
Old 12-28-2020, 01:13 PM   #101
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

So, I tried my version of the GUI template of MIDI Ex Machina. I made an simpler exemple and commented in it ( I addimit I got lazy at some point ). So I would remember what is what.

I also added the Status bar from lemerchand . And made some tweaks in sliders and knobs now they have the option to be float or integers. Also there was somethings in how the sliders and knobs was draw that I changed.


Edit: now I saw that in the gif I selected Cubase ( it was by accident, never used it , just went clicking random buttons to show the ui)

It still needs an Text Editor. I open up Lokasenna and Amalgama set/get chunk today and tried to copy it, but it is too complicated for me....

https://stash.reaper.fm/v/40937/Script.lua -- An script exemple
https://stash.reaper.fm/v/40936/dl_gui.lua -- The Library
(put in the same folder and run the script)

Last edited by daniellumertz; 12-29-2020 at 05:01 AM.
daniellumertz is offline   Reply With Quote
Old 12-29-2020, 07:04 PM   #102
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

I still use this library from times to times. I like the fact it is both minimalist/understandable and quite extensible.


Scythe is very nice cause it has a lot of complex elements like text input but it is more complex to go under the hood.
X-Raym is offline   Reply With Quote
Old 12-30-2020, 01:36 AM   #103
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Yes I like it, is just missing some text editor. I thought of bringing amagalma or lokasenna to it but it would be a puzzle that I don't have enough xp to do.

It would be easier to create lokasenna classes using this library as a model.

studying lokasenna gui now, is fascinating.
daniellumertz is offline   Reply With Quote
Old 04-28-2022, 03:03 PM   #104
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@daniellumertz
I just tried your library.
I especially like the status bar.
Now to my question:
How can I change the background color?
Thanks
Dragonetti is offline   Reply With Quote
Old 04-28-2022, 04:30 PM   #105
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Have been much time since I don't use this lob . Maybe you need to draw a rectangle In the background.
daniellumertz is offline   Reply With Quote
Old 04-28-2022, 04:52 PM   #106
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

the first version of Eugen (Wnd_bgd)
Code:
function Init()
    -- Some gfx Wnd Default Values --
    local R,G,B = 50,50,50               -- 0..255 form
    local Wnd_bgd = R + G*256 + B*65536  -- red+green*256+blue*65536  
    local Wnd_Title = "CPO"
    local Wnd_Dock,Wnd_X,Wnd_Y = 0,100,240
    Wnd_W,Wnd_H = 1200,160 -- global values(used for define zoom level)
    -- Init window ------
    gfx.clear = Wnd_bgd         
    gfx.init( Wnd_Title, Wnd_W,Wnd_H, Wnd_Dock, Wnd_X,Wnd_Y )
    -- Init mouse last --
    last_mouse_cap = 0
    last_x, last_y = 0, 0
    mouse_ox, mouse_oy = -1, -1
end
would that be the place in your script?
Code:
function InitGFX()
  ----Load extstate:
  __, pExtStateStr = reaper.GetProjExtState(0, script.name, "pExtState")
  if pExtStateStr ~= "" then
    pExtState = unpickle(pExtStateStr)
  end 
  ------------------------------
  ----  Set script.xyd, script.zoom if found in extstate 
  SetDefaultWindowOpts()
  
  gfx.init("CPO",script.w * e.gScale,script.h * e.gScale,script.d,script.x,script.y)
  -----------------
  -- Last mouse position and state:
  gLastMouseCap, gLastMouseX, gLastMouseY = 0, 0, 0
  gMouseOX, gMouseOY = -1, -1
end
Maybe you can take a look there?
I'm done with my script and only have to change the background color.
thanks a lot for your efforts

Last edited by Dragonetti; 04-28-2022 at 05:00 PM.
Dragonetti is offline   Reply With Quote
Old 04-28-2022, 05:39 PM   #107
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

It has been a long long time since I use it...

have you tried

Code:
    local R,G,B = 50,50,50               -- 0..255 form
    local Wnd_bgd = R + G*256 + B*65536  -- red+green*256+blue*65536 
    gfx.clear = Wnd_bgd
before gfx.init?
daniellumertz is offline   Reply With Quote
Old 04-28-2022, 06:01 PM   #108
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Thanks very much
worked great.

May I ask one more general question?
How can I tell a function not to do anything if no items are selected?

Thanks

edit:
I think I managed it myself. let's see if it works
Code:
ItemsSelCount = reaper.CountSelectedMediaItems(0)
if ItemsSelCount ==0 then return
end

Last edited by Dragonetti; 04-28-2022 at 06:09 PM.
Dragonetti is offline   Reply With Quote
Old 04-29-2022, 06:37 AM   #109
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@danillummertz

It might be possible for you to look here again?
Actually everything works great.
I would rather do the grid selection with "e.Rad_Button" instead of "e.Button".
There is no vertical line break (here after 6 entries).
Can you install something like this?

A worse option, which might also work, would be a completely horizontal orientation.
Thank you very much




Code:
--------------------------------------------------------------------------------
--  Radio Button Class Methods
--------------------------------------------------------------------------------
function e.Rad_Button:update_zoom() -- handle window zooming
  if not e.gScaleState then return end
  -- zoom font  
  self.font_sz = math.max(10, self.def_xywh[5] * e.gScale)
  self.font_sz = math.min(28, self.font_sz)
  -- zoom x pos, y pos 
  self.x = math.ceil(self.def_xywh[1] * e.gScale)
  self.y = math.ceil(self.def_xywh[2] * e.gScale)
  -- zoom checkboxes
  self.cbox_w = math.ceil(self.def_xywh[6] * e.gScale)
  self.cbox_h = math.ceil(self.def_xywh[7] * e.gScale)   
  -- zoom width
  local str_w, str_h, max_w = 0, 0, 0
  gfx.setfont(1, self.font, self.font_sz)
  for i = 1, #self.val2 do
    str_w, str_h = gfx.measurestr(self.val2[i])
    if str_w > max_w then max_w = str_w end  
  end
  self.def_xywh[3] = max_w + self.cbox_w + 15
  self.w = math.ceil(self.def_xywh[3])
  -- zoom height  
  self.def_xywh[4] = self.cbox_h * #self.val2
  self.h = math.ceil(self.def_xywh[4]) -- * gZoomH) --scale) 
end
--------------------------------------------------------------------------------
function e.Rad_Button:set_norm_val_m_wheel()
  if gfx.mouse_wheel == 0 then return false end  -- return if m_wheel = 0
  if gfx.mouse_wheel < 0 then self.val1 = math.min(self.val1 + 1, #self.val2) end
  if gfx.mouse_wheel > 0 then self.val1 = math.max(self.val1 - 1, 1) end
  return true
end
--------------------------------------------------------------------------------
function e.Rad_Button:set_val1()
  local y, h = self.y + 2, self.h - 4 -- padding
  local tOptions = self.val2
  local val = math.floor(((gfx.mouse_y - y) / h) * #tOptions) + 1
  if val < 1 then val = 1 elseif val > #tOptions then val = #tOptions end
  self.val1 = val
end
--------------------------------------------------------------------------------
function e.Rad_Button:draw_body()
  local x, y = self.x + 2, self.y -- padding
  local padSize = .25 * e.gScale -- more padding...
  local r = self.cbox_w / 3
  local centerOffset = ((self.cbox_w - (2 * r)) / 2)
  -- adjust the options to be centered
  cx, cy = x + centerOffset, y + centerOffset
  for i = 1, #self.val2 do
    local optY = cy + ((i - 1) * self.cbox_w)
    gfx.circle(cx + r, optY + r, r, false)
    gfx.circle(cx + r, optY + r, r - padSize, false, true)
    if i == self.val1 then
	gfx.circle(cx + r, optY + r, r, true) -- big circle  
	gfx.circle(cx + r, optY + r, r * 0.5, true) -- small circle
	gfx.circle(cx + r, optY + r, r * 0.5, false) -- small frame
    end
  end
end
--------------------------------------------------------------------------------
function e.Rad_Button:draw_vals()
  local x, y, optY = self.x + 2, self.y + 2 -- padding
  local tOptions = self.val2 -- table of options
  -- to match up with the options
  local r = self.cbox_w / 3
  local centerOffset = ((self.optSpacing - (2 * r)) / 2)
  cx, cy = x + self.cbox_w + centerOffset, y + centerOffset
  for i = 1, #tOptions do
    optY = cy + ((i - 1) * self.cbox_w)
    gfx.x, gfx.y = cx, optY
    gfx.drawstr(tOptions[i])
  end
end
--------------------------------------------------------------------------------
function e.Rad_Button:draw_label()
  local x, y = self.x, self.y + 2 -- padding
  local optSpacing = self.optSpacing
  -- to match up with the first option
  local r = self.cbox_w / 3
  local centerOffset = ((self.cbox_w - (2 * r)) / 2)
  y = y + centerOffset
  local labelWidth, labelHeight = gfx.measurestr(self.label)
  gfx.x = x + centerOffset-- labelWidth - 5
  gfx.y = self.y + self.h + labelHeight / 2 
  gfx.drawstr(self.label) 
end
--------------------------------------------------------------------------------
function e.Rad_Button:draw()
  while not self.setup do -- on first run, set the correct width and height
    local str_w, str_h, max_w = 0, 0, 0  
    self.cbox_w, self.cbox_h = self.w, self.h
    gfx.setfont(1, self.font, self.font_sz)
    for i = 1, #self.val2 do
	str_w, str_h = gfx.measurestr(self.val2[i])      
	if str_w > max_w then max_w = str_w end
    end
    self.def_xywh[3] = self.cbox_w + max_w + 15; self.w = self.def_xywh[3]
    self.def_xywh[4] = self.cbox_h * #self.val2; self.h = self.def_xywh[4]
    self.def_xywh[6] = self.cbox_w; self.def_xywh[7] = self.cbox_h
    self.setup = true
  end
  self:update_zoom() -- check and update if window resized
  if (self.tab & (1 << e.gActiveLayer)) == 0 and self.tab ~= 0 then return end 
  self:Display(self.help)
  local a = self.a -- local alpha value required for highlighting the e.Element
  self.optSpacing = (self.h / (#self.val2 or 1)) -- e.Element height / number of options
  if self:mouseIN() then a = a + 0.1 -- if in e.Element, increase opacity 
    if self:set_norm_val_m_wheel() then 
	if self.onLClick then self.onLClick() end 
    end 
  end
  -- in elm L_up(released and was previously pressed)
  if self:mouseLDown() then a = a + 0.2 end -- if e.Element clicked, increase opacity more
  -- in elm L_up(released and was previously pressed)
  if self:mouseLClick() then 
    self:set_val1()
    if self.onLClick then self.onLClick() end -- if mouseL clicked and released, execute onLClick()
  end
  if self:mouseRClick() and self.onRClick then self.onRClick() end -- if mouseR clicked and released, execute onRClick()
  gfx.set(self.r, self.g, self.b, a) -- set the drawing colour for the e.Element
  -- self:draw_frame()  -- looks better without the frame
  self:draw_body()
  gfx.set(table.unpack(self.font_rgba)) -- set label color
  gfx.setfont(1, self.font, self.font_sz) -- set label font 
  self:draw_vals()
  self:draw_label()
end
Dragonetti is offline   Reply With Quote
Old 04-29-2022, 09:21 AM   #110
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Sorry bud I dont have time right now
daniellumertz is offline   Reply With Quote
Old 04-29-2022, 10:10 AM   #111
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Ok, thank you anyway
Dragonetti is offline   Reply With Quote
Old 10-14-2022, 11:57 PM   #112
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

The design is kind of blurry on a Retina Mac Air M1. Can this be improved or should I switch to IMGui?
Dragonetti is offline   Reply With Quote
Old 10-15-2022, 01:23 AM   #113
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Dragonetti View Post
The design is kind of blurry on a Retina Mac Air M1. Can this be improved or should I switch to IMGui?
This thread might be helpful (see code example in post #40): https://forum.cockos.com/showthread....16#post2493416
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 10-15-2022, 06:16 AM   #114
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Thank you, let's see if I can get this right.
Edit: works

Last edited by Dragonetti; 10-15-2022 at 03:28 PM.
Dragonetti 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:50 AM.


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