Re: Graphical glitch in a scrolled window



On Sun, 2008-07-27 at 12:52 -0400, muppet wrote:
On Jul 27, 2008, at 9:02 AM, Tian wrote:

I did a small test program that I attached. Run it, and scroll down.  
You will see that things goes weird somewhere. I am not sure if it's  
always on the same line that it occurs. And also resizing the window  
can do some changes in the way it is displayed.

I added this:

$scroll->get_vadjustment ()->signal_connect (value_changed => sub {
      my ($self) = @_;
      print "v: ".join(' ', $self->value, $self->page_size,
                            $self->value + $self->page_size) ."\n";
});


and then ran the program and scrolled to where the glitch starts.   
With the window set such that the bottom of the last image that  
doesn't have the glitch is at the bottom of the scrolled window (as  
close as i could get it with the mouse, at least), i get this:

v: 32326.1739130435 380 32706.1739130435

and with that same spot just past the top of the window, i get this:

v: 32701.3291925466 380 33081.3291925466

Now, knowing that the upper bound of a signed 16 bit integer is 0x7FFF  
= 32767, and also that there are signed 16-bit integers used in the  
size parameters for X window objects, a diagnosis leaps to mind...


It looks like the vbox is calculating the spacing for its children  
correctly, but the tiling logic for the GtkStyle suffers rounding  
error that messes up the tiling.


I'd say, port this to C and file a bug against gtk+.


I've hit this problem in my app (gmusicbrowser) too.
I worked around it by using a simple DrawingArea instead of a
ScrolledWindow. You just need to add the scrollbars yourself, and then
draw on the DrawingArea according to the position of the scrollbars.

Note that while using only one scrollbar is easy. If you want both
vertical and horizontal scrollbars, it's a bit more complicated.
I had to subclass a VBox so that it could be added directly to a
ScrolledWindow (and not via a Viewport) :

package ViewVBox;
use Glib::Object::Subclass
Gtk2::VBox::,
        signals => {
                set_scroll_adjustments => {
                        class_closure => sub {},
                        flags         => [qw(run-last action)],
                        return_type   => undef,
                        param_types   => [Gtk2::Adjustment::,Gtk2::Adjustment::],
                },
        },

Quentin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]