Jump to content


Photo

Help with vb.views resizing


  • Please log in to reply
7 replies to this topic

#1 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 30 September 2018 - 16:39

I am just trying to polish up this tool a bit:

 

http://forum.renoise...ed/#entry372866

 

There is a formatted string that automatically resizes the gui as you press UPDATE on different target instruments (as expected with default resizing behaviour).

 

post-428-0-67792900-1538247521.png

 

I want to reset the size of the gui between UPDATE actions, as sometimes the larger strings can warp the gui dimensions too much.

 

To deal with this I have a main vb:column{ id = "main col" } which I have tried to reset in the instrument popup notifier:

vb.views["main col"].width = 300

however this seems to set the width permanently to 300, so that when subsequently a new long string is added to the GUI , it will no long resize the whole GUI and just gets truncated so you can`t read it all.

 

Any way to deal with this, to keep the dynamic re-sizing?


Edited by Ledger, 30 September 2018 - 16:51.

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#2 Raul (ulneiz)

Raul (ulneiz)

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1544 posts
  • Gender:Male
  • Location:Spain

Posted 30 September 2018 - 17:53

If the object has the "tostring" property, you can restrict the number of characters using string.sub, like this example:

tostring = function( value ) return ("%s"):format( string.sub( renoise.song():instrument( value +1 ).name, 1, 15 ) ) end

The width of the text will not exceed 15 characters. Maybe you can adjust this in your code, according to the maximum width you do not want to overcome.

 

This is a good way to prevent the length of the text from influencing the width of the GUI. Some API objections already seem to work this way. But others need to restrict them.

 

You can use this with a, value, valuebox or valuefield, for example.  any case, it is to restrict the string with string.sub ( "string", val_1, val_2). Maybe you can include it in a class, to return those lines: Patterns: 0 lines bla bla bla...


:excl: Development of my tools: KangarooX120SamRenderPhraseTouch  |  GT16-Colors (old)

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 26 September 2017):

Spoiler

#3 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 30 September 2018 - 18:02

Thanks for answering!

 

The thing is, I want to allow the text to resize the GUI.

 

The issue I need to overcome is (re)setting the width manually seems to disable the ability of text to expand the gui.


--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#4 Raul (ulneiz)

Raul (ulneiz)

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1544 posts
  • Gender:Male
  • Location:Spain

Posted 30 September 2018 - 18:16

Thanks for answering!

 

The thing is, I want to allow the text to resize the GUI.

 

The issue I need to overcome is (re)setting the width manually seems to disable the ability of text to expand the gui.

 

Ah ok. Maybe you can force it by adding a row as an envelope to each text. Then, if the text deforms the row, the row can deform the wrapping column again. I have not tried it. Maybe it works.

 
It would be nice to see the exact code you're referring to.

:excl: Development of my tools: KangarooX120SamRenderPhraseTouch  |  GT16-Colors (old)

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 26 September 2017):

Spoiler

#5 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 30 September 2018 - 18:26

ok, here is the gui code.


The other thought I had was to use a textfield and see what can be done there, but at the same time I`m curious if there is a solution for standard text on the gui. It feels there `should` be.

 
    my_first_element = vb:column{
                        id = "main col",
                        -- width =  300,
                        vb:popup{
                         width = 250,
                         items = get_instrument_names(),
                         value = song.selected_instrument_index,
                         id = "inst. select",
                         notifier = function()
                                     
                                     vb.views["main col"].width = 300
                                     vb.views["readout string"].text = "Click UPDATE"
                                   end
                         },
                       
                         vb:row{
                          margin = 4,
                            vb:button{
                              text = "UPDATE",
                              notifier = function()
                                      
                                           local selected_inst_popup = vb.views["inst. select"].value
                                           vb.views["readout string"].text = update_readout_string(nil,selected_inst_popup)
                                           vb.views["main col"].width = 300
                                         end
                        
                          }--button
                         },--row

                        vb:text { 
                         id = "readout string",
                         font = "bold",
                         text = update_readout_string()
                        }
                       }

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#6 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 30 September 2018 - 18:38

Turns out multiline_textfield works:
 

   vb:multiline_textfield { 
                         id = "readout string",
                         width = 300,
                         height = 200,
                         text = update_readout_string()
                        }

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites


#7 Raul (ulneiz)

Raul (ulneiz)

    Guruh Motha Fakka is Levitating and Knows Everything About Renoise Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 1544 posts
  • Gender:Male
  • Location:Spain

Posted 30 September 2018 - 18:47

 

Turns out multiline_textfield works:
 

   vb:multiline_textfield { 
                         id = "readout string",
                         width = 300,
                         height = 200,
                         text = update_readout_string()
                        }

 

The vb:text also has the width and the height properties. Even using vb: text, it might be possible to detect the width of the tecto, and compare it with the wraparound column. Anyway, if it already works with multiline_textfield ... It will add a vertical slider, right?


:excl: Development of my tools: KangarooX120SamRenderPhraseTouch  |  GT16-Colors (old)

 

:excl: My API wishlist R3.1 (updated 24 July 2017):

Spoiler

 

:excl: My Renoise 3.1 wishlist (updated 26 September 2017):

Spoiler

#8 Ledger

Ledger

    Guruh Motha Fakka Knows More About Renoise Than Taktik

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3645 posts
  • Gender:Male

Posted 30 September 2018 - 19:14

The vb:text also has the width and the height properties. Even using vb: text, it might be possible to detect the width of the tecto, and compare it with the wraparound column. Anyway, if it already works with multiline_textfield ... It will add a vertical slider, right?

 

Yes a slider gets added for the vertical over-run and it wraps the text horizontally (automatic internal "\n")

 

As for detecting the text width, that may be another avenue to explore.  I was initially character counting the longest lines I would add, but of course characters are all different widths so impossible to get the pixel count - without some Major working around at least, checking each individual character against table, which I guess you would work out, through a nightmare of trial and error!


Edited by Ledger, 30 September 2018 - 19:14.

--> Lua for newbies <--

My Scripts On Forum

Top Tip!

 

cpu : Xeon 1231 v3, os : Win 7 64bit, audio: Audient iD4
posts as 4tune @ KvR and some other music related sites