How to change a property of object in run time

General discussion on Visual GLCD Software.
Post Reply
Author
Message
mostafa_mech
Posts: 37
Joined: 23 Apr 2011 12:09

How to change a property of object in run time

#1 Post by mostafa_mech » 06 Sep 2011 06:32

Hello

I want to change a property of an object in run time. I tried to change Button2.Visible to equal 0, but this causes no effect on GLCD.

Code: Select all


#include "GLCD2_objects.h"
#include "GLCD2_resources.h"

//--------------------- User code ---------------------//

//----------------- End of User code ------------------//

// Event Handlers

void Button1Click() {
Rb6_bit = ~Rb6_bit;
Button1.Visible  = 0;
}


What is the correct way to do so ?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: How to change a property of object in run time

#2 Post by filip » 06 Sep 2011 08:53

Hi,

When you change the component property, you will need to draw it, in order to make the change visible :

Code: Select all

void Button1Click() {
Rb6_bit = ~Rb6_bit;
Button1.Visible  = 0;
DrawButton(&Button1);
}
Regards,
Filip.

mostafa_mech
Posts: 37
Joined: 23 Apr 2011 12:09

Re: How to change a property of object in run time

#3 Post by mostafa_mech » 06 Sep 2011 16:03

filip wrote:Hi,

When you change the component property, you will need to draw it, in order to make the change visible :

Code: Select all

void Button1Click() {
Rb6_bit = ~Rb6_bit;
Button1.Visible  = 0;
DrawButton(&Button1);
}
Regards,
Filip.
Thanks for your reply.

The code made effect only when I added these 2 lines:
DrawButton(&Button1);
DrawScreen(&Screen1);


but this makes all the screen redrawn again. Actually I do not want to do this. I wanted to change visible property to make something like blinking in button. Is there other better approach to make it blinks ?


Thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: How to change a property of object in run time

#4 Post by filip » 07 Sep 2011 09:40

Hi,

You can do this also by drawing a box with the same dimensions over it, thus masking the Button.

Regards,
Filip.

mostafa_mech
Posts: 37
Joined: 23 Apr 2011 12:09

Re: How to change a property of object in run time

#5 Post by mostafa_mech » 10 Sep 2011 04:47

filip wrote:Hi,

You can do this also by drawing a box with the same dimensions over it, thus masking the Button.

Regards,
Filip.
Thanks for help.

I can draw a rectangle using GLCD_Rectangle function, and make it with inverted color, but I ask about the Visual Glcd tool, Can I make an object to invert its color? I searched the properties of objects and I found nothing that can make this

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: How to change a property of object in run time

#6 Post by filip » 12 Sep 2011 10:02

Hi,

Currently, this kind of feature is not supported.
As a workaround, you can do this as I said above, by drawing a box over it.

Regards,
Filip.

Gladiador
Posts: 1
Joined: 20 Sep 2011 04:33

Re: How to change a property of object in run time

#7 Post by Gladiador » 20 Sep 2011 05:25

Sadly I ran into the same problem, and felt a bit frustated. But I found the way of changing the visible property in run time.
When VisualGLCD creates the code, it creates the Draw function for the object, but it is not really complete. Let me show you using a circle, for instance.

Code: Select all

#include "SmartGLCD_objects.h"
#include "SmartGLCD_resources.h"

//--------------------- User code ---------------------//
//----------------- End of User code ------------------//
// Event Handlers

void Circle1Click() {
RF6_bit = ~RF6_bit;
if (RF6_bit == 0)
   Circle1.Visible = 0;
else
   Circle1.Visible = 1;
DrawCircle(&Circle1);
}
In the Routine list within the project manager, you can see the DrawCircle function, double click it to jump to its code, you will see something like this:

Code: Select all

void DrawCircle(TCircle *ACircle) {
  if (ACircle->Visible == 1) {
    if (ACircle->Transparent == 1) {
      T6963C_circle(ACircle->Left + ACircle->Radius,
        ACircle->Top  + ACircle->Radius,
        ACircle->Radius, T6963C_WHITE);
    }
    else {
      T6963C_Circle_Fill(ACircle->Left + ACircle->Radius,
        ACircle->Top  + ACircle->Radius,
        ACircle->Radius, T6963C_WHITE);
    }
  }
}
And here is the problem. When the Visible property is set to 1, the function draws the circle, transparent or not, but when you set the Visible property to 0, it does absolutely nothing.
If you add a little piece of code to complement the if(Acircle->Visible == 1) statement the job will be done:

Code: Select all

void DrawCircle(TCircle *ACircle) {
  if (ACircle->Visible == 1) {
    if (ACircle->Transparent == 1) {
      T6963C_circle(ACircle->Left + ACircle->Radius,
        ACircle->Top  + ACircle->Radius,
        ACircle->Radius, T6963C_WHITE);
    }
    else {
      T6963C_Circle_Fill(ACircle->Left + ACircle->Radius,
        ACircle->Top  + ACircle->Radius,
        ACircle->Radius, T6963C_WHITE);
    }
  }
else {
      T6963C_Circle_Fill(ACircle->Left + ACircle->Radius,
        ACircle->Top  + ACircle->Radius,
        ACircle->Radius, T6963C_BLACK);
   }
}
This is something the software must do on its own. I hope this is fixed soon.

Thanks...

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: How to change a property of object in run time

#8 Post by filip » 20 Sep 2011 09:50

Hi,

Thank you for this interesting workaround, I'm sure it will be helpful to our users.
We will do our best to add some kind of a feature to make our objects invisible.

Regards,
Filip.

Post Reply

Return to “Visual GLCD General”