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

Great news, I know this is a much-requested feature.

​I would go as far as to say it's a flaw, currently, as far as creating easily maintainable applications with good architecture.

GBert.2
Senior

Thanks for sharing @Martin KJELDSEN​. This looks very interesting.

Has this feature been added in the touchGFX ecosystem?

Regards,

Gabriel.

Hi Gabriel,

It has not, yet, sorry! It's in a special fast-track backlog now though :) The proper solution has been discussed at length here at the office.

/Martin

SBACO
Associate III

@moredatalesscenter​ It could be helpful if you can share your python script ? waiting for the option of baseView integrated in the designer directly (@Martin KJELDSEN​ hopefully soon ;) )

Right on, this is long waited feature that our project is waiting eagerly!

Redacted Python script attached. I can't remember how it works now, it was some time ago.

Thanks a lot ;)

The corresponding Post Generate Command in TouchGFX Designer Build options is also set to:

python PostTouchGFXGenerate.py && touchgfx update_project --project-file=simulator/msvs/Application.vcxproj

I'll try to get a read from the designer team on how it's coming along. I'll admit it's taking a lot longer to get prioritized than expected. Stay tuned.