Skip to content

glgui framed container

Jonathan Chan edited this page Jun 4, 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 refers 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 widgets 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
frame-w Width of the frame in pixels
frame-h Height of the frame in pixels
content-w Width of the content in pixels
content-h Height of the content in pixels

Attributes

In addition to the above parameters, the returned container widget has the following attributes which can be set using glgui-widget-set! and retrieved using glgui-widget-get.

Attribute Default Value Description
scrollcolor DimGrey Colour of the scrollbars
scrollwidth 4 Thickness of the scrollbars
scrollrounded #f Enables rounded scrollbars instead of rectangular

Functions

There are a few other functions taking in the same g and the returned container c that have to do with the content container.

Function Effect/Return Value
(glgui-framed-container-content-ofs-set! g c new-ofs ofs) Sets the x-position (if ofs == 'xofs) or y-position (if ofs == 'yofs) of the content container to new-ofs, relative to g.
(glgui-framed-container-content-ofs-reset! g frame) Sets the x- and y-positions of the content container to its default, i.e. aligns its upper-left corner with frame.
(glgui-framed-container-content-position-valid? g c) Returns #t or #f depending on whether content has a valid position relative to frame, i.e. if the bottom of content is not above the bottom of frame, the top of content is not below the top of frame, and likewise for the left and right sides. This is useful if content has been shifted using glgui-framed-container-content-ofs-set! beyond valid positions and has become undraggable.
(glgui-framed-container-content-grow g c delta dim) Grows (or shrinks, if delta is negative) the width (if dim == 'w) or height (if dim == 'h) of content by delta, and adjusts scrollbars accordingly.

Example

Example 1: Create a framed container scrollable in the y direction and add two boxes two 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