FixGUI Documentation

Back to summary

import "gui/subview";

SubView class

Super class of custom views.

Subclasses: SubLabel, SubButton, SubTextField, SubScrollBar, SubScrollView, SubDivider, CodeEditor

Object

static function create(): SubView
Creates the subview.
static function is_instance(obj): Boolean
Returns true when the passed object is a subview.

Attributes

function set_attribute(key: Dynamic, value: Dynamic)
Sets an attribute, use null as a value to remove an attribute.
function get_attribute(key: Dynamic): Dynamic
Returns the value of an attribute or null when it's not present.

Root & View compatibility

function as_view(): Canvas
Returns a corresponding SubViewCanvasRoot wrapper so the subview can be directly added as a native canvas. It is created on the first use of this function. You can also add subviews directly into views as this method is called internally.
function assign_view(canvas: Canvas)
Explicitly assignes the subview to the provided canvas.
function set_root(root: SubViewRoot)
Sets the SubViewRoot. The subview must not have a parent.
function get_root(): SubViewRoot
Returns the SubViewRoot for this subview hierarchy.

Scaling

function get_scale(): Float
Returns the scale of this subview (the SubViewRoot scale is used or the default scale if the subview is without a root).
function set_default_scale(scale: Float)
Sets the default scale of this subview (used when not yet assigned to a SubViewRoot).

Position & size

function set_rect(rect: Rect) function set_rect(x: Integer, y: Integer, width: Integer, height: Integer)
Sets the rectangle within the parent subview coordinate system.
function get_x(): Integer
Returns the X coordinate of the subview.
function get_y(): Integer
Returns the Y coordinate of the subview.
function get_width(): Integer
Returns the width of the subview.
function get_height(): Integer
Returns the height of the subview.
function get_rect(): Rect
Returns a copy of the subview rectangle in the parent subview coordinate system.
function get_local_rect(): Rect
Returns a copy of the subview rectangle in the local coordinate system (the X and Y coordinates are always zero).

Hierarchy

function add(view: SubView)
Adds given subview to this subview.
function remove(view: SubView)
Removes given subview from this subview.
function remove_all()
Removes all child subviews.
function remove_self()
Removes itself from the parent subview. Does nothing when the subview has no parent.
function get_parent(): SubView
Returns the parent of this subview.
function get_children(): SubView[]
Returns children subviews in an array (as a copy).
function get_child_count(): Integer
Returns the number of child subviews.
function get_child(idx: Integer): SubView
Returns the child subview by index.
function get_child_index(view: SubView): Integer
Returns the index for given child subview.
virtual function point_to_parent(point: Integer[]): SubView
Adjusts the point to the parent coordinate system. The default implementation adds the position in the parent.
function point_to_top(point: Integer[]): SubView
Adjusts the point to the topmost subview and returns it.
function set_logical_top_view(enable: Boolean)
Sets this subview as a logical topmost subview.
function is_logical_top_view(): Boolean
Returns true when this subview is a logical topmost subview.
function get_next_child(view: SubView): SubView
function get_prev_child(view: SubView): SubView
function get_next_focus_child(current_focus: SubView, wrap: Boolean): SubView
function get_prev_focus_child(current_focus: SubView, wrap: Boolean): SubView
Allows traversing between child subviews in depth-first order.
function get_top_view(x: Integer, y: Integer): SubView
Returns the topmost subview for given coordinates within the same subview hierarchy.
function get_top_child_view(x: Integer, y: Integer): SubView
Returns the topmost subview for given coordinates inside this subview.

Mouse cursor

function set_cursor(cursor)
Sets the mouse cursor. The cursor value can be completely custom. By default the integer values are interpreted the same as for View.
function get_cursor(): Dynamic
Returns the mouse cursor.
function get_current_cursor(event: MouseEvent)
function get_current_cursor(x: Integer, y: Integer)
Returns the current mouse cursor for given coordinates. The children subviews are traversed to get the topmost subview under the coordinates. You can also pass directly a MouseEvent to get the coordinates.
function set_canvas_cursor(event: MouseEvent)
Used by the SubViewRoot to set the proper cursor for Canvas.

Focus

function set_focusable(enable: Boolean)
Sets the subview focusable.
function is_focusable(): Boolean
Returns true when the subview is focusable.
function focus()
Focuses this subview (making it receive keyboard events).
function unfocus()
Unfocuses this subview if it had focus.
function has_focus(): Boolean
Returns whether this subview has keyboard focus.
function get_current_focus(): SubView
Returns the focused subview (if any) within the same subview hierarchy.

Events & drawing

virtual function handle_resize()
Override to handle resizing of the subview.
virtual function handle_paint(p: Painter)
Override to handle painting of the subview. The default implementation just calls the draw_children method.
function draw_children(p: Painter)
Draws the children subviews.
virtual function draw(p: Painter)
Override to customize drawing of the subview. The default implementation translates and clips the painting to the position/size and calls the handle_paint method.
virtual function accept_mouse_event(event: MouseEvent): Boolean
virtual function accept_touch_event(event: TouchEvent): Boolean
Override filtering of mouse/touch events. The default implementation returns true. Return false in case you don't want to receive the given mouse/touch event.
virtual function handle_mouse_event(event: MouseEvent): Boolean
virtual function handle_touch_event(event: TouchEvent): Boolean
virtual function handle_key_event(event: KeyEvent): Boolean
Override to process mouse/touch/key events. Return true if you handled the event and want to stop further processing.
virtual function catch_mouse_event(event: MouseEvent): Boolean
virtual function catch_touch_event(event: TouchEvent): Boolean
virtual function catch_key_event(event: KeyEvent): Boolean
Override to process unhandled mouse/touch/key events from children. Return true to stop further processing.
virtual function handle_focus_event(event: FocusEvent)
Override to process the focus event. The default implementation does nothing.
virtual function handle_repaint(rect: Rect)
Override to adjust repainting of dirty rectangles. The default implementation intersects the rectangle with itself. The repainting is cancelled when the rectangle becomes invalid.
function process_event(event: Event): Boolean
Processes the given (possibly artifical) event. Returns true if it was handled.

Repainting

function repaint()
function repaint(x: Integer, y: Integer, width: Integer, height: Integer)
function repaint(rect: Rect)
Schedules a repaint of either the whole subview or it's part. The repainting will be done after other events are processed. The area from multiple calls is combined to do a single repainting at once.

The repaint is handled by the handle_repaint event handler for the current view and all the parents. Then it is passed to the SubViewRoot class. The request is ignored when there is no root assigned.