Next: , Previous: , Up: C API   [Contents][Index]


5.26 libgui

5.26.1 Overview

View lcov test coverage results on http://www.ufoot.org/liquidwar/v6/doc/coverage/src/lib/gui/index.html.

5.26.2 API

Function: void lw6gui_button_register_down (lw6sys_context_t * sys_context, lw6gui_button_t * button, int64_t timestamp)

sys_context: global system context

button: the button to update

timestamp: the current ticks (milliseconds)

Registers a "down" (press) event on a button.

Return value: none.

Function: void lw6gui_button_register_up (lw6sys_context_t * sys_context, lw6gui_button_t * button)

sys_context: global system context

button: the button to update

Registers a "up" (release) event on a button.

Return value: none.

Function: int lw6gui_button_is_pressed (lw6sys_context_t * sys_context, const lw6gui_button_t * button)

sys_context: global system context

button: the button to query

Tells wether a button is pressed or not.

Return value: 1 if pressed, 0 if not.

Function: int lw6gui_button_pop_press (lw6sys_context_t * sys_context, lw6gui_button_t * button)

sys_context: global system context

button: the button to query

Tells how many times the button has been pressed. Typical usage: the button is pressed, released, pressed, released several times. Then, after all this, you want to know how many times it has been pressed. Querying its state with lw6gui_button_is_pressed won’t tell you much but this pop_press function will return 1 for each press there’s been.

Return value: 1 if there’s a press event in the queue, 0 if empty.

Function: int lw6gui_button_pop_simple_click (lw6sys_context_t * sys_context, lw6gui_button_t * button)

sys_context: global system context

button: the button to query

Tells how many times the button has been simpleclicked. This is different from a simple press, in fact, there’s a delay, we must wait until the double-click delay is elapsed to make sure this is a simple click... Designed for use with mouse to differentiate fire and alternate fire.

Return value: 1 if there’s a simpleclick event in the queue, 0 if empty.

Function: int lw6gui_button_pop_double_click (lw6sys_context_t * sys_context, lw6gui_button_t * button)

sys_context: global system context

button: the button to query

Tells how many times the button has been doubleclicked. Typical usage: the button is doubleclicked, released, doubleclicked, released several times. Then, after all this, you want to know how many times it has been doubleclicked.

Return value: 1 if there’s a doubleclick event in the queue, 0 if empty.

Function: int lw6gui_button_pop_triple_click (lw6sys_context_t * sys_context, lw6gui_button_t * button)

sys_context: global system context

button: the button to query

Tells how many times the button has been tripleclicked. Typical usage: the button is tripleclicked, released, tripleclicked, released several times. Then, after all this, you want to know how many times it has been tripleclicked.

Return value: 1 if there’s a tripleclick event in the queue, 0 if empty.

Function: void lw6gui_button_update_repeat (lw6sys_context_t * sys_context, lw6gui_button_t * button, lw6gui_repeat_settings_t * repeat_settings, int64_t timestamp, int auto_release_enabled)

sys_context: global system context

button: the button to update

repeat_settings: the repeat settings

timestamp: the current ticks (milliseconds)

Updates the repeat informations for a button, must be called regularly, as often as possible.

Return value: none.

Function: int lw6gui_button_sync (lw6sys_context_t * sys_context, lw6gui_button_t * dst, lw6gui_button_t * src)

sys_context: global system context

dst: the target button object

src: the source button object

Synchronizes two button objects. This is typically used to pass data from one thread to another. This is not a simple copy, it will handle data such as "when was it pressed last" it an intelligent manner, popping src data to put it in dst, and clearing src.

Return value: 1 if success, O if failure.

Function: int lw6gui_coord_calc_xy (lw6sys_context_t * sys_context, float * dst_x, float * dst_y, float dst_x0, float dst_y0, float dst_w, float dst_h, float src_x, float src_y, float src_x0, float src_y0, float src_w, float src_h)

sys_context: global system context

dst_x: the x coord to return

dst_y: the y coord to return

dst_x0: the x coord of point 0 in destination coord system

dst_y0: the y coord of point 0 in destination coord system

dst_w: the width of the area in destination coord system

dst_h: the width of the area in destination coord system

src_x: the x coord in source coord system

src_y: the y coord in source coord system

src_x0: the x coord of point 0 in source coord system

src_y0: the y coord of point 0 in source coord system

src_w: the width of the area in source coord system

src_h: the width of the area in source coord system

Registers a "down" (press) event on a button.

Return value: 1 if OK, 0 if error (unable to calculate).

Function: void lw6gui_coords_fix_xy_float (lw6sys_context_t * sys_context, float * x, float * y, int * x_flip, int * y_flip, float w, float h, int x_polarity, int y_polarity)

sys_context: global system context

x: x coord (in/out param)

y: y coord (in/out param)

x_flip: flip on x (out param, -1 or +1)

y_flip: flip on y (out param, -1 or +1)

w: width

h: height

x_polarity: x polarity (-1, 0 or 1)

y_polarity: y polarity (-1, 0 or 1)

Same as lw6map_fix_coords except it operates on floats. Usefull for cursor and other rendering operations. Additionnally, will keep track of inversions, that is to say if map is flip in one or another way. Be carefull, the flip values are -1 or 1 so that it’s easy to multiply an offset by it, for instance, but this means testing if flip is not 0 will always return true, you must test if flip is stritly positive or negative.

Return value: none

Function: int lw6gui_input_init (lw6sys_context_t * sys_context, lw6gui_input_t * input)

sys_context: global system context

input: the input struct to initialise

Initialises an input structure, don’t use twice, it won’t free a previous init.

Return value: a pointer to the newly allocated object.

Function: void lw6gui_input_quit (lw6sys_context_t * sys_context, lw6gui_input_t * input)

sys_context: global system context

input: the input struct to uninitialise

Unitialises an input structure, need to call it to free event queue.

Return value: a pointer to the newly allocated object.

Function: lw6gui_input_t * lw6gui_input_new (lw6sys_context_t * sys_context)

sys_context: global system context

Creates an input structure, which can be used to handle input state & buffer.

Return value: a pointer to the newly allocated object.

Function: void lw6gui_input_free (lw6sys_context_t * sys_context, lw6gui_input_t * input)

sys_context: global system context

input: the input object to free.

Deletes an input structure.

Return value: none.

Function: int lw6gui_input_reset (lw6sys_context_t * sys_context, lw6gui_input_t * input)

sys_context: global system context

input: the input struct to reset

Resets an input structure. Must have been initialized before. It will empty all queues and mark everything as unpressed.

Return value: 1 on success, 0 if failure.

Function: void lw6gui_input_update_repeat (lw6sys_context_t * sys_context, lw6gui_input_t * input, lw6gui_repeat_settings_t * repeat_settings, int64_t timestamp)

sys_context: global system context

input: the input to update

repeat_settings: the repeat settings (delay + interval)

timestamp: the current ticks (milliseconds)

Updates the repeat informations for an input, must be called regularly, as often as possible.

Return value: none.

Function: void lw6gui_input_register_change (lw6sys_context_t * sys_context, lw6gui_input_t * input)

sys_context: global system context

input: the input to update

Tells an input object that one of its descendants has been modified. This will affect the return value of lw6gui_input_need_sync

Return value: none.

Function: int lw6gui_input_need_sync (lw6sys_context_t * sys_context, const lw6gui_input_t * input)

sys_context: global system context

input: the input to test

Tests wether an input object contains was modified and needs synchronisation.

Return value: 1 if sync is need, 0 if not.

Function: int lw6gui_input_sync (lw6sys_context_t * sys_context, lw6gui_input_t * dst, lw6gui_input_t * src)

sys_context: global system context

dst: the target input object

src: the source input object

Synchronizes two input objects. This is typically used to pass data from one thread to another. This is not a copy, it will brute-force copy the static data such as mouse position, but anything like a queue will be treated in a "empty source and fill target with data" scheme. So source will be affected by this, the key buffer will be emptied, and so on. And if there are key in the target buffer, they won’t be overwritten but kept in front of the FIFO list.

Return value: 1 if success, O if failure.

Function: void lw6gui_input_enable_auto_release (lw6sys_context_t * sys_context, lw6gui_input_t * input)

sys_context: global system context

input: input object to modify

Enables auto_release mode, in this mode, it’s assummed after some time any key is automatically released.

Return value: none.

Function: int lw6gui_joystick_check_index (lw6sys_context_t * sys_context, int i)

sys_context: global system context

i: index to check

Checks wether the index is correct. Does not mean the joystick exists, it’s just to avoid out of bounds errors.

Return value: 1 if within range, 0 if not.

Function: void lw6gui_joystick_update_axis_x (lw6sys_context_t * sys_context, lw6gui_joystick_t * joystick, int x, int limit, int64_t timestamp)

sys_context: global system context

joystick: joystick to update

x: x-axis position, as returned by the driver

limit: the limit, under this, buttons are considered unpressed.

timestamp: current ticks (timestamp in ms)

Updates the x axis of a joystick, this will convert an information of analog type such as "joystick is here" to a pad-like information such as "pressed in that direction".

Return value: 1 if within range, 0 if not.

Function: void lw6gui_joystick_update_axis_y (lw6sys_context_t * sys_context, lw6gui_joystick_t * joystick, int y, int limit, int64_t timestamp)

sys_context: global system context

joystick: joystick to update

limit: the limit, under this, buttons are considered unpressed.

timestamp: current ticks (timestamp in ms)

Updates the y axis of a joystick, this will convert an information of analog type such as "joystick is here" to a pad-like information such as "pressed in that direction".

Return value: 1 if within range, 0 if not.

Function: void lw6gui_joystick_update_repeat (lw6sys_context_t * sys_context, lw6gui_joystick_t * joystick, lw6gui_repeat_settings_t * repeat_settings, int64_t timestamp)

sys_context: global system context

joystick: the joystick to update

repeat_settings: the repeat settings (delay + interval)

timestamp: the current ticks (milliseconds)

Updates the repeat informations for a joystick, must be called regularly, as often as possible.

Return value: none.

Function: int lw6gui_joystick_sync (lw6sys_context_t * sys_context, lw6gui_joystick_t * dst, lw6gui_joystick_t * src)

sys_context: global system context

dst: the target joystick object

src: the source joystick object

Synchronizes two joystick objects. This is typically used to pass data from one thread to another.

