Class OUI


  • public class OUI
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long nuiAllocHandle​(int item, int size)
      Unsafe version of: AllocHandle
      static int nuiContains​(int item, int x, int y)
      Unsafe version of: Contains
      static void nuiDestroyContext​(long ctx)
      Unsafe version of: DestroyContext
      static int nuiGetButton​(int button)
      Unsafe version of: GetButton
      static void nuiGetCursor​(long __result)
      Unsafe version of: GetCursor
      static void nuiGetCursorDelta​(long __result)
      Unsafe version of: GetCursorDelta
      static void nuiGetCursorStart​(long __result)
      Unsafe version of: GetCursorStart
      static void nuiGetCursorStartDelta​(long __result)
      Unsafe version of: GetCursorStartDelta
      static long nuiGetHandler()
      Unsafe version of: GetHandler
      static void nuiGetRect​(int item, long __result)
      Unsafe version of: GetRect
      static void nuiGetScroll​(long __result)
      Unsafe version of: GetScroll
      static void nuiSetButton​(int button, int mod, int enabled)
      Unsafe version of: SetButton
      static void nuiSetFrozen​(int item, int enable)
      Unsafe version of: SetFrozen
      static void nuiSetHandler​(long handler)
      Unsafe version of: SetHandler
      static void nuiSetKey​(int key, int mod, int enabled)
      Unsafe version of: SetKey
      static void nuiSetMargins​(int item, short l, short t, short r, short b)
      Unsafe version of: SetMargins
      static java.nio.ByteBuffer uiAllocHandle​(int item, int size)
      Allocates space for application-dependent context data and assign it as the handle to the item.
      static int uiAppend​(int item, int sibling)
      Assigns an item to the same container as another item.
      static void uiBeginLayout()
      Clears the item buffer.
      static void uiClearState()
      Resets the currently stored hot/active etc.
      static boolean uiContains​(int item, int x, int y)
      Returns 1 if an items absolute rectangle contains a given coordinate, otherwise 0.
      static long uiCreateContext​(int item_capacity, int buffer_capacity)
      Creates a new UI context; call MakeCurrent to make this context the current context.
      static void uiDestroyContext​(long ctx)
      Releases the memory of an UI context created with CreateContext; if the context is the current context, the current context will be set to NULL.
      static void uiEndLayout()
      Layout all added items starting from the root item 0.
      static int uiFindItem​(int item, int x, int y, int flags, int mask)
      Returns the topmost item containing absolute location (x,y), starting with item as parent, using a set of flags and masks as filter.
      static int uiFirstChild​(int item)
      Returns the first child item of a container item.
      static void uiFocus​(int item)
      Sets item as recipient of all keyboard events.
      static int uiGetAllocSize()
      Returns the total bytes that have been allocated by AllocHandle
      static int uiGetBox​(int item)
      Returns the box model as set by SetBox.
      static boolean uiGetButton​(int button)
      Returns the current state of an application dependent input button as set by SetButton.
      static int uiGetClicks()
      Returns the number of chained clicks; 1 is a single click, 2 is a double click, etc.
      static long uiGetContext()
      Returns the currently selected context or NULL.
      static UIVec2 uiGetCursor​(UIVec2 __result)
      Returns the current cursor position in screen coordinates as set by SetCursor.
      static UIVec2 uiGetCursorDelta​(UIVec2 __result)
      Returns the offset of the cursor relative to the last call to Process.
      static UIVec2 uiGetCursorStart​(UIVec2 __result)
      Returns the beginning point of a drag operation.
      static UIVec2 uiGetCursorStartDelta​(UIVec2 __result)
      Returns the offset of the cursor relative to the beginning point of a drag operation.
      static int uiGetEvents​(int item)
      Returns the event flags for an item as passed to SetEvents
      static int uiGetFlags​(int item)
      Returns the user-defined flags for an item as passed to SetFlags
      static int uiGetFocusedItem()
      Returns the item that is currently focused or -1 for none.
      static long uiGetHandle​(int item)
      Returns the application-dependent handle of the item as passed to SetHandle or AllocHandle.
      static UIHandler uiGetHandler()
      Returns the handler callback as passed to SetHandler
      static int uiGetHeight​(int item)
      Return the height of the item as set by SetSize.
      static int uiGetHotItem()
      Returns the item that is currently under the cursor or -1 for none.
      static int uiGetItemCount()
      Returns the total number of allocated items
      static int uiGetKey()
      When handling a KEY_DOWN/KEY_UP event: the key that triggered this event.
      static int uiGetLastItemCount()
      Returns the number if items that have been allocated in the last frame.
      static int uiGetLayout​(int item)
      Returns the anchoring behavior as set by SetLayout.
      static short uiGetMarginDown​(int item)
      Returns the bottom margin of the item as set with SetMargins.
      static short uiGetMarginLeft​(int item)
      Returns the left margin of the item as set with SetMargins.
      static short uiGetMarginRight​(int item)
      Returns the right margin of the item as set with SetMargins.
      static short uiGetMarginTop​(int item)
      Returns the top margin of the item as set with SetMargins.
      static int uiGetModifier()
      When handling a keyboard or mouse event: the active modifier keys.
      static UIRect uiGetRect​(int item, UIRect __result)
      Returns the items layout rectangle in absolute coordinates.
      static UIVec2 uiGetScroll​(UIVec2 __result)
      Returns the currently accumulated scroll wheel offsets for this frame
      static int uiGetState​(int item)
      Returns the current state of the item.
      static int uiGetWidth​(int item)
      Returns the width of the item as set by SetSize.
      static int uiInsert​(int item, int child)
      Assigns an item to a container.
      static int uiInsertBack​(int item, int child)
      Inserts child into container item like Insert, but prepend it to the first child item, effectively putting it in the background.
      static int uiInsertFront​(int item, int child)
      Same as Insert.
      static int uiItem()
      Creates a new UI item and return the new item's ID.
      static void uiMakeCurrent​(long ctx)
      Selects an UI context as the current context; a context must always be selected before using any of the other UI functions.
      static int uiNextSibling​(int item)
      Returns an items next sibling in the list of the parent containers children.
      static void uiProcess​(int timestamp)
      Updates the internal state according to the current cursor position and button states, and call all registered handlers.
      static int uiRecoverItem​(int olditem)
      When BeginLayout is called, the most recently declared items are retained.
      static void uiRemapItem​(int olditem, int newitem)
      In cases where it is important to recover old state over changes in the view, and the built-in remapping fails, the UI declaration can manually remap old items to new IDs in cases where e.g.
      static void uiSetBox​(int item, int flags)
      Sets the box model behavior of the item to one or multiple UIboxFlags.
      static void uiSetButton​(int button, int mod, boolean enabled)
      Sets a mouse or gamepad button as pressed/released button is in the range 0..63 and maps to an application defined input source.
      static void uiSetChar​(int value)
      Sends a single character for text input; the character is usually in the unicode range, but can be application defined.
      static void uiSetCursor​(int x, int y)
      Sets the current cursor position (usually belonging to a mouse) to the screen coordinates at (x,y).
      static void uiSetEvents​(int item, int flags)  
      static void uiSetFlags​(int item, int flags)  
      static void uiSetFrozen​(int item, boolean enable)
      Sets an items state to frozen.
      static void uiSetHandle​(int item, long handle)
      Sets the application-dependent handle of an item.
      static void uiSetHandler​(UIHandlerI handler)
      Sets the global handler callback for interactive items.
      static void uiSetKey​(int key, int mod, boolean enabled)
      Sets a key as down/up; the key can be any application defined keycode.
      static void uiSetLayout​(int item, int flags)
      Sets the anchoring behavior of the item to one or multiple UIlayoutFlags.
      static void uiSetMargins​(int item, int l, int t, int r, int b)
      Sets the left, top, right and bottom margins of an item.
      static void uiSetScroll​(int x, int y)
      Accumulates scroll wheel offsets for the current frame.
      static void uiSetSize​(int item, int w, int h)
      Sets the size of the item.
      static void uiUpdateHotItem()
      Updates the current hot item; this only needs to be called if items are kept for more than one frame and EndLayout is not called.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • uiCreateContext

        public static long uiCreateContext​(int item_capacity,
                                           int buffer_capacity)
        Creates a new UI context; call MakeCurrent to make this context the current context.

        The context is managed by the client and must be released using DestroyContext.

        Parameters:
        item_capacity - the maximum number of items that can be declared. 4096 is a good starting value.
        buffer_capacity - the maximum total size of bytes that can be allocated using AllocHandle; you may pass 0 if you don't need to allocate handles. (1<<20) is a good starting value.
      • uiMakeCurrent

        public static void uiMakeCurrent​(long ctx)
        Selects an UI context as the current context; a context must always be selected before using any of the other UI functions.
      • nuiDestroyContext

        public static void nuiDestroyContext​(long ctx)
        Unsafe version of: DestroyContext
      • uiDestroyContext

        public static void uiDestroyContext​(long ctx)
        Releases the memory of an UI context created with CreateContext; if the context is the current context, the current context will be set to NULL.
      • uiGetContext

        public static long uiGetContext()
        Returns the currently selected context or NULL.
      • uiSetCursor

        public static void uiSetCursor​(int x,
                                       int y)
        Sets the current cursor position (usually belonging to a mouse) to the screen coordinates at (x,y).
      • nuiGetCursor

        public static void nuiGetCursor​(long __result)
        Unsafe version of: GetCursor
      • uiGetCursor

        public static UIVec2 uiGetCursor​(UIVec2 __result)
        Returns the current cursor position in screen coordinates as set by SetCursor.
      • nuiGetCursorDelta

        public static void nuiGetCursorDelta​(long __result)
        Unsafe version of: GetCursorDelta
      • uiGetCursorDelta

        public static UIVec2 uiGetCursorDelta​(UIVec2 __result)
        Returns the offset of the cursor relative to the last call to Process.
      • nuiGetCursorStart

        public static void nuiGetCursorStart​(long __result)
        Unsafe version of: GetCursorStart
      • uiGetCursorStart

        public static UIVec2 uiGetCursorStart​(UIVec2 __result)
        Returns the beginning point of a drag operation.
      • nuiGetCursorStartDelta

        public static void nuiGetCursorStartDelta​(long __result)
        Unsafe version of: GetCursorStartDelta
      • uiGetCursorStartDelta

        public static UIVec2 uiGetCursorStartDelta​(UIVec2 __result)
        Returns the offset of the cursor relative to the beginning point of a drag operation.
      • nuiSetButton

        public static void nuiSetButton​(int button,
                                        int mod,
                                        int enabled)
        Unsafe version of: SetButton
      • uiSetButton

        public static void uiSetButton​(int button,
                                       int mod,
                                       boolean enabled)
        Sets a mouse or gamepad button as pressed/released button is in the range 0..63 and maps to an application defined input source.
        Parameters:
        mod - an application defined set of flags for modifier keys
        enabled - is 1 for pressed, 0 for released
      • nuiGetButton

        public static int nuiGetButton​(int button)
        Unsafe version of: GetButton
      • uiGetButton

        public static boolean uiGetButton​(int button)
        Returns the current state of an application dependent input button as set by SetButton.
        Returns:
        1 if the button has been set to pressed, 0 for released
      • uiGetClicks

        public static int uiGetClicks()
        Returns the number of chained clicks; 1 is a single click, 2 is a double click, etc.
      • nuiSetKey

        public static void nuiSetKey​(int key,
                                     int mod,
                                     int enabled)
        Unsafe version of: SetKey
      • uiSetKey

        public static void uiSetKey​(int key,
                                    int mod,
                                    boolean enabled)
        Sets a key as down/up; the key can be any application defined keycode.

        All key events are being buffered until the next call to Process.

        Parameters:
        mod - an application defined set of flags for modifier keys
        enabled - 1 for key down, 0 for key up
      • uiSetChar

        public static void uiSetChar​(int value)
        Sends a single character for text input; the character is usually in the unicode range, but can be application defined.

        All char events are being buffered until the next call to Process.

      • uiSetScroll

        public static void uiSetScroll​(int x,
                                       int y)
        Accumulates scroll wheel offsets for the current frame.

        All offsets are being accumulated until the next call to Process.

      • nuiGetScroll

        public static void nuiGetScroll​(long __result)
        Unsafe version of: GetScroll
      • uiGetScroll

        public static UIVec2 uiGetScroll​(UIVec2 __result)
        Returns the currently accumulated scroll wheel offsets for this frame
      • uiBeginLayout

        public static void uiBeginLayout()
        Clears the item buffer.

        uiBeginLayout() should be called before the first UI declaration for this frame to avoid concatenation of the same UI multiple times. After the call, all previously declared item IDs are invalid, and all application dependent context data has been freed.

        uiBeginLayout() must be followed by EndLayout.

      • uiEndLayout

        public static void uiEndLayout()
        Layout all added items starting from the root item 0.

        After calling uiEndLayout(), no further modifications to the item tree should be done until the next call to BeginLayout. It is safe to immediately draw the items after a call to uiEndLayout().

        This is an O(N) operation for N = number of declared items.

      • uiUpdateHotItem

        public static void uiUpdateHotItem()
        Updates the current hot item; this only needs to be called if items are kept for more than one frame and EndLayout is not called.
      • uiProcess

        public static void uiProcess​(int timestamp)
        Updates the internal state according to the current cursor position and button states, and call all registered handlers.

        No further modifications to the item tree should be done until the next call to BeginLayout. Items should be drawn before a call to uiProcess().

        This is an O(N) operation for N = number of declared items.

        Parameters:
        timestamp - the time in milliseconds relative to the last call to uiProcess() and is used to estimate the threshold for double-clicks after calling uiProcess().
      • uiClearState

        public static void uiClearState()
        Resets the currently stored hot/active etc. handles.

        This should be called when a re-declaration of the UI changes the item indices, to avoid state related glitches because item identities have changed.

      • uiItem

        public static int uiItem()
        Creates a new UI item and return the new item's ID.
      • nuiSetFrozen

        public static void nuiSetFrozen​(int item,
                                        int enable)
        Unsafe version of: SetFrozen
      • uiSetFrozen

        public static void uiSetFrozen​(int item,
                                       boolean enable)
        Sets an items state to frozen.

        The UI will not recurse into frozen items when searching for hot or active items; subsequently, frozen items and their child items will not cause mouse event notifications. The frozen state is not applied recursively; GetState will report COLD for child items. Upon encountering a frozen item, the drawing routine needs to handle rendering of child items appropriately.

      • uiSetHandle

        public static void uiSetHandle​(int item,
                                       long handle)
        Sets the application-dependent handle of an item.
        Parameters:
        handle - an application defined 64-bit handle. If NULL, the item will not be interactive.
      • nuiAllocHandle

        public static long nuiAllocHandle​(int item,
                                          int size)
        Unsafe version of: AllocHandle
      • uiAllocHandle

        @Nullable
        public static java.nio.ByteBuffer uiAllocHandle​(int item,
                                                        int size)
        Allocates space for application-dependent context data and assign it as the handle to the item.

        The memory of the pointer is managed by the UI context and released upon the next call to BeginLayout.

      • nuiSetHandler

        public static void nuiSetHandler​(long handler)
        Unsafe version of: SetHandler
      • uiSetHandler

        public static void uiSetHandler​(UIHandlerI handler)
        Sets the global handler callback for interactive items.

        The handler will be called for each item whose event flags are set using SetEvents.

      • uiSetFlags

        public static void uiSetFlags​(int item,
                                      int flags)
        Parameters:
        flags - a user-defined set of flags defined by USERMASK
      • uiInsert

        public static int uiInsert​(int item,
                                   int child)
        Assigns an item to a container.

        An item ID of 0 refers to the root item. The function searches for the last item and calls Append on it, which is an O(N) operation for N siblings. It is usually more efficient to call uiInsert() for the first child, then chain additional siblings using uiAppend().

        Returns:
        the child item ID if the container has already added items
      • uiAppend

        public static int uiAppend​(int item,
                                   int sibling)
        Assigns an item to the same container as another item.
        Parameters:
        sibling - inserted after item
      • uiInsertBack

        public static int uiInsertBack​(int item,
                                       int child)
        Inserts child into container item like Insert, but prepend it to the first child item, effectively putting it in the background.

        It is efficient to call uiInsertBack() repeatedly in cases where drawing or layout order doesn't matter.

      • uiInsertFront

        public static int uiInsertFront​(int item,
                                        int child)
        Same as Insert.
      • uiSetSize

        public static void uiSetSize​(int item,
                                     int w,
                                     int h)
        Sets the size of the item.

        A size of 0 indicates the dimension to be dynamic; if the size is set, the item can not expand beyond that size.

      • nuiSetMargins

        public static void nuiSetMargins​(int item,
                                         short l,
                                         short t,
                                         short r,
                                         short b)
        Unsafe version of: SetMargins
      • uiSetMargins

        public static void uiSetMargins​(int item,
                                        int l,
                                        int t,
                                        int r,
                                        int b)
        Sets the left, top, right and bottom margins of an item.

        When the item is anchored to the parent or another item, the margin controls the distance from the neighboring element.

      • uiFocus

        public static void uiFocus​(int item)
        Sets item as recipient of all keyboard events.
        Parameters:
        item - if -1, no item will be focused
      • uiFirstChild

        public static int uiFirstChild​(int item)
        Returns the first child item of a container item.

        If the item is not a container or does not contain any items, -1 is returned.

        Parameters:
        item - if 0, the first child item of the root item will be returned
      • uiNextSibling

        public static int uiNextSibling​(int item)
        Returns an items next sibling in the list of the parent containers children.

        If item is 0 or the item is the last child item, -1 will be returned.

      • uiGetItemCount

        public static int uiGetItemCount()
        Returns the total number of allocated items
      • uiGetAllocSize

        public static int uiGetAllocSize()
        Returns the total bytes that have been allocated by AllocHandle
      • uiGetState

        public static int uiGetState​(int item)
        Returns the current state of the item.

        This state is only valid after a call to Process. The returned value is one of COLD, HOT, ACTIVE, FROZEN.

      • uiGetHandle

        public static long uiGetHandle​(int item)
        Returns the application-dependent handle of the item as passed to SetHandle or AllocHandle.
      • uiGetHotItem

        public static int uiGetHotItem()
        Returns the item that is currently under the cursor or -1 for none.
      • uiGetFocusedItem

        public static int uiGetFocusedItem()
        Returns the item that is currently focused or -1 for none.
      • uiFindItem

        public static int uiFindItem​(int item,
                                     int x,
                                     int y,
                                     int flags,
                                     int mask)
        Returns the topmost item containing absolute location (x,y), starting with item as parent, using a set of flags and masks as filter.

        If both flags and mask are ANY, the first topmost item is returned. If mask is ANY, the first topmost item matching any of flags is returned. otherwise the first item matching (item.flags & flags) == mask is returned. You may combine box, layout, event and user flags. Frozen items will always be ignored.

      • nuiGetHandler

        public static long nuiGetHandler()
        Unsafe version of: GetHandler
      • uiGetHandler

        @Nullable
        public static UIHandler uiGetHandler()
        Returns the handler callback as passed to SetHandler
      • uiGetEvents

        public static int uiGetEvents​(int item)
        Returns the event flags for an item as passed to SetEvents
      • uiGetFlags

        public static int uiGetFlags​(int item)
        Returns the user-defined flags for an item as passed to SetFlags
      • uiGetKey

        public static int uiGetKey()
        When handling a KEY_DOWN/KEY_UP event: the key that triggered this event.
      • uiGetModifier

        public static int uiGetModifier()
        When handling a keyboard or mouse event: the active modifier keys.
      • nuiGetRect

        public static void nuiGetRect​(int item,
                                      long __result)
        Unsafe version of: GetRect
      • uiGetRect

        public static UIRect uiGetRect​(int item,
                                       UIRect __result)
        Returns the items layout rectangle in absolute coordinates.

        If uiGetRect() is called before EndLayout, the values of the returned rectangle are undefined.

      • nuiContains

        public static int nuiContains​(int item,
                                      int x,
                                      int y)
        Unsafe version of: Contains
      • uiContains

        public static boolean uiContains​(int item,
                                         int x,
                                         int y)
        Returns 1 if an items absolute rectangle contains a given coordinate, otherwise 0.
      • uiGetWidth

        public static int uiGetWidth​(int item)
        Returns the width of the item as set by SetSize.
      • uiGetHeight

        public static int uiGetHeight​(int item)
        Return the height of the item as set by SetSize.
      • uiGetLayout

        public static int uiGetLayout​(int item)
        Returns the anchoring behavior as set by SetLayout.
      • uiGetBox

        public static int uiGetBox​(int item)
        Returns the box model as set by SetBox.
      • uiGetMarginLeft

        public static short uiGetMarginLeft​(int item)
        Returns the left margin of the item as set with SetMargins.
      • uiGetMarginTop

        public static short uiGetMarginTop​(int item)
        Returns the top margin of the item as set with SetMargins.
      • uiGetMarginRight

        public static short uiGetMarginRight​(int item)
        Returns the right margin of the item as set with SetMargins.
      • uiGetMarginDown

        public static short uiGetMarginDown​(int item)
        Returns the bottom margin of the item as set with SetMargins.
      • uiRecoverItem

        public static int uiRecoverItem​(int olditem)
        When BeginLayout is called, the most recently declared items are retained. When EndLayout completes, it matches the old item hierarchy to the new one and attempts to map old items to new items as well as possible. When passed an item Id from the previous frame, uiRecoverItem() returns the item's new assumed Id, or -1 if the item could not be mapped. It is valid to pass -1 as item.
      • uiRemapItem

        public static void uiRemapItem​(int olditem,
                                       int newitem)
        In cases where it is important to recover old state over changes in the view, and the built-in remapping fails, the UI declaration can manually remap old items to new IDs in cases where e.g. the previous item ID has been temporarily saved; uiRemapItem() would then be called after creating the new item using Item.
      • uiGetLastItemCount

        public static int uiGetLastItemCount()
        Returns the number if items that have been allocated in the last frame.