1 // Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
3 SHADER_DEFINE( shader_ui
,
6 "layout (location=0) in vec2 a_co;" // i16, i16, .. ?
7 "layout (location=1) in vec2 a_uv;" // i16, i16
8 "layout (location=2) in vec4 a_colour;" // u32
9 "layout (location=3) in vec4 a_clip;" // i16, i16, i16, i16
12 "out vec2 aTexCoords;"
19 "gl_Position = vec4( uPv * vec3( a_co, 1.0 ), 1.0 );"
20 "aTexCoords = a_uv * 0.01388888888;"
28 "uniform sampler2D uTexGlyphs;"
39 "float clip_blend = step( aWsp.x, aClip.z ) * step( aWsp.y, aClip.w ) * step( aClip.x, aWsp.x ) * step( aClip.y, aWsp.y );"
40 "vec4 glyph = vec4(1.0,1.0,1.0,1.0);"
42 "if( aColour.a == 0.0 )"
44 "glyph = texture( uTexGlyphs, aTexCoords );"
45 "glyph.a = smoothstep( 0.47, 0.53, glyph.r );"
49 "glyph.a = aColour.a;"
52 "FragColor = vec4( aColour.rgb, glyph.a*clip_blend );"
55 UNIFORMS({ "uPv", "uTexGlyphs" })
58 #define UI_AUTO_FILL 0
62 // ===========================================================================================================
65 typedef u32 ui_colour
;
66 typedef ui_px ui_rect
[4];
67 typedef struct ui_ctx ui_ctx
;
68 typedef struct ui_colourset ui_colourset
;
122 u32 capture_mouse_id
;
129 int click_state
; // 0: released, 1: on down, 2: pressed, 3: on release
131 ui_colourset
*colours_main
;
132 ui_colourset
*colours_current
;
148 // ===========================================================================================================
151 int ui_glyph_override
= 0;
152 ui_px ui_glyph_spacing_x
= 6;
153 GLuint ui_glyph_texture
= 0;
155 ui_colourset ui_default_colours
= {
160 ui_ctx ui_global_ctx
= {
162 .colours_main
= &ui_default_colours
167 // ===========================================================================================================
169 static void ui_reset_colours( ui_ctx
*ctx
);
170 static void ui_init_context( ui_ctx
*ctx
, int index_buffer_size
)
172 ui_reset_colours( ctx
);
174 u32 vertex_buffer_size
= (index_buffer_size
+(index_buffer_size
/2));
176 // Generate the buffer we are gonna be drawing to
178 glGenVertexArrays(1, &ctx
->vao
);
179 glGenBuffers( 1, &ctx
->vbo
);
180 glGenBuffers( 1, &ctx
->ebo
);
181 glBindVertexArray( ctx
->vao
);
183 glBindBuffer( GL_ARRAY_BUFFER
, ctx
->vbo
);
185 glBufferData( GL_ARRAY_BUFFER
, vertex_buffer_size
* sizeof( struct ui_vert
), NULL
, GL_DYNAMIC_DRAW
);
186 glBindVertexArray( ctx
->vao
);
188 glBindBuffer( GL_ELEMENT_ARRAY_BUFFER
, ctx
->ebo
);
189 glBufferData( GL_ELEMENT_ARRAY_BUFFER
, index_buffer_size
* sizeof( u16
), NULL
, GL_DYNAMIC_DRAW
);
191 u32
const stride
= sizeof( struct ui_vert
);
194 glVertexAttribPointer( 0, 2, GL_SHORT
, GL_FALSE
, stride
, (void *)offsetof( struct ui_vert
, co
) );
195 glEnableVertexAttribArray( 0 );
198 glVertexAttribPointer( 1, 2, GL_UNSIGNED_BYTE
, GL_FALSE
, stride
, (void *)offsetof( struct ui_vert
, uv
) );
199 glEnableVertexAttribArray( 1 );
202 glVertexAttribPointer( 2, 4, GL_UNSIGNED_BYTE
, GL_TRUE
, stride
, (void *)offsetof( struct ui_vert
, colour
) );
203 glEnableVertexAttribArray( 2 );
206 glVertexAttribPointer( 3, 4, GL_SHORT
, GL_FALSE
, stride
, (void *)offsetof( struct ui_vert
, clip
) );
207 glEnableVertexAttribArray( 3 );
210 // Initialize default context
212 ctx
->verts
= (struct ui_vert
*)malloc( vertex_buffer_size
* sizeof(struct ui_vert
) );
213 ctx
->indices
= (u16
*)malloc( index_buffer_size
* sizeof(u16
) );
217 static void ui_context_free( ui_ctx
*ctx
)
219 glDeleteVertexArrays( 1, &ctx
->vao
);
220 glDeleteBuffers( 1, &ctx
->vbo
);
221 glDeleteBuffers( 1, &ctx
->ebo
);
224 free( ctx
->indices
);
227 static void ui_override_font( GLuint new_tex
, ui_px space_x
)
229 if( ui_glyph_texture
)
230 glDeleteTextures( 1, &ui_glyph_texture
);
232 ui_glyph_texture
= new_tex
;
233 ui_glyph_override
= 1;
234 ui_glyph_spacing_x
= space_x
;
237 static void ui_default_init(void)
240 if( !ui_glyph_override
)
243 #include "fonts/weiholmir.h"
246 u32 pixels
= 0, total
= 72*72, data
= 0;
247 u8
*image
= malloc( total
);
249 while( pixels
< total
)
251 for( int b
= 31; b
>= 0; b
-- )
253 image
[ pixels
++ ] = (compressed
[data
] & (0x1 << b
))? 0xff: 0x00;
255 if( pixels
>= total
)
264 glGenTextures( 1, &ui_glyph_texture
);
265 glBindTexture( GL_TEXTURE_2D
, ui_glyph_texture
);
267 glTexImage2D( GL_TEXTURE_2D
, 0, GL_R8
, 72, 72, 0, GL_RED
, GL_UNSIGNED_BYTE
, image
);
275 // Setup OpenGL memory
276 SHADER_INIT( shader_ui
);
277 ui_init_context( &ui_global_ctx
, 20000 );
280 static void ui_default_free(void)
282 if( !ui_glyph_override
)
283 glDeleteTextures( 1, &ui_glyph_texture
);
285 ui_context_free( &ui_global_ctx
);
288 static struct ui_vert
*ui_fill_rect_uv( ui_ctx
*ctx
, ui_rect rect
, u32 colour
, ui_px uv
[4] );
289 static void ui_draw( ui_ctx
*ctx
, m3x3f view_override
)
291 u32 num_indices_normal
= ctx
->num_indices
;
293 // Append images to back of buffer
294 for( int i
= 0; i
< ctx
->image_count
; i
++ )
295 ui_fill_rect_uv( ctx
, ctx
->images
[i
].rc
, 0xffffffff, (ui_px
[4]){0,0,128,128} );
297 glBindVertexArray( ctx
->vao
);
299 glBindBuffer( GL_ARRAY_BUFFER
, ctx
->vbo
);
300 glBufferSubData( GL_ARRAY_BUFFER
, 0, ctx
->num_verts
* sizeof( struct ui_vert
), ctx
->verts
);
302 glBindBuffer( GL_ELEMENT_ARRAY_BUFFER
, ctx
->ebo
);
303 glBufferSubData( GL_ELEMENT_ARRAY_BUFFER
, 0, ctx
->num_indices
* sizeof( u16
), ctx
->indices
);
306 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
307 glBlendEquation(GL_FUNC_ADD
);
309 SHADER_USE( shader_ui
);
311 m3x3f view
= M3X3_IDENTITY
;
315 view_override
= view
;
317 m3x3_translate( view
, (v3f
){ -1.0f
, 1.0f
, 0.0f
} );
318 m3x3_scale( view
, (v3f
){ 1.0f
/((float)vg_window_x
*0.5f
), -1.0f
/((float)vg_window_y
*0.5f
), 1.0f
} );
321 glUniformMatrix3fv( SHADER_UNIFORM( shader_ui
, "uPv" ), 1, GL_FALSE
, (float *)view_override
);
323 glActiveTexture( GL_TEXTURE0
);
324 glBindTexture( GL_TEXTURE_2D
, ui_glyph_texture
);
325 glUniform1i( SHADER_UNIFORM( shader_ui
, "uTexGlyphs" ), 0 );
327 glDrawElements( GL_TRIANGLES
, num_indices_normal
, GL_UNSIGNED_SHORT
, (void*)(0) );
329 // Draw image elements
330 for( int i
= 0; i
< ctx
->image_count
; i
++ )
332 struct ui_image
*img
= &ctx
->images
[i
];
334 glBindTexture( GL_TEXTURE_2D
, img
->image
);
335 glDrawElements( GL_TRIANGLES
, 6, GL_UNSIGNED_SHORT
, (void*)( (num_indices_normal
+ 6*i
)*sizeof(u16
) ) );
342 // ===========================================================================================================
344 static void ui_rect_copy( ui_rect src
, ui_rect dst
)
352 static void ui_rect_pad( ui_rect rect
, ui_px pad
)
360 static void ui_vis_rect( ui_rect rect
, u32 colour
)
368 p1
[0] = rect
[0]+rect
[2];
369 p1
[1] = rect
[1]+rect
[3];
371 vg_line( p0
, (v2f
){p1
[0],p0
[1]}, colour
);
372 vg_line( (v2f
){p1
[0],p0
[1]}, p1
, colour
);
373 vg_line( p1
, (v2f
){p0
[0],p1
[1]}, colour
);
374 vg_line( (v2f
){p0
[0],p1
[1]}, p0
, colour
);
379 // ===========================================================================================================
381 static struct ui_qnode
*ui_current( ui_ctx
*ctx
)
383 return &ctx
->stack
[ ctx
->stack_count
-1 ];
386 static void ui_new_node( ui_ctx
*ctx
)
388 if( ctx
->stack_count
== vg_list_size( ctx
->stack
) )
389 vg_exiterr( "[UI] Stack overflow while creating box!" );
391 struct ui_qnode
*parent
= &ctx
->stack
[ ctx
->stack_count
-1 ];
392 struct ui_qnode
*node
= &ctx
->stack
[ ctx
->stack_count
++ ];
393 ui_rect_copy( ctx
->cursor
, node
->rect
);
395 if( parent
->mouse_over
)
397 if( ctx
->mouse
[0] >= node
->rect
[0] && ctx
->mouse
[0] < node
->rect
[0]+node
->rect
[2] &&
398 ctx
->mouse
[1] >= node
->rect
[1] && ctx
->mouse
[1] < node
->rect
[1]+node
->rect
[3] )
399 node
->mouse_over
= 1;
401 node
->mouse_over
= 0;
405 node
->mouse_over
= 0;
409 static int ui_hasmouse( ui_ctx
*ctx
)
411 struct ui_qnode
*node
= ui_current( ctx
);
412 return (node
->mouse_over
&& (node
->capture_id
== ctx
->capture_mouse_id
));
415 static void ui_end( ui_ctx
*ctx
)
417 struct ui_qnode
*node
= &ctx
->stack
[ --ctx
->stack_count
];
419 ui_rect_copy( node
->rect
, ctx
->cursor
);
420 ui_vis_rect( ctx
->cursor
,
421 (node
->mouse_over
&& (node
->capture_id
== ctx
->capture_mouse_id
))? 0xffff0000: 0xff0000ff );
424 static void ui_end_down( ui_ctx
*ctx
)
426 ui_px height
= ui_current( ctx
)->rect
[3];
428 ctx
->cursor
[1] += height
;
431 static void ui_end_right( ui_ctx
*ctx
)
433 ui_px width
= ui_current( ctx
)->rect
[2];
435 ctx
->cursor
[0] += width
;
438 static void ui_fill_y( ui_ctx
*ctx
)
440 struct ui_qnode
*node
= ui_current( ctx
);
441 ctx
->cursor
[3] = node
->rect
[3] - (ctx
->cursor
[1]-node
->rect
[1]);
444 static void ui_fill_x( ui_ctx
*ctx
)
446 struct ui_qnode
*node
= ui_current( ctx
);
447 ctx
->cursor
[2] = node
->rect
[2] - (ctx
->cursor
[0]-node
->rect
[0]);
450 // Alignment: | [] | -> | []|
451 static void ui_align_bottom( ui_ctx
*ctx
)
453 struct ui_qnode
*node
= ui_current( ctx
);
454 ctx
->cursor
[1] = node
->rect
[1] + node
->rect
[3] - ctx
->cursor
[3];
457 static void ui_align_right( ui_ctx
*ctx
)
459 struct ui_qnode
*node
= ui_current( ctx
);
460 ctx
->cursor
[0] = node
->rect
[0] + node
->rect
[2] - ctx
->cursor
[2];
463 static void ui_align_top( ui_ctx
*ctx
)
465 ctx
->cursor
[1] = ui_current( ctx
)->rect
[1];
468 static void ui_align_left( ui_ctx
*ctx
)
470 ctx
->cursor
[0] = ui_current( ctx
)->rect
[0];
473 static void ui_clamp_rect( ui_rect parent
, ui_rect dest
)
475 dest
[0] = vg_min( parent
[0] + parent
[2] - dest
[2], dest
[0] );
476 dest
[1] = vg_min( parent
[1] + parent
[3] - dest
[3], dest
[1] );
477 dest
[0] = vg_max( parent
[0], dest
[0] );
478 dest
[1] = vg_max( parent
[1], dest
[1] );
481 static u32
ui_group_id( ui_ctx
*ctx
, u32 lesser_unique
)
483 return ctx
->id_base
| lesser_unique
;
486 static void ui_capture_mouse( ui_ctx
*ctx
, u32 id
)
488 u32 group_uid
= ui_group_id(ctx
,id
);
490 struct ui_qnode
*node
= &ctx
->stack
[ ctx
->stack_count
-1 ];
491 node
->capture_id
= group_uid
;
493 if( !ctx
->capture_lock
&& node
->mouse_over
)
495 ctx
->capture_mouse_id
= group_uid
;
499 static int ui_want_mouse( ui_ctx
*ctx
)
501 return ctx
->capture_mouse_id
== 0? 0: 1;
504 static void ui_set_clip( ui_ctx
*ctx
, ui_rect clip
)
506 ctx
->clipping
[0] = clip
[0];
507 ctx
->clipping
[1] = clip
[1];
508 ctx
->clipping
[2] = clip
[0] + clip
[2];
509 ctx
->clipping
[3] = clip
[1] + clip
[3];
512 static void ui_release_clip( ui_ctx
*ctx
)
514 ctx
->clipping
[0] = -32000;
515 ctx
->clipping
[1] = -32000;
516 ctx
->clipping
[2] = 32000;
517 ctx
->clipping
[3] = 32000;
521 // ===========================================================================================================
523 static struct ui_vert
*ui_fill_rect_uv( ui_ctx
*ctx
, ui_rect rect
, u32 colour
, ui_px uv
[4] )
525 struct ui_vert
*vertices
= &ctx
->verts
[ ctx
->num_verts
];
526 vertices
[0].co
[0] = rect
[0];
527 vertices
[0].co
[1] = rect
[1];
528 vertices
[0].uv
[0] = uv
[0];
529 vertices
[0].uv
[1] = uv
[1];
530 vertices
[0].colour
= colour
;
531 vertices
[1].co
[0] = rect
[0]+rect
[2];
532 vertices
[1].co
[1] = rect
[1];
533 vertices
[1].uv
[0] = uv
[2];
534 vertices
[1].uv
[1] = uv
[1];
535 vertices
[1].colour
= colour
;
536 vertices
[2].co
[0] = rect
[0]+rect
[2];
537 vertices
[2].co
[1] = rect
[1]+rect
[3];
538 vertices
[2].uv
[0] = uv
[2];
539 vertices
[2].uv
[1] = uv
[3];
540 vertices
[2].colour
= colour
;
541 vertices
[3].co
[0] = rect
[0];
542 vertices
[3].co
[1] = rect
[1]+rect
[3];
543 vertices
[3].uv
[0] = uv
[0];
544 vertices
[3].uv
[1] = uv
[3];
545 vertices
[3].colour
= colour
;
546 u16 ind_start
= ctx
->num_verts
;
547 u16
*indices
= &ctx
->indices
[ ctx
->num_indices
];
549 ui_rect_copy( ctx
->clipping
, vertices
[0].clip
);
550 ui_rect_copy( ctx
->clipping
, vertices
[1].clip
);
551 ui_rect_copy( ctx
->clipping
, vertices
[2].clip
);
552 ui_rect_copy( ctx
->clipping
, vertices
[3].clip
);
554 indices
[0] = ind_start
+0;
555 indices
[1] = ind_start
+2;
556 indices
[2] = ind_start
+1;
558 indices
[3] = ind_start
+0;
559 indices
[4] = ind_start
+3;
560 indices
[5] = ind_start
+2;
562 ctx
->num_indices
+= 6;
568 static struct ui_vert
*ui_fill_rect( ui_ctx
*ctx
, ui_rect rect
, u32 colour
)
570 return ui_fill_rect_uv( ctx
, rect
, colour
, (ui_px
[4]){ 4,124,4,124 } );
573 static void ui_text( ui_ctx
*ctx
, const char *str
, ui_px scale
)
577 text_cursor
[0] = ctx
->cursor
[0];
578 text_cursor
[1] = ctx
->cursor
[1];
579 text_cursor
[2] = 7*scale
;
580 text_cursor
[3] = 7*scale
;
582 u32 current_colour
= 0x00ffffff;
584 const char *_c
= str
;
586 while( (c
= *(_c
++)) )
590 text_cursor
[1] += 10*scale
;
591 text_cursor
[0] = ctx
->cursor
[0];
594 else if( c
>= 33 && c
<= 126 )
597 u8 glyph_index
= c
- 32;
598 glyph_base
[0] = glyph_index
%10;
599 glyph_base
[1] = (glyph_index
-glyph_base
[0])/10;
604 ui_fill_rect_uv( ctx
, text_cursor
, current_colour
, (ui_px
[4]){glyph_base
[0],glyph_base
[1],glyph_base
[0]+7,glyph_base
[1]+7} );
606 else if( c
== '\x1B' )
610 for( int i
= 0; i
< 3; i
++ )
620 case '0': current_colour
= 0x00ffffff; break;
621 case '3'|'1'<<8: current_colour
= 0x00201fee; break;
622 case '3'|'2'<<8: current_colour
= 0x0037e420; break;
623 case '3'|'3'<<8: current_colour
= 0x000ed8e2; break;
624 case '3'|'4'<<8: current_colour
= 0x00f15010; break;
625 case '3'|'5'<<8: current_colour
= 0x00ee20ee; break;
626 case '3'|'6'<<8: current_colour
= 0x00eeee20; break;
627 case '3'|'7'<<8: current_colour
= 0x00ffffff; break;
633 colour_id
|= _c
[i
] << (i
*8);
643 text_cursor
[0] += 6*scale
;
648 // ====================================================================
650 static void ui_begin( ui_ctx
*ctx
, ui_px res_x
, ui_px res_y
)
654 ctx
->cursor
[2] = res_x
;
655 ctx
->cursor
[3] = res_y
;
657 ui_rect_copy( ctx
->cursor
, ctx
->stack
[0].rect
);
658 ctx
->stack
[0].mouse_over
= 1;
660 ctx
->stack_count
= 1;
663 ctx
->num_indices
= 0;
665 ui_release_clip( ctx
);
667 if( ctx
->click_state
== 0 )
668 ctx
->capture_mouse_id
= 0;
670 ctx
->image_count
= 0;
673 static void ui_resolve( ui_ctx
*ctx
)
675 if( ctx
->stack_count
-1 )
676 vg_exiterr( "[UI] Mismatched node create/drestroy!" );
678 if( ctx
->click_state
== 3 || ctx
->click_state
== 0 )
680 ctx
->capture_lock
= 0;
685 // ====================================================================
687 static void ui_set_mouse( ui_ctx
*ctx
, int x
, int y
, int click_state
)
692 ctx
->click_state
= click_state
;
695 // High level controls
696 // ====================================================================
704 ui_px drag_offset
[2];
709 k_button_released
= 0,
710 k_button_start_click
,
715 static int ui_button( ui_ctx
*ctx
, u32 id
)
719 ui_capture_mouse( ctx
, id
);
721 if( ui_hasmouse(ctx
) )
723 ui_fill_rect( ctx
, ctx
->cursor
, ctx
->colours_current
->hover
);
725 if( ctx
->click_state
== 1 )
727 ctx
->capture_lock
= 1;
728 return k_button_start_click
;
730 else if( ctx
->capture_lock
&& ctx
->click_state
== 3 )
731 return k_button_click
;
732 else if( ctx
->capture_lock
&& ctx
->click_state
== 2 )
733 return k_button_hold
;
736 ui_fill_rect( ctx
, ctx
->cursor
, ctx
->colours_current
->main
);
739 return k_button_released
;
742 static int ui_window( ui_ctx
*ctx
, struct ui_window
*window
, u32 control_group
)
744 ctx
->id_base
= control_group
<< 16;
748 window
->transform
[0] = ctx
->mouse
[0]+window
->drag_offset
[0];
749 window
->transform
[1] = ctx
->mouse
[1]+window
->drag_offset
[1];
751 ui_clamp_rect( ctx
->stack
[0].rect
, window
->transform
);
753 if( ctx
->click_state
== 0 || ctx
->click_state
== 3 )
759 ui_rect_copy( window
->transform
, ctx
->cursor
);
763 ui_capture_mouse( ctx
, __COUNTER__
);
769 ui_capture_mouse( ctx
, __COUNTER__
);
771 struct ui_vert
*drag_bar
= ui_fill_rect( ctx
, ctx
->cursor
, 0xff555555 );
776 ui_text( ctx
, window
->title
, 2 );
781 ui_align_right( ctx
);
783 ui_rect_pad( ctx
->cursor
, 4 );
785 if( ui_button( ctx
, __COUNTER__
) )
787 vg_info( "Click clacked\n" );
790 ui_text( ctx
, "x", 2 );
793 if( ui_hasmouse( ctx
) )
795 drag_bar
[0].colour
= 0xff777777;
796 drag_bar
[1].colour
= 0xff777777;
797 drag_bar
[2].colour
= 0xff777777;
798 drag_bar
[3].colour
= 0xff777777;
801 if( ctx
->click_state
== 1 )
804 window
->drag_offset
[0] = window
->transform
[0]-ctx
->mouse
[0];
805 window
->drag_offset
[1] = window
->transform
[1]-ctx
->mouse
[1];
825 static void ui_scrollbar( ui_ctx
*ctx
, struct ui_scrollbar
*scrollbar
, u32 id
)
827 scrollbar
->view_height
= ctx
->cursor
[3];
829 if( scrollbar
->drag
)
831 scrollbar
->py
= ctx
->mouse
[1]+scrollbar
->drag_offset
;
832 scrollbar
->py
= VG_MAX( scrollbar
->py
, 0 );
833 scrollbar
->py
= VG_MIN( scrollbar
->py
, ctx
->cursor
[3] - scrollbar
->bar_height
);
835 if( ctx
->click_state
== 0 || ctx
->click_state
== 3 )
841 ui_fill_rect( ctx
, ctx
->cursor
, ctx
->colours_current
->background
);
842 ui_capture_mouse( ctx
, id
);
844 ctx
->cursor
[1] += scrollbar
->py
;
845 ctx
->cursor
[3] = scrollbar
->bar_height
;
849 ui_capture_mouse( ctx
, __COUNTER__
);
850 struct ui_vert
*drag_bar
= ui_fill_rect( ctx
, ctx
->cursor
, ctx
->colours_current
->bar
);
852 if( ui_hasmouse( ctx
) || scrollbar
->drag
)
854 drag_bar
[0].colour
= ctx
->colours_current
->bar_hover
;
855 drag_bar
[1].colour
= ctx
->colours_current
->bar_hover
;
856 drag_bar
[2].colour
= ctx
->colours_current
->bar_hover
;
857 drag_bar
[3].colour
= ctx
->colours_current
->bar_hover
;
860 if( ctx
->click_state
== 1 )
863 scrollbar
->drag_offset
= scrollbar
->py
- ctx
->mouse
[1];
872 static ui_px
ui_calculate_content_scroll( struct ui_scrollbar
*scrollbar
, ui_px content
)
874 float overlap
= vg_maxf( 0.0f
, (float)(content
- scrollbar
->view_height
) );
876 float range
= scrollbar
->view_height
- scrollbar
->bar_height
;
877 return ((float)scrollbar
->py
/ range
) * overlap
;
880 static void ui_override_colours( ui_ctx
*ctx
, ui_colourset
*set
)
882 ctx
->colours_current
= set
;
885 static void ui_reset_colours( ui_ctx
*ctx
)
887 ctx
->colours_current
= ctx
->colours_main
;
888 ctx
->override_colour
= 0xffffffff;
891 static void ui_push_image( ui_ctx
*ctx
, ui_rect rc
, GLuint image
)
893 struct ui_image
*img
= &ctx
->images
[ ctx
->image_count
++ ];
894 ui_rect_copy( rc
, img
->rc
);
899 #define gui_draw(...) ui_draw( &ui_global_ctx, __VA_ARGS__)
900 #define gui_current(...) ui_current( &ui_global_ctx, __VA_ARGS__)
901 #define gui_new_node() ui_new_node( &ui_global_ctx )
902 #define gui_hasmouse(...) ui_hasmouse( &ui_global_ctx, __VA_ARGS__)
903 #define gui_end() ui_end( &ui_global_ctx )
904 #define gui_end_down() ui_end_down( &ui_global_ctx )
905 #define gui_end_right() ui_end_right( &ui_global_ctx )
906 #define gui_fill_y() ui_fill_y( &ui_global_ctx)
907 #define gui_fill_x() ui_fill_x( &ui_global_ctx)
908 #define gui_align_bottom() ui_align_bottom( &ui_global_ctx )
909 #define gui_align_right() ui_align_right( &ui_global_ctx )
910 #define gui_align_top() ui_align_top( &ui_global_ctx )
911 #define gui_align_left() ui_align_left( &ui_global_ctx )
912 #define gui_clamp_rect(...) ui_clamp_rect( &ui_global_ctx, __VA_ARGS__)
913 #define gui_group_id(...) ui_group_id( &ui_global_ctx, __VA_ARGS__)
914 #define gui_capture_mouse(...) ui_capture_mouse( &ui_global_ctx, __VA_ARGS__)
915 #define gui_set_clip(...) ui_set_clip( &ui_global_ctx, __VA_ARGS__)
916 #define gui_release_clip() ui_release_clip( &ui_global_ctx )
917 #define gui_fill_rect_uv(...) ui_fill_rect_uv( &ui_global_ctx, __VA_ARGS__)
918 #define gui_fill_rect(...) ui_fill_rect( &ui_global_ctx, __VA_ARGS__)
919 #define gui_text(...) ui_text( &ui_global_ctx, __VA_ARGS__)
920 #define gui_begin(...) ui_begin( &ui_global_ctx, __VA_ARGS__)
921 #define gui_resolve(...) ui_resolve( &ui_global_ctx, __VA_ARGS__)
922 #define gui_set_mouse(...) ui_set_mouse( &ui_global_ctx, __VA_ARGS__)
923 #define gui_button(...) ui_button( &ui_global_ctx, __VA_ARGS__)
924 #define gui_window(...) ui_window( &ui_global_ctx, __VA_ARGS__)
925 #define gui_want_mouse() ui_want_mouse( &ui_global_ctx )
926 #define gui_push_image(...) ui_push_image( &ui_global_ctx, __VA_ARGS__ )
927 #define gui_scrollbar(...) ui_scrollbar( &ui_global_ctx, __VA_ARGS__)
928 #define gui_override_colours(...) ui_override_colours( &ui_global_ctx, __VA_ARGS__)
929 #define gui_reset_colours(...) ui_reset_colours( &ui_global_ctx )