Return value: 1 if success, O if failure.

Function: void lw6gui_joystick_get_move_pad (lw6sys_context_t * sys_context, const lw6gui_joystick_t * joystick, lw6gui_move_pad_t * move_pad)

sys_context: global system context

joystick: the joystick to query

move_pad: the structure which will contain the results

Returns the state of the joystick in a uniform, non-device specific structure containing only the up/down/left/right information.

Return value: none, the value are stored in move_pad.

Function: int lw6gui_keyboard_check_keysym (lw6sys_context_t * sys_context, int keysym)

sys_context: global system context

keysym: the keysym to check

Tells wether the keysym is valid or not.

Return value: 1 if valid, 0 if not

Function: lw6gui_keypress_t * lw6gui_keyboard_pop_keypress (lw6sys_context_t * sys_context, lw6gui_keyboard_t * keyboard)

sys_context: global system context

keyboard: the keyboard structure which stores keyboard state

Pops (in FIFO mode) a keypress stored in the keyboard buffer. You must free the obtained keypress object after you’re done with it.

Return value: a newly allocated pointer, or NULL if no keypress pending.

Function: int lw6gui_keyboard_is_pressed (lw6sys_context_t * sys_context, const lw6gui_keyboard_t * keyboard, int keysym)

sys_context: global system context

keyboard: the keyboard structure which stores keyboard state

Tells wether a key is pressed or not. The function will test out of bound values.

Return value: 1 if pressed, 0 if not.

Function: int lw6gui_keyboard_register_key_down (lw6sys_context_t * sys_context, lw6gui_keyboard_t * keyboard, int keysym, int unicode, char * label, int64_t timestamp)

sys_context: global system context

keyboard: the keyboard structure which will store the keypress

keysym: the keysym for the keypress

unicode: the ASCII/unicode code for the keypress

label: the label for the keypress

timestamp: the current ticks (timestamp in ms)

Registers a keypress event, that is, puts it in the event queue. This function does not take an lw6gui_keypress_t structure but separated args, this is because it will construct the object internally. You may free label after calling this, an internal copy will be done. This function will also maintain the array of key states up to date.

Return value: 1 if success, O if failure.

Function: int lw6gui_keyboard_register_key_up (lw6sys_context_t * sys_context, lw6gui_keyboard_t * keyboard, int keysym)

sys_context: global system context

keyboard: the keyboard structure which will store the keypress

keysym: the keysym for the keypress

Registers a key release event.

Return value: 1 if success, O if failure.

Function: void lw6gui_keyboard_update_repeat (lw6sys_context_t * sys_context, lw6gui_keyboard_t * keyboard, lw6gui_repeat_settings_t * repeat_settings, int64_t timestamp)

sys_context: global system context

keyboard: the keyboard to update

repeat_settings: the repeat settings (delay + interval)

timestamp: the current ticks (milliseconds)

Updates the repeat informations for a keyboard, must be called regularly, as often as possible.

Return value: none.

Function: int lw6gui_keyboard_sync (lw6sys_context_t * sys_context, lw6gui_keyboard_t * dst, lw6gui_keyboard_t * src)

sys_context: global system context

dst: the target keyboard object

src: the source keyboard object

Synchronizes two keyboard objects. This is typically used to pass data from one thread to another. Will pop the src queue to fill the dst queue.

Return value: 1 if success, O if failure.

Function: void lw6gui_keyboard_get_move_pad (lw6sys_context_t * sys_context, const lw6gui_keyboard_t * keyboard, lw6gui_move_pad_t * move_pad)

sys_context: global system context

keyboard: the keyboard to query

move_pad: the structure which will contain the results

Returns the state of the keyboard in a uniform, non-device specific structure containing only the up/down/left/right information.

Return value: none, the value are stored in move_pad.

Function: lw6gui_keypress_t * lw6gui_keypress_new (lw6sys_context_t * sys_context, int keysym, int unicode, const char * label)

sys_context: global system context

keysym: the keysym to use

unicode: the unicode value for this keysym

label: the label (optional, might be NULL)

Creates a keypress structure, the only reason for needing a contructor is that the label field needs be duplicated.

Return value: a pointer to the newly allocated object.

Function: void lw6gui_keypress_free (lw6sys_context_t * sys_context, lw6gui_keypress_t * keypress)

sys_context: global system context

keypress: the keypress object to free.

Deletes a keypress structure.

Return value: none.

Function: char * lw6gui_keypress_repr (lw6sys_context_t * sys_context, const lw6gui_keypress_t * keypress)

sys_context: global system context

keypress: the keypress to work on

Returns a human-readable representation of the keypress.

Return value: a newly allocated string

Function: lw6gui_look_t * lw6gui_look_new (lw6sys_context_t * sys_context, const lw6map_style_t * map_style)

sys_context: global system context

map_style: map_style to use as a base

Create a new look object, a look is basically a style plus some dynamic parameters.

Return value: newly created object.

Function: void lw6gui_look_free (lw6sys_context_t * sys_context, lw6gui_look_t * look)

sys_context: global system context

look: look object to free

Frees a look and all its members.

Return value: none.

Function: int lw6gui_look_memory_footprint (lw6sys_context_t * sys_context, const lw6gui_look_t * look)

sys_context: global system context

look: look object to query

Gives the memory taken by this object in memory.

Return value: number of bytes.

Function: char * lw6gui_look_repr (lw6sys_context_t * sys_context, const lw6gui_look_t * look)

sys_context: global system context

look: look object to describe

Returns a readable description of the object.

Return value: newly allocated string.

Function: int lw6gui_look_set (lw6sys_context_t * sys_context, lw6gui_look_t * look, char * key, char * value)

sys_context: global system context

look: look object to modify

key: the key to change

value: the new value for the key

Sets a new value for a given key in the look. The value is always a string, it will be converted/casted to the right type if needed.

Return value: 1 on success, 0 on failure.

Function: char * lw6gui_look_get (lw6sys_context_t * sys_context, const lw6gui_look_t * look, char * key)

sys_context: global system context

look: look object to query

key: the key to get

Gets a new value for a given key in the look. The value is always a string, it will be converted/casted from the right type if needed.

Return value: dynamically allocated string.

Function: int lw6gui_look_is_same (lw6sys_context_t * sys_context, const lw6gui_look_t * look_a, const lw6gui_look_t * look_b)

sys_context: global system context

look_a: first object to compare

look_b: second object to compare

Compares two look objects, doing recursive comparisons. This can be very usefull if, for instance, a graphics renderer is using some contextual objects that depend on the look (colors?) and need to be updated/regenerated on a look change

Return value: 1 if they are the same, 0 if not.

Function: lw6gui_look_t * lw6gui_look_dup (lw6sys_context_t * sys_context, const lw6gui_look_t * look)

sys_context: global system context

look: object to duplicate

Duplicates a look object, performing recursive copies.

Return value: newly allocated object.

Function: void lw6gui_look_fix (lw6sys_context_t * sys_context, lw6gui_look_t * look)

sys_context: global system context

look: look object to modify

Peforms sanity checks and modifies the look if needed, to make all values fit within acceptable ranges, among other things.

Return value: none.

Function: int lw6gui_look_zoom_in (lw6sys_context_t * sys_context, lw6gui_look_t * look, float zoom_step)

sys_context: global system context

look: look object to act upon

zoom_step: how much we should zoom, 2.0 means 2 times bigger

Zooms in, the function does not only multiplicates the current zoom, it also performs sanity checks.

Return value: 1 if zoom was changed, 0 if not.

Function: int lw6gui_look_zoom_out (lw6sys_context_t * sys_context, lw6gui_look_t * look, float zoom_step)

sys_context: global system context

look: look object to act upon

zoom_step: how much we should zoom, 2.0 means 2 times smaller

Zooms out, the function does not only divides the current zoom, it also performs sanity checks.

Return value: 1 if zoom was changed, 0 if not.

Function: lw6gui_menu_t * lw6gui_menu_new (lw6sys_context_t * sys_context, const char * title, const char * help, const char * popup, const char * esc, int enable_esc)

sys_context: global system context

title: the string to be displayed, what the user sees. Can be freed after the call is done, function will make a copy internally.

help: a string introducing the menu, describing what it does, giving hints on how to use it.

popup: a string to be displayed in popup mode when menu is displayed for the first time.

esc: the label to be displayed in the ESC button

enable_esc: wether to enable the escape button.

Constructs a new menu object. Note that you can always call other functions to modify it afterwards.

Return value: a pointer to the newly allocated object.

Function: void lw6gui_menu_free (lw6sys_context_t * sys_context, lw6gui_menu_t * menu)

sys_context: global system context

menu: a pointer to the menu.

Frees the menu, checking if things are OK before doing so.

Return value: none.

Function: int lw6gui_menu_memory_footprint (lw6sys_context_t * sys_context, lw6gui_menu_t * menu)

sys_context: global system context

menu: a pointer to the menu.

Gets the memory occupied by the menu. Could be usefull to help a garbage collector taking decisions or reporting erros, for instance.

Return value: the number of bytes used.

Function: char * lw6gui_menu_repr (lw6sys_context_t * sys_context, const lw6gui_menu_t * menu)

sys_context: global system context

menu: a pointer to the menu.

Constructs a readable description of the object. Usefull for debugging, or to introspect things using scripts, at run-time. Does not necessarly describe all the informations about the object, but helps knowing what it is.

Return value: a string describing the object, must be freed.

Function: void lw6gui_menu_set_title (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, const char * title)

sys_context: global system context

menu: a pointer to the menu.

title: the new title, you can free it after calling the function, an internal copy will be made.

Change the title of the menu. Use this function to change the title, don’t try to access the struct directly. The idea is to have safe memory management.

Return value: none

Function: void lw6gui_menu_set_help (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, const char * help)

sys_context: global system context

menu: a pointer to the menu.

help: the new help, you can free it after calling the function, an internal copy will be made.

Change the help of the menu. Use this function to change the help, don’t try to access the struct directly. The idea is to have safe memory management.

Return value: none

Function: void lw6gui_menu_set_popup (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, const char * popup)

sys_context: global system context

menu: a pointer to the menu.

popup: the new popup, you can free it after calling the function, an internal copy will be made.

Change the popup of the menu. That is to say, its popup. Use this function to change the popup, don’t try to access the struct directly. The idea is to have safe memory management.

