Menu

#70 JSCWindow:drawHook painting twice?

open
nobody
None
2
2012-02-26
2009-07-27
Anonymous
No

I 'm trying some things with swingosc and get the same problem over and over again with different situations. It seems in some cases a window refresh causes the Pen functions to be rendered multiple times on top of each other. I get it with my RoundButton -> swingosc experiments, but also with simple drawHook functions. It seems to happen most often when a .clip and/or a .use is included in the drawHook.

GUI.swing;
w = Window().front;

(
w.drawHook = { |win|
var rect;

rect = win.asView.bounds;

Pen.line( rect.leftBottom, rect.rightTop );
Pen.line( rect.rightBottom, rect.leftTop );
Pen.stroke;

Pen.use({
Pen.color = Color.blue(0.5).alpha_(0.5);
Pen.addRect( rect.copy.width_( (rect.width * 0.5).floor ) );
Pen.clip;
Pen.addRect( rect );
Pen.fill;
});

Pen.use({
Pen.color = Color.blue(0.5).alpha_(0.5);
Pen.addRect( rect.copy
.width_( (rect.width * 0.5).floor )
.moveBy( (rect.width * 0.5).floor, 0 ) );
Pen.clip;
Pen.addRect( rect );
Pen.fill;
});

}; w.refresh;
)

now if I resize the window I see the blue rects flashing darker and lighter, indicating that they are layered on top of each other. They flash independent of each other, even though they are in the same drawHook. When I remove the Pen.clip; and Pen.addRect( rect ); lines it gets less. Also when I move the functions outside the Pen.use({ ... }) statements it gets less. But still it happens sometimes. It also happens with functions inside UserViews, especially when clicking another userview in the same window.

I use OSX 10.5.7 & SwingOSC 0.62 (recent build with fillAxialGradient)

cheers,
Wouter

Discussion

  • sciss

    sciss - 2012-02-26

    It is a specific problem when resizing the window with the mouse (doesn't occur when using bounds_ for example). I can confirm it, and I have seen it with other components than user view. Note that the drawHook is not executed repeatedly, but it appears rather to be a problem of clearing the background during resizing. Don't have a solution for this at hand at the moment.

     
  • sciss

    sciss - 2012-02-26
    • priority: 5 --> 2
     

Log in to post a comment.

MongoDB Logo MongoDB