SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::UI Namespace Reference

Immediate-mode UI calls available to game code. More...

Enumerations

enum  PanelFlags : int {
  PanelFlags_None = 0 , PanelFlags_NoTitleBar = 1 << 0 , PanelFlags_AutoResize = 1 << 1 , PanelFlags_NoMove = 1 << 2 ,
  PanelFlags_NoInput = 1 << 3 , PanelFlags_NoFocusOnAppear = 1 << 4
}
enum  StyleColor : int {
  StyleColor_Text = 0 , StyleColor_WindowBg = 2 , StyleColor_ChildBg = 3 , StyleColor_Button = 21 ,
  StyleColor_ButtonHovered = 22 , StyleColor_ButtonActive = 23 , StyleColor_FrameBg = 7 , StyleColor_Header = 24 ,
  StyleColor_HeaderHovered = 25 , StyleColor_HeaderActive = 26 , StyleColor_ScrollbarBg = 14
}
enum  StyleVar : int {
  StyleVar_WindowPadding = 2 , StyleVar_WindowRounding = 3 , StyleVar_FramePadding = 11 , StyleVar_FrameRounding = 12 ,
  StyleVar_ItemSpacing = 14
}

Functions

ENGINE_API void BeginChild (const char *name)
ENGINE_API void BeginChildSized (const char *name, float width, float height=0.0f)
ENGINE_API void BeginGroup ()
ENGINE_API bool BeginListBox (const char *label, float width, float height)
ENGINE_API void BeginPanel (const char *name, float x, float y, float bgAlpha=0.4f, int flags=PanelFlags_NoTitleBar|PanelFlags_AutoResize|PanelFlags_NoMove|PanelFlags_NoInput|PanelFlags_NoFocusOnAppear)
 Opens a floating overlay window at (x, y); pair with EndPanel.
ENGINE_API bool Button (const char *label)
ENGINE_API bool ButtonSized (const char *label, float width, float height=0.0f)
ENGINE_API bool Checkbox (const char *label, bool *value)
ENGINE_API bool Combo (const char *label, int *current, const char *const items[], int count)
ENGINE_API Sleak::TextureCreateTextureFromPixels (uint32_t width, uint32_t height, const void *rgbaPixels, uint32_t maxMipLevels=0)
 Create a texture from raw RGBA pixel data (for runtime atlas building etc.).
ENGINE_API bool DragFloat (const char *label, float *value, float speed=1.0f, float min=0.0f, float max=0.0f)
ENGINE_API void DrawFilledRect (float x, float y, float w, float h, float r, float g, float b, float a=1.0f, float rounding=0.0f)
ENGINE_API void DrawImage (uint64_t textureID, float x, float y, float width, float height)
ENGINE_API void DrawLine (float x1, float y1, float x2, float y2, float r, float g, float b, float a=1.0f, float thickness=1.0f)
ENGINE_API void DrawRect (float x, float y, float w, float h, float r, float g, float b, float a=1.0f, float thickness=1.0f, float rounding=0.0f)
ENGINE_API void DrawText (const char *text, float x, float y, float r, float g, float b, float a=1.0f)
ENGINE_API void Dummy (float width, float height)
ENGINE_API void EndChild ()
ENGINE_API void EndGroup ()
ENGINE_API void EndListBox ()
ENGINE_API void EndPanel ()
ENGINE_API void FreeImagePixels (unsigned char *pixels)
ENGINE_API float GetContentRegionAvailWidth ()
ENGINE_API float GetCursorPosY ()
ENGINE_API float GetViewportHeight ()
ENGINE_API float GetViewportWidth ()
ENGINE_API void Image (uint64_t textureID, float width, float height)
ENGINE_API bool InputText (const char *label, char *buf, size_t bufSize)
ENGINE_API bool InputTextString (const char *label, std::string *str)
ENGINE_API unsigned char * LoadImagePixels (const char *path, int *w, int *h)
 Load image file into RGBA pixels (caller must free with FreeImagePixels).
ENGINE_API uint64_t LoadTextureForUI (const std::string &filePath, float *outWidth=nullptr, float *outHeight=nullptr)
 Loads an image file and caches it as a UI-bindable texture id, reusing the cache on repeat calls for the same path.
ENGINE_API void PopStyleColor (int count=1)
ENGINE_API void PopStyleVar (int count=1)
ENGINE_API void ProgressBar (float fraction, float width=-1.0f, float height=0.0f, const char *overlay=nullptr)
ENGINE_API void PushStyleColor (int idx, float r, float g, float b, float a)
ENGINE_API void PushStyleVar (int idx, float val)
ENGINE_API void PushStyleVarVec (int idx, float x, float y)
ENGINE_API void SameLine ()
ENGINE_API bool Selectable (const char *label, bool selected)
ENGINE_API void Separator ()
ENGINE_API void SetCursorPosX (float x)
ENGINE_API void SetCursorPosY (float y)
ENGINE_API void SetNextItemWidth (float width)
ENGINE_API void SetNextWindowPos (float x, float y, bool always=false)
ENGINE_API void SetNextWindowSize (float w, float h, bool always=false)
ENGINE_API void ShutdownTextureCache ()
ENGINE_API void Spacing ()
ENGINE_API void Text (const char *fmt,...)
ENGINE_API void TextColored (float r, float g, float b, float a, const char *fmt,...)
ENGINE_API void TextDisabled (const char *fmt,...)
ENGINE_API void TextWrapped (const char *fmt,...)