Return value: none

Function: void lw6gui_menu_close_popup (lw6sys_context_t * sys_context, lw6gui_menu_t * menu)

sys_context: global system context

menu: a pointer to the menu.

Closes the popup, in practice, this is equivalent to setting the popup string to "" or NULL.

Return value: none

Function: int lw6gui_menu_has_popup (lw6sys_context_t * sys_context, lw6gui_menu_t * menu)

sys_context: global system context

menu: a pointer to the menu.

Tells wether a popup is defined. Behavior is simplistic, at creation (when a non-NULL non-empty popup string has been set) then the popup is displayed. In this state, popup is considered to be defined. Then it can be close, and after this action the popup ain’t here anymore, program continues the way it started.

Return value: 1 if has popup, 0 if does not

Function: lw6gui_menuitem_t * lw6gui_menu_get_item (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int position)

sys_context: global system context

menu: the menu we want to query

position: the order of the item we want

Gets the menu item at the given position. First item is 0, last is N-1. Returns a pointer on the real object, not a copy.

Return value: a pointer to a menu item, NULL if out of range.

Function: int lw6gui_menu_select (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int position, int allow_scroll, int64_t now)

sys_context: global system context

menu: the menu we want to modify

position: the position of the item we want to select

allow_scroll: wether scrolling should be allowed when displaying it

now: the current time, as a timestamp.

Selects the item at the given position. Use this function to be sure that only one item is selected, and all other states are consistent. Timestamp is needed for the sake of eye-candy.

Return value: 1 if success, 0 if failure (out of range).

Function: void lw6gui_menu_select_esc (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int state, int64_t now)

sys_context: global system context

menu: the menu we want to modify

state: 1 to select, 0 to unselect

now: the current time, as a timestamp.

Selects the escape item, this does not affect other items, it’s mostly. to handle eye candy.

Return value: none.

Function: void lw6gui_menu_enable_esc (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int state, int64_t now)

sys_context: global system context

menu: the menu we want to modify

state: 1 to enable, 0 to disable

now: the current time, as a timestamp.

Enables the escape item, this does not affect other items, it’s mostly. to handle eye candy.

Return value: none.

Function: int lw6gui_menu_scroll_up (lw6sys_context_t * sys_context, lw6gui_menu_t * menu)

sys_context: global system context

menu: the menu to scroll

Scrolls a menu up, used as a callback for mouse wheel up for instance. The idea is just to decrement the first displayed item index.

Return value: 1 if OK, 0 if failed (out of range).

Function: int lw6gui_menu_scroll_down (lw6sys_context_t * sys_context, lw6gui_menu_t * menu)

sys_context: global system context

menu: the menu to scroll

Scrolls a menu down, used as a callback for mouse wheel down for instance. The idea is just to increment the first displayed item index.

Return value: 1 if OK, 0 if failed (out of range).

Function: int lw6gui_menu_set_breadcrumbs (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, lw6sys_list_t * breadcrumbs)

sys_context: global system context

menu: the menu to scroll

breadcrumbs: list of strings containing breadcrumbs

Set the breadcrumbs, that’s to say the readable, logical path to get to a given menu. This is just eye candy, not linked to any logic at this level.

Return value: 1 if OK, 0 if failed.

Function: void lw6gui_menu_center (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int position, int max_displayed_items)

sys_context: global system context

menu: the menu to center

position: the position of the menuitem to be put in the center

max_displayed_items: the maximum number of items displayed

Centers the menu on a given menuitem. Typically used when pushing a menu with a menuitem selected ’anywhere’ in the list.

Return value: none.

Function: int lw6gui_menu_insert (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, lw6gui_menuitem_t * menuitem, int position, int64_t now)

sys_context: global system context

menu: the menu we want to modify

menuitem: the item to insert

position: the position the new item will occupy ("insert before" mode)

now: the current time, as a timestamp.

Inserts the given item in the menu. All items starting at the insert position will be "pushed" (that is, their position incremented by 1). Once the menuitem is inserted, the menu object will take care of memory management and automatically free it when needed.

Return value: 1 if success, 0 if failure (memory problem, out of range).

Function: int lw6gui_menu_append (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, lw6gui_menuitem_t * menuitem, int64_t now)

sys_context: global system context

menu: the menu we want to modify

menuitem: the item to insert

now: the current time, as a timestamp.

Appends the given item to the menu. Once the menuitem is appended, the menu object will take care of memory management and automatically free it when needed.

Return value: 1 if success, 0 if failure (memory problem).

Function: int lw6gui_menu_remove (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int position, int64_t now)

sys_context: global system context

menu: the menu we want to modify

position: the item to insert

now: the current time, as a timestamp.

Removes an item from the menu. It will automatically be freed.

Return value: 1 if success, 0 if failure (out of range).

Function: int lw6gui_menu_remove_all (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int64_t now)

sys_context: global system context

menu: the menu we want to modify

now: the current time, as a timestamp.

Removes all items from the menu, usefull when one wants to repopulate the items completely, from scratch.

Return value: 1 if success, 0 if failure.

Function: void lw6gui_menu_update_display_range (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int max_displayed_items)

sys_context: global system context

menu: the menu concerned

max_displayed_items: the maximum number of items to display at once

Updates the display range. The reason for having this is that the first item, that is, how far we scroll in a very long menu, depends on the previous position. Plus you have to handle limit cases (begin/end). Thus, this function, which will automatically pick-up a suitable position. Of course, first_item_displayed is not necessarly equal to selected_item.

Return value: none.

Function: int lw6gui_menu_insert_for_id_use (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, char * label, char * tooltip, int value, int enabled, int selected, int colored, int position, int64_t now)

sys_context: global system context

menu: the menu to work on

label: the label of the menuitem to append

tooltip: the tooltip of the menuitem to append

value: the value of the menuitem to append

enabled: wether the inserted menuitem should be enabled

selected: wether the inserted menuitem should be selected

colored: wether the inserted menuitem should use value as its color

now: current time (timestamp)

Inserts a menu item at the given position. The idea is that the menu item object is automatically constructed on the fly, and an id is returned, which can be passed to ’_using_id’ menu-related functions. This is typically for using in scripts. The idea is that the script just keeps a copy of the id returned, and can this way operate directly on the menuitem without keeping a pointer, a smob or anything internally. From the C point of view, having a real C structure enables persistent data from one display to the other, and this is nice and conveninent. I acknowledge the prototype is scary.

Return value: 0 if error, or else an id which will later be used with ’_using_id’ functions.

Function: int lw6gui_menu_append_for_id_use (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, char * label, char * tooltip, int value, int enabled, int selected, int colored, int64_t now)

sys_context: global system context

menu: the menu to work on

label: the label of the menuitem to append

tooltip: the tooltip of the menuitem to append

value: the value of the menuitem to append

enabled: wether the appended menuitem should be enabled

selected: wether the appended menuitem should be selected

colored: wether the appended menuitem should use value as its color

now: current time (timestamp)

Appends a menuitem using the same logic as lw6gui_menu_insert_for_id_use that is to say a parameter is returned which can later be used to directly operate on a given menuitem, without having its pointer, and even if its position changes.

Return value: 0 if error, or else an id which will later be used with ’_using_id’ functions.

Function: int lw6gui_menu_remove_using_id (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int menuitem_id, int64_t now)

sys_context: global system context

menu: the menu to work on

menuitem_id: the id of the menuitem to remove

now: current time (timestamp)

Deletes the menuitem with the given id. Very important: the id is not the position. Id are arbitrary numbers that stick to menuitems, but they are not directly linked with the position. This function is practical to use if, for some reason, you don’t have the pointer on the menuitem.

Return value: 1 if success, 0 if failure (out of range).

Function: void lw6gui_menu_sync_using_id (lw6sys_context_t * sys_context, lw6gui_menu_t * menu, int menuitem_id, char * label, char * tooltip, int value, int enabled, int selected, int colored, int64_t now)

sys_context: global system context

menu: the menu to work on

menuitem_id: the id of the menuitem to synchronize

label: menu label

tooltip: menu tooltip

value: value

enabled: wether it’s usable or not

selected: 1 if the menuite is current item

colored: wether to use color

now: current time (timestamp)

Updates the menuitem with the given id. Very important: the id is not the position. Id are arbitrary numbers that stick to menuitems, but they are not directly linked with the position. This function is practical to use if, for some reason, you don’t have the pointer on the menuitem. In practice, it’s heavily used in the game to transmit informations from the scripts to the core C engine. Additionnaly, this function will automatically synchronize the selected_item field of the menu struct.

Return value: 1 if success, 0 if failure (out of range).

Function: int lw6gui_menu_is_same (lw6sys_context_t * sys_context, const lw6gui_menu_t * menu_a, const lw6gui_menu_t * menu_b)

sys_context: global system context

menu_a: first item to compare

menu_b: second item to compare

Compares two menus.

Return value: 1 if they are the same, 0 if not

Function: lw6gui_menu_t * lw6gui_menu_dup (lw6sys_context_t * sys_context, const lw6gui_menu_t * menu)

sys_context: global system context

menu: the menu to duplicate

Duplicates a menu structure.

Return value: a pointer to the new menu.

Function: int lw6gui_menu_sync (lw6sys_context_t * sys_context, lw6gui_menu_t * dst, lw6gui_menu_t * src)

sys_context: global system context

dst: the target menu

src: the source menu

Synchronizes two menus, this supposes that they represent the same menu, but simply in a different state. This function does not really copy src to dst, it has a special behavior, indeed everything is copied from src to dst, except the first_item_displayed and nb_items_displayed which are taken from dst and copied to src. This is because in practise, those values are updated in the display loop/thread, which is the one which uses the target. This is not very orthodox, but should work.

Return value: 1 if success, 0 if failure

Function: lw6gui_menuitem_t * lw6gui_menuitem_new (lw6sys_context_t * sys_context, const char * label, const char * tooltip, int value, int enabled, int selected, int colored)

sys_context: global system context

label: the string to be displayed, what the user sees. Can be freed after the call is done, function will make a copy internally.

tooltip: the string to be displayed as a tooltip, describing the menu item in detail. Can be NULL if you don’t want to use this feature.

value: the value. No GUI function uses this, this is the "real" value associated to the item.

enabled: wether the menu item can be selected, used, and so on

