Jump to content

Regrading label background transparent


gobardhan92

Recommended Posts

The current implementation of the label widget does not provide the possibility to render a with a transparent background. The only widget that provides transparent background is the container.

However, you can easily implement this yourself. What you need to change: Locate the function gwinLabelDefaultDraw() in the file /src/gwin/gwin_label.c, copy it, name it something like gwinLabelTransparentDraw() and replace all gdispGFillStringBox() function calls with the appropriate gdispGDrawStringBox() function calls. The only thing left to do is replacing the gwinLabelDefaultDraw entry in the VMT (line 53) with gwinLabelTransparentDraw.

You should now have a transparent background.

You can find the API of gdispGDrawStringBox() here: http://api.ugfx.org/master/group___g_d_ ... ddd6d6da52

We will eventually add a transparent background rendering option of the label widget ourselves (I put it on the ToDo list) but this won't happen before the weekend for sure.

~ Tectu

Link to comment
Share on other sites

Probably better is to use the custom draw capability of a widget.

As above create your transparent background draw routine. When you initialise the label put your transparent draw routine into the customDraw member of the widget initialisation structure. That saves having to play with the vmt structure or altering any of the standard widget code.

Link to comment
Share on other sites

  • 3 months later...

I have done something similar, but with a pushbutton.

In principle the system works, but only if I put the custom routine in gwin_button.c (since it refers to buttonVMT,which is static).


void gwinButtonDraw_Frame(GWidgetObject *gw, void *param) {
const GColorSet * pcol;
(void) param;

if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
pcol = getButtonColors(gw);

gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, pcol->fill);
}

Am I doing something wrong? Is there any way to put the custom routine in a separate file?

thank You

Link to comment
Share on other sites

You should never ever modify the uGFX library sources to archive something in the application level of things.

You can submit a custom rendering routine either through the widget initialization struct (the customStyle field) or the function gwinSetCustomDraw(). It doesn't matter where you implement your custom rendering routine. Usually they are located in a separate file.

You can find more information here: http://wiki.ugfx.org/index.php?title=Cr ... ng_routine

The uGFX-Studio currently only uses this feature to create custom rendering routines for the container backgrounds which you can create in the Backgrounds Manager tool. Maybe you can have a look at some of the generated code to see how it is used.

~ Tectu

Link to comment
Share on other sites

Unfortunately, my license for uGFX-Studio 0.7 has expired. How can I get a new one?

A simple forum search would have fixed your issue some time ago ;)

Another community member encountered this issue and we fixed it: viewtopic.php?f=28&t=263

Please let us know in the uGFX-Studio section of the forum whenever you encounter a problem with the studio.

~ Tectu

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...