Containers - coldrockgames/gml-raptor GitHub Wiki

You are here:

Base Controls - โœ”Containers - Tooltips - Clickables - Checkables - ListBox - InputBox - Mouse Cursor - ControlTree


Container Controls

This is a new control type since version 3.0 and is the base control for Window and Panel, where each of them has additional children, like MessageBoxWindow and the UiRootPanel.

They only add three additional variable definitions to the Base Controls:

image
control_tree This expression defines the ControlTree for the new UI Subsystem from release 3.0.
maximize_on_create Set this to true to have the control align itself to the maximum size,
either of the gui size (if draw_on_gui is true), or the view size
is_touchable Remember this flag from the _raptorBase object. By default, containers are "transparent" for the mouse, they don't receive mouse_enter/leave events. Set this to true, to change this.

The Panel Object

This is a lightweight invisible object, that acts "just as a container". It does nothing by itself, except that it provides its own ControlTree, so you can add controls to it.

The ScrollPanel Object

This is a very powerful container, as it allows you to freely scroll its contents. It offers many options for drag support, wheel support and even scrollbars.

Its best used for world maps, mini maps or any other scrolling content, like the normally quite long texts of class descriptions in fantasy games.

image

horizontal_scrollbar
vertical_scrollbar
Show/Hide the scrollbars.
drag_xoffset
drag_yoffset
Set the initial "drag" position. Use this to center the view or for any situation, where "top left corner" is not the ideal starting position of the content.
mouse_drag_mode The enum offers: .none, .left, .middle and .right
Hold and drag with the specified button to freely pan the content.
mouse_drag_inverted Like the "Invert Y-Axis" option, you might know from some games. Inverts the X and Y movement when dragging with the mouse.
mouse_drag_multiplier Sometimes you might want to show some really huge thing as scrollable content. By default, dragging is translated 1:1 from your mouse movement to the drag position (you move the mouse 100 pixels, and so does the content).
However, if your content is really huge, you might want to have this movement a bit faster. This value is the multiplier for the translation from your mouse movement to the drag distance.
wheel_scroll_lines Named identically to the other controls with mouse-support, this values sets "how much" vertical scroll happens, when you use the mouse wheel. The default 3 Lines are roughly like 36 pixels (3 lines รก 12px font size, which is the default).

ScrollPanel Functions

/// @func	set_scroll_position_uv(_xuv, _yuv)
/// @desc	Set the scroll position in uv coordinates (0..1)
///			To scroll to "top-left", send 0,0
///			To scroll to "bottom-right", send 1,1
///			To center, send 0.5,0.5
set_scroll_position_uv = function(_xuv, _yuv) {
/// @func	set_content_autofill(_autofill, _inner_padding)
/// @desc	Set a value (default is true, if you never call this)
///			indicating whether the content object shall be resized
///			via scale_sprite_to(...) to the visible area inside the
///			scrollpanel.
///			By default, the content is resized to fit with an optional
///			_inner_padding. This padding might vanish if the content grows
///			as it can be scrolled freely. Keep that in mind.
set_content_autofill = function(_autofill, _inner_padding) {
/// @func	set_content(_instance, _custom_draw_method = undefined)
/// @desc	Sets the content instance for this scroll panel.
///			You may supply a method name in the instance to draw the
///			instance, if you have some custom draw mechanism.
///			If you don't specify one, GameMaker's "draw_self()"
///			method will be used to draw the clipped content.
///			By default, the "__draw_self()" of raptor's control classes
///			will be detected and invoked, you don't need to specify a
///			custom draw, when setting any raptor control as content.
set_content = function(_instance, _custom_draw_method = undefined) {
/// @func	set_content_object(_object_type, _init_struct = undefined, _custom_draw_method = undefined)
/// @desc	Convenience shortcut to set the content through an object type
///			This method will call "instance_create" on the object type 
///			for you and supply the init struct.
set_content_object = function(_object_type, _init_struct = undefined, _custom_draw_method = undefined) {
/// @func	clear_content()
/// @desc	Removes the content object
clear_content = function() {
/// @func mouse_over_content()
/// @desc Determines, whether the mouse is currently over the clipping area
mouse_over_content = function() {

The Window Object

This control allows you to create your game's UI windows, be it the Settings, Statistics or any other kind of detail window in a strategy game, whatever you can imagine. Create your layout by adding controls to the ControlTree of the window.

To configure the look & feel of the window, it offers these variable definitions:

image

center_on_open If true, the window will center itself, depending on the value of draw_on_gui,
either in the center of the UI layer (draw_on_gui = true),
or in the center of the room (draw_on_gui = false)
title The title text. Supports LG Localization like all other caption properties
title_color Render color of the title text
title_color_mouse_over Render color of the title text when the mouse hovers over the title bar of the window
title_xoffset
title_yoffset
Depending on your window sprite, it may be necessary to offset the text a bit, because the nine-slice will most likely affect only the client area of the window, but not the title bar
titlebar_height The height of the titlebar-part of your window-sprite
scribble_title_align The same alignment settings like in a text align property
focus_border_color You may specify a different blend color for the window frame when it has focus
window_x_button_visible If true, a button of type window_x_button_object will be shown in the top right corner of the window
window_x_button_object The object type to use as x-button
on_opening
on_closing
callbacks to be invoked when the window opens/closes
window_is_movable
window_is_sizable
Allow the window to be moved and/or resized
window_resize_border_width The width of the border (from the sprite's edges) on all four sides that shall be interpreted as the "sizing border". When the mouse is in the sizing area, the Mouse Cursor will change to a sizing symbol based on the corner or side that is touched by the mouse

You are here:

Base Controls - โœ”Containers - Tooltips - Clickables - Checkables - ListBox - InputBox - Mouse Cursor - ControlTree

โš ๏ธ **GitHub.com Fallback** โš ๏ธ