selected: wether the menu item is the item selected among all menu items.

colored: wetherr the menu item must, when drawn, be colored according to its value.

Constructs a new menuitem object. Note that you can always call other functions to modify these values afterwards, this might change rendering since lw6gui_menuitem_set_value or lw6gui_menuitem_set_label will, for instance, modify the "when was that item last modified" information.

Return value: a pointer to the newly allocated object.

Function: void lw6gui_menuitem_free (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem)

sys_context: global system context

menuitem: a pointer to the menuitem.

Frees the menuitem, checking if things are OK before doing so.

Return value: none.

Function: int lw6gui_menuitem_memory_footprint (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem)

sys_context: global system context

menuitem: a pointer to the menuitem.

Gets the memory occupied by the menuitem. Could be usefull to help a garbage collector taking decisions or reporting erros, for instance.

Return value: the number of bytes used.

Function: char * lw6gui_menuitem_repr (lw6sys_context_t * sys_context, const lw6gui_menuitem_t * menuitem)

sys_context: global system context

menuitem: a pointer to the menuitem.

Constructs a readable description of the object. Usefull for debugging, or to introspect things using scripts, at run-time. Does not necessarly describe all the informations about the object, but helps knowing what it is.

Return value: a string describing the object, must be freed.

Function: void lw6gui_menuitem_set_label (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem, const char * label, int64_t now)

sys_context: global system context

menuitem: a pointer to the menuitem.

label: the new label, you can free it after calling the function, an internal copy will be made.

now: the current time, as a timestamp.

Change the label of the menu item. That is to say, what the user sees. Use this function to change the menuitem value, don’t try to access the struct directly. The idea is 1) to have safe memory management and 2) to keep the last_change member up to date. It can be later used for eye-candy effects.

Return value: none

Function: void lw6gui_menuitem_set_tooltip (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem, const char * tooltip, int64_t now)

sys_context: global system context

menuitem: a pointer to the menuitem.

tooltip: the new tooltip, you can free it after calling the function, an internal copy will be made.

now: the current time, as a timestamp.

Change the tooltip of the menu item (the explanation of what the item is about) Use this function to change the menuitem value, don’t try to access the struct directly. The idea is 1) to have safe memory management and 2) to keep the last_change member up to date. It can be later used for eye-candy effects.

Return value: none

Function: void lw6gui_menuitem_set_value (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem, int value, int64_t now)

sys_context: global system context

menuitem: a pointer to the menuitem.

value: the new value.

now: the current time, as a timestamp.

Changes the value of a menuitem. This is the internal value, not what the user sees. Use this function to change the menuitem value, don’t try to access the struct directly. The idea is to keep the last_change member up to date. It can be later used for eye-candy effects.

Return value: none

Function: void lw6gui_menuitem_select (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem, int state, int64_t now)

sys_context: global system context

menuitem: a pointer to the menuitem.

state: 1 to select, 0 to unselect

now: the current time, as a timestamp.

Switches the menuitem to (un)selected state. Use this function, don’t try to modify the struct members directly. The idea is to have the last_select parameter up to date. It can be later used for eye-candy effects.

Return value: none

Function: void lw6gui_menuitem_enable (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem, int state, int64_t now)

sys_context: global system context

menuitem: a pointer to the menuitem.

state: 1 to enable, 0 to disable

now: the current time, as a timestamp.

Switches the menuitem to enabled/disabled state. Use this function, don’t try to modify the struct members directly. The idea is to have the last_select parameter up to date. It can be later used for eye-candy effects.

Return value: none

Function: u_int32_t lw6gui_menuitem_checksum (lw6sys_context_t * sys_context, lw6gui_menuitem_t * menuitem, lw6gui_look_t * look)

sys_context: global system context

menuitem: the menuitem we want to identify

Returns a checksum which can be used to know, for instance, wether the menuitem has changed or not, and if we should redraw it.

Return value: a checksum.

Function: int lw6gui_menuitem_is_same (lw6sys_context_t * sys_context, const lw6gui_menuitem_t * menuitem_a, const lw6gui_menuitem_t * menuitem_b)

sys_context: global system context

menuitem_a: first item to compare

menuitem_b: second item to compare

Compares two menuitems.

Return value: 1 if they are the same, 0 if not

Function: lw6gui_menuitem_t * lw6gui_menuitem_dup (lw6sys_context_t * sys_context, const lw6gui_menuitem_t * menuitem)

sys_context: global system context

menuitem: the menuitem to duplicate

The menuitem to duplicate.

Return value: a pointer to the duplicted menuitem.

Function: int lw6gui_menuitem_sync (lw6sys_context_t * sys_context, lw6gui_menuitem_t * dst, lw6gui_menuitem_t * src)

sys_context: global system context

dst: the target menuitem

src: the source menuitem

Synchronizes two menuitems, this supposes that they represent the same item, but simply in a different state.

Return value: 1 if success, 0 if failure

Function: void lw6gui_mouse_register_move (lw6sys_context_t * sys_context, lw6gui_mouse_t * mouse, int screen_pos_x, int screen_pos_y, int64_t timestamp)

sys_context: global system context

mouse: the mouse object to work on

screen_pos_x: the x position on screen

screen_pos_y: the y position on screen

timestamp: current timestamp

Registers a mouse move event.

Return value: note.

Function: int lw6gui_mouse_poll_move (lw6sys_context_t * sys_context, lw6gui_mouse_t * mouse, int * screen_pos_x, int * screen_pos_y)

sys_context: global system context

mouse: the mouse object to poll

screen_pos_x: pointer to the x position (can be NULL), will be updated even if no move

screen_pos_y: pointer to the y position (can be NULL), will be updated even if no move

Asks wether the mouse has moved or not.

Return value: 1 if mouse was moved since last call, 0 if not.

Function: void lw6gui_mouse_update_repeat (lw6sys_context_t * sys_context, lw6gui_mouse_t * mouse, lw6gui_repeat_settings_t * repeat_settings, int64_t timestamp)

mouse: the mouse to update

repeat_settings: the repeat settings (delay + interval)

timestamp: the current ticks (milliseconds)

Updates the repeat informations for a mouse, must be called regularly, as often as possible.

Return value: none.

Function: int lw6gui_mouse_sync (lw6sys_context_t * sys_context, lw6gui_mouse_t * dst, lw6gui_mouse_t * src)

sys_context: global system context

dst: the target mouse object

src: the source mouse object

Synchronizes two mouse objects. This is typically used to pass data from one thread to another. Will handle "mouse move" attribute and clear it in src if needed while setting it in dst.

Return value: 1 if success, O if failure.

Function: void lw6gui_mouse_drag_begin (lw6sys_context_t * sys_context, lw6gui_mouse_t * mouse)

sys_context: global system context

mouse: mouse struct to update

To be called when one wants to start recording a drag session, typically when left button is pressed.

Return value: none.

Function: void lw6gui_mouse_drag_end (lw6sys_context_t * sys_context, lw6gui_mouse_t * mouse)

sys_context: global system context

mouse: mouse struct to update

To be called when one wants to stop recording a drag session, typically when left button is released.

Return value: none.

Function: int lw6gui_mouse_drag_pop (lw6sys_context_t * sys_context, lw6gui_mouse_t * mouse, int * delta_x, int * delta_y, int * pos_x, int * pos_y, int * speed_x, int * speed_y)

sys_context: global system context

mouse: mouse struct to query

delta_x: x movement (on screen, out param can be NULL)

delta_y: y movement (on screen, out param can be NULL)

pos_x: x pos (on screen, out param can be NULL)

pos_y: y pos (on screen, out param can be NULL)

speed_x: x speed (on screen, out param can be NULL)

speed_y: y speed (on screen, out param can be NULL)

To be called when one wants to stop recording a drag session, typically when left button is released.

Return value: none.

Function: int lw6gui_point_is_inside_rect (lw6sys_context_t * sys_context, lw6gui_point_t point, const lw6gui_rect_t * rect)

sys_context: global system context

point: point to test

rect: rectangle in which point is supposed to be

Tests wether a point is inside a rectangle, this is typically used to know if a point is inside the right texture or if we’re outside.

Return value: 1 if OK, 0 if outside

Function: int lw6gui_power_of_two_ge (lw6sys_context_t * sys_context, int input)

sys_context: global system context

input: the value to approach

Finds the closest power of two, which is at least greater or equal to input. Typically used to size textures.

Return value: a power of two.

Function: int lw6gui_power_of_two_le (lw6sys_context_t * sys_context, int input)

sys_context: global system context

input: the value to approach

Finds the closest power of two, which is equal of inferior to input. Typically used to size textures.

Return value: a power of two.

Function: int lw6gui_quad_is_inside_rect (lw6sys_context_t * sys_context, const lw6gui_quad_t * quad, const lw6gui_rect_t * rect)

sys_context: global system context

quad: quad to test

rect: rectangle in which quad is supposed to be

Tests wether a quad is inside a rectangle, this is typically used to know if a quad is inside the right texture or if we’re outside.

Return value: 1 if OK, 0 if outside

Function: int lw6gui_rect_array_init (lw6sys_context_t * sys_context, lw6gui_rect_array_t * rect_array, int w, int h, int tile_size, int border_size)

sys_context: global system context

rect_array: the rectangle array to initializae

w: width of the zone to initialize

h: height of the zone to initialize

tile_size: tile size, that is, width and height of sub rectangles

border_size: border to add so that sub rectangles overlap

Initializes a rect array structure, this is usefull for texture handling, it builds an array of sub-rectangle which slightly overlap each other.

Return value: 1 on success, 0 on failure.

Function: int lw6gui_rect_array_get_tile_by_source_xy (lw6sys_context_t * sys_context, const lw6gui_rect_array_t * rect_array, lw6gui_rect_t * rect, int * i, int source_x, int source_y)

sys_context: global system context

rect_array: the rectangle array to initializae

rect: the sub-rectangle (out param)

i: the index of the sub-rectangle (out param)

source_x: the x position on the global rect array

source_y: the y position on the global rect array

Finds out which sub-rectangle is the right one, given a source position. The output values are a correctly initialized sub-rectangle with relative position set plus its index within the container rectangle array.

Return value: 1 on success, 0 on failure.

Function: int lw6gui_rect_array_get_tile_by_i (lw6sys_context_t * sys_context, const lw6gui_rect_array_t * rect_array, lw6gui_rect_t * rect, int i)

