mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-24 12:42:32 +00:00
[ui] Make windows respect their size fields
If auto_fit is true, then the old behavior is retained. This is actually better than the set size thing, but that's probably still useful.
This commit is contained in:
parent
f80f265a07
commit
a300e2330d
6 changed files with 35 additions and 4 deletions
|
@ -85,12 +85,13 @@ typedef struct imui_window_s {
|
|||
int mode;
|
||||
bool is_open;
|
||||
bool is_collapsed;
|
||||
bool no_collapse;
|
||||
bool auto_fit;
|
||||
|
||||
const char *reference;
|
||||
grav_t reference_gravity;
|
||||
grav_t anchor_gravity;
|
||||
struct imui_window_s *parent; // for submenus
|
||||
bool no_collapse;
|
||||
} imui_window_t;
|
||||
|
||||
typedef struct imui_io_s {
|
||||
|
|
|
@ -313,6 +313,7 @@ color_window (void)
|
|||
.xpos = 75,
|
||||
.ypos = 75,
|
||||
.is_open = false,
|
||||
.auto_fit = true,
|
||||
};
|
||||
static int style_selection;
|
||||
static int style_mode;
|
||||
|
@ -484,14 +485,17 @@ static imui_window_t system_info_window = {
|
|||
.name = "System Info##window",
|
||||
.xpos = 50,
|
||||
.ypos = 50,
|
||||
.auto_fit = true,
|
||||
};
|
||||
|
||||
static imui_window_t cam_window = {
|
||||
.name = "Debug Camera",
|
||||
.auto_fit = true,
|
||||
};
|
||||
|
||||
static imui_window_t inp_window = {
|
||||
.name = "Debug Input",
|
||||
.auto_fit = true,
|
||||
};
|
||||
|
||||
static imui_window_t debug_menu = {
|
||||
|
@ -499,6 +503,7 @@ static imui_window_t debug_menu = {
|
|||
.group_offset = 0,
|
||||
.is_open = true,
|
||||
.no_collapse = true,
|
||||
.auto_fit = true,
|
||||
};
|
||||
|
||||
static imui_window_t renderer_menu = {
|
||||
|
@ -506,6 +511,7 @@ static imui_window_t renderer_menu = {
|
|||
.group_offset = 1,
|
||||
.reference_gravity = grav_northwest,
|
||||
.anchor_gravity = grav_southwest,
|
||||
.auto_fit = true,
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
|
@ -118,6 +118,7 @@ bi(IMUI_NewWindow)
|
|||
*window = (imui_window_t) {
|
||||
.name = name,
|
||||
.is_open = true,
|
||||
.auto_fit = true,
|
||||
};
|
||||
RETURN_POINTER (pr, window);
|
||||
}
|
||||
|
@ -140,6 +141,14 @@ bi(IMUI_Window_IsCollapsed)
|
|||
R_INT (pr) = window->is_collapsed;
|
||||
}
|
||||
|
||||
bi(IMUI_Window_SetSize)
|
||||
{
|
||||
auto window = (imui_window_t *) P_GPOINTER (pr, 0);
|
||||
window->auto_fit = false;
|
||||
window->xlen = P_INT (pr, 1);
|
||||
window->ylen = P_INT (pr, 2);
|
||||
}
|
||||
|
||||
bi(IMUI_NewContext)
|
||||
{
|
||||
imui_resources_t *res = _res;
|
||||
|
@ -411,6 +420,7 @@ static builtin_t builtins[] = {
|
|||
bi(IMUI_DeleteWindow, 1, p(ptr)),
|
||||
bi(IMUI_Window_IsOpen, 1, p(ptr)),
|
||||
bi(IMUI_Window_IsCollapsed, 1, p(ptr)),
|
||||
bi(IMUI_Window_SetSize , 3, p(ptr), p(int), p(int)),
|
||||
|
||||
bi(IMUI_NewContext, 2, p(string), p(float)),
|
||||
bi(IMUI_DestroyContext, 2, p(int)),
|
||||
|
|
|
@ -1177,25 +1177,37 @@ IMUI_StartPanel (imui_ctx_t *ctx, imui_window_t *panel)
|
|||
state->draw_order = ++ctx->draw_order;
|
||||
}
|
||||
|
||||
auto semantic = panel->auto_fit ? imui_size_fitchildren : imui_size_pixels;
|
||||
|
||||
ctx->current_parent = panel_view;
|
||||
*View_Control (panel_view) = (viewcont_t) {
|
||||
.gravity = gravity,
|
||||
.visible = 1,
|
||||
.semantic_x = imui_size_fitchildren,
|
||||
.semantic_y = imui_size_fitchildren,
|
||||
.semantic_x = semantic,
|
||||
.semantic_y = semantic,
|
||||
.free_x = 1,
|
||||
.free_y = 1,
|
||||
.vertical = true,
|
||||
.active = 1,
|
||||
};
|
||||
View_SetPos (panel_view, panel->xpos, panel->ypos);
|
||||
View_SetLen (panel_view, panel->xlen, panel->ylen);
|
||||
if (panel->auto_fit) {
|
||||
View_SetLen (panel_view, 0, 0);
|
||||
} else {
|
||||
View_SetLen (panel_view, panel->xlen, panel->ylen);
|
||||
}
|
||||
|
||||
auto bg = ctx->style.background.normal;
|
||||
UI_Vertical {
|
||||
if (!panel->auto_fit) {
|
||||
IMUI_Layout_SetYSize (ctx, imui_size_expand, 100);
|
||||
}
|
||||
ctx->style.background.normal = 0;//FIXME style
|
||||
IMUI_Spacer (ctx, imui_size_expand, 100, imui_size_pixels, 2);
|
||||
UI_Horizontal {
|
||||
if (!panel->auto_fit) {
|
||||
IMUI_Layout_SetYSize (ctx, imui_size_expand, 100);
|
||||
}
|
||||
IMUI_Spacer (ctx, imui_size_pixels, 2, imui_size_expand, 100);
|
||||
UI_Vertical {
|
||||
IMUI_Layout_SetXSize (ctx, imui_size_expand, 100);
|
||||
|
|
|
@ -38,6 +38,7 @@ imui_window_t *IMUI_NewWindow (string name);
|
|||
void IMUI_DeleteWindow (imui_window_t *window);
|
||||
int IMUI_Window_IsOpen (imui_window_t *window);
|
||||
int IMUI_Window_IsCollapsed (imui_window_t *window);
|
||||
void IMUI_Window_SetSize (imui_window_t *window, int xlen, int ylen);
|
||||
|
||||
imui_ctx_t IMUI_NewContext (string font, float fontsize);
|
||||
void IMUI_DestroyContext (imui_ctx_t ctx);
|
||||
|
|
|
@ -7,6 +7,7 @@ imui_ctx_t IMUI_NewContext (string font, float fontsize) = #0;
|
|||
void IMUI_DestroyContext (imui_ctx_t ctx) = #0;
|
||||
int IMUI_Window_IsOpen (imui_window_t *window) = #0;
|
||||
int IMUI_Window_IsCollapsed (imui_window_t *window) = #0;
|
||||
void IMUI_Window_SetSize (imui_window_t *window, int xlen, int ylen) = #0;
|
||||
|
||||
void IMUI_SetVisible (imui_ctx_t ctx, int visible) = #0;
|
||||
void IMUI_SetSize (imui_ctx_t ctx, int xlen, int ylen) = #0;
|
||||
|
|
Loading…
Reference in a new issue