Changes from Version 1 of documentation/StyleGuide

Show
Ignore:
Author:
peterc (IP: 203.96.63.172)
Timestamp:
02/14/08 13:01:06 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/StyleGuide

    v0 v1  
     1= Style Guide = 
     2 
     3libRocket and the controls plugin features several functional elements that need to by sized and decorated with RCSS properties, such as scrollbars, sliders and drop-down boxes. This document will go over all these elements and give recommendations on how you should style them. 
     4 
     5== Scrollbars == 
     6 
     7Any element with scrolling overflow (a value of 'scroll' or 'auto' on either of the 'overflow-x' or 'overflow-y' properties) may generate scrollbars along its bottom or right side. By default, these are simple block elements with no background colour or decorator. 
     8 
     9=== Generated elements === 
     10 
     11The scrollbar elements are tagged ''scrollbarhorizontal'' or ''scrollbarvertical'', depending on their orientation. They are hidden elements parented directly to the scrolling element. Each scrollbar element contains four child elements: 
     12 
     13 * ''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. 
     14 * ''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. 
     15 * ''slidertrack'': The track that runs between the two arrow buttons. 
     16 * ''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. 
     17 
     18<img> 
     19 
     20When 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. 
     21 
     22=== Applying RCSS properties === 
     23 
     24All 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): 
     25 
     26 1. Set the 'width' property of the ''scrollbarvertical'' element to the appropriate value for your interface design. This should be enough to encompass the arrows, track and bar. 
     27 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. 
     28 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. 
     29 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. 
     30 1. Apply decorators to the elements as appropriate.  
     31 
     32See the Rocket Invaders from Mars demo style sheet and the [wiki:documentation/tutorials/WindowTemplate templating tutorial] for more pointers. 
     33 
     34=== The 'scrollbar-margin' property === 
     35 
     36As 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. 
     37 
     38=== Example RCSS === 
     39 
     40The following is the section of the style sheet for Rocket Invaders from Mars relevant for scrollbars. 
     41 
     42{{{ 
     43/* Fix the width and push the scrollbar back to the extents of the window. */ 
     44scrollbarvertical 
     45{ 
     46        margin-top: -6px; 
     47        margin-bottom: -6px; 
     48        margin-right: -11px; 
     49        width: 27px; 
     50} 
     51 
     52/* Decorate the slider track. */ 
     53scrollbarvertical slidertrack 
     54{ 
     55        background-decorator: tiled-vertical; 
     56        background-top-image: invader.png 70px 199px 97px 201px; 
     57        background-center-image: invader.png stretch 70px 201px 97px 202px; 
     58        background-bottom-image: invader.png 70px 203px 97px 204px; 
     59} 
     60 
     61/* Push the slider bar in 4 pixels from the left edge. Fix the width of the bar and make sure 
     62   the height doesn't drop below 46 pixels; under that the decorator will start squishing the 
     63   images. */ 
     64scrollbarvertical sliderbar 
     65{ 
     66        margin-left: 4px; 
     67        width: 23px; 
     68        min-height: 46px; 
     69 
     70        background-decorator: tiled-vertical; 
     71        background-top-image: invader.png 56px 152px 79px 175px; 
     72        background-center-image: invader.png stretch 56px 175px 79px 175px; 
     73        background-bottom-image: invader.png 56px 176px 79px 198px; 
     74} 
     75 
     76/* Animate the bar's decorator on hover. */ 
     77scrollbarvertical sliderbar:hover 
     78{ 
     79        background-top-image-s: 80px 103px; 
     80        background-center-image-s: 80px 103px; 
     81        background-bottom-image-s: 80px 103px; 
     82} 
     83 
     84/* Animate the bar's decorator on active. */ 
     85scrollbarvertical sliderbar:active 
     86{ 
     87        background-top-image-s: 104px 127px; 
     88        background-center-image-s: 104px 127px; 
     89        background-bottom-image-s: 104px 127px; 
     90} 
     91 
     92/* Fix the size of the 'page up' slider arrow and decorate it appropriately. */ 
     93scrollbarvertical sliderarrowdec 
     94{ 
     95        width: 27px; 
     96        height: 24px; 
     97         
     98        icon-decorator: image; 
     99        icon-image: invader.png 0px 152px 27px 176px; 
     100} 
     101 
     102/* Fix the size of the 'page down' slider arrow and decorate it appropriately. */ 
     103scrollbarvertical sliderarrowinc 
     104{ 
     105        width: 27px; 
     106        height: 24px; 
     107         
     108        icon-decorator: image; 
     109        icon-image: invader.png 28px 152px 55px 176px; 
     110} 
     111 
     112/* Animate the arrows on hover. */ 
     113scrollbarvertical sliderarrowdec:hover, 
     114scrollbarvertical sliderarrowinc:hover 
     115{ 
     116        icon-image-t: 177px 201px; 
     117} 
     118 
     119/* Animate the arrows on active. */ 
     120scrollbarvertical sliderarrowdec:active, 
     121scrollbarvertical sliderarrowinc:active 
     122{ 
     123        icon-image-t: 202px 226px; 
     124} 
     125}}}