sys_context: global system context

rect_array: the rectangle array to initializae

rect: the sub-rectangle (out param)

i: the index of the sub-rectangle

Finds out which sub-rectangle is the right one, given a source position. The output value is a correctly initialized sub-rectangle with relative position set.

Return value: 1 on success, 0 on failure.

Function: int lw6gui_rect_array_get_tile_and_quad (lw6sys_context_t * sys_context, const lw6gui_rect_array_t * rect_array, lw6gui_rect_t * rect, int * i, lw6gui_quad_t * quad, const lw6gui_quad_t * source_quad, int x_polarity, int y_polarity)

sys_context: global system context

rect_array: the rectangle array to initializae

rect: the sub-rectangle (out param)

i: the index of the sub-rectangle (out param)

quad: the 4 corresponding points within the sub-rectangle (out param)

source_quad: 4 points within the container rectangle array

x_polarity: polarity along the X axis

y_polarity: polarity along the Y axis

Finds out which sub-rectangle is the right one, given 4 points as an input, and places these 4 points on the sub-rectangle, taking in account the polarity. This is typically used for texture mapping. Note that a rectangle array can’t handle all requests, it need have the good size, granularity.

Return value: 1 on success, 0 on failure.

Function: void lw6gui_rect_init_x1y1x2y2 (lw6sys_context_t * sys_context, lw6gui_rect_t * rect, int x1, int y1, int x2, int y2)

sys_context: global system context

rect: the structure to initialize

x1: x for top left corner

y1: y for top left corner

x2: x for bottom right corner

y2: y for bottom right corner

Initializes a rect structure, will calculate w & h.

Return value: none.

Function: void lw6gui_rect_init_xywh (lw6sys_context_t * sys_context, lw6gui_rect_t * rect, int x, int y, int w, int h)

sys_context: global system context

rect: the structure to initialize

x: x for top left corner

y: y for top left corner

w: width

h: height

Initializes a rect structure, will calculate x2 & y2.

Return value: none.

Function: void lw6gui_rect_clip (lw6sys_context_t * sys_context, lw6gui_rect_t * dst, const lw6gui_rect_t * src, const lw6gui_rect_t * clip)

sys_context: global system context

dst: the structure which will contain the result

src: the source rect

clip: the clipping rect (boundaries)

Clips a rect (think of rectangle clips).

Return value: none.

Function: int lw6gui_segment_is_inside_rect (lw6sys_context_t * sys_context, const lw6gui_segment_t * segment, const lw6gui_rect_t * rect)

sys_context: global system context

segment: segment to test

rect: rectangle in which segment is supposed to be

Tests wether a segment is inside a rectangle, this is typically used to know if a segment is inside the right texture or if we’re outside.

Return value: 1 if OK, 0 if outside

Function: void lw6gui_smoother_init (lw6sys_context_t * sys_context, lw6gui_smoother_t * smoother, float value, int duration)

sys_context: global system context

smoother: the structure to initialize

value: the value to use for now

duration: the duration of a standard move, in ticks (msec)

Initializes a smoother object, with a default value. The important point is the duration which will condition all the behavior of the object.

Return value: none.

Function: void lw6gui_smoother_immediate_force (lw6sys_context_t * sys_context, lw6gui_smoother_t * smoother, float value)

sys_context: global system context

smoother: the structure to use

value: the target value

Forces a smoother object to immediately point on a value.

Return value: none.

Function: void lw6gui_smoother_set_target (lw6sys_context_t * sys_context, lw6gui_smoother_t * smoother, float value, int64_t now)

sys_context: global system context

smoother: the structure to use

value: the target value

now: the current timestamp

Sets a new target, will automatically calculate current speed to smooth the next returned values.

Return value: none.

Function: float lw6gui_smoother_get_value (lw6sys_context_t * sys_context, const lw6gui_smoother_t * smoother, int64_t now)

sys_context: global system context

smoother: the structure to use

now: the current timestamp

Returns the current value of the smoother.

Return value: a float.

Function: void lw6gui_smoother_fix_overflow (lw6sys_context_t * sys_context, lw6gui_smoother_t * smoother, int step)

sys_context: global system context

smoother: object to modify

step: step size, typically twice the map size

Companion function of lw6pil_coords_fix_x10, this one will fix a smoother target to avoid crazy scrolls when cursor is on a map edge.

Return value: none.

Function: int lw6gui_test_register (lw6sys_context_t * sys_context, int mode)

sys_context: global system context

mode: test mode (bitmask)

Registers all tests for the libgui module.

Return value: 1 if test is successfull, 0 on error.

Function: int lw6gui_test_run (lw6sys_context_t * sys_context, int mode)

sys_context: global system context

mode: test mode (bitmask)

Runs the gui module test suite, testing most (if not all...) functions.

Return value: 1 if test is successfull, 0 on error.

Function: int lw6gui_triangle_is_inside_rect (lw6sys_context_t * sys_context, const lw6gui_triangle_t * triangle, const lw6gui_rect_t * rect)

sys_context: global system context

triangle: triangle to test

rect: rectangle in which triangle is supposed to be

Tests wether a triangle is inside a rectangle, this is typically used to know if a triangle is inside the right texture or if we’re outside.

Return value: 1 if OK, 0 if outside

Function: int lw6gui_video_mode_find_closest (lw6sys_context_t * sys_context, lw6gui_video_mode_t * closest, const lw6gui_video_mode_t * wished, lw6sys_list_t * available)

sys_context: global system context

closest: the closest video_mode found

wished: the wished video_mode

available: a list of available video_modes (list of lw6gui_video_mode_t *)

Finds the closest video_mode available, this is just a small utility to cope with different screen shapes and avoid requesting 640x480 when it’s just not available but there’s a 640x400 instead.

Return value: 1 if the wished video_mode exists in available list and was found, else 0 if the wished video_mode doesn’t exist and an approximative match was picked.

Function: int lw6gui_video_mode_is_same (lw6sys_context_t * sys_context, const lw6gui_video_mode_t * mode_a, const lw6gui_video_mode_t * mode_b)

sys_context: global system context

mode_a: first mode to compare

mode_b: second mode to compare

Compares two video modes, to know if they’re the same.

Return value: 1 if equal, 0 if not.

Function: int lw6gui_video_mode_sync_ratio (lw6sys_context_t * sys_context, lw6gui_video_mode_t * dst, const lw6gui_video_mode_t * src)

sys_context: global system context

dst: the target video mode

src: the source video mode

Applies the ratio of src to dst, for instance if src is 16/9, then dst will be made 16/9 too, trying to keep the same surface.

Return value: 1 on success, 0 on failure

Function: int lw6gui_viewport_init (lw6sys_context_t * sys_context, lw6gui_viewport_t * viewport, int screen_w, int screen_h, float drawable_x1, float drawable_y1, float drawable_x2, float drawable_y2, float center_x, float center_y, int map_w, int map_h, int x_polarity, int y_polarity, int x_wrap, int y_wrap, int keep_ratio, float global_zoom, float scroll_limit, int use_old_center)

sys_context: global system context

viewport: the viewport to initalize

screen_w: screen width

screen_h: screen height

drawable_x1: viewport min x

drawable_y1: viewport min y

drawable_x2: viewport max x

drawable_y2: viewport max y

center_x: center of display (in map coordinates)

center_y: center of display (in map coordinates)

map_w: map width (shape)

map_h: map height (shape)

x_polarity: x polarity

y_polarity: y polarity

x_wrap: wether to wrap horizontally

y_wrap: wether to wrap vertically

keep_ratio: wether to adapt to viewport shape or keep original

global_zoom: global zoom is style_zoom * dynamic_zoom

scroll_limit: inside this zone, don’t scroll

use_old_center: wether to take previous center in account

Initializes all the (jumbo?) viewport structure which will contain valuable informations for a simple "flat" display. Special renderers might not find usefull some fields and handle wrapping and zooming their own way, but this offers a basic skeleton.

Return value: 1 if ok, 0 on failure

Function: void lw6gui_viewport_map_to_screen (lw6sys_context_t * sys_context, lw6gui_viewport_t * viewport, float * screen_x, float * screen_y, float map_x, float map_y, int clip)

sys_context: global system context

viewport: the viewport to use

screen_x: the x coord on the screen

screen_y: the y coord on the screen

map_x: the x coord in map coordinates

map_y: the y coord in map coordinates

clip: wether to clip returned values

Translates from map coords to screen coords. Returned values might be outside screen boundaries if clip is 0. If screen coords are outside drawable area anc clip is 1, then they will be clipped.

Return value: NULL

Function: void lw6gui_viewport_screen_to_map (lw6sys_context_t * sys_context, lw6gui_viewport_t * viewport, float * map_x, float * map_y, float screen_x, float screen_y, int wrap)

sys_context: global system context

viewport: the viewport to use

map_x: the x coord in map coordinates

map_y: the y coord in map coordinates

screen_x: the x coord on the screen

screen_y: the y coord on the screen

wrap: wether to use polarity informations to wrap coords.

Translates from screen coords to map coords. If wrap is set, it will interpret coords the way lw6map_coords_fix_xy would, only it can still be formally outside map boundaries for it can return a value exactly equal to w,h while in interger mode it would be w-1,h-1.

Return value: NULL

Function: void lw6gui_viewport_calc_drag (lw6sys_context_t * sys_context, lw6gui_viewport_t * viewport, float * map_dst_x, float * map_dst_y, float map_src_x, float map_src_y, int screen_dx, int screen_dy)

sys_context: global system context

viewport: viewport to work on

map_dst_x: map det x coord (out param)

map_dst_y: map dst y coord (out param)

map_src_x: map src x coord

map_src_y: map src y coord

screen_dx: drag x (on screen)

screen_dy: drag y (on screen)

Used to calculate the new "center" when in drag mode.

Return value: none.

Function: void lw6gui_zone_init_x1y1x2y2 (lw6sys_context_t * sys_context, lw6gui_zone_t * zone, float x1, float y1, float x2, float y2)

sys_context: global system context

zone: the structure to initialize

x1: x for top left corner

y1: y for top left corner

x2: x for bottom right corner

y2: y for bottom right corner

Initializes a zone structure, will calculate w & h.

Return value: none.

