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 frame or x, y dimensions refer to the dimensions of the container which will be visible, while content refers to the dimensions of the draggable container corresponding to the total dimensions of the widgets. Naturally, content should be larger than frame 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 subwidgets should be put in. The frame and content containers begin aligned at their upper-left hand corners.

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

Attributes

In addition to the above parameters, the returned container widget 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 framed-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 of the frame, initially set to x
yofs (set by constructor) Vertical position of the frame, 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 the content is too far left (i.e. its right side is to the left of the frame's right side) or too far right (i.e. its left side is to the right of the frame's left side), then its left or right side will align to the left or right side of the frame.
(glgui-framed-container-position-y-snap! g wgt) If the content is too high (i.e. its bottom is above the bottom of the frame) or too low (i.e. its top is below the top of the frame), then its top or bottom will align to the top or bottom of the frame.

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