UI clean-up
This commit is contained in:
13
ui/ui.jai
13
ui/ui.jai
@@ -3,6 +3,7 @@ MAX_BOXES :: 4096;
|
||||
MAX_WINDOWS :: 128;
|
||||
|
||||
SCROLL_SPEED :: 5;
|
||||
DEFAULT_PADDING :: 5;
|
||||
|
||||
WINDOW_TITLE_BAR_HEIGHT :: 20.0;
|
||||
WINDOW_BORDER_WIDTH :: 3;
|
||||
@@ -109,7 +110,7 @@ UI_Child_Axis :: enum {
|
||||
UI_Child_Alignment :: enum {
|
||||
LEFT;
|
||||
RIGHT;
|
||||
CENTERED;
|
||||
CENTERED_VERTICALLY;
|
||||
}
|
||||
|
||||
UI_Text_Alignment_Flags :: enum_flags u8 {
|
||||
@@ -664,8 +665,9 @@ ui_set_rect_recursively :: (parent: *UI_Box) {
|
||||
while child != null {
|
||||
defer child = child.next;
|
||||
|
||||
if parent.layout.alignment == .CENTERED {
|
||||
|
||||
if parent.layout.alignment == .CENTERED_VERTICALLY {
|
||||
child.rect.x = starting_offset_x;
|
||||
child.rect.y = parent.rect.y + parent.rect.h / 2 - child.rect.h / 2;
|
||||
} else {
|
||||
child.rect.x = starting_offset_x;
|
||||
child.rect.y = starting_offset_y;
|
||||
@@ -851,11 +853,12 @@ ui_render :: () {
|
||||
{
|
||||
if window.title.count > 0 {
|
||||
font_handle := ui_state.fonts.regular;
|
||||
x : float = cast(float)(xx window.actual_position.x + cast(u32)WINDOW_BORDER_WIDTH + 2);
|
||||
x : float = cast(float)(xx window.actual_position.x + cast(u32)WINDOW_BORDER_WIDTH + DEFAULT_PADDING);
|
||||
y : float = (cast(float)engine.renderer.render_target_height - (window.actual_position.y + WINDOW_BORDER_WIDTH + 2.0));
|
||||
|
||||
text_size := get_text_size(engine.renderer, window.title, font_handle);
|
||||
y -= text_size.y;
|
||||
y -= text_size.y / 2 + (WINDOW_TITLE_BAR_HEIGHT - WINDOW_BORDER_WIDTH) / 2;
|
||||
y = round(y);
|
||||
render_data := bake_text(engine.renderer, x, y, window.title, font_handle, .{1,1,1,1});
|
||||
font := *engine.renderer.fonts[font_handle - 1];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user