Skip to content

glgui framed container

Jonathan Chan edited this page Jun 13, 2018 · 5 revisions

Similar to glgui-container with draggable_x? and draggable_y? enabled, this container is framed so that widgets surpassing the given bounds will not be visible but can be brought into view by dragging, like a scrollbox. The w, h dimensions refer to the dimensions of the container which will be visible, while content-w, content-h refer to the dimensions of the draggable container corresponding to the total dimensions of the widgets. Naturally, content should be larger in at least one dimension for dragging to be enabled, and the total dimensions of the widgets should be no larger than content in order for all widgets to be visible on dragging. This function returns the container that widgets should be put in and begins with content scrolled to the top and the left.

Parameter Description
g Graphical User Interface (GUI) for this widget
x Lower left corner along the x-axis in pixels
y Lower left corner along the y-axis in pixels
w Width of the visible area in pixels
h Height of the visible area in pixels
content-w Width of content (widget area) in pixels
content-h Height of content (widget area) in pixels

Attributes

In addition to the above parameters, the returned container has the following attributes which can also be set using glgui-widget-set! and retrieved using glgui-widget-get. (Note that setting x or y will not do anything; the position of the container must be set using xofs or yofs as described below.)

Attribute Default Value Description
hidden #f Hides the entire widget
scrollcolor DimGrey Colour of the scrollbars
scrollwidth 4 Thickness of the scrollbars
scrollrounded #f Enables rounded scrollbars instead of rectangular
scroll-x 0 How far right the content has been scrolled over (updated during drag)
scroll-y 0 How far down the content has been scrolled over (updated during drag)
xofs (set by constructor) Horizontal position, initially set to x
yofs (set by constructor) Vertical position, initially set to y

Procedures

There are a few other procedures taking in the same g and the returned widget wgt.

Procedure Effect
(glgui-framed-container-position-x-snap! g wgt) If content is too far left (i.e. its right side is to the left of the container's right side) or too far right (i.e. its left side is to the right of the container's left side), then its left or right side will align to the left or right side of the container.
(glgui-framed-container-position-y-snap! g wgt) If the content is too high (i.e. its bottom is above the bottom of the container) or too low (i.e. its top is below the top of the container), then its top or bottom will align to the top or bottom of the container.

Example

Example 1: Create a framed container scrollable in the y direction and add two boxes to it. The second box will be visible by dragging upwards.

(set! fcontainer (glgui-framed-container gui 0 0 100 100 100 200))
(glgui-box fcontainer 0 100 100 100 Red)
(glgui-box fcontainer 0   0 100 100 Blue)
Clone this wiki locally