cancel
Showing results for 
Search instead for 
Did you mean: 

How to make items made on the TouchGFX gui visible?

scottSD
Lead

Please excuse me if this is a very basic question. I created a screen with a couple of buttons on it and a text area with a wildcard on it to increase in value when one button is pressed and decrease in value when the other button pressed. This works fine without any problems.

However, the next thing I did was add code to the screen to a needle "Shape" that will be rotated in one direction when a button is pressed and in the other direction when the other button is pressed. This was all done by editing the code of the screen instead of using the TouchGFX gui. This works fine as well.

However, the buttons and the text area created in the TouchGFX gui are not visible with the added code for the needle. I see there is a way to set the Z order within the gui but the needle I added in code is not available in the gui. I can click in the area where the button is located (but not visible) and the needle rotates as expected.

The items in the gui are located in the view "Base" files which are gui_generated. I have access to them in the screen code, but cannot simply do an "add" for the item because the compiler complains that they are already added.

Are items added to the design using the TouchGFX gui compatible with items added to the screen's cpp code?

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi scott,

The Z order is determined by the order in which you add items to the root container of your concrete view. Widgets/Drawables are visible by default. The following code executed in setupScreen() of your view:

add(myButton1);
add(myButton2);
add(background);

Here are a few hints:

You're not seeing some drawables all of a sudden because:

1) You've added an element on top (last add() to root container)

2) The element takes up a large portion of the screen covering widgets below it due to 1). The code sample above would most likely hide every widget added before it because it's full screen.

3) Because it is not transparent - e.g. if your container was full screen but only had a small element in one of the corners, you would be able to see elements below it because the remaining "pixels" of that container are transparent.

/Martin

View solution in original post

5 REPLIES 5
Martin KJELDSEN
Chief III

Hi scott,

The Z order is determined by the order in which you add items to the root container of your concrete view. Widgets/Drawables are visible by default. The following code executed in setupScreen() of your view:

add(myButton1);
add(myButton2);
add(background);

Here are a few hints:

You're not seeing some drawables all of a sudden because:

1) You've added an element on top (last add() to root container)

2) The element takes up a large portion of the screen covering widgets below it due to 1). The code sample above would most likely hide every widget added before it because it's full screen.

3) Because it is not transparent - e.g. if your container was full screen but only had a small element in one of the corners, you would be able to see elements below it because the remaining "pixels" of that container are transparent.

/Martin

Martin,

Thanks for your reply to my question. I think #1 may be my issue but am not sure.

What is the "concrete view"? Any documentation for this would be very helpful. Do you mean the one that resides under the "generated" folder? This is where I find the items added from the TouchGFX Designer. Here are the items I added using the Designer.

0690X000008iTs1QAE.png

Below is the constructor, which according to the comment at the top of the file, should not be modified. The items are added at the end of the speedoScreenViewBase constructor:

0690X000008iTsLQAU.png

After I had done this work in the Designer, I manually added the needle shape as well as some other items. I did this in that screen's setupScreen function (in the file gui/src/speedoscreen_screen/speedoScreenView.cpp). I tried placing the call to the speedoScreenViewBase constructor before the "add" calls to these manual items as well as after, neither resulting in items in the Designer being visible.

By "Concrete" view i simply mean a concrete implementation of a baseview. e.g.

class MyView : public MyViewBase

These will be placed inside the gui/ folder and not the generated/gui_generated folder. You should try to do your initialization in setupScreen() and not in the constructor. It can cause weird behavior (Maybe not in this case) since we use setupScreen() internally to initialize views.

I can't see your application. Can you try rearranging the elements to see if the order had an impact? From a designer perspective, your background / widgets that cover most space, should be at the bottom of the list.

/Martin

This was an experiment that I was conducting. I started a new project using the textureMapper and things seem to be working now, so I must have been doing something wrong in the previous example using Shape.

I agree that one should use the setupScreen function and not the constructor to do initialization. I was curious because the gui_generated base was doing initialization in the constructor.

Here is TouchGFX's "Animation TextureMapper Example" where the gui_generated file "mainViewBase.cpp". The initialization was placed in the constructor and not in setupScreen:

0690X000008iXzfQAE.png

Yes, you're right and i've flagged this a while back. I hope we can get around to it soon :)

/Martin