cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to dynamically change the Z-Order of touchGfx Widgets.

PSucr.1
Associate II

The current Z-Order of widgets is based on the order of the "Add(widget)".

I want to create a number of widgets at the same location as an existing widget, but want this widget to under other widgets.

Currently, the only way this seems possible is to modify the "xxxBase.cpp" file and add your widgets where you want them in the Z-Order.

Another way I found is to take all the widgets you want above the Z-Order of the newly created widgets, and "remove(widget)" them. Then create your widgets, and "add(widget)", then add the "remove"d widgets.

Do you have a call, which is add(widget, order). Which is maybe preceded by the call order = getWidgetZOrder(widget). Or a call, which is setWidgetZOrder(widget, order).

3 REPLIES 3
Martin KJELDSEN
Chief III

In your own implementation of the class ( inside /gui/) you can re-arrange the widgets as you please, dynamically, by calling remove() and then add() again, doing some book keeping to keep track of which widgets you had to remove and re-add.

PSucr.1
Associate II

I don't like this method, since now the code is closely coupled to the touchGfx designer. Just adding another widget means, I have to peruse the code, and possibly reorganize, for every widget added/removed.

Much better would be my method, where you only have coupling to a single widget in the GUI.

My usage method, was to use this single widget for the color/size/location, of all the new widgets which were created.

So my only coupling is a single widget, which provides input for my widgets.

It would be nice to see this implementation in a future version of touchGfx.

z-order = getWidgetZOrder(widget)

insertWidget(z-order, widget)

So I would use the single widget, to insert all new widgets at that location. So if the widget location is 32, I would be like I was inserting widgets at location 32.1, 32.2, 32.3, etc.

When I'm done the next, and all subsequent widget in the order, could be increased by the number added.

Seems to be a simple change to a future version of code, which yields a richer interface.

CTapp.1
Senior

I've solved this by using containers for the Z-orders that I want to move things between. For example, if I have a widget I want to put something under I have:

Z-Over Containter  :
Regular content    : SomeWidget
Z-Under Containter : Under-the-widget

 If I then want it over the widget, I "remove" it from the Z-Under container and "add" it to the Z-Over container.

Z-Over Containter  : Under-the-widget
Regular content    : SomeWidget
Z-Under Containter :