[Top][All Lists]

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

Re: Gtk scrollbar: thumb too short

From: Owen Taylor
Subject: Re: Gtk scrollbar: thumb too short
Date: 28 Mar 2003 12:27:43 -0500

On Fri, 2003-03-28 at 10:21, Richard Stallman wrote:
>     > What happens if the app specifies a position that is less than one
>     > page away from the end?  Is that considered invalid?
>     Not invalid, but the position is silently changed to be a page away from 
> the 
>     end.  GTK scroll bars adjust position values to be in the interval
>     [minimum value for the scroll bar, maximum value - one page size]
> I think GTK should have an option to accept such values
> and display them in some sensible way.
>     > My suggestion is to display a thumb that rises from the bottom of the
>     > scroll bar, but is shorter than normal, as if the bottom of the thumb
>     > were hidden beyond the end of the scroll bar.  Others may think
>     > of a better way to indicate this situation.
>     As the native scroll bars do?  The disadvantage is that then the
>     thumb size in relation to the scroll bar size looses the
>     connection of how much of the buffer you are seeing w.r.t. the
>     size of the buffer.
> Either we are miscommunicating about something basic, or I disagree.
> In what I envision, the visible thumb size would reflect the amount of
> real text visible in the window.  As window-start gets closer to
> point-max, the amount of visible text decreases, and so should the
> thumb size.

This is certainly _also_ a possible interpretation the scrollbar thumb

 n_characters_visible / n_total_characters

is as logical as:

 (n_characters_visible + (factor) * n_dummy_lines) /
 (n_total_characters + (factor) * n_dummy_lines)

But if you take this interpretation then when you "overscroll",
then the scrollbar should simply get smaller, not go off the end
of the scrollbar. 

An observation I'd make is that a scrollbar really encodes two

 - A value
 - A percentage of a total size

If we look at the scrollbar on the screen, we have:

 v = thumb_start / (trough_pixels - thumb_pixels)
 p = thumb_pixels / trough_pixels

For the normal GTK+ case these two quantities are related to the
document size.

 v = start_of_visible / MAX (size_of_visible, size_of_document) - 
 p = size_of_visible / MAX (size_of_visible, size_of_document)

Or, in terms of GtkAdjustment parameters

 v = value / (max - page_size)
 p = page_size / max

For what you want in Emacs, v and p are computed differently:

 v = start_of_visible / character_index_of_start_of_last_line
 p = visible_chars / total_chars

What we simply need to do is compute GtkAdjustment parameters that
give these same v and p.

Fixing, say, max = total_characters, then we have:

 max = total_characters
 page_size = max * p = visible_characters
 value = v * (max - page_size) 
       = (start_of_visible / character_index_of_start_of_last_line) * 
         (total_chars - visible_chars)

Now, clearly there are some complexities from the fact that
visible_chars changes as the position changes. But I think the
approach is workable and will be a whole lot less confusing
then some sort of idea of the thumb of the scrollbar going off
the edge of the scrollbar trough.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]