-
Notifications
You must be signed in to change notification settings - Fork 2
Depth
In uiZ, when you have multiple objects, there is always an order in which objects overlay each other. For example, you may have two windows overlapping each other. One window is placed in front of the other window. In uiZ, objects can have depth. However, all depth is hierarchical. This means that depth behaves more like a tree in stead of a single list. A button which is inside the window in the background will never be able to draw in front of a window in the foreground. Consider this tree for example:
In the image you can see that by using a tree, any objects may never overlap another object if the current object's parent is not also overlapping the other object's parent. (unless the two objects have the same parent of course).
If the explanation is a bit confusing to you, just remember that when changing the depth of objects, you only have to worry about objects within the same window, frame or other object.
Now, how does uiZ determine which objects should be drawn over another object? For that there is a depth variable. This works just like the old depth system in GameMaker Studio 1.x. Each object has it's own depth variable. Objects with a lower depth value are placed at the front, while objects with a higher depth value are placed at the back.
To change the depth, you can use these functions:
-
uiz_depth_set(instanceid, depth):
- instanceid: The instanceid of the uiZ object that you want to modify
- depth: The depth value of this object. With lower values the object is placed further to the front, while higher values make it go further to the back.
-
depth = uiz_depth_get(instanceid):
- depth: The depth value of this object. With lower values the object is placed further to the front, while higher values make it go further to the back.
- instanceid: The instanceid of the uiZ object that you want to read the depth value from.
-
uiz_depth_foreground(instanceid): Makes the depth of the given object the lowest among it's siblings (other objects in the same parent). Sets the depth of the given instance to the depth of the previous most-front object minus one.
- instanceid: The instanceid of the uiZ object that you want to read the depth value from.
Depth sorting in uiZ is really quick, because it's not recalculated every step but only when you call any of the depth functions. Also, only objects in the same parent have to be reconsidered when changing the depth of an object, releasing some burden on the internal sorting algorithm.
πTutorials
Basics 1: Basic positioning
Basics 2: Parenting system
Basics 3: Advanced positioning
Basics 4: Advanced sizing and set point
Basics 5: Canvas and containment
Basics 6: Alpha and depth
Basics 7: Using the manual and Animations
Basics 8: Object backgrounds
Basics 9: Grids
Basics 10: Framesets
Basics 11: Windows
Basics 12: Scroll bars
βοΈ Positioning
π Depth
π Structures
π Objects
obj_uiZ_3waybutton
obj_uiZ_button
obj_uiZ_checkbox
obj_uiZ_clock
obj_uiZ_colorbox
obj_uiZ_cover
obj_uiZ_drawdslist
obj_uiZ_dropdown
obj_uiZ_easybutton
obj_uiZ_frame
obj_uiZ_framescrollbar
obj_uiZ_functionbar
obj_uiZ_gradientsquare
obj_uiZ_gradientroundrect
obj_uiZ_gridlist
obj_uiZ_huesquare
obj_uiZ_loadingbar
obj_uiZ_loadingcircle
obj_uiZ_menubutton
obj_uiZ_mousemenu
obj_uiZ_radiobox
obj_uiZ_rotator
obj_uiZ_slider
obj_uiZ_scrollbar
obj_uiZ_slider_2col
obj_uiZ_slickslider
obj_uiZ_slideframe
obj_uiZ_sprbutton
obj_uiZ_spriteanimationbutton
obj_uiZ_spritecounter
obj_uiZ_stringbox
obj_uiZ_sliderstruct
obj_uiZ_surfacecanvas
obj_uiZ_sprite
obj_uiZ_square
obj_uiZ_squarebutton
obj_uiZ_swipicon
obj_uiZ_switch
obj_uiZ_tabslider
obj_uiZ_tabs
obj_uiZ_treelist
obj_uiZ_text
obj_uiZ_text_background
obj_uiZ_textarea
obj_uiZ_valuebox
π Strings
uiz_addChar
uiz_changechar
uiz_charCanHaveAddon
uiz_returnCharAddon
uiz_charIsNumber
uiz_charIsNumberOrText
uiz_getlines
uiz_gettext_contained
uiz_gettextlines_contained
uiz_getValidVariableName
uiz_isSpaceChar
uiz_lastStringChars
uiz_removeChar
uiz_replaceChars_
uiz_string_copy
uiz_string_digits
uiz_string_format
uiz_string_fromReal
uiz_string_real_getFracLength
uiz_string_real_getIntLength
uiz_string_repeat
uiz_string_replace
uiz_string_pos_at
uiz_stringUntilNewline