- new_text_node
- storm_default_event
- storm_default_frame
- get_screen_size
- new_storm_context
- Node
- NodeR2D
- NodeV2D
- AppContext
- AppConfig
- AppWindow
- TextConfig
- TouchList
- WindowConfig
pub fn new_text_node(config TextConfig, text string) &Node
Creates a new text node with the specified config and string.
fn storm_default_event(e &gg.Event, mut app AppContext)
Function run by default when an event occured. (internal use only)
fn storm_default_frame(mut app AppContext)
Function run by default when a frame needs to be shown. (internal use only)
pub fn get_screen_size() NodeV2D
Gets the screen size.
pub fn new_storm_context(mut args AppConfig) &AppContext
Creates a new app context.
[heap]
pub struct Node {
mut:
// Components are containers holding data as any struct.
components map[string]voidptr
// Children are other nodes that have the current node as parent.
children map[string]&Node
// Functions are methods that can be executed ON the node.
functions map[string]fn (&Node)
pub mut:
parent &Node = unsafe { 0 }
context &AppContext = unsafe { 0 }
}
pub fn (mut e Node) add_component(what voidptr, str string)
Adds a component to the node.
The component can be any struct and is saved as a refference to the original data.
pub fn (mut e Node) has_component(str string) bool
Checks if a component with a specific name exists.
pub fn (mut e Node) delete_component(str string)
Deletes a component from the node.
pub fn (e Node) get_component(str string) voidptr
Gets a specific component.
! Returns a voidptr that needs to be converted to the intended data struct !
fn (mut e Node) change_context(newc &AppContext)
Changes the context of the node (internal use only).
pub fn (mut e Node) add_child(mut new Node, str string)
Adds a child to the node.
pub fn (mut e Node) has_child(str string) bool
Returns if the child with the specified name exists.
pub fn (mut e Node) get_child(str string) &Node
Gets a child with a specified name.
pub fn (mut e Node) remove_child(str string)
Removes a child with a specified name.
pub fn (mut e Node) add_function(new fn (&Node), str string)
Adds a method with a specified name.
pub fn (mut e Node) execute(str string)
Executes a function on itself going down recursively if it also exists there.
pub fn (mut e Node) execute_one(func fn (&Node))
Executes a specific function of the current entity.
pub fn (mut e Node) execute_all(func fn (&Node))
Executes a specific function on the current entity AND its children.
pub struct NodeR2D {
pub mut:
// Position
pos NodeV2D
// Size
siz NodeV2D
}
Struct that represents a 2D rectangle into memory.
pub fn (n NodeR2D) check_inside(what NodeV2D) bool
Checks if a point represented by a 2D vertex is inside the rectangle.
pub fn (n NodeR2D) get_relative_to(what NodeV2D) NodeR2D
Returns a modified version of the current rectangle relative to the argument vertex.
It can return the original rectangle if the relative flag is not set for both the size and position.
pub struct NodeV2D {
pub mut:
x f32
y f32
r bool
}
Struct that represents a 2D vertex into memory.
Can be relative to another 2D vertex.
pub fn (a NodeV2D) divide_by<T>(b T) NodeV2D
Divide the vertex by a scalar.
pub fn (a NodeV2D) multiply_by<T>(b T) NodeV2D
Mulitiply the vertex by a scalar.
fn (a NodeV2D) - (b NodeV2D) NodeV2D
Subtract a vertex from another.
fn (a NodeV2D) + (b NodeV2D) NodeV2D
Add two vertexes.
pub fn (n NodeV2D) get_relative_to(what NodeV2D) NodeV2D
Returns a modified version of the current vertex relative to the argument vertex.
This happens only if the relative flag is set to true, otherwise the original is returned.
[heap]
pub struct AppContext {
pub mut:
win &AppWindow
root &Node
}
Struct that contains all the data about the app.
pub fn (mut app AppContext) run()
Runs the created app context.
pub struct AppConfig {
pub mut:
winconfig WindowConfig
}
Used to initialise the framework.
[heap]
pub struct AppWindow {
pub mut:
gg &gg.Context = unsafe { 0 }
latest_event &gg.Event = unsafe { 0 }
show_fps bool
// Mostly internal use
force_scale f32 = 1
}
Struct containing all the info about the window
pub fn (win AppWindow) get_app_scale() f32
Gets current window scaling to be used with drawing functions.
pub fn (win AppWindow) get_touches() TouchList
Gets current touches state.
pub fn (win AppWindow) get_mouse_pos() NodeV2D
Gets current mouse position.
pub fn (win AppWindow) get_size() NodeV2D
Gets current window size.
pub fn (win AppWindow) get_scale_relative_to(what NodeV2D) f32
Gets scale compared to a specific size.
fn (mut win AppWindow) init(parent &AppContext, mut args WindowConfig)
Initialises the app window using the specified window config.
fn (mut win AppWindow) run()
Starts the window.
pub struct TextConfig {
pub mut:
color gx.Color
size f32
italic bool
relative bool
text string
position NodeV2D
align gx.HorizontalAlign
vertical_align gx.VerticalAlign
}
Config for the text to draw with.
struct TouchList {
pub:
count int
list []NodeV2D
}
Struct containing all the info about the touches.
pub struct WindowConfig {
pub mut:
title string
size NodeV2D
fullscreen bool
ui_mode bool
init_fn fn (&AppContext)
}
Used to initialise the window.