Skip to content
Thomas edited this page Aug 24, 2020 · 1 revision

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.

Wiki pages

🏑Home / General
πŸ“ƒTutorials
πŸ‘ͺ Parent
↕️ Positioning
πŸ›  Fixing & Updating
πŸ• Depth
πŸ“ƒ Templates and Examples
πŸŒ† Background
πŸ“‡ 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


🎈 Your own objects
🚫 Destroy
🐭 Mouse
πŸ’» Windows (uiz)
🌌 Animations
❓ General
πŸ“’ Numbers
πŸ“’ Strings
✏️ Draw
🚩 Popup
πŸ“‚ Files
πŸ’» Windows (os)
Clone this wiki locally