Redraw/Remove Gui

Hello,

on a certain event, I would like to redraw my GUI. To build up a gui I use:

vb = renoise.ViewBuilder()   
.. fill with buttons etc..  

How to destroy/remove this vb?
With again declaring vb in the same way, a second gui popups, but the old gui stays. Also vb = nil does not have any effect.

A vb only creates new GUI elements. If you want to remove previously added view components, you can do so via:
my_view:remove_child(some_child_view)

See https://code.google.com/p/xrnx/source/browse/trunk/Documentation -> Renoise.ViewBuilder.API.lua for more info

Thanks. Then there would be a my_view:remove_all_childs very helpful.
You either can not remove an former created dialog, can you?

app():show_custom_dialog  

To remove all views with a single “remove_child” call, add all your views into one “big” parent view. Like for example a row, column. Then you only need to remove this row or rack to get rid of everything…

Thank you.

But when putting my views into one big parent view, I got an error, when recreating/adding the previously removed view again:

*** std::logic_error: 'ViewBuilder: a view with the id 'track_number1' was already registered to this viewbuilder instance.'  
*** stack traceback:  

The child view I added to the parent view has the id “track_number”…i

  
 local track_number = vb:popup {  
 id = 'track_number'..i,  
 bind = tracks[i].track_number,  
 value = tracks[i].track_number.value,  
 width = 80,  
 items = track_names  
 }  
 lights_rows[i]:add_child(track_number)  
...  
  

Do I have to remove explicit all views with a certain id? (Removing a parent view does not automatically remove all id’s of the child views?)

Cie: Could you let us know what exactly you need/want to do? Its about recreating or updating the step sequencer GUI, isn’t it? What do you want to do there? I think it makes more sense to find a solution for this special case, your tool.

Re: ‘ViewBuilder: a view with the id ‘track_number1’ was already registered to this viewbuilder instance.’

You can use as many “ViewBuilder”'s you need or want. Even multiple ones per GUI, dialog. They only hold view IDs in a table, you can later on access and do the construction of views.

If you anyway have locals of your views, like here:
local track_number = vb:popup {
id = ‘track_number’…i
}

then you don’t need an ID at all, and could collect, memorize the view object directly in a table.

But as said above: Let us know what exactly you need to do in your tool, and lets try to find a solution for exactly this problem instead.

Thank you Taktik for your will to help, it is really appreciated. :)
Sorry for the late reply, unfortunately I had the last weeks no time due to work.

Yes this question refers to the StepSequencer. What I would like to do in my GUI is to add/remove dynamically a row of steps (that represents a track), if the user adds/removes a track. So when the Sequencer Gui is visible, and the user removes a track or adds one, a new row of steps becomes visible or gets removed.
As there is no possibility to check which track-number exactly was removed (only in general, that the amount of tracks has changed is observable), I had the idea to remove all rows of steps from the gui, parse all tracks, and add for each track a row again. Unfortunately I use IDs for each row to adress them from anywhere within the application; and when recreating the rows (with the same IDs) there is an error not to use the same ID again. At this point I got stuck.
If the gui is closed completely after a new track is added/removed, and then reloaded through clicking on the menue entry, it works well. Unfortunately I do not know how to close and restart the gui with a lua command.
If you know a way how to solve this problem, it would be great. Thank you anyway for your effort and your help.

Info about what exactly happened to the tracks (or patterns, instruments and so on list) is passed as “notification” argument to the notifier:
See GitHub - renoise/xrnx: The official Renoise Lua Scripting repository for more info please.

For a removed track you will get the following argument passed to your notifier: {
type = “remove”,
index = track_index which got removed
}


If the view builder IDs are then still in your way, then use a builder per track you are showing, or clear old IDs before assigning new ones:
vb.views[“some_view”] = nil – then create new views with the same id and same view builder

1 Like

Thank you very much, that solved my gui update problem.