No announcement yet.

Dimming a Widget only.

  • Filter
  • Time
  • Show
Clear All
new posts

  • Dimming a Widget only.

    Is there a way to dim only the widget or smart widget in 4D ViSi Pro? This will be for the Diablo processor. For example a SmartGauge Wideget to be dimmed but the buttons on the rest of the screen to stay the same.

  • #2
    Hello ua100k,

    I would suggest using an Image manipulation software to create a "dimmed" version of your smart widget then adding it as a second Image on the Image list editor.


    • #3
      Good day ua100K,

      May I ask what 4D programming environment are you going to use? ViSi or ViSi-Genie?
      There is no way of dimming option for the widgets

      Here's what I can suggest.

      If you are going to build your own widget (like in the Smart Gauge), you can create a image state wherein the widget is dimmed. For example, when the widget receives a value of 0 or 101, the widget will show its 0th or 101st image state/frame which is dimmed. Of course, you must set the max values on the object inspector for this. You can practice this method by creating a userimage with 101 frames.

      Another suggestion:
      Place an image with 50% transparency built on any image/photo editor application. Then place it on top of the widget to create a dimmed effect. This is best performed on ViSi since all can be coded accordingly.


      • #4
        Thanks for the ideas. All rather interesting.
        I understand Transparency eats a lot of cycles causing programs to run noticeably slower.

        Question: Can you dim a background image?

        The IDE is Visi Pro. Genie does not seem to allow code to be entered directly, and only using magic items to certain spots. It seems very limiting.


        • #5
          On the same note. Once a image is put into a form, how do you remove the image?


          • #6
            Hi ua100k,

            Images in the 4DGL environment works by writtting on top of each other. To remove an image, you can clear the whole screen using the gfx_Cls() function.
            However, the bigger the screen, the more the clearing is noticeable.

            If youre just going to clear/hide an object, I suggest that you draw a primitive rectangle shape with its color as the background.
            For example you have a black background:

            gfx_RectangleFilled(102, 84, 229, 183, BLACK) ;

            Use the shape to cover up the widget. However, you must still execute the code img_SetAttributes(hndl, iWidget, I_TOUCH_ENABLE); to disable the widget (if the widget is an input-widget) to prevent it from activating when touched.

            The background image cannot be dimmed, once it has been set up in the Object Inspector of the form. Whoever, when you place a transparent image, this may cause an dimmed effect on the background image.
            Last edited by Mark Kevin; 15th January 2018, 11:05 AM.


            • #7
              Thank you Mark.

              Regarding the background image. I put one into the form in the 4D Visi, and I cannot seem to remove it from the form in the 4D Visi IDE. Is there a way to remove an image on the form, once inserted?



              • #8
                Hi ua100k,

                Are you adding/removing the image during design-time? (Design time is where you are still coding and putting widgets)
                Click image for larger version

Name:	2018-01-15_11-14-07.jpg
Views:	1
Size:	65.7 KB
ID:	61401

                However, in run-time, (Run time is where your code is now loaded and running on the display module) this cannot be performed.

                If in case you do not want to show a background image of the form, you do not need to "paste code" the form object/widget to the code.
                Inside your code, you dont need to use the img_Show(hndl, iForm1);

                If you need sample projects or codes, you can check out our project making website:

                We have lots of projects that implement the clearing/removing and showing background images using the ViSi programming environment.


                • #9
                  Just to close this out.

                  dimming the widget is not possible. Interestingly it is quite simple to graphically draw any widget rather then use images. It takes a little bit of work but creating the image creates work also.

                  Using the graphics to draw the widgets is very fast, too fast that I had to slow the update of the display using pause. A good problem to have.

                  This also allows a lot of other features to be introduced.


                  • #10

                    If you are using a ulcd-43 display, it has the ability to draw on a page and then switch to another. It means that you can draw a whole lot of images and then display a page and switch to the other page to draw again and then switch again. It is very useful if drawing your own widgets etc and don't wont to see them being drawn.

                    Best regards



                    • #11
                      How do you switch pages? I don't see that in the manuals


                      • #12

                        You can use this code to switch between pages

                              gfx_Set(DISPLAY_PAGE,1) ;
                              pause(2) ;
                              gfx_Set(WRITE_PAGE,0) ;
                              gfx_Set(DISPLAY_PAGE,0) ;
                              pause(2) ;
                              gfx_Set(WRITE_PAGE,1) ;
                        page ^= 1 ; //toggle pages
                        If you put this at the end of your main loop it will aternate between pages and will always draw on the screen that isn't being displayed. It is only the gen4-uLCD 43 or the uLCD 43 screens that have this feature.

                        Best regards



                        • #13
                          Thank you very much.


                          • #14
                            I presume your widgets must be quite simple to be able draw them 'very fast', perhaps you can share your code?

                            Also, have you seen the img_Lighten() function?