Function: void lw6gui_zone_init_xywh (lw6sys_context_t * sys_context, lw6gui_zone_t * zone, float x, float y, float w, float h)

sys_context: global system context

zone: the structure to initialize

x: x for top left corner

y: y for top left corner

w: width

h: height

Initializes a zone structure, will calculate x2 & y2.

Return value: none.

Function: void lw6gui_zone_clip (lw6sys_context_t * sys_context, lw6gui_zone_t * dst, lw6gui_zone_t * src, lw6gui_zone_t * clip)

sys_context: global system context

dst: the structure which will contain the result

src: the source zone

clip: the clipping zone (boundaries)

Clips a zone (think of rectangle clips).

Return value: none.

Struct: lw6gui_button_s

Used to store a complete button state, along with repeat informations, queues. It might be overkill for basic cases, having different types of buttons (union?) for different cases might be a good idea.

Member of lw6gui_button_s: is_pressed

Type: int

Definition: int lw6gui_button_s::is_pressed

Wether button is pressed, 1 means pressed, 0 unpressed.

Member of lw6gui_button_s: press_queue

Type: int

Definition: int lw6gui_button_s::press_queue

Each time the button is pressed, this increases, each times one "pops" a press from it, it’s decreased. This allows for button buffering, as events might take some time to go through the pipeline given the heavily multithreaded nature of the dsp/gfx couple.

Member of lw6gui_button_s: simple_click_queue

Type: int

Definition: int lw6gui_button_s::simple_click_queue

Simple-click counter, as opposed to double-click. A "simple-click" is validated when one has pressed the button, and then waiting long enough to discard the possibility to double-click. This is not really buffered, queue will ignore simple-clicks if one is already buffered.

Member of lw6gui_button_s: double_click_queue

Type: int

Definition: int lw6gui_button_s::double_click_queue

Double-click counter. This is not really buffered, queue will ignore double-clicks if one is already buffered.

Member of lw6gui_button_s: triple_click_queue

Type: int

Definition: int lw6gui_button_s::triple_click_queue

Triple-click counter. This is not really buffered, queue will ignore triple-clicks if one is already buffered.

Member of lw6gui_button_s: last_press

Type: int64_t

Definition: int64_t lw6gui_button_s::last_press

Timestamp of last key press.

Member of lw6gui_button_s: last_repeat

Type: int64_t

Definition: int64_t lw6gui_button_s::last_repeat

Timestamp of last key repeat.

Member of lw6gui_button_s: double_click_t1

Type: int64_t

Definition: int64_t lw6gui_button_s::double_click_t1

Used to handle multiple-clicks, this is the timestamp of the click "2 clicks ago".

Member of lw6gui_button_s: double_click_t2

Type: int64_t

Definition: int64_t lw6gui_button_s::double_click_t2

Used to handle multiple-clicks, this is the timestamp of the click just before the last click.

Member of lw6gui_button_s: double_click_t3

Type: int64_t

Definition: int64_t lw6gui_button_s::double_click_t3

Used to handle multiple-clicks, this is the timestamp of the last click.

Struct: lw6gui_fullscreen_modes_s

Contains information about available fullscreen modes.

Member of lw6gui_fullscreen_modes_s: low

Type: lw6gui_video_mode_t

Definition: lw6gui_video_mode_t lw6gui_fullscreen_modes_s::low

Low resolution mode.

Member of lw6gui_fullscreen_modes_s: standard

Type: lw6gui_video_mode_t

Definition: lw6gui_video_mode_t lw6gui_fullscreen_modes_s::standard

Standard resolution mode.

Member of lw6gui_fullscreen_modes_s: high

Type: lw6gui_video_mode_t

Definition: lw6gui_video_mode_t lw6gui_fullscreen_modes_s::high

High resolution mode.

Struct: lw6gui_input_s

Global input state, contains informations about the keyboard, mouse and joystick. This is the macro object used to exchange data and transmit input information from the rendering thread which gathers it to the logical thread which computes the game state.

Member of lw6gui_input_s: need_sync

Type: int

Definition: int lw6gui_input_s::need_sync

Wether this input struct has changed and needs to be synchronized.

Member of lw6gui_input_s: keyboard

Type: lw6gui_keyboard_t

Definition: lw6gui_keyboard_t lw6gui_input_s::keyboard

Keyboard information.

Member of lw6gui_input_s: mouse

Type: lw6gui_mouse_t

Definition: lw6gui_mouse_t lw6gui_input_s::mouse

Mouse information.

Member of lw6gui_input_s: joysticks

Type: lw6gui_joystick_t

Definition: lw6gui_joystick_t lw6gui_input_s::joysticks[LW6GUI_NB_JOYSTICKS]

Joysticks information.

Struct: lw6gui_joystick_s

Joystick information, contains detailed joystick state. This structure uses a pad-like interface, there’s no knowledge of analog interfaces, it transforms everything to a binary "up or down" and "left or right". This interface only knows about 6 buttons, this is done on purpose, the logic behind it is that more than 6 buttons makes the control way too complicated. Actually, most common functions are and should be available through the 4 first (a,b,c,d) buttons. The e and f are here for additionnal not-so-important features.

Member of lw6gui_joystick_s: pad_up

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::pad_up

Joystick up button state.

Member of lw6gui_joystick_s: pad_down

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::pad_down

Joystick down button state.

Member of lw6gui_joystick_s: pad_left

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::pad_left

Joystick left button state.

Member of lw6gui_joystick_s: pad_right

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::pad_right

Joystick right button state.

Member of lw6gui_joystick_s: button_a

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::button_a

Joystick a button state.

Member of lw6gui_joystick_s: button_b

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::button_b

Joystick b button state.

Member of lw6gui_joystick_s: button_c

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::button_c

Joystick c button state.

Member of lw6gui_joystick_s: button_d

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::button_d

Joystick d button state.

Member of lw6gui_joystick_s: button_e

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::button_e

Joystick e button state.

Member of lw6gui_joystick_s: button_f

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_joystick_s::button_f

Joystick f button state.

Struct: lw6gui_keyboard_s

Stores a complete keyboard state.

Member of lw6gui_keyboard_s: auto_release_enabled

Type: int

Definition: int lw6gui_keyboard_s::auto_release_enabled

Wether auto_release mode is set.

Member of lw6gui_keyboard_s: arrow_up

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::arrow_up

State of keyboard up arrow. This can be the combination of several keys, for instance the numeric pad up arrow, and the corresponding arrow pad key.

Member of lw6gui_keyboard_s: arrow_down

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::arrow_down

State of keyboard down arrow. This can be the combination of several keys, for instance the numeric pad down arrow, and the corresponding arrow pad key.

Member of lw6gui_keyboard_s: arrow_left

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::arrow_left

State of keyboard left arrow. This can be the combination of several keys, for instance the numeric pad left arrow, and the corresponding arrow pad key.

Member of lw6gui_keyboard_s: arrow_right

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::arrow_right

State of keyboard right arrow. This can be the combination of several keys, for instance the numeric pad right arrow, and the corresponding arrow pad key.

Member of lw6gui_keyboard_s: key_enter

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::key_enter

State of keyboard ENTER key. This can be the combination of several keys, for instance both the numeric pad ENTER and the standard, default one.

Member of lw6gui_keyboard_s: key_esc

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::key_esc

State of keyboard ESC key. This can be the combination of several keys, for instance both the standard ESC key and another key.

Member of lw6gui_keyboard_s: key_ctrl

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::key_ctrl

State of keyboard ESC key. This can be the combination of several keys, for instance both left and right CTRL keys.

Member of lw6gui_keyboard_s: key_alt

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::key_alt

State of keyboard ESC key. This can be the combination of several keys, for instance both left and right ALT keys.

Member of lw6gui_keyboard_s: key_pgup

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::key_pgup

State of keyboard PAGE UP key. This can be the combination of several keys.

Member of lw6gui_keyboard_s: key_pgdown

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::key_pgdown

State of keyboard PAGE UP key. This can be the combination of several keys.

Member of lw6gui_keyboard_s: queue

Type: lw6sys_list_t *

Definition: lw6sys_list_t* lw6gui_keyboard_s::queue

List of events, contains keypress objects.

Member of lw6gui_keyboard_s: keys_state

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_keyboard_s::keys_state[LW6GUI_NB_KEYS]

Array of button states, indexed by keycodes.

Struct: lw6gui_keypress_s

Keypress information, contains more than just a keycode but also meta/readable informations about it.

Member of lw6gui_keypress_s: keysym

Type: int

Definition: int lw6gui_keypress_s::keysym

The keysym, note that this is implementation specific. In practice, SDL uniformizes this, but there’s no garantee all graphics engine are SDL based, so don’t rely on this too much outside the graphics backend.

Member of lw6gui_keypress_s: unicode

Type: int

Definition: int lw6gui_keypress_s::unicode

Unicode code for this letter/key.

Member of lw6gui_keypress_s: label

Type: char *

Definition: char* lw6gui_keypress_s::label

Readable label for the key, typically usable in a "choose keyboard settings" interface.

Struct: lw6gui_look_s

The look structure contains everything the renderer needs to skin the display. This is where one specifies the color set, dynamic zoom effect, and possibly other things.

Member of lw6gui_look_s: id

Type: u_int32_t

Definition: u_int32_t lw6gui_look_s::id

The id of the object, this is non-zero and unique within one run session, incremented at each object creation.

Member of lw6gui_look_s: dynamic_zoom

Type: float

Definition: float lw6gui_look_s::dynamic_zoom

Dynamic zoom, this is multiplicated by the map zoom, and gives the global zoom, the one finally used.

Member of lw6gui_look_s: gfx_quality

Type: int

Definition: int lw6gui_look_s::gfx_quality

Overall graphics quality, the higher the better, will trigger various parameters, depending on the renderer.

Member of lw6gui_look_s: style

Type: lw6map_style_t

Definition: lw6map_style_t lw6gui_look_s::style

A style structure which will override the one from the map, depending on the local options (config file, environnement, command-line options).

Struct: lw6gui_menuitem_s

Menu item object. Basically, a menu is an array of these items, it’s up to the gfx backend to render this as accurately as possible. The most important field is probably the label.

Member of lw6gui_menuitem_s: id

Type: u_int32_t

Definition: u_int32_t lw6gui_menuitem_s::id

The id of the object, this is non-zero and unique within one run session, incremented at each object creation.

