}
*verts;
#pragma pack(pop)
+
+ u32 control_id;
u32 num_verts;
u16 *indices;
u32 stack_count;
u32 capture_mouse_id;
int capture_lock;
- u32 id_base;
- int glyph_base;
+
/* User input */
ui_px mouse[2];
dest[1] = vg_max( parent[1], dest[1] );
}
-static u32 ui_group_id( ui_ctx *ctx, u32 lesser_unique )
-{
- return ctx->id_base | lesser_unique;
-}
-
static void ui_capture_mouse( ui_ctx *ctx, u32 id )
{
- u32 group_uid = ui_group_id(ctx,id);
-
struct ui_qnode *node = &ctx->stack[ ctx->stack_count-1 ];
- node->capture_id = group_uid;
+ node->capture_id = id;
if( !ctx->capture_lock && node->mouse_over )
{
- ctx->capture_mouse_id = group_uid;
+ ctx->capture_mouse_id = id;
}
}
k_button_hold
};
-static int ui_button( ui_ctx *ctx, u32 id )
+static int ui_button( ui_ctx *ctx )
{
+ u32 uid = ctx->control_id ++;
+
ui_new_node( ctx );
{
- ui_capture_mouse( ctx, id );
+ ui_capture_mouse( ctx, uid );
if( ui_hasmouse(ctx) )
{
static int ui_window( ui_ctx *ctx, struct ui_window *window, u32 control_group )
{
- ctx->id_base = control_group << 16;
-
if( window->drag )
{
window->transform[0] = ctx->mouse[0]+window->drag_offset[0];
ui_new_node( ctx );
{
- ui_capture_mouse( ctx, __COUNTER__ );
+ ui_capture_mouse( ctx, ctx->control_id ++ );
/* Drag bar */
ctx->cursor[3] = 25;
ui_new_node( ctx );
{
- ui_capture_mouse( ctx, __COUNTER__ );
+ ui_capture_mouse( ctx, ctx->control_id ++ );
struct ui_vert *drag_bar = ui_fill_rect( ctx, ctx->cursor, 0xff555555 );
ui_align_top( ctx );
ui_rect_pad( ctx->cursor, 4 );
- if( ui_button( ctx, __COUNTER__ ) )
+ if( ui_button( ctx ) )
{
vg_info( "Click clacked\n" );
}
ctx->cursor[2] = fwidth;
ctx->cursor[0] = slider_start + fpos * fmove;
- /* TODO.. */
- u32 uid = (u32)(u64)slider->data;
- int status = ui_button( ctx, uid );
-
- if( ctx->capture_lock &&
- (ctx->capture_mouse_id == ui_group_id( ctx, uid )))
+ u32 uid = ctx->control_id ++;
+ int status = ui_button( ctx );
+ if( ctx->capture_lock && (ctx->capture_mouse_id == uid))
{
float ui_new = ctx->mouse[0],
local = ui_new - (slider_start + fstart),
snprintf( buf, 12, "%.2f", *slider->data );
ui_text( ctx, ctx->cursor, buf, 1, 0 );
ui_end_down( ctx );
-
ui_end_down( ctx );
}
static void ui_checkbox( ui_ctx *ctx, struct ui_checkbox *cb )
{
- u32 uid = (u32)(u64)cb->data;
- if( ui_button(ctx,uid) == k_button_click )
+ if( ui_button(ctx) == k_button_click )
*cb->data ^= 0x1;
ui_new_node(ctx);
#define gui_align_top() ui_align_top( &ui_global_ctx )
#define gui_align_left() ui_align_left( &ui_global_ctx )
#define gui_clamp_rect(...) ui_clamp_rect( &ui_global_ctx, __VA_ARGS__)
-#define gui_group_id(...) ui_group_id( &ui_global_ctx, __VA_ARGS__)
#define gui_capture_mouse(...) ui_capture_mouse( &ui_global_ctx, __VA_ARGS__)
#define gui_set_clip(...) ui_set_clip( &ui_global_ctx, __VA_ARGS__)
#define gui_release_clip() ui_release_clip( &ui_global_ctx )