Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Detect a control is visible and skip drawing
Detect a control is visible and skip drawing [message #854667] Tue, 24 April 2012 06:18 Go to next message
Leung Wang Hei is currently offline Leung Wang HeiFriend
Messages: 64
Registered: July 2010
Member
All,

We are tackling performance issue on control redraw. A quick thought
might be to skip redraw for all invisible control. To be simple,
invisible here means it's own visible flay set to false and none of the
region is covered by other control/windows.

Digging around the web and notice isVisible() and getVisible() only
returns the visible flag but not the effective visibility on the screen.

API like this would be perfect:


control.isEffectivlyVisible()




I suspect it may require some OS-depedent code. At the moment, solution
for Windows would be good enough.

Thanks for your time.
Re: Detect a control is visible and skip drawing [message #855034 is a reply to message #854667] Tue, 24 April 2012 13:19 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What about a pattern similar to GridLayout? GridLayout does this by providing an exclude flag on its GridData. The combination is set the control to visible==false and set its GridData exclude to true, and then it will be invisible and skipped in the layout.

PW


Re: Detect a control is visible and skip drawing [message #855794 is a reply to message #855034] Wed, 25 April 2012 05:27 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
i was in need for a similar problem, so i submitted a bugreport/featurerequest.
actually i was flamed within a few hours, because changing the visible flag of a control by a layout seems to be 'forbidden' or bad coding.
so i wrote my own layout and i am happy with it.

mine is based on gridlayout and automatically hides (no drawing) any fields with isVisible = false
as additional goodie you can sort the components without removing and adding them to parent. (also here i got flamed because i am using an integer value, which is NOT unique - but it does what is shall do, sort the components in correct order. if there are two of a kind its the programmers fault and does not affect the algorithm in a bad way.)

greets
lumo
Re: Detect a control is visible and skip drawing [message #856065 is a reply to message #855794] Wed, 25 April 2012 10:35 Go to previous messageGo to next message
Leung Wang Hei is currently offline Leung Wang HeiFriend
Messages: 64
Registered: July 2010
Member
What about if the widget is in a visible state but being obscured by
other windows (from the same app or other app, java or non-java)?

I suppose the OS is smart enough to skip the actual redraw but preparing
all font/colour, creating/disposing GC/clipping all do add penalty,
which is totally unnecessary.

On 4/25/2012 1:27 PM, Ludwig Moser wrote:
> i was in need for a similar problem, so i submitted a
> bugreport/featurerequest.
> actually i was flamed within a few hours, because changing the visible
> flag of a control by a layout seems to be 'forbidden' or bad coding.
> so i wrote my own layout and i am happy with it.
>
> mine is based on gridlayout and automatically hides (no drawing) any
> fields with isVisible = false
> as additional goodie you can sort the components without removing and
> adding them to parent. (also here i got flamed because i am using an
> integer value, which is NOT unique - but it does what is shall do, sort
> the components in correct order. if there are two of a kind its the
> programmers fault and does not affect the algorithm in a bad way.)
>
> greets
> lumo
Re: Detect a control is visible and skip drawing [message #856357 is a reply to message #856065] Wed, 25 April 2012 15:36 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
The OS takes care of considerations such as whether a control is
partially obscured, etc. You should only receive an SWT.Paint callback
if painting _needs_ to be done, and the Paint event's clipping bounds
should indicate the specific region needing to be painted. Any
optimization beyond this is up to the app (eg.- not re-computing
font/color info on every Paint call, only doing the work necessary to
paint the area that's included in the clipping region, etc.).

Grant


On 4/25/2012 6:35 AM, Leung Wang Hei wrote:
> What about if the widget is in a visible state but being obscured by
> other windows (from the same app or other app, java or non-java)?
>
> I suppose the OS is smart enough to skip the actual redraw but preparing
> all font/colour, creating/disposing GC/clipping all do add penalty,
> which is totally unnecessary.
>
> On 4/25/2012 1:27 PM, Ludwig Moser wrote:
>> i was in need for a similar problem, so i submitted a
>> bugreport/featurerequest.
>> actually i was flamed within a few hours, because changing the visible
>> flag of a control by a layout seems to be 'forbidden' or bad coding.
>> so i wrote my own layout and i am happy with it.
>>
>> mine is based on gridlayout and automatically hides (no drawing) any
>> fields with isVisible = false
>> as additional goodie you can sort the components without removing and
>> adding them to parent. (also here i got flamed because i am using an
>> integer value, which is NOT unique - but it does what is shall do, sort
>> the components in correct order. if there are two of a kind its the
>> programmers fault and does not affect the algorithm in a bad way.)
>>
>> greets
>> lumo
>
Previous Topic:Some inconsistent changes found in SWT repository
Next Topic:Implementing Untyped Messages for unknown message types
Goto Forum:
  


Current Time: Thu Apr 25 20:41:47 GMT 2024

Powered by FUDForum. Page generated in 0.03141 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top