Member of lw6gui_menuitem_s: label

Type: char *

Definition: char* lw6gui_menuitem_s::label

What is displayed in the menu item.

Member of lw6gui_menuitem_s: tooltip

Type: char *

Definition: char* lw6gui_menuitem_s::tooltip

An additionnal tooltip explaining what the item is about.

Member of lw6gui_menuitem_s: value

Type: int

Definition: int lw6gui_menuitem_s::value

The value for this item, can typically be used for booleans and integer values, in addition to the information conveyed by the label. One special case is colored items, in that case the value will be used as a color index.

Member of lw6gui_menuitem_s: enabled

Type: int

Definition: int lw6gui_menuitem_s::enabled

Wether the item is valid and can be used.

Member of lw6gui_menuitem_s: selected

Type: int

Definition: int lw6gui_menuitem_s::selected

Wether the item is the current selection.

Member of lw6gui_menuitem_s: colored

Type: int

Definition: int lw6gui_menuitem_s::colored

Wether to colorize the item, and in that case, use the value field to know which color to use.

Member of lw6gui_menuitem_s: last_change

Type: int

Definition: int lw6gui_menuitem_s::last_change

Timestamp of last time the menu item was updated and changed.

Member of lw6gui_menuitem_s: last_select

Type: int

Definition: int lw6gui_menuitem_s::last_select

Timestamp of last time the menu was selected.

Member of lw6gui_menuitem_s: last_unselect

Type: int

Definition: int lw6gui_menuitem_s::last_unselect

Timestamp of last time the menu was unselected.

Struct: lw6gui_menu_s

Menu item object. Basically, a menu is an array of menu items, it’s up to the gfx backend to render this as accurately as possible. The most important field is probably the items labels. The menu object also stores state information such as what was the first item displayed lately.

Member of lw6gui_menu_s: id

Type: u_int32_t

Definition: u_int32_t lw6gui_menu_s::id

The id of the object, this is non-zero and unique within one run session, incremented at each object creation.

Member of lw6gui_menu_s: title

Type: char *

Definition: char* lw6gui_menu_s::title

Title of the menu, used for breadcrumbs.

Member of lw6gui_menu_s: help

Type: char *

Definition: char* lw6gui_menu_s::help

Additionnal help text, explaining what the menu is about.

Member of lw6gui_menu_s: popup

Type: char *

Definition: char* lw6gui_menu_s::popup

Popup text, will be displayed when the menu is first displayed, and then disappear.

Member of lw6gui_menu_s: nb_items

Type: int

Definition: int lw6gui_menu_s::nb_items

Number of items.

Member of lw6gui_menu_s: esc_item

Type: lw6gui_menuitem_t *

Definition: lw6gui_menuitem_t* lw6gui_menu_s::esc_item

Special item describing the ESC button.

Member of lw6gui_menu_s: items

Type: lw6gui_menuitem_t **

Definition: lw6gui_menuitem_t** lw6gui_menu_s::items

Array of items, containing all the menu items.

Member of lw6gui_menu_s: selected_item

Type: int

Definition: int lw6gui_menu_s::selected_item

The current selection.

Member of lw6gui_menu_s: first_item_displayed

Type: int

Definition: int lw6gui_menu_s::first_item_displayed

The first item displayed, this is mandatory if we want the menus to be displayable in different states, for instance with first item being 2 and items displayed from 2 to 10 or with first item being 5 and items displayed from 2 to 10. In the first case the 1st item is selected, in the second case it’s the 4th.

Member of lw6gui_menu_s: nb_items_displayed

Type: int

Definition: int lw6gui_menu_s::nb_items_displayed

Number of items displayed.

Member of lw6gui_menu_s: order_of_selected_on_display

Type: int

Definition: int lw6gui_menu_s::order_of_selected_on_display

Index, display-based (that is, 0 here means first displayed and not necessarly first in the items array), of the selected item.

Member of lw6gui_menu_s: allow_scroll

Type: int

Definition: int lw6gui_menu_s::allow_scroll

Wether scrolling is allowed.

Member of lw6gui_menu_s: breadcrumbs

Type: lw6sys_list_t *

Definition: lw6sys_list_t* lw6gui_menu_s::breadcrumbs

List of strings containing the breadcrumbs, that is to say all the menu titles that one must use to get here.

Struct: lw6gui_mouse_pointer_s

Use to store mouse pointer information.

Member of lw6gui_mouse_pointer_s: pos_x

Type: int

Definition: int lw6gui_mouse_pointer_s::pos_x

Mouse X position (pixels).

Member of lw6gui_mouse_pointer_s: pos_y

Type: int

Definition: int lw6gui_mouse_pointer_s::pos_y

Mouse Y position (pixels).

Member of lw6gui_mouse_pointer_s: speed_x

Type: int

Definition: int lw6gui_mouse_pointer_s::speed_x

Mouse X speed. The unit is pixels per second. This is based on the last move, for instance if between two moves 100 msec have elapsed, and mouse moved 13 pixels, then speed is 130.

Member of lw6gui_mouse_pointer_s: speed_y

Type: int

Definition: int lw6gui_mouse_pointer_s::speed_y

Mouse Y speed. The unit is pixels per second. This is based on the last move, for instance if between two moves 100 msec have elapsed, and mouse moved 13 pixels, then speed is 130.

Struct: lw6gui_mouse_s

Mouse information, contains detailed mouse state, including mouse position and button states but also keeps track of mouse speed as well as its corresponding map coordinates. That is, given the current screen position, what does it mean on the logical map/battlefield.

Member of lw6gui_mouse_s: moved

Type: int

Definition: int lw6gui_mouse_s::moved

Wether mouse was moved lately. 1 means yes, 0 no.

Member of lw6gui_mouse_s: last_moved

Type: int64_t

Definition: int64_t lw6gui_mouse_s::last_moved

Timestamp of last move.

Member of lw6gui_mouse_s: screen_pointer

Type: lw6gui_mouse_pointer_t

Definition: lw6gui_mouse_pointer_t lw6gui_mouse_s::screen_pointer

Information about the mouse pointer, using screen coordinates, the unit being pixels.

Member of lw6gui_mouse_s: map_pointer

Type: lw6gui_mouse_pointer_t

Definition: lw6gui_mouse_pointer_t lw6gui_mouse_s::map_pointer

Information about the mouse pointer, using map coordinates, the unit being the map slot. This is possibly very different from screen coordinates, they can be inverted, have a different scale, and globally it’s just something else, even if it refers to the same physical move.

Member of lw6gui_mouse_s: screen_drag_start

Type: lw6gui_mouse_pointer_t

Definition: lw6gui_mouse_pointer_t lw6gui_mouse_s::screen_drag_start

Information about the mouse pointer when drag mode was entered. The unit is screen pixels.

Member of lw6gui_mouse_s: drag_mode

Type: lw6gui_drag_mode_t

Definition: lw6gui_drag_mode_t lw6gui_mouse_s::drag_mode

The current drag state.

Member of lw6gui_mouse_s: menu_position

Type: int

Definition: int lw6gui_mouse_s::menu_position

The index of the menu item the mouse is on. This is the only was to know when to select an item, one should not use mouse coords outside the gfx renderer code for this purpose, it’s the renderer which has knowledge about where menu items are.

Member of lw6gui_mouse_s: menu_scroll

Type: int

Definition: int lw6gui_mouse_s::menu_scroll

Set to -1 if one needs to scroll up (decrease menu index) to +1 if one needs to scroll down (increase menu index) and 0 if one needs to do nothing as far as scrolling is concerned.

Member of lw6gui_mouse_s: menu_esc

Type: int

Definition: int lw6gui_mouse_s::menu_esc

Wether mouse pointer is over the ESC button.

Member of lw6gui_mouse_s: button_left

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_mouse_s::button_left

Mouse left button state.

Member of lw6gui_mouse_s: button_right

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_mouse_s::button_right

Mouse right button state.

Member of lw6gui_mouse_s: button_middle

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_mouse_s::button_middle

Mouse middle button state.

Member of lw6gui_mouse_s: wheel_up

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_mouse_s::wheel_up

Mouse wheel up state.

Member of lw6gui_mouse_s: wheel_down

Type: lw6gui_button_t

Definition: lw6gui_button_t lw6gui_mouse_s::wheel_down

Mouse wheel down state.

Struct: lw6gui_move_pad_s

Standard interface for joypad-like interfaces, can also be used to map keyboard arrows.

Member of lw6gui_move_pad_s: up

Type: int

Definition: int lw6gui_move_pad_s::up

Up button (boolean).

Member of lw6gui_move_pad_s: down

Type: int

Definition: int lw6gui_move_pad_s::down

Down button (boolean).

Member of lw6gui_move_pad_s: left

Type: int

Definition: int lw6gui_move_pad_s::left

Left button (boolean).

Member of lw6gui_move_pad_s: right

Type: int

Definition: int lw6gui_move_pad_s::right

Right button (boolean).

Struct: lw6gui_point_s

Basic point type, 3 floating point coords.

Member of lw6gui_point_s: x

Type: float

Definition: float lw6gui_point_s::x

X position.

Member of lw6gui_point_s: y

Type: float

Definition: float lw6gui_point_s::y

Y position.

Member of lw6gui_point_s: z

Type: float

Definition: float lw6gui_point_s::z

Z position.

Struct: lw6gui_quad_s

Basic quad type, composed of 4 points (floating point values).

Member of lw6gui_quad_s: p1

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_quad_s::p1

1st point.

Member of lw6gui_quad_s: p2

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_quad_s::p2

2nd point.

Member of lw6gui_quad_s: p3

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_quad_s::p3

3rd point.

Member of lw6gui_quad_s: p4

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_quad_s::p4

4th point.

Struct: lw6gui_rect_array_s

Array of rectangles. This is typically used to make tiles that overlap. It’s mostly used to display fighters/maps using multiple textures when the whole stuff does not fit in one single OpenGL texture and needs to be splitted. Technically, when one needs to split textures, performance is poor, but still better than relying on software renderer only.

Member of lw6gui_rect_array_s: source

Type: lw6sys_whd_t

Definition: lw6sys_whd_t lw6gui_rect_array_s::source

Size of original source data.

Member of lw6gui_rect_array_s: limits

Type: lw6gui_rect_t

