add padding parameter to ui_fit
This commit is contained in:
parent
e0c79dd2b0
commit
bb322b64ca
@ -11,8 +11,12 @@ PP_WidgetTheme PP_GetWidgetTheme(void)
|
||||
theme.window_width = 300;
|
||||
theme.window_padding = theme.window_border - 1;
|
||||
theme.divider_color = theme.window_border_color;
|
||||
|
||||
theme.font_size = 16;
|
||||
theme.window_title_font_size = 16;
|
||||
theme.text_padding_x = 3;
|
||||
theme.text_padding_y = 3;
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
@ -75,7 +79,7 @@ void PP_EndCommandsWidget(PP_CommandsWidget *widget)
|
||||
// UI_Push(Rounding, UI_RPIX(15));
|
||||
UI_Push(Rounding, UI_RPIX(15));
|
||||
UI_Push(Width, UI_PIX(theme.window_width, 0));
|
||||
UI_Push(Height, UI_FIT(0));
|
||||
UI_Push(Height, UI_FIT(0, 0));
|
||||
UI_Push(ChildLayoutAxis, Axis_Y);
|
||||
UI_Push(FloatingPos, widget->pos);
|
||||
UI_SetNext(Flags, UI_BoxFlag_Floating);
|
||||
@ -102,7 +106,7 @@ void PP_EndCommandsWidget(PP_CommandsWidget *widget)
|
||||
/* Title box */
|
||||
UI_SetNext(FontSize, theme.window_title_font_size);
|
||||
UI_SetNext(ChildAlignment, UI_Alignment_Center);
|
||||
UI_SetNext(Width, UI_FIT(1));
|
||||
UI_SetNext(Width, UI_FIT(0, 1));
|
||||
UI_SetNext(Text, Lit("Commands"));
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
UI_BuildBox(UI_NilKey);
|
||||
@ -171,8 +175,12 @@ void PP_EndCommandsWidget(PP_CommandsWidget *widget)
|
||||
|
||||
/* Command hotkey button */
|
||||
UI_SetNext(Text, UI_StringF("Test"));
|
||||
UI_SetNext(Width, UI_FIT(1));
|
||||
UI_SetNext(Width, UI_FIT(theme.text_padding_x, 1));
|
||||
UI_SetNext(Height, UI_FIT(theme.text_padding_y, 1));
|
||||
UI_SetNext(Rounding, UI_RPIX(0));
|
||||
UI_SetNext(Border, 1);
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(ChildAlignment, UI_Alignment_Center);
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Interactable);
|
||||
UI_PushCP(UI_BuildRow(UI_NilKey));
|
||||
{
|
||||
@ -245,13 +253,13 @@ UI_Box *PP_BuildConsoleWidget(b32 minimized)
|
||||
{
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(Width, UI_PIX(500, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Height, UI_FIT(0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_SetNext(BackgroundColor, Rgba(1, 1, 1, 0.02));
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Height, UI_FIT(0, 1));
|
||||
}
|
||||
console_box = UI_BuildColumn(UI_KeyF("Console box"));
|
||||
UI_PushCP(console_box);
|
||||
@ -325,7 +333,7 @@ UI_Box *PP_BuildConsoleWidget(b32 minimized)
|
||||
UI_Push(Border, 0);
|
||||
UI_Push(Text, text);
|
||||
UI_Push(Width, UI_FILL(1, 0));
|
||||
UI_Push(Height, UI_FIT(1));
|
||||
UI_Push(Height, UI_FIT(0, 1));
|
||||
UI_Push(Flags, UI_BoxFlag_DrawText);
|
||||
UI_BuildBox(UI_NilKey);
|
||||
}
|
||||
|
||||
@ -13,6 +13,9 @@ Struct(PP_WidgetTheme)
|
||||
f32 window_border;
|
||||
f32 window_padding;
|
||||
f32 window_width;
|
||||
|
||||
f32 text_padding_x;
|
||||
f32 text_padding_y;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Label helpers
|
||||
|
||||
UI_Box *UI_BuildLabel(String text)
|
||||
{
|
||||
UI_Box *parent = UI_UseTop(Parent);
|
||||
@ -15,8 +16,8 @@ UI_Box *UI_BuildLabel(String text)
|
||||
UI_SetNext(Tint, tint);
|
||||
UI_SetNext(Font, font);
|
||||
UI_SetNext(FontSize, font_size);
|
||||
UI_SetNext(Width, UI_FIT(1));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Width, UI_FIT(0, 1));
|
||||
UI_SetNext(Height, UI_FIT(0, 1));
|
||||
UI_SetNext(Text, text);
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
box = UI_BuildBox(UI_NilKey);
|
||||
|
||||
@ -801,7 +801,7 @@ i64 UI_EndFrame(UI_Frame frame)
|
||||
text_size = box->font->ascent + box->font->descent;
|
||||
}
|
||||
}
|
||||
box->solved_dims[axis] = text_size;
|
||||
box->solved_dims[axis] = text_size + (pref_size.v * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -857,7 +857,7 @@ i64 UI_EndFrame(UI_Frame frame)
|
||||
}
|
||||
}
|
||||
}
|
||||
box->solved_dims[axis] = accum;
|
||||
box->solved_dims[axis] = accum + (pref_size.v * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ UI_Style UI_PopStyle(UI_StyleDesc desc);
|
||||
#define UI_SIZE(_kind, _v, _s) (UI_Size) { .kind = (_kind), .v = (_v), .strictness = (_s) }
|
||||
|
||||
#define UI_PIX(_v, _s) UI_SIZE(UI_SizeKind_Pixel, (_v), (_s))
|
||||
#define UI_FIT(_s) UI_SIZE(UI_SizeKind_Fit, 0, (_s))
|
||||
#define UI_FIT(_v, _s) UI_SIZE(UI_SizeKind_Fit, (_v), (_s))
|
||||
#define UI_FILL(_v, _s) UI_SIZE(UI_SizeKind_Fill, (_v), (_s))
|
||||
#define UI_FNT(_v, _s) UI_SIZE(UI_SizeKind_Pixel, (f32)UI_PeekTop(FontSize) * (_v), (_s))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user