Changes from Version 1 of documentation/C++Manual/Scrollbars

Show
Ignore:
Author:
peterc (IP: 192.168.0.1)
Timestamp:
11/21/07 12:27:56 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/C++Manual/Scrollbars

    v0 v1  
     1[[PageOutline(1-5, Contents)]] 
     2= Element scrollbars = 
     3 
     4When appropriate, Rocket automatically generates hidden scrollbar elements for elements with content overflow. The size and positioning of the scrollbar elements can be influenced through RCSS properties. Custom elements can make use of the scrollbar functionality to generate scrollbars of their own. 
     5 
     6== Hidden elements == 
     7 
     8Scrollbar elements are tagged ''scrollbarvertical'' or ''scrollbarhorizontal'' depending on their orientation, and are parented directly to the elements that generated them. Each scrollbar element contains four hidden child elements: 
     9 * ''sliderarrowdec'': The button at the top (or left) of the scrollbar which can be clicked to scroll further up (or to the left) the element. 
     10 * ''sliderarrowinc'': The button at the bottom (or right) of the scrollbar which can be clicked to scroll further down (or to the right) the element. 
     11 * ''slidertrack'': The track that runs between the two arrow buttons. 
     12 * ''sliderbar'': The bar that runs on the track. It represents the size and position of the visible segment of the element's content. It can be dragged to scroll the visible window around. 
     13 
     14[[Image(scrollbars_1.gif, nolink)]] 
     15 
     16When both horizontal and vertical scrollbars are present on an element, they are both shortened by the amount necessary to avoid an intersection. Another element is created and placed in this intersection point, placed and sized appropriately. This corner element is tagged ''scrollbarcorner'' and exists only for decoration purposes. 
     17 
     18=== Applying RCSS properties === 
     19 
     20All of these elements can be styled through RCSS to be sized, positioned and rendered appropriately. The recommended method for configuring a scrollbar is given below (note that this is for a vertical scrollbar; for a horizontal, swap width and height): 
     21 
     22 1. Set the 'width' property of the ''scrollbarvertical'' element to the appropriate value for your interface design. This needs to be enough to encompass  
     23 1. Set the 'width' and 'height' properties of the ''sliderarrowdec'' and ''sliderarrowinc'' elements as appropriate. Set them to '0' if you don't want buttons. 
     24 1. Set the 'width' property of the ''slidertrack'' as appropriate. The 'height' value will be ignored for the track and will always be set internally. Use 'margin-left' to position the track within the scrollbar. 
     25 1. Set the 'width' property of the ''sliderbar'' as appropriate. The height of the bar will be generated internally, but you can override this with the 'height' property, or use the 'min-height' and 'max-height' properties to influence it. 
     26 1. Apply decorators to the elements as appropriate. 
     27 
     28See the Rocket Invaders from Mars demo style sheet and the [wiki:documentation/tutorials/WindowTemplate#Step4:Addingascrollbar templating tutorial] for more pointers. 
     29 
     30=== The 'scrollbar-margin' property === 
     31 
     32As described above, the scrollbar elements (''scrollbarvertical'' and ''scrollbarhorizontal'') will shorten themselves automatically to avoid a corner intersection. This can lead to scenarios where a scrollbar is popping on and off (during a window resize, for example) and causing the other scrollbar to rapidly change size. To avoid this, and force a scrollbar to always shorten itself for a corner, you can use the numerical 'scrollbar-margin' property on a scrollbar element. An element will shorten itself (on the bottom or right side, as appropriate) by the minimum of the appropriate corner dimension and the scrollbar margin. 
     33 
     34== Generating scrollbars == 
     35 
     36Custom elements can generate scrollbars using the element's scroll interface. This is done, for example, by the text area form control in the Controls plugin. 
     37 
     38Scrollbar generation is usually done in a custom element in response to the "resize" event, sent during layout. To retrieve a pointer to an element's scroll interface, call GetElementScroll() on the element. This will return a Rocket::Core::ElementScroll object. 
     39 
     40{{{ 
     41/// Returns the element's scrollbar functionality. 
     42/// @return The element's scrolling functionality. 
     43Rocket::Core::ElementScroll* GetElementScroll() const; 
     44}}} 
     45 
     46To enable or disable one of the element's scrollbars, call EnableScrollbar() or DisableScrollbar(): 
     47 
     48{{{ 
     49// Enables and sizes one of the scrollbars. 
     50// @param[in] orientation Which scrollbar (vertical or horizontal) to enable. 
     51// @param[in] element_width The current computed width of the element, used only to resolve percentage properties. 
     52void EnableScrollbar(Rocket::Core::ElementScroll::Orientation orientation, float element_width); 
     53 
     54// Disables and hides one of the scrollbars. 
     55// @param[in] orientation Which scrollbar (vertical or horizontal) to disable. 
     56void DisableScrollbar(Rocket::Core::ElementScroll::Orientation orientation); 
     57}}} 
     58 
     59As the object will remember the state of both previous scrollbars, it is recommended you explicitly enable or disable both scrollbars. 
     60 
     61Call FormatScrollbars() once you have set the state of both scrollbars and set the size (and content size) of the scrolling element. 
     62 
     63{{{ 
     64// Formats the enabled scrollbars based on the current size of the host element. 
     65void FormatScrollbars(); 
     66}}}