Definition: lw6gui_rect_t lw6gui_rect_array_s::limits

Boundary limits of the rect array, this is typically bigger that source size, it starts at negative values and finishes outside the source. It’s interesting to cover that big an area to enable both the water effect and proper wrapping/clamping.

Member of lw6gui_rect_array_s: tile_size

Type: int

Definition: int lw6gui_rect_array_s::tile_size

Width and height of the tiles, this is typically a power of two, as it’s designed to match an OpenGL low-level texture object.

Member of lw6gui_rect_array_s: border_size

Type: int

Definition: int lw6gui_rect_array_s::border_size

The border size one needs to cut from the tile_size (on both sides, up and down or left and right) to get the real usable size of the tile.

Member of lw6gui_rect_array_s: tile_spacing

Type: int

Definition: int lw6gui_rect_array_s::tile_spacing

The tile spacing, difference of X or Y between two tiles, this is typically smaller that tile_size.

Member of lw6gui_rect_array_s: nb_tiles_w

Type: int

Definition: int lw6gui_rect_array_s::nb_tiles_w

Number of tiles on the X axis (width).

Member of lw6gui_rect_array_s: nb_tiles_h

Type: int

Definition: int lw6gui_rect_array_s::nb_tiles_h

Number of tiles on the Y axis (height).

Member of lw6gui_rect_array_s: nb_tiles

Type: int

Definition: int lw6gui_rect_array_s::nb_tiles

Overall number of tiles.

Struct: lw6gui_rect_s

A basic rectangle data. The idea is to store both corner positions and width and height to cache the values and avoid always recalculating them. Values are integer based, for a floating point equivalent, see the zone struct.

Member of lw6gui_rect_s: x1

Type: int

Definition: int lw6gui_rect_s::x1

Top-left corner X position.

Member of lw6gui_rect_s: y1

Type: int

Definition: int lw6gui_rect_s::y1

Top-left corner Y position.

Member of lw6gui_rect_s: x2

Type: int

Definition: int lw6gui_rect_s::x2

Bottom-right corner X position.

Member of lw6gui_rect_s: y2

Type: int

Definition: int lw6gui_rect_s::y2

Bottom-right corner Y position.

Member of lw6gui_rect_s: w

Type: int

Definition: int lw6gui_rect_s::w

Width.

Member of lw6gui_rect_s: h

Type: int

Definition: int lw6gui_rect_s::h

Height.

Struct: lw6gui_repeat_settings_s

Parameters used to handle repeat. This is used both by keys and buttons (joystick buttons and mouse buttons).

Member of lw6gui_repeat_settings_s: delay

Type: int

Definition: int lw6gui_repeat_settings_s::delay

Delay, in milliseconds, after which a given key/button enters repeat mode.

Member of lw6gui_repeat_settings_s: interval

Type: int

Definition: int lw6gui_repeat_settings_s::interval

Interval, in milliseconds, between two key/button press events in repeat mode.

Member of lw6gui_repeat_settings_s: double_click_delay

Type: int

Definition: int lw6gui_repeat_settings_s::double_click_delay

If pressed twice within this delay (in milliseconds) then a double-click event is generated.

Member of lw6gui_repeat_settings_s: auto_release_delay

Type: int

Definition: int lw6gui_repeat_settings_s::auto_release_delay

After this delay (milliseconds) any key will be considered be unpressed, that is, it will be released automatically. This is usefull when the input library (depends on the gfx backend) does not send proper "key up" events. The workarround is to automatically consider the key is released after some time. Usually, this would typically be set just below the repeat delay.

Struct: lw6gui_segment_s

Basic segment type, composed of 2 points (floating point values).

Member of lw6gui_segment_s: p1

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_segment_s::p1

1st point.

Member of lw6gui_segment_s: p2

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_segment_s::p2

2nd point.

Struct: lw6gui_smoother_s

Statefull object used to make transitions between 2 floats. Basically, one needs to choose a target, which is y2, and give a start, which is defined by s1 and y1 (speed and y value). Then with t1 (start timestamp) and duration the object has functions which enables interpolation between those two values, knowing at the end the value will be y2 and the speed 0. To some extent, this is a primitive bezier-like tool.

Member of lw6gui_smoother_s: s1

Type: float

Definition: float lw6gui_smoother_s::s1

Speed at startup.

Member of lw6gui_smoother_s: y1

Type: float

Definition: float lw6gui_smoother_s::y1

Y value at startup.

Member of lw6gui_smoother_s: y2

Type: float

Definition: float lw6gui_smoother_s::y2

Y target value.

Member of lw6gui_smoother_s: t1

Type: int64_t

Definition: int64_t lw6gui_smoother_s::t1

Timestamp at startup.

Member of lw6gui_smoother_s: duration

Type: int

Definition: int lw6gui_smoother_s::duration

Duration (in milliseconds) of the transition.

Struct: lw6gui_triangle_s

Basic triangle type, composed of 3 points (floating point values).

Member of lw6gui_triangle_s: p1

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_triangle_s::p1

1st point.

Member of lw6gui_triangle_s: p2

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_triangle_s::p2

2nd point.

Member of lw6gui_triangle_s: p3

Type: lw6gui_point_t

Definition: lw6gui_point_t lw6gui_triangle_s::p3

3rd point.

Struct: lw6gui_video_mode_s

Contains the parameters for a video mode, regardless of driver used.

Member of lw6gui_video_mode_s: width

Type: int

Definition: int lw6gui_video_mode_s::width

Width, in pixels.

Member of lw6gui_video_mode_s: height

Type: int

Definition: int lw6gui_video_mode_s::height

Height, in pixels.

Member of lw6gui_video_mode_s: fullscreen

Type: int

Definition: int lw6gui_video_mode_s::fullscreen

1 for fullscreen mode, 0 for windowed mode.

Struct: lw6gui_viewport_s

Macro object used to store viewport information. Viewport here means "what part of the map should we display, on which part of the screen, and with which parameters".

Member of lw6gui_viewport_s: map_shape

Type: lw6sys_whd_t

Definition: lw6sys_whd_t lw6gui_viewport_s::map_shape

Shape of the map to display, unit is map slot.

Member of lw6gui_viewport_s: screen_shape

Type: lw6sys_whd_t

Definition: lw6sys_whd_t lw6gui_viewport_s::screen_shape

Shape of the screen, unit is pixels.

Member of lw6gui_viewport_s: center_x

Type: float

Definition: float lw6gui_viewport_s::center_x

X coord of the point we want to display at the center of the screen. This is typically our main cursor if we’re using the keyboard to move it. Unit is map slot.

Member of lw6gui_viewport_s: center_y

Type: float

Definition: float lw6gui_viewport_s::center_y

Y coord of the point we want to display at the center of the screen. This is typically our main cursor if we’re using the keyboard to move it. Unit is map slot.

Member of lw6gui_viewport_s: old_center_x

Type: float

Definition: float lw6gui_viewport_s::old_center_x

Previous X coord of the point we wanted to display at the center of the screen. This is typically our main cursor if we’re using the keyboard to move it. Unit is map slot.

Member of lw6gui_viewport_s: old_center_y

Type: float

Definition: float lw6gui_viewport_s::old_center_y

Previous Y coord of the point we wanted to display at the center of the screen. This is typically our main cursor if we’re using the keyboard to move it. Unit is map slot.

Member of lw6gui_viewport_s: speed_x

Type: float

Definition: float lw6gui_viewport_s::speed_x

Speed at which the viewport is moving on the X axis, unit is map slot per second.

Member of lw6gui_viewport_s: speed_y

Type: float

Definition: float lw6gui_viewport_s::speed_y

Speed at which the viewport is moving on the Y axis, unit is map slot per second.

Member of lw6gui_viewport_s: x_polarity

Type: int

Definition: int lw6gui_viewport_s::x_polarity

X-polarity parameter (1=on, 0=off, -1=invert).

Member of lw6gui_viewport_s: y_polarity

Type: int

Definition: int lw6gui_viewport_s::y_polarity

Y-polarity parameter (1=on, 0=off, -1=invert).

Member of lw6gui_viewport_s: x_wrap

Type: int

Definition: int lw6gui_viewport_s::x_wrap

Wether to wrap map on the X axis.

Member of lw6gui_viewport_s: y_wrap

Type: int

Definition: int lw6gui_viewport_s::y_wrap

Wether to wrap map on the Y axis.

Member of lw6gui_viewport_s: drawable

Type: lw6gui_zone_t

Definition: lw6gui_zone_t lw6gui_viewport_s::drawable

Drawable zone, this is the physical on-screen viewport. Unit is pixels.

Member of lw6gui_viewport_s: map_main

Type: lw6gui_zone_t

Definition: lw6gui_zone_t lw6gui_viewport_s::map_main

Zone corresponding to the map, if it was to be drawn as a whole, regardless of drawable size, wrapping and polarity.

Member of lw6gui_viewport_s: map_main_clipped

Type: lw6gui_zone_t

Definition: lw6gui_zone_t lw6gui_viewport_s::map_main_clipped

Zone corresponding to the map, only the main map, ignoring wrapping and polarity, but clipped with drawable zone.

Member of lw6gui_viewport_s: map_visible

Type: lw6gui_zone_t

Definition: lw6gui_zone_t lw6gui_viewport_s::map_visible

Actual visible zone of the map, including wrapping, polarity, and drawable clip aware.

Struct: lw6gui_zone_s

A basic rectangle data. The idea is to store both corner positions and width and height to cache the values and avoid always recalculating them. Values are float based, for an integer point equivalent, see the rect struct.

Member of lw6gui_zone_s: x1

Type: float

Definition: float lw6gui_zone_s::x1

Top-left corner X position.

Member of lw6gui_zone_s: y1

Type: float

Definition: float lw6gui_zone_s::y1

Top-left corner Y position.

Member of lw6gui_zone_s: x2

Type: float

Definition: float lw6gui_zone_s::x2

Bottom-right corner X position.

Member of lw6gui_zone_s: y2

Type: float

Definition: float lw6gui_zone_s::y2

Bottom-right corner Y position.

Member of lw6gui_zone_s: w

Type: float

Definition: float lw6gui_zone_s::w

Width.

Member of lw6gui_zone_s: h

Type: float

Definition: float lw6gui_zone_s::h

Height.


Next: , Previous: , Up: C API   [Contents][Index]