opacity helper
[vg.git] / vg_imgui.h
index b95e3143d806bf09692ce4f83b19d704e140e831..0a83a53f714e6fe6e59bac27fe03eedfa2582e7d 100644 (file)
@@ -358,7 +358,7 @@ static struct vg_shader _shader_ui_image = {
    }
 };
 
-VG_STATIC void _vg_ui_init(void){
+static void _vg_ui_init(void){
    if( !vg_shader_compile( &_shader_ui ) ||
        !vg_shader_compile( &_shader_ui_image ) ) 
       vg_fatal_error( "Failed to compile ui shader" );
@@ -475,7 +475,7 @@ static void rect_copy( ui_rect a, ui_rect b ){
       b[i] = a[i];
 }
 
-VG_STATIC void ui_flush( enum ui_shader shader ){
+static void ui_flush( enum ui_shader shader ){
    u32 vertex_offset = vg_ui.vert_start*sizeof(ui_vert),
        vertex_count  = vg_ui.cur_vert-vg_ui.vert_start,
        vertex_size   = vertex_count*sizeof(ui_vert),
@@ -850,6 +850,11 @@ static void ui_text_glyph( const struct ui_font *font, ui_px scale,
    out_texcoords[3] = out_texcoords[1] + font->glyph_height;
 }
 
+static u32 ui_opacity( u32 colour, f32 opacity ){
+   u32 alpha = opacity * 255.0f;
+   return (colour & 0x00ffffff) | (alpha << 24);
+}
+
 static u32 ui_ntext( ui_rect rect, const char *str, u32 len, ui_px scale, 
                      enum ui_align align, u32 colour ){
        ui_rect text_cursor;
@@ -984,6 +989,12 @@ static void ui_standard_widget( ui_rect inout_panel, ui_rect out_rect,
              out_rect, inout_panel );
 }
 
+static void ui_info( ui_rect inout_panel, const char *text ){
+   ui_rect box;
+   ui_standard_widget( inout_panel, box, 1 );
+   ui_text( box, text, 1, k_ui_align_middle_left, 0 );
+}
+
 static void ui_image( ui_rect rect, GLuint image ){
    ui_flush( k_ui_shader_colour );
    glActiveTexture( GL_TEXTURE0 );
@@ -2040,7 +2051,7 @@ static void _ui_proc_key( SDL_Keysym ev ){
 /*
  * Callback for text entry mode
  */
-VG_STATIC void ui_proc_utf8( const char *text ){
+static void ui_proc_utf8( const char *text ){
    if( vg_ui.focused_control_type == k_ui_control_textbox ){
       const char *ptr = text;