PackageDescription: SparingScrollbars(Bundle)


Sparing Scrollbars

Last published: July 29, 2015 by 'wenk'


SparingScrollbars is a temporary bundle in response to AR50314. It contains extensions to UI classes and extensions to the UIPainter package to implement optional dynamic scrollbars which appear and disappear depending on the actual and visible bounds of the content the scrollbars wrap. There are also some test and sample classes which demonstrate the usage of this new behavior.

NOTE:
The contents of this bundle will soon be merged, as appropriate, into the Base VisualWorks bundle and the UIPainter package, and some selected examples will be upgraded to support optional dynamic scrollbars, or additional examples will be added to demonstrate this usage.

The following comments from the AR discuss the changes in this bundle and how to configure applications to use this new behavior.
---------------

A widget with optional dynamic scroll bars should show scroll bars only when there is more content than can be seen for its size. That means the scroll bars should be visible if the size of the window or widget is shrunk or if content is added.

The BorderDecorator wrapper controls scroll bars. Messages such as #noHorizontalScrollBar or #useHorizontalScrollBar are sent to it to remove or add scrollbars. A ScrollWrapper appears as a component of a BorderDecorator and it translates and models scroll position of its view component. Only a ScrollWrapper may know if scroll is unnecessary. A ScrollWrapper will need to notify its container BorderDecorator if the BorderDecorator is to control scroll bar visibility.

The widgetFlags instance variable of BorderDecorator and flags instance variable of all the widget specs named above retains the state of border, scroll, disabled, and visibility settings. The widgetFlags or flags instance variable encodes the boolean state of each option to one bit position using :

bit 6 (32) = Disabled
bit 5 (16) = Invisible
bit 4 (8) = Has border
bit 3 (4) = Has menu bar
bit 2 (2) = Has H scroll bar
bit 1 (1) = Has V scroll bar

This bundle adds two new bit positions to interpret whether scroll bars are used "sparingly" and shown only when needed. These may be set in the UIPainter from the Details tab for the widget.

bit 8 (128) = Use H scroll bar sparingly
bit 7 (64) = Use V scroll bar sparingly

When widgetFlags "Use H scroll bar sparingly" (bit 7) is set, the BorderDecorator will toggle "Has V scroll bar" (bit 1) as necessary to make the vertical scroll bar visible when needed. BorderDecorator will change its answer to #hasVerticalScrollBar based on whether the vertical scroll bar is currently visible. Settings and use of the horizontal scroll bar are similar.

The current visibility of a scroll bar does not change bitwise assignments to the flags variable of a widget's spec instance. If a widget spec is set to show a scroll bar it will always show the scroll bar by default. The spec must set both bits for the scroll bar to show, and to show sparingly, in order to have the scrollbar appear only when necessary.