C++ UI Framework
For my master’s degree, I built a small UI library as part of an independent study. The UI library is built on top of the existing game/animation engine I built in years past which allowed me to utilize its memory system, data structures, and more.
The UI library is all handled through the singleton UIManager
class. The UIManager
loads the necessary assets up front into a TextureLibrary
where I can lookup textures by enumeration. UIObjects
are added to the UIManager
‘s PCSTree structure so that it can handle all of their updates.
Each frame the UIManager
updates all the UIObjects'
positions and checks for collisions. Collisions (and clicks) are handled in screen space against the mouse cursor. When implementing a class that inherits from the UIObject
, you can override all of the collision handling. For example, the large UIObject_Preview
object on the right side of the grid overrides the OnClick()
function to do nothing as it’s not necessary. But when you click any of the UIObjects
in the grid, we swap the UIObject_Preview
‘s sprite to be the one that was clicked.
UI Library Features:
Texture pooling system built on top of OpenGL
Toggleable debug collision sprites displaying active state
World space to screen space conversion for collisions
Overridable
OnHightlightEnter()
,OnHighlightExit()
, andOnClick()
functionsSingle-side collisions on 2D objects
Debug collision printing
3D position interpolation on highlight enter and exit
Quaternion rotations