cancel
Showing results for 
Search instead for 
Did you mean: 

Example: Grouping of Views with Common Functionality.

Martin KJELDSEN
Chief III

Hi everyone,

It's not unknown to people that TouchGFX designer is missing a key functionality: Grouping of views that have shared functionality, and separating the shared code into some interface. It's a feature that will appear in the Designer since it is currently not able to do this.

So far people are adding the same custom container to different views to achieve "shared" functionality, but this only takes care of the UI definitions and not code that could also be shared, like handlers for buttons (which had to be written again in each view).

A proper solution requires modifying the generated files, which will get overwritten again during the next code generation. Still, i've put together an example that you can look at to get a general overview. I'm attaching it here now, and will follow up with a detailed description of what's going on. I suppose we could consider this a pre-cursor to what will happen in the designer at some point and then you'll be READY and understand everything! =)

I will also write some scripts that you can use in your post-generate commands to modify groups of screens to inherit some common View AND presenter code. (e.g. A status bar and a presenter that can receive updates for it, completely abstracted away from the concrete views you're working on.

The Base View and Presenter must be written by hand, but i'll lay this out in what you need to consider here. You could use the designer to generate the view code and simply copy it. I'll build up the example as i go. This won't be required when the real features hits the designer, of course !: )

My plan is something like:

  1. Provide example that shows how to abstract shared View UI (Done)
  2. Modify example to show how to abstract shared Presenter logic (e.g. gotoScreen(X), showOverlay(), etc)
  3. Provide guidelines and script that can modify view code, post-generate, to inherit this functionality.
  4. Modify example to show how to abstract common helper functions into different interface that will be usable from all views.
  5. ....

Let me know if there are other requests.

I'll update this thread as i go with improved functionality and project attachments. For now please find attached a project that will take you from screen1 to screen 2 to screen 3 to screen 1... (interactions and buttons for now) but using a shared BaseView interface that lets each screen set the color of their inherited TopBar. I'll get into details later.

Instructions:

Do not generate code from the TouchGFX designer or you'll overwrite the changes. I will come up with a script at some later time that you will insert into the post-generate-command to fix up all generated view groups.

To simply run the project without generating view code simply run this command from your TouchGFX environment:

make -f simulator/gcc/Makefile

Note: I removed anything but the win32 mingw simulator library to keep it small.

Below screenshots show two of the three screens in the application where each concrete View class calls a function defined in their base view to set the color of the inherited/shared top-bar.

0693W000000UzbcQAC.png

0693W000000UzbhQAC.png

/Martin

25 REPLIES 25

Hello,

Any news on this feature? It seems really interesting.

@Martin KJELDSEN​ 

can we expect this feauture in next release ?

Hello @Community member​ ,

That is a big feature, and we want to do it right. So it might take some time.

Even though we are planning to work on it for further releases,

we cannot assure that it would be done for the next one, or give a accurate release date for that functionality.

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX

@Yoann KLEIN​  thank you for the information. I wish you all success.

Regards,

Jure

Will this feature ever make it into the Designer? I understand that this will take some time, but the last answer was 1.5 years ago.

 

Another great possibility would be if the custom containers were simply given a presenter and could exchange data with the model via this.

 

Best regards

Hello! Will this feature ever make it into the TouchGFX Core?

This is greatly needed for big applications with (sometimes more than two) custom containers populating 75% of the screens.

Best regards!