Top |
The StScrollable interface is exposed by actors that support scrolling.
The interface contains methods for getting and setting the adjustments
for scrolling; these adjustments will be used to hook the scrolled
position up to scrollbars or other external controls. When a StScrollable
is added to a parent container, the parent container is responsible
for setting the adjustments. The parent container then sets the adjustments
back to NULL
when the scrollable is removed.
For StScrollable supporting height-for-width size negotiation, size negotiation works as follows:
In response to get_preferred_width()
, the scrollable should report
the minimum width at which horizontal scrolling is needed for the
preferred width, and natural width of the actor when not
horizontally scrolled as the natural width.
The for_width passed into get_preferred_height()
is the width at which
the scrollable will be allocated; this will be smaller than the minimum
width when scrolling horizontally, so the scrollable may want to adjust
it up to the minimum width before computing a preferred height. (Other
scrollables may want to fit as much content into the allocated area
as possible and only scroll what absolutely needs to scroll - consider,
for example, the line-wrapping behavior of a text editor where there
is a long line without any spaces.) As for width, get_preferred_height()
should return the minimum size at which no scrolling is needed for the
minimum height, and the natural size of the actor when not vertically scrolled
as the natural height.
In allocate()
the allocation box passed in will be actual allocated
size of the actor so will be smaller than the reported minimum
width and/or height when scrolling is present. Any scrollable actor
must support being allocated at any size down to 0x0 without
crashing, however if the actor has content around the scrolled area
and has an absolute minimum size that's bigger than 0x0 its
acceptable for it to misdraw between 0x0 and the absolute minimum
size. It's up to the application author to avoid letting the user
resize the scroll view small enough so that the scrolled area
vanishes.
In response to allocate, in addition to normal handling, the scrollable should also set the limits of the the horizontal and vertical adjustments that were set on it earlier. The standard settings are:
lower: 0 page_size: allocated size (width or height) upper: MAX (total size of the scrolled area,allocated_size) step_increment: natural row/column height or a fixed fraction of the page size page_increment: page_size - step_increment
void st_scrollable_set_adjustments (StScrollable *scrollable
,StAdjustment *hadjustment
,StAdjustment *vadjustment
);
void st_scrollable_get_adjustments (StScrollable *scrollable
,StAdjustment **hadjustment
,StAdjustment **vadjustment
);