No announcement yet.

Best approach for sharing common elements between multiple forms

  • Filter
  • Time
  • Show
Clear All
new posts

  • Best approach for sharing common elements between multiple forms

    I am planning out my next Visi-Genie app that will use a Diablo touchscreen and an Arduino controller. Unlike similar apps I've built, I would like this one to have a common header/menu bar across the top of the screen with navigation buttons, notifiers, etc, that will be shared by many of the forms. It will also have several common/shared smart objects in the body of the forms.

    A few questions some to mind...

    1) When I simply copy and paste a smart gauge from one form to another, the IDE seems to be making an unlinked copy of the smart gauge config. How can I re-use smart gauge configs between forms so that they are not being copied/duplicated and instead just reference back to the original config? The goal would be to only have to edit the original config to update the smart gauge on all forms. (I think I remember seeing the use of aliases mentioned before but can't seem to find an app note for it.)

    2) Is there a way to do this for user buttons as well, re-using a single user button configuration that can be updated once instead of having to edit the user button images on each form?

    3) For the common header/menu bar... It would be very nice if in my Arduino code if I could reference the header objects with constant identifiers no matter which form is active. However if the header bar is re-built on each individual form, all of those widgets will have different object reference numbers (ie. GENIE_OBJ_ISMARTGAUGE, 0x02). Is there a way to build the app so that the objects that make up the common header bar are the same objects, or can at least be referenced by the same identifiers, from form to form? I know that one approach would be to have the app use only one form, and simply hide and unhide elements rather than changing forms, but my forms have so many objects on them that would get very tedious. Is there another approach I can use to prevent having to rebuild the header bar on each individual form and reference the header objects with unique identifiers on every form?

    Thanks in advance!

  • #2

    Here's a quick answer for your questions:

    1. Each copied Smart Widget will always be unique to each other as most of the time they need to be customized individually. The alias is there for simplifying calls to the widget.
    2. No, each button is also unique. One workaround is to
    3. Each widget would need to be unique otherwise they will be too complicated to address. The best approach still is to reuse or stack widgets on the same form to retain your common elements.

    If you want total control over your widget you might as well want to try using some magic codes/events or completely switch over to ViSi where in both ways you can code in it 4DGL to handle it the way you want it to.

    Best Regards,


    • #3
      Jerson, thank you for the answers. I must say I’m a bit surprised that there is no way to re-use a master smart widget config, that would be really helpful in instances when we’re using the same widget over and over again on multiple forms. This happens a lot more often than you are suggesting. And having to edit that smart widget multiple times on multiple forms is very time consuming.

      And I understand that you’re saying that having my entire app reside on one form is technically the best way to achieve what I want in VisiGenie, but if you have an app with a dozen forms and some of those forms have two dozen elements on them, this method becomes very unwieldy and messy. I have no desire to try to place/position/hide/unhide/manage hundreds of widgets on one single canvas.

      Your answer to #2 seems to have been cut short. What is the workaround?

      So are you saying that if i switch over to Visi i can make multiple instances of a master smart widget and place them on multiple forms, and have them all refer back to one widget config? Or were you saying that using Visi I could have a common header bar on multiple forms that contains only one set of common widgets that i can refer to using the same arduino code regardless of the form that is active? Or both?



      • Jerson
        Jerson commented
        Editing a comment
        They are also stored on that folder. But you might need to restart Workshop4 for it to reflect. You can also try duplicating the Smart widget configs by loading the 4Dsmart file also located on that folder.

      • ironhalo
        ironhalo commented
        Editing a comment
        So you’re saying that multiple smart widgets all reference the same image files as long as they are named the same? So updating the one image file manually will update the image within all smart widgets after compiling? If this is the case this is a huge help in itself, as much of the iterative updates that I do are refining the widget graphics rather than updating the widget configs. Simply being able to centrally update common images within multiple smart widgets is a time saver.

      • Jerson
        Jerson commented
        Editing a comment
        Yes, you will notice it right away when you check your imgdata folder. You can also peek at the 4DSmart file using notepad to see which file is referenced to.

    • #4

      Genie was never designed in this way to reuse widgets, so really its not a viable option. Attempting to create the IDE to handle the reusing of widgets is not a trivial one either.

      In ViSi, you have full control, so you can reuse whatever you like, when you like, where you like etc. In Visi there is not really such a thing as a Form or Page, its simply a concept created for the benefit of Genie to easily design things, and create a virtual container if you will.
      In ViSi you have a collection of widgets you show and hide as you see fit. You can group these in code if you like, so you can change between visible sets of Widgets, and therefore you can use the same widget on multiple pages as you wish. This likely is the best solution for you.
      The downside is you miss out on the genie protocol and touch handling being done for you, so you would have to write the serial handler and the touch handling routines yourself.

      I agree that stacking objects on top of each other in Genie, is not easy to deal with. Funnily though, this is how Genie started off, there was only 1 page when it was first released, and that soon changed to have multiple forms/pages, to make the designing experience better. When you have a single page full of widgets, it soon gets overwhelming with them all on top of each other.

      So to recap, in ViSi you have all the widgets you want in your project, and you can create groups of widgets in code (ie a Form) which show the various widgets you want and enable the touch on the ones you want. To then change a form you would hide those first widgets and disable touch, and then move to show another set of widgets and enable the touch on those relevant ones. Those widgets might be common to some on the first form. There is nothing stopping you doing this, as in ViSi you have full control.

      Think of the display screen as being like a refrigerator door and each of the widgets are childrens magnets. You have one surface where you can stick the magnets on. Changing page just involves clearing things and putting new things back on again. Some widgets you might leave stuck from the previous form (or clear them all off and redraw them, its up to you), while others you take off. The concept here is the same. Its however up to you to manage this in code, which is what Genie would otherwise do for you automatically. It just cannot reuse the same thing on multiple forms (this may come in the future, but not plans yet).

      Hope that helps



      • #5
        James, thanks very much for the thorough explanation. All of that detail was very helpful, I now have a much better understanding of Genie vs Visi in relation to my query.

        It sounds like Visi is the direction I need to be headed for these larger apps in the future. I will likely mire through this next app in Genie, but will spend some time experimenting in Visi in the mean time.

        Thanks to you both for the info.