Variables

static std::unordered_map< std::string, Sleak::Texture * > s_uiTextures

Detailed Description

Immediate-mode UI calls available to game code.

Thin Dear ImGui wrapper; the only UI surface Game is allowed to call (ImGui itself is a private Engine dependency).

A flat wrapper over the engine's vendored Dear ImGui build, which is a private dependency. Build HUDs and debug panels by calling BeginPanel, the widget functions, and EndPanel from a scene update.

Function Documentation

◆ BeginChild()

void Sleak::UI::BeginChild ( const char * name)

Definition at line 90 of file UI.cpp.

◆ BeginChildSized()

void Sleak::UI::BeginChildSized ( const char * name,
float width,
float height = 0.0f )

Definition at line 94 of file UI.cpp.

◆ BeginGroup()

void Sleak::UI::BeginGroup ( )

Definition at line 82 of file UI.cpp.

◆ BeginListBox()

bool Sleak::UI::BeginListBox ( const char * label,
float width,
float height )

Definition at line 184 of file UI.cpp.

◆ BeginPanel()

void Sleak::UI::BeginPanel ( const char * name,
float x,
float y,
float bgAlpha = 0.4f,
int flags = PanelFlags_NoTitleBar | PanelFlags_AutoResize | PanelFlags_NoMove | PanelFlags_NoInput | PanelFlags_NoFocusOnAppear )

Opens a floating overlay window at (x, y); pair with EndPanel.

Definition at line 14 of file UI.cpp.

◆ Button()

bool Sleak::UI::Button ( const char * label)

Definition at line 62 of file UI.cpp.

◆ ButtonSized()

bool Sleak::UI::ButtonSized ( const char * label,
float width,
float height = 0.0f )

Definition at line 144 of file UI.cpp.

◆ Checkbox()

bool Sleak::UI::Checkbox ( const char * label,
bool * value )

Definition at line 58 of file UI.cpp.

◆ Combo()

bool Sleak::UI::Combo ( const char * label,
int * current,
const char *const items[],
int count )

Definition at line 70 of file UI.cpp.

◆ CreateTextureFromPixels()

Sleak::Texture * Sleak::UI::CreateTextureFromPixels ( uint32_t width,
uint32_t height,
const void * rgbaPixels,
uint32_t maxMipLevels = 0 )

Create a texture from raw RGBA pixel data (for runtime atlas building etc.).

Definition at line 279 of file UI.cpp.

◆ DragFloat()

bool Sleak::UI::DragFloat ( const char * label,
float * value,
float speed = 1.0f,
float min = 0.0f,
float max = 0.0f )

Definition at line 66 of file UI.cpp.

◆ DrawFilledRect()

void Sleak::UI::DrawFilledRect ( float x,
float y,
float w,
float h,
float r,
float g,
float b,
float a = 1.0f,
float rounding = 0.0f )

Definition at line 123 of file UI.cpp.

◆ DrawImage()

void Sleak::UI::DrawImage ( uint64_t textureID,
float x,
float y,
float width,
float height )

Definition at line 240 of file UI.cpp.

◆ DrawLine()

void Sleak::UI::DrawLine ( float x1,
float y1,
float x2,
float y2,
float r,
float g,
float b,
float a = 1.0f,
float thickness = 1.0f )

Definition at line 110 of file UI.cpp.

◆ DrawRect()

void Sleak::UI::DrawRect ( float x,
float y,
float w,
float h,
float r,
float g,
float b,
float a = 1.0f,
float thickness = 1.0f,
float rounding = 0.0f )

Definition at line 116 of file UI.cpp.

◆ DrawText()

void Sleak::UI::DrawText ( const char * text,
float x,
float y,
float r,
float g,
float b,
float a = 1.0f )

Definition at line 130 of file UI.cpp.

◆ Dummy()

void Sleak::UI::Dummy ( float width,
float height )

Definition at line 160 of file UI.cpp.

◆ EndChild()

void Sleak::UI::EndChild ( )

Definition at line 98 of file UI.cpp.

◆ EndGroup()

void Sleak::UI::EndGroup ( )

Definition at line 86 of file UI.cpp.

◆ EndListBox()

void Sleak::UI::EndListBox ( )

Definition at line 188 of file UI.cpp.

◆ EndPanel()

void Sleak::UI::EndPanel ( )

Definition at line 33 of file UI.cpp.

◆ FreeImagePixels()

void Sleak::UI::FreeImagePixels ( unsigned char * pixels)

Definition at line 289 of file UI.cpp.

◆ GetContentRegionAvailWidth()

float Sleak::UI::GetContentRegionAvailWidth ( )

Definition at line 204 of file UI.cpp.

◆ GetCursorPosY()

float Sleak::UI::GetCursorPosY ( )

Definition at line 200 of file UI.cpp.

◆ GetViewportHeight()

float Sleak::UI::GetViewportHeight ( )

Definition at line 106 of file UI.cpp.

◆ GetViewportWidth()

float Sleak::UI::GetViewportWidth ( )

Definition at line 102 of file UI.cpp.

◆ Image()

void Sleak::UI::Image ( uint64_t textureID,
float width,
float height )

Definition at line 227 of file UI.cpp.

◆ InputText()

bool Sleak::UI::InputText ( const char * label,
char * buf,
size_t bufSize )

Definition at line 136 of file UI.cpp.

◆ InputTextString()

bool Sleak::UI::InputTextString ( const char * label,
std::string * str )

Definition at line 140 of file UI.cpp.

◆ LoadImagePixels()

unsigned char * Sleak::UI::LoadImagePixels ( const char * path,
int * w,
int * h )

Load image file into RGBA pixels (caller must free with FreeImagePixels).

Definition at line 284 of file UI.cpp.

◆ LoadTextureForUI()

uint64_t Sleak::UI::LoadTextureForUI ( const std::string & filePath,
float * outWidth = nullptr,
float * outHeight = nullptr )

Loads an image file and caches it as a UI-bindable texture id, reusing the cache on repeat calls for the same path.

Definition at line 256 of file UI.cpp.

◆ PopStyleColor()

void Sleak::UI::PopStyleColor ( int count = 1)

Definition at line 168 of file UI.cpp.

◆ PopStyleVar()

void Sleak::UI::PopStyleVar ( int count = 1)

Definition at line 180 of file UI.cpp.

◆ ProgressBar()

void Sleak::UI::ProgressBar ( float fraction,
float width = -1.0f,
float height = 0.0f,
const char * overlay = nullptr )

Definition at line 216 of file UI.cpp.

◆ PushStyleColor()

void Sleak::UI::PushStyleColor ( int idx,
float r,
float g,
float b,
float a )

Definition at line 164 of file UI.cpp.

◆ PushStyleVar()

void Sleak::UI::PushStyleVar ( int idx,
float val )

Definition at line 172 of file UI.cpp.

◆ PushStyleVarVec()

void Sleak::UI::PushStyleVarVec ( int idx,
float x,
float y )

Definition at line 176 of file UI.cpp.

◆ SameLine()

void Sleak::UI::SameLine ( )

Definition at line 78 of file UI.cpp.

◆ Selectable()

bool Sleak::UI::Selectable ( const char * label,
bool selected )

Definition at line 148 of file UI.cpp.

◆ Separator()

void Sleak::UI::Separator ( )

Definition at line 74 of file UI.cpp.

◆ SetCursorPosX()

void Sleak::UI::SetCursorPosX ( float x)

Definition at line 192 of file UI.cpp.

◆ SetCursorPosY()

void Sleak::UI::SetCursorPosY ( float y)

Definition at line 196 of file UI.cpp.

◆ SetNextItemWidth()

void Sleak::UI::SetNextItemWidth ( float width)

Definition at line 152 of file UI.cpp.

◆ SetNextWindowPos()

void Sleak::UI::SetNextWindowPos ( float x,
float y,
bool always = false )

Definition at line 208 of file UI.cpp.

◆ SetNextWindowSize()

void Sleak::UI::SetNextWindowSize ( float w,
float h,
bool always = false )

Definition at line 212 of file UI.cpp.

◆ ShutdownTextureCache()

void Sleak::UI::ShutdownTextureCache ( )

Definition at line 273 of file UI.cpp.

◆ Spacing()

void Sleak::UI::Spacing ( )

Definition at line 156 of file UI.cpp.

◆ Text()

void Sleak::UI::Text ( const char * fmt,
... )

Definition at line 37 of file UI.cpp.

◆ TextColored()

void Sleak::UI::TextColored ( float r,
float g,
float b,
float a,
const char * fmt,
... )

Definition at line 44 of file UI.cpp.

◆ TextDisabled()

void Sleak::UI::TextDisabled ( const char * fmt,
... )

Definition at line 51 of file UI.cpp.

◆ TextWrapped()

void Sleak::UI::TextWrapped ( const char * fmt,
... )

Definition at line 220 of file UI.cpp.

Variable Documentation

◆ s_uiTextures

std::unordered_map<std::string, Sleak::Texture*> Sleak::UI::s_uiTextures
static

Definition at line 254 of file UI.cpp.