Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified
Accepted Solution

Rendering Issues with setGlobalAlpha

[ Edited ]
    We wanted to utilize the setGlobalAlpha() method of Graphics to show a “grayed out” screen for when we are loading things in our application.  This works for most standard and some custom GUI constructs.  Principally we have issues in two places with Buttons, and by association with dropdown selectors on the storm, and with custom rendered UI.  Attached is a sample app which shows these issues.  Click the login button to change the alpha.

 

Before: Normal pictures

 

  The issue with buttons is that odd shaded boxes appear on each of the four corners of the button (and storm dropdowns)  and that with the Custom rendering, if you paint the same spot twice, it will actually become darker.  In the sample, the custom field’s paint method calls fillRect() twice, once for the top 2/3 and once for the bottom 2/3.

 

After: Lowered Alpha

 

Any insight here?

 

A link to the sample code is here : Sample Link

Message Edited by haagmm on 12-26-2008 11:27 AM
BlackBerry Development Advisor
Posts: 14,971
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Rendering Issues with setGlobalAlpha

Thank you for the detailed report.  I was able to reproduce this behaviour and have sent this issue to our development team.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 178
Registered: ‎07-29-2008
My Device: Not Specified

Re: Rendering Issues with setGlobalAlpha

hey mark, After speaking with some other people who showed me where i was going wrong, i just wanted to make a point, to achive the desired effects the right solution is to draw normal THEN lower the alpha and draw a rect on top of the screen. 

 

ie rather than doing what i showed above

 

public void paint(Graphics g) { if(grayOut) g.setGlobalAlpha(150); super.paint(g); }

 

 do this

 

 

public void paint(Graphics g) { super.paint(g); if(grayOut) paintGray(g); } protected void paintGray(Graphics g) { int oldAlpha = g.getGlobalAlpha(); g.setGlobalAlpha(150); g.setColor(0x00ffffff); g.fillRect(getExtent().x, getExtent().y, getExtent().width, getExtent().height); g.setGlobalAlpha(oldAlpha); }

 

 

 

 

 

BlackBerry Development Advisor
Posts: 14,971
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Rendering Issues with setGlobalAlpha

I'm glad to see you got it working.  Thank you for posting the update!
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker