2024-05-09 01:02:33 -07:00
|
|
|
package sectr
|
|
|
|
|
2024-05-13 07:40:29 -07:00
|
|
|
// TODO(Ed): We problably can embedd this info into the UI_Layout with the regular text_alignment
|
2024-05-11 19:38:05 -07:00
|
|
|
UI_TextAlign :: enum u32 {
|
|
|
|
Left,
|
|
|
|
Center,
|
|
|
|
Right,
|
|
|
|
Count
|
2024-05-09 01:02:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
UI_StylePreset :: enum u32 {
|
|
|
|
Default,
|
|
|
|
Disabled,
|
|
|
|
Hot,
|
|
|
|
Active,
|
|
|
|
Count,
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_Style :: struct {
|
|
|
|
bg_color : Color,
|
|
|
|
border_color : Color,
|
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
// TODO(Ed): We cannot support individual corners unless we add it to raylib (or finally change the rendering backend)
|
2024-05-13 07:40:29 -07:00
|
|
|
corner_radii : [Corner.Count]f32,
|
2024-05-11 19:38:05 -07:00
|
|
|
|
2024-05-09 01:02:33 -07:00
|
|
|
// TODO(Ed) : Add support for this eventually
|
|
|
|
blur_size : f32,
|
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
// TODO(Ed): Add support for textures
|
|
|
|
// texture : Texture2,
|
|
|
|
|
|
|
|
// TODO(Ed): Add support for custom shader
|
|
|
|
// shader : UI_Shader,
|
|
|
|
|
2024-05-13 07:40:29 -07:00
|
|
|
font : FontID,
|
|
|
|
text_color : Color,
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
// TODO(Ed) : Support setting the cursor state
|
2024-05-09 01:02:33 -07:00
|
|
|
cursor : UI_Cursor,
|
|
|
|
|
|
|
|
// Used with style, prev_style, and style_delta to produce a simple interpolated animation
|
|
|
|
// Applied in the layout pass & the rendering pass for their associated fields.
|
|
|
|
transition_time : f32,
|
|
|
|
}
|
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
UI_StyleCombo :: struct #raw_union {
|
2024-05-09 01:02:33 -07:00
|
|
|
array : [UI_StylePreset.Count] UI_Style,
|
|
|
|
using styles : struct {
|
|
|
|
default, disabled, hot, active : UI_Style,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
to_ui_style_combo :: #force_inline proc( style : UI_Style ) -> UI_StyleCombo { return { styles = {style, style, style, style} } }
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
/*
|
|
|
|
Style Interface
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
Style for UI_Boxes in the state graph is stored on a per-graph UI_State basis in the fixed sized stack called style_combo_stack.
|
|
|
|
The following provides a convient way to manipulate this stack from the assuption of the program's state.ui_context
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
The following procedure overloads are available from grime.odin :
|
|
|
|
* ui_style
|
|
|
|
* ui_style_push
|
|
|
|
*/
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
ui_style_peek :: #force_inline proc() -> UI_StyleCombo { return stack_peek( & get_state().ui_context.style_combo_stack ) }
|
|
|
|
ui_style_ref :: #force_inline proc() -> (^ UI_StyleCombo) { return stack_peek_ref( & get_state().ui_context.style_combo_stack ) }
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
ui_style_push_style :: #force_inline proc( style : UI_Style ) { push( & get_state().ui_context.style_combo_stack, to_ui_style_combo(style)) }
|
|
|
|
ui_style_push_combo :: #force_inline proc( combo : UI_StyleCombo ) { push( & get_state().ui_context.style_combo_stack, combo ) }
|
|
|
|
ui_style_pop :: #force_inline proc() { pop( & get_state().ui_context.style_combo_stack ) }
|
2024-05-09 23:08:36 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
@(deferred_none = ui_style_pop) ui_style_via_style :: #force_inline proc( style : UI_Style ) { ui_style_push( style) }
|
|
|
|
@(deferred_none = ui_style_pop) ui_style_via_combo :: #force_inline proc( combo : UI_StyleCombo ) { ui_style_push( combo) }
|
2024-05-09 01:02:33 -07:00
|
|
|
|
2024-05-11 19:38:05 -07:00
|
|
|
ui_style_set :: #force_inline proc ( style : UI_Style, preset : UI_StylePreset ) { stack_peek_ref( & get_state().ui_context.style_combo_stack ).array[preset] = style }
|