$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
app_ui.h File Reference

UI rendering module for the application. More...

#include "app_settings.h"
#include "glad/glad.h"
#include "ui.h"
#include <GLFW/glfw3.h>
#include <cglm/types.h>
#include <stdbool.h>
Include dependency graph for app_ui.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  KeyPos
 
struct  KeyboardLayoutConfig
 
struct  AppUIOverlay
 

Enumerations

enum  { HISTO_BUCKETS = 256 }
 
enum  { UI_LOADING_TEXT_SIZE = 64 }
 
enum  {
  DEBUG_TEXT_BUFFER_SIZE = 128 , RANGE_TEXT_BUFFER_SIZE = 64 , ENV_TEXT_BUFFER_SIZE = 256 , EXPOSURE_TEXT_BUFFER_SIZE = 64 ,
  MODIFIER_BUFFER_SIZE = 16 , KEYBOARD_BUFFER_SIZE = 256
}
 
enum  {
  ROW_SYSTEM = 0 , ROW_NUMBERS = 1 , ROW_QWERTY = 2 , ROW_ASDF = 3 ,
  ROW_ZXCV = 4 , ROW_BOTTOM = 5
}
 

Functions

void app_draw_help_overlay (const App *app)
 Draws the help overlay with keyboard shortcuts. More...
 
void app_draw_debug_overlay (const App *app)
 Draws the debug overlay with performance metrics and settings. More...
 
void app_render_ui (const App *app)
 Main UI rendering entry point. More...
 
int compute_luminance_histogram (const App *app, int *buckets, int size, float *min_lum, float *max_lum)
 Computes the luminance histogram from current frame data. More...
 
void app_ui_init (AppUIOverlay *overlay)
 
void app_ui_cleanup (AppUIOverlay *overlay)
 
void app_ui_update (AppUIOverlay *overlay, double delta_time)
 
void app_ui_handle_mouse (AppUIOverlay *overlay, double xpos, double ypos, int width, int height)
 

Variables

static const float DEFAULT_BASE_RESOLUTION_HEIGHT = 1080.0F
 
static const float DEFAULT_KBD_KEY_SIZE = 60.0F
 
static const float DEFAULT_KBD_KEY_PADDING = 10.0F
 
static const float DEFAULT_KBD_KEY_RADIUS = 10.0F
 
static const float DEFAULT_KBD_LABEL_SCALE = 0.75F
 
static const float DEFAULT_KBD_TITLE_Y_OFFSET = 140.0F
 
static const float DEFAULT_KBD_DETAIL_Y_OFFSET = 100.0F
 
static const float LUMINANCE_EPSILON = 0.0001F
 
static const float UI_CENTER_FACTOR = 0.5F
 
static const float GRAPH_TEXT_PADDING = 20.0F
 
static const float DEBUG_TEXT_Y_OFFSET = DEFAULT_FONT_SIZE * 4.0F
 
static const float LEGEND_Y_FACTOR = 0.6F
 
static const float LEGEND_X_START_FACTOR = 0.25F
 
static const float LEGEND_STEP_FACTOR = 0.18F
 
static const float LEGEND_COMBO_STEP_MULT = 1.9F
 
static const float GRAPH_POS_X = 20.0F
 
static const float GRAPH_POS_Y_OFF = 200.0F
 
static const float GRAPH_DIM_W = 300.0F
 
static const float GRAPH_DIM_H = 100.0F
 
static const float DEFAULT_KBD_BLOOM_SCALE = 1.3F
 
static const float DEFAULT_KBD_UNBOUND_ALPHA = 0.22F
 
static const float DEFAULT_KBD_BOUND_ALPHA = 0.88F
 
static const float PANEL_FRAME_ALPHA = 0.72F
 
static const float BLOOM_MAX_INTENSITY = 0.5F
 
static const float GLOW_HOVER_ALPHA = 0.6F
 
static const float BLOOM_PRESS_MAX_ALPHA = 0.9F
 
static const float HELP_BG_ALPHA = 0.88F
 
static const float KEY_PRESSED_ALPHA = 0.95F
 
static const float KEY_DEFAULT_ALPHA = 0.4F
 
static const float KEY_PRESS_BRIGHTEN_MIN = 0.6F
 
static const float HELP_TEXT_ALPHA = 0.8F
 
static const float HELP_EXIT_HINT_X_OFF = 300.0F
 
static const float HELP_EXIT_HINT_Y_OFF = 50.0F
 
static const vec3 KEY_COLOR_DEFAULT = {0.15F, 0.15F, 0.20F}
 
static const vec3 KEY_COLOR_TOGGLE = {0.0F, 0.82F, 0.92F}
 
static const vec3 KEY_COLOR_CYCLE = {0.12F, 0.90F, 0.12F}
 
static const vec3 KEY_COLOR_COMBINATION = {1.0F, 0.56F, 0.05F}
 
static const vec3 HELP_BG_COLOR = {0.05F, 0.05F, 0.07F}
 
static const vec3 CYBER_TITLE_COLOR = {0.0F, 0.90F, 0.95F}
 
static const vec3 ENV_TEXT_COLOR = {0.7F, 0.7F, 0.7F}
 
static const vec3 GRAPH_TEXT_COLOR = {0.8F, 0.8F, 0.8F}
 
static const vec3 DEBUG_ORANGE_COLOR = {1.0F, 0.5F, 0.0F}
 
static const vec3 HISTO_BAR_COLOR_GREEN = {0.0F, 0.7F, 0.0F}
 
static const vec3 HISTO_BAR_COLOR_BLUE = {0.0F, 0.5F, 0.8F}
 
static const vec3 HISTO_BAR_COLOR_RED = {0.8F, 0.5F, 0.0F}
 
static const float GLOBAL_DIM_MAX_FALLOFF = 0.7F
 
static const float GLOBAL_DIM_SMOOTH_FACTOR = 15.0F
 
static const double HOVER_DECAY_DURATION = 0.15
 
static const float HELP_PRESS_DURATION = 2.0F
 
static const double UI_SPINNER_SPEED = 10.0
 
static const float UI_LOADING_TEXT_WIDTH_FACTOR = 20.0F
 
static const float UI_SPINNER_SIZE = 64.0F
 
static const float UI_TEXT_OFFSET_FACTOR = 0.8F
 
static const vec3 UI_SPINNER_COLOR
 
static const KeyPos KEY_LAYOUT_QWERTY []
 

Detailed Description

UI rendering module for the application.

This module handles all UI-related drawing operations, including help overlays, debug information, and luminance statistics.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HISTO_BUCKETS 

◆ anonymous enum

anonymous enum
Enumerator
UI_LOADING_TEXT_SIZE 

◆ anonymous enum

anonymous enum
Enumerator
DEBUG_TEXT_BUFFER_SIZE 
RANGE_TEXT_BUFFER_SIZE 
ENV_TEXT_BUFFER_SIZE 
EXPOSURE_TEXT_BUFFER_SIZE 
MODIFIER_BUFFER_SIZE 
KEYBOARD_BUFFER_SIZE 

◆ anonymous enum

anonymous enum
Enumerator
ROW_SYSTEM 
ROW_NUMBERS 
ROW_QWERTY 
ROW_ASDF 
ROW_ZXCV 
ROW_BOTTOM 

Function Documentation

◆ app_draw_debug_overlay()

void app_draw_debug_overlay ( const App app)

Draws the debug overlay with performance metrics and settings.

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_draw_help_overlay()

void app_draw_help_overlay ( const App app)

Draws the help overlay with keyboard shortcuts.

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_render_ui()

void app_render_ui ( const App app)

Main UI rendering entry point.

Orchestrates all UI elements (overlays, histograms, loading spinners).

Parameters
appPointer to the application state.
Here is the call graph for this function:

◆ app_ui_cleanup()

void app_ui_cleanup ( AppUIOverlay overlay)
Here is the call graph for this function:

◆ app_ui_handle_mouse()

void app_ui_handle_mouse ( AppUIOverlay overlay,
double  xpos,
double  ypos,
int  width,
int  height 
)

◆ app_ui_init()

void app_ui_init ( AppUIOverlay overlay)
Here is the call graph for this function:

◆ app_ui_update()

void app_ui_update ( AppUIOverlay overlay,
double  delta_time 
)

◆ compute_luminance_histogram()

int compute_luminance_histogram ( const App app,
int *  buckets,
int  size,
float *  min_lum,
float *  max_lum 
)

Computes the luminance histogram from current frame data.

Scans the luminance buffer to populate buckets for visualization.

Parameters
appPointer to the application state.
bucketsArray to fill with histogram data.
sizeNumber of buckets in the array.
[out]min_lumMinimum luminance found in the data.
[out]max_lumMaximum luminance found in the data.
Returns
Number of samples processed or error code.
Here is the call graph for this function:

Variable Documentation

◆ BLOOM_MAX_INTENSITY

const float BLOOM_MAX_INTENSITY = 0.5F
static

◆ BLOOM_PRESS_MAX_ALPHA

const float BLOOM_PRESS_MAX_ALPHA = 0.9F
static

◆ CYBER_TITLE_COLOR

const vec3 CYBER_TITLE_COLOR = {0.0F, 0.90F, 0.95F}
static

◆ DEBUG_ORANGE_COLOR

const vec3 DEBUG_ORANGE_COLOR = {1.0F, 0.5F, 0.0F}
static

◆ DEBUG_TEXT_Y_OFFSET

const float DEBUG_TEXT_Y_OFFSET = DEFAULT_FONT_SIZE * 4.0F
static

◆ DEFAULT_BASE_RESOLUTION_HEIGHT

const float DEFAULT_BASE_RESOLUTION_HEIGHT = 1080.0F
static

◆ DEFAULT_KBD_BLOOM_SCALE

const float DEFAULT_KBD_BLOOM_SCALE = 1.3F
static

◆ DEFAULT_KBD_BOUND_ALPHA

const float DEFAULT_KBD_BOUND_ALPHA = 0.88F
static

◆ DEFAULT_KBD_DETAIL_Y_OFFSET

const float DEFAULT_KBD_DETAIL_Y_OFFSET = 100.0F
static

◆ DEFAULT_KBD_KEY_PADDING

const float DEFAULT_KBD_KEY_PADDING = 10.0F
static

◆ DEFAULT_KBD_KEY_RADIUS

const float DEFAULT_KBD_KEY_RADIUS = 10.0F
static

◆ DEFAULT_KBD_KEY_SIZE

const float DEFAULT_KBD_KEY_SIZE = 60.0F
static

◆ DEFAULT_KBD_LABEL_SCALE

const float DEFAULT_KBD_LABEL_SCALE = 0.75F
static

◆ DEFAULT_KBD_TITLE_Y_OFFSET

const float DEFAULT_KBD_TITLE_Y_OFFSET = 140.0F
static

◆ DEFAULT_KBD_UNBOUND_ALPHA

const float DEFAULT_KBD_UNBOUND_ALPHA = 0.22F
static

◆ ENV_TEXT_COLOR

const vec3 ENV_TEXT_COLOR = {0.7F, 0.7F, 0.7F}
static

◆ GLOBAL_DIM_MAX_FALLOFF

const float GLOBAL_DIM_MAX_FALLOFF = 0.7F
static

◆ GLOBAL_DIM_SMOOTH_FACTOR

const float GLOBAL_DIM_SMOOTH_FACTOR = 15.0F
static

◆ GLOW_HOVER_ALPHA

const float GLOW_HOVER_ALPHA = 0.6F
static

◆ GRAPH_DIM_H

const float GRAPH_DIM_H = 100.0F
static

◆ GRAPH_DIM_W

const float GRAPH_DIM_W = 300.0F
static

◆ GRAPH_POS_X

const float GRAPH_POS_X = 20.0F
static

◆ GRAPH_POS_Y_OFF

const float GRAPH_POS_Y_OFF = 200.0F
static

◆ GRAPH_TEXT_COLOR

const vec3 GRAPH_TEXT_COLOR = {0.8F, 0.8F, 0.8F}
static

◆ GRAPH_TEXT_PADDING

const float GRAPH_TEXT_PADDING = 20.0F
static

◆ HELP_BG_ALPHA

const float HELP_BG_ALPHA = 0.88F
static

◆ HELP_BG_COLOR

const vec3 HELP_BG_COLOR = {0.05F, 0.05F, 0.07F}
static

◆ HELP_EXIT_HINT_X_OFF

const float HELP_EXIT_HINT_X_OFF = 300.0F
static

◆ HELP_EXIT_HINT_Y_OFF

const float HELP_EXIT_HINT_Y_OFF = 50.0F
static

◆ HELP_PRESS_DURATION

const float HELP_PRESS_DURATION = 2.0F
static

◆ HELP_TEXT_ALPHA

const float HELP_TEXT_ALPHA = 0.8F
static

◆ HISTO_BAR_COLOR_BLUE

const vec3 HISTO_BAR_COLOR_BLUE = {0.0F, 0.5F, 0.8F}
static

◆ HISTO_BAR_COLOR_GREEN

const vec3 HISTO_BAR_COLOR_GREEN = {0.0F, 0.7F, 0.0F}
static

◆ HISTO_BAR_COLOR_RED

const vec3 HISTO_BAR_COLOR_RED = {0.8F, 0.5F, 0.0F}
static

◆ HOVER_DECAY_DURATION

const double HOVER_DECAY_DURATION = 0.15
static

◆ KEY_COLOR_COMBINATION

const vec3 KEY_COLOR_COMBINATION = {1.0F, 0.56F, 0.05F}
static

◆ KEY_COLOR_CYCLE

const vec3 KEY_COLOR_CYCLE = {0.12F, 0.90F, 0.12F}
static

◆ KEY_COLOR_DEFAULT

const vec3 KEY_COLOR_DEFAULT = {0.15F, 0.15F, 0.20F}
static

◆ KEY_COLOR_TOGGLE

const vec3 KEY_COLOR_TOGGLE = {0.0F, 0.82F, 0.92F}
static

◆ KEY_DEFAULT_ALPHA

const float KEY_DEFAULT_ALPHA = 0.4F
static

◆ KEY_LAYOUT_QWERTY

const KeyPos KEY_LAYOUT_QWERTY[]
static

◆ KEY_PRESS_BRIGHTEN_MIN

const float KEY_PRESS_BRIGHTEN_MIN = 0.6F
static

◆ KEY_PRESSED_ALPHA

const float KEY_PRESSED_ALPHA = 0.95F
static

◆ LEGEND_COMBO_STEP_MULT

const float LEGEND_COMBO_STEP_MULT = 1.9F
static

◆ LEGEND_STEP_FACTOR

const float LEGEND_STEP_FACTOR = 0.18F
static

◆ LEGEND_X_START_FACTOR

const float LEGEND_X_START_FACTOR = 0.25F
static

◆ LEGEND_Y_FACTOR

const float LEGEND_Y_FACTOR = 0.6F
static

◆ LUMINANCE_EPSILON

const float LUMINANCE_EPSILON = 0.0001F
static

◆ PANEL_FRAME_ALPHA

const float PANEL_FRAME_ALPHA = 0.72F
static

◆ UI_CENTER_FACTOR

const float UI_CENTER_FACTOR = 0.5F
static

◆ UI_LOADING_TEXT_WIDTH_FACTOR

const float UI_LOADING_TEXT_WIDTH_FACTOR = 20.0F
static

◆ UI_SPINNER_COLOR

const vec3 UI_SPINNER_COLOR
static
Initial value:
= {90.0F / 255.0F, 111.0F / 255.0F,
185.0F / 255.0F}

◆ UI_SPINNER_SIZE

const float UI_SPINNER_SIZE = 64.0F
static

◆ UI_SPINNER_SPEED

const double UI_SPINNER_SPEED = 10.0
static

◆ UI_TEXT_OFFSET_FACTOR

const float UI_TEXT_OFFSET_FACTOR = 0.8F
static