Help with vb.views resizing


(Ledger) #1

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

https://forum.renoise.com/t/show-where-how-many-times-this-instrumentis-used/49630

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?


(Raul (ulneiz)) #2

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…


(Ledger) #3

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.


(Raul (ulneiz)) #4

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.


(Ledger) #5

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 Im curious if there is a solution for standard text on the gui. It feels thereshould` 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()
                        }
                       }

(Ledger) #6

Turns out multiline_textfield works:

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

(Raul (ulneiz)) #7

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?


(Ledger) #8

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!