|
From: Jeroen v. d. Z. <jv...@cf...> - 2001-12-14 16:13:28
|
On Thursday 13 December 2001 23:47, you wrote:
> I noticed something about FXSwitcher that could possibly be improved...
>
> In my sound editor, I have some playing LED indicators which are just
> labels with an FXIcon... Well, I put two labels on a switcher: one with
> the 'LED-on' image and one with the 'LED-off' image... So when playing
> starts, I setCurrent(...) on the switcher and then again when it
> stops...
> Well, in my situation, I have the waveform in another FX...Frame
> above the status frame where the LEDs are. When I switch the switcher,
> it recalculates the layout of the switcher which causes everything in
> the window to have to refresh, hence, the entire waveform view
> redraws... I noticed this when I was printing everytime I draw part of
> the waveform in order to figure out if I'm unnecessarily drawing many
> times at startup (which I was, but I've supressed all the redraws during
> initial layout adjustments until I know I'm ready)...
When FXSwitcher switches to another panel, it simply raises it to the
top. FXSwitcher::layout() may run, and it will position each child
again; however, FXWindow::position() contains a test to see if a resize
happened (or stuff just got moved to a new place) and only calls layout
when the size was changed).
Of course if something is brought to the top it *WILL* have to be redrawn.
> Anyway, I understand that it may be necessary to re-layout stuff upon
> using the switcher, but the two things in the switcher are the same
> size, so it shouldn't be necessary to do the layout... I guess this
> would just be a special case to check in the FXSwitcher implementation,
> but it's one of those optimizations you can do after most everything
> else is working.
See above.
> (Anyway for now.. I'm going to put 2 labels on top if each other and use
> raise() to bring to the top which ever I want to show... I only hope
> this doesn't have the same side effect)
To verify things, you could enable tracing. FXWindow::position() prints
out the new size. If the size is the same as before and there are no
other reasons for layout then it should not call layout again.
Does your layout() routine reset the dirty flag at the end, as below:
void MyWidget::layout(){
....
flags&=~FLAG_DIRTY;
}
If it is not marked as "clean" then layout will be called again and
again.
The flag is to force layout under certain conditions even when size
has not changed.
- Jeroen
--
+-------------------------------+--------------------------------------------+
| E-Mail : jv...@cf... | The FOX Platform Independent GUI Toolkit: |
| USMail : 215 Wynn Drive, | |
| Huntsville, AL 35805 | Official Site: |
| Phone : (256) 726-4820 | http://www.fox-toolkit.org |
| Fax : (256) 726-4806 | ftp://ftp.fox-toolkit.org/pub |
| WWW : http://www.cfdrc.com | |
+-------------------------------+--------------------------------------------+
| Copyright (C) 15:10 10/10/2001 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
|