general imgui improvements & tabs
authorhgn <hgodden00@gmail.com>
Mon, 11 Sep 2023 06:26:51 +0000 (07:26 +0100)
committerhgn <hgodden00@gmail.com>
Mon, 11 Sep 2023 06:26:51 +0000 (07:26 +0100)
compile_font.sh [new file with mode: 0755]
src/fonts/vg_font_thin.png
src/fonts/vg_font_thin.xcf
src/fonts/vg_font_thin_v1.png [new file with mode: 0644]
submodules/SDL_GameControllerDB
submodules/anyascii
submodules/qoi
submodules/stb
vg_console.h
vg_imgui.h
vg_pxfont_thin.h

diff --git a/compile_font.sh b/compile_font.sh
new file mode 100755 (executable)
index 0000000..929b865
--- /dev/null
@@ -0,0 +1 @@
+./vg/bin/fontcomp vg/src/fonts/vg_font_thin.png vg/vg_pxfont_thin.h
index 78a2cbca42c61cc1745ffde72e09e877b41da4dc..f03727a147c6f797820617366b557806590b2a07 100644 (file)
Binary files a/src/fonts/vg_font_thin.png and b/src/fonts/vg_font_thin.png differ
index a247fcff69252f06a373a92098c2c1fe97c924d0..9d991f0a0fb16a39e166c68de9078271b233702e 100644 (file)
Binary files a/src/fonts/vg_font_thin.xcf and b/src/fonts/vg_font_thin.xcf differ
diff --git a/src/fonts/vg_font_thin_v1.png b/src/fonts/vg_font_thin_v1.png
new file mode 100644 (file)
index 0000000..78a2cbc
Binary files /dev/null and b/src/fonts/vg_font_thin_v1.png differ
index 6ed8d054340ee8a93a684e11360b66cd8a5c168e..c5b4df0e1061175cb11e3ebbf8045178339864a5 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 6ed8d054340ee8a93a684e11360b66cd8a5c168e
+Subproject commit c5b4df0e1061175cb11e3ebbf8045178339864a5
index 44e971c774d9ec67ca6c1f16c5a476724821ab63..eb5332d0b5e48d58397e6f27475a18e058330d23 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 44e971c774d9ec67ca6c1f16c5a476724821ab63
+Subproject commit eb5332d0b5e48d58397e6f27475a18e058330d23
index b8d77df1e80b652a57f0b7270449b179a6b91f40..dfc056e813c98d307238d35f7f041a725d699dfc 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b8d77df1e80b652a57f0b7270449b179a6b91f40
+Subproject commit dfc056e813c98d307238d35f7f041a725d699dfc
index 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55..5736b15f7ea0ffb08dd38af21067c314d6a3aae9 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55
+Subproject commit 5736b15f7ea0ffb08dd38af21067c314d6a3aae9
index a38a64d6eafd3431839e9a8f892eebe71afe2591..25bad63d3c37186534f201ae40dceaed5876ad76 100644 (file)
@@ -682,7 +682,7 @@ VG_STATIC void _vg_console_draw(void)
    SDL_AtomicLock( &log_print_sl );
 
        int ptr = vg_log.log_line_current;
-   int const fh = 14, log_lines = 32;
+   int const fh = vg_ui.font->line_height, log_lines = 32;
    int console_lines = VG_MIN( log_lines, vg_log.log_line_count );
 
    ui_rect rect_log   = { 0, 0,                vg.window_x, log_lines*fh },
@@ -716,7 +716,8 @@ VG_STATIC void _vg_console_draw(void)
       .change = _vg_console_on_update,
       .enter = _vg_console_on_enter
    };
-   ui_textbox( rect_input, vg_console.input, vg_list_size(vg_console.input),
+   ui_textbox( rect_input, NULL, 
+               vg_console.input, vg_list_size(vg_console.input), 1,
                UI_TEXTBOX_AUTOFOCUS, &callbacks );
 
    /* 
@@ -726,9 +727,9 @@ VG_STATIC void _vg_console_draw(void)
       ui_rect rect_suggest;
       rect_copy( rect_input, rect_suggest );
 
-      rect_suggest[0] += 6 + UI_GLYPH_SPACING_X*vg_console.suggestion_pastepos;
+      rect_suggest[0] += 6 + vg_ui.font->spacing*vg_console.suggestion_pastepos;
       rect_suggest[1] += rect_input[3];
-      rect_suggest[2]  = UI_GLYPH_SPACING_X * vg_console.suggestion_maxlen;
+      rect_suggest[2]  = vg_ui.font->spacing * vg_console.suggestion_maxlen;
       rect_suggest[3]  = vg_console.suggestion_count * fh;
 
       ui_fill( rect_suggest, bg_colour );
index 8938acbcb1d01ee3accb1508c8533935d4b62f5c..6e8537c2882bd142880951432325396ac1acdd26 100644 (file)
@@ -52,7 +52,7 @@ enum ui_align
 struct ui_vert
 {
    ui_px co[2];
-   u8 uv[2];
+   u16 uv[2];
    u32 colour;
 };
 #pragma pack(pop)
@@ -73,11 +73,45 @@ enum ui_scheme_colour{
 };
 
 static ui_px k_ui_widget_height = 28,
-             k_ui_scale = 2,
+             k_ui_scale = 1,
              k_ui_padding = 8;
 
 typedef u32 ui_scheme[8*4];
 
+struct ui_font {
+   ui_px glyph_width,
+         glyph_height,
+         glyph_baseline,
+         line_height,
+         sheet_size,
+         spacing,
+         offset_y;
+
+   u8 ascii_start;
+};
+typedef struct ui_font ui_font;
+
+static const ui_font vg_ui_font_small = {
+   .glyph_width    = 8,
+   .glyph_height   = 14,
+   .glyph_baseline = 4,
+   .line_height    = 14,
+   .sheet_size     = 256,
+   .spacing        = 8,
+   .ascii_start    = ' ',
+   .offset_y = 0
+},
+vg_ui_font_big = {
+   .glyph_width  = 12,
+   .glyph_height = 21,
+   .glyph_baseline = 6,
+   .line_height = 21,
+   .sheet_size = 256,
+   .spacing = 10,
+   .ascii_start = ' ',
+   .offset_y = 84
+};
+
 #define UI_RGB( STDHEX )          0xff000000       |\
                          ((STDHEX&0x000000ff)<<16) |\
                          ((STDHEX&0x0000ff00)    ) |\
@@ -97,6 +131,11 @@ typedef u32 ui_scheme[8*4];
 #define UI_MOUSE_RIGHT  (SDL_BUTTON(SDL_BUTTON_RIGHT))
 #define UI_MOUSE_MIDDLE (SDL_BUTTON(SDL_BUTTON_MIDDLE))
 
+#define UI_TOP 0x1
+#define UI_LEFT 0x2
+#define UI_BOTTOM 0x4
+#define UI_RIGHT 0x8
+
 struct{
    struct ui_vert *vertex_buffer;
    u16            *indice_buffer;
@@ -170,6 +209,7 @@ struct{
    float click_fade_opacity;
 
    ui_scheme scheme;
+   const ui_font *font;
 
    enum ui_cursor{
       k_ui_cursor_default,
@@ -217,7 +257,8 @@ static vg_ui = {
       [ k_ui_blue   + k_ui_brighter ] = UI_RGB( 0x83a598 ),
       [ k_ui_purple + k_ui_brighter ] = UI_RGB( 0xd3869b ),
       [ k_ui_gray   + k_ui_brighter ] = UI_RGB( 0xa89984 ),
-   }
+   },
+   .font = &vg_ui_font_small
 };
 
 static struct vg_shader _shader_ui =
@@ -240,7 +281,7 @@ static struct vg_shader _shader_ui =
        "void main()"
        "{"
                "gl_Position = vec4( uPv * vec3( a_co, 1.0 ), 1.0 );"
-               "aTexCoords = a_uv * 0.0078125;"
+               "aTexCoords = a_uv * 0.00390625;" /* TODO: Uniform */
                "aColour = a_colour;"
                
                "aWsp = a_co;"
@@ -258,12 +299,6 @@ static struct vg_shader _shader_ui =
        ""
        "in vec2 aWsp;"
 
-   "vec2 rand_hash22( vec2 p )"
-   "{"
-      "vec3 p3 = fract(vec3(p.xyx) * 213.8976123);"
-      "p3 += dot(p3, p3.yzx+19.19);"
-      "return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));"
-   "}"
        ""
        "void main()"
        "{"
@@ -279,8 +314,7 @@ static struct vg_shader _shader_ui =
    }
 };
 
-static struct vg_shader _shader_ui_image =
-{
+static struct vg_shader _shader_ui_image = {
    .name = "[vg] ui_image",
    .link = NULL,
    .vs = 
@@ -299,7 +333,7 @@ static struct vg_shader _shader_ui_image =
        "void main()"
        "{"
                "gl_Position = vec4( uPv * vec3( a_co, 1.0 ), 1.0 );"
-               "aTexCoords = a_uv * 0.0078125;"
+               "aTexCoords = a_uv * 0.00390625;"
                "aColour = a_colour;"
                
                "aWsp = a_co;"
@@ -323,10 +357,8 @@ static struct vg_shader _shader_ui_image =
        "}"
    }
 };
-#define UI_GLYPH_SPACING_X 8
 
-VG_STATIC void _vg_ui_init(void)
-{
+VG_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" );
@@ -367,7 +399,7 @@ VG_STATIC void _vg_ui_init(void)
    glEnableVertexAttribArray( 0 );
    
    /* UV */
-   glVertexAttribPointer( 1, 2, GL_UNSIGNED_BYTE, GL_FALSE, stride, 
+   glVertexAttribPointer( 1, 2, GL_UNSIGNED_SHORT, GL_FALSE, stride, 
                           (void *)offsetof( struct ui_vert, uv ) );
    glEnableVertexAttribArray( 1 );
    
@@ -408,19 +440,6 @@ VG_STATIC void _vg_ui_init(void)
       }
       data++;
    }
-
-#if 0
-   for( u32 y=1; y<256; y++ ){
-      for( u32 x=0; x<256; x++ ){
-         u32 above = (y-1)*256 + x,
-             below = y*256+x;
-
-         if( (image[ below ] == 0) && (image[ above ] == 255) ){
-            image[ below ] = 128;
-         }
-      }
-   }
-#endif
    
    glGenTextures( 1, &vg_ui.tex_glyphs );
    glBindTexture( GL_TEXTURE_2D, vg_ui.tex_glyphs );
@@ -451,14 +470,12 @@ enum ui_shader {
    k_ui_shader_image
 };
 
-static void rect_copy( ui_rect a, ui_rect b )
-{
+static void rect_copy( ui_rect a, ui_rect b ){
    for( int i=0; i<4; i++ )
       b[i] = a[i];
 }
 
-VG_STATIC void ui_flush( enum ui_shader shader )
-{
+VG_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),
@@ -518,8 +535,7 @@ VG_STATIC void ui_flush( enum ui_shader shader )
    vg_ui.vert_start = vg_ui.cur_vert;
 }
 
-static void ui_fill_rect( ui_rect rect, u32 colour, ui_px uv[4] )
-{
+static void ui_fill_rect( ui_rect rect, u32 colour, ui_px uv[4] ){
    /* this if far from ideal but stops us from crashing */
    if( (vg_ui.cur_vert + 4 > vg_ui.max_verts) || 
        (vg_ui.cur_indice + 6 > vg_ui.max_indices))
@@ -561,13 +577,11 @@ static void ui_fill_rect( ui_rect rect, u32 colour, ui_px uv[4] )
        vg_ui.cur_vert += 4;
 }
 
-static void ui_fill( ui_rect rect, u32 colour )
-{
+static void ui_fill( ui_rect rect, u32 colour ){
    ui_fill_rect( rect, colour, (ui_px[4]){ 4,4,4,4 } );
 }
 
-static void ui_outline( ui_rect rect, ui_px thickness, u32 colour )
-{
+static void ui_outline( ui_rect rect, ui_px thickness, u32 colour, u32 mask ){
    /* this if far from ideal but stops us from crashing */
    if( (vg_ui.cur_vert + 8 > vg_ui.max_verts) || 
        (vg_ui.cur_indice + 24 > vg_ui.max_indices))
@@ -602,18 +616,24 @@ static void ui_outline( ui_rect rect, ui_px thickness, u32 colour )
        u16 start = vg_ui.cur_vert;
    u32 mesh[] = { 0,5,4, 0,1,5, 1,6,5, 1,2,6, 2,7,6, 2,3,7, 3,4,7, 3,0,4 };
 
-   for( u32 i=0; i<vg_list_size(mesh); i++ ){
-      indices[i] = start+mesh[i];
+   if( !mask ) 
+      mask = UI_TOP|UI_LEFT|UI_BOTTOM|UI_RIGHT;
+
+   u32 c = 0;
+   for( u32 i=0; i<vg_list_size(mesh)/6; i++ ){
+      if( (0x1<<i) & mask ){
+         for( u32 j=0; j<6; j++ )
+            indices[c ++] = start+mesh[i*6+j];
+      }
    }
        
-       vg_ui.cur_indice += 24;
+       vg_ui.cur_indice += c;
        vg_ui.cur_vert += 8;
 }
 
 static void ui_split( ui_rect rect, 
                        enum ui_axis other, ui_px width, ui_px gap,
-                       ui_rect l, ui_rect r )
-{
+                       ui_rect l, ui_rect r ){
    enum ui_axis dir = other ^ 0x1;
 
    if( width < 0 ) width = rect[ 2+dir ] + width;
@@ -633,14 +653,12 @@ static void ui_split( ui_rect rect,
 
 static ui_px ui_text_line_width( const char *str );
 
-static void ui_rect_center( ui_rect parent, ui_rect rect )
-{
+static void ui_rect_center( ui_rect parent, ui_rect rect ){
    rect[0] = parent[0] + (parent[2]-rect[2])/2;
    rect[1] = parent[1] + (parent[3]-rect[3])/2;
 }
 
-static void ui_fit_item( ui_rect rect, ui_px size[2], ui_rect d )
-{
+static void ui_fit_item( ui_rect rect, ui_px size[2], ui_rect d ){
    i32 rp = (i32)rect[2] * (i32)size[1],
        rc = (i32)size[0] * (i32)rect[3];
 
@@ -656,22 +674,19 @@ static void ui_fit_item( ui_rect rect, ui_px size[2], ui_rect d )
 }
 
 static void ui_split_ratio( ui_rect rect, enum ui_axis dir, float ratio, 
-                            ui_px gap, ui_rect l, ui_rect r )
-{
+                            ui_px gap, ui_rect l, ui_rect r ){
    ui_px width = (float)rect[ 2+(dir^0x1) ] * ratio;
    ui_split( rect, dir, width, gap, l, r );
 }
 
-static void ui_rect_pad( ui_rect rect, ui_px pad[2] )
-{
+static void ui_rect_pad( ui_rect rect, ui_px pad[2] ){
    rect[0] += pad[0];
    rect[1] += pad[1];
    rect[2] -= pad[0]*2;
    rect[3] -= pad[1]*2;
 }
 
-static ui_px ui_text_line_width( const char *str )
-{
+static ui_px ui_text_line_width( const char *str ){
    int length = 0;
    const char *_c = str;
    u8 c;
@@ -681,11 +696,10 @@ static ui_px ui_text_line_width( const char *str )
       else if( c == '\n' ) break;
    }
 
-   return length * 8;
+   return length * vg_ui.font->spacing;
 }
 
-static ui_px ui_text_string_height( const char *str )
-{
+static ui_px ui_text_string_height( const char *str ){
    int height = 1;
    const char *_c = str;
    u8 c;
@@ -698,8 +712,7 @@ static ui_px ui_text_string_height( const char *str )
 }
 
 static ui_px ui_text_aligned_x( const char *str, ui_rect rect, ui_px scale,
-                                enum ui_align align )
-{
+                                enum ui_align align ){
    enum ui_align lwr = k_ui_align_lwr & align;
    if( lwr == k_ui_align_left ){
       return rect[0];
@@ -716,13 +729,11 @@ static ui_px ui_text_aligned_x( const char *str, ui_rect rect, ui_px scale,
 
 static ui_px ui_min( ui_px a, ui_px b ){ return a<b?a:b; }
 static ui_px ui_max( ui_px a, ui_px b ){ return a>b?a:b; }
-static ui_px ui_clamp( ui_px a, ui_px min, ui_px max )
-{
+static ui_px ui_clamp( ui_px a, ui_px min, ui_px max ){
    return ui_min( max, ui_max( a, min ) );
 }
 
-static int ui_clip( ui_rect parent, ui_rect child, ui_rect clipped )
-{
+static int ui_clip( ui_rect parent, ui_rect child, ui_rect clipped ){
    ui_px parent_max[2], child_max[2];
    parent_max[0] = parent[0]+parent[2];
    parent_max[1] = parent[1]+parent[3];
@@ -744,21 +755,18 @@ static int ui_clip( ui_rect parent, ui_rect child, ui_rect clipped )
    return 1;
 }
 
-static int ui_inside_rect( ui_rect rect, ui_px co[2] )
-{
+static int ui_inside_rect( ui_rect rect, ui_px co[2] ){
    if( co[0] >= rect[0] &&
        co[1] >= rect[1] &&
        co[0] < rect[0]+rect[2] &&
-       co[1] < rect[1]+rect[3] )
-   {
+       co[1] < rect[1]+rect[3] ){
       return 1;
    }
    else 
       return 0;
 }
 
-static int ui_click_down( u32 mask )
-{
+static int ui_click_down( u32 mask ){
    if( vg_ui.ignore_input_frames ) return 0;
    if( (vg_ui.mouse_state[0] & mask) &&
       !(vg_ui.mouse_state[1] & mask) )
@@ -767,14 +775,12 @@ static int ui_click_down( u32 mask )
       return 0;
 }
 
-static int ui_clicking( u32 mask )
-{
+static int ui_clicking( u32 mask ){
    if( vg_ui.ignore_input_frames ) return 0;
    return vg_ui.mouse_state[0] & mask;
 }
 
-static int ui_click_up( u32 mask )
-{
+static int ui_click_up( u32 mask ){
    if( vg_ui.ignore_input_frames ) return 0;
    if( (vg_ui.mouse_state[1] & mask) &&
       !(vg_ui.mouse_state[0] & mask) )
@@ -783,8 +789,7 @@ static int ui_click_up( u32 mask )
       return 0;
 }
 
-static void ui_prerender(void)
-{
+static void ui_prerender(void){
    int x, y;
    vg_ui.mouse_state[1] = vg_ui.mouse_state[0];
    vg_ui.mouse_state[0] = SDL_GetMouseState( &x, &y );
@@ -810,14 +815,12 @@ static void ui_prerender(void)
    }
 }
 
-static u32 ui_colour( enum ui_scheme_colour id )
-{
+static u32 ui_colour( enum ui_scheme_colour id ){
    return vg_ui.scheme[ id ];
 }
 
 /* get an appropriately contrasting colour given the base */
-static u32 ui_colourcont( enum ui_scheme_colour id )
-{
+static u32 ui_colourcont( enum ui_scheme_colour id ){
    if     ( id < k_ui_bg+6 )              return ui_colour( k_ui_fg );
    else if( id < k_ui_fg   )              return ui_colour( k_ui_bg+1 );
    else if( id < k_ui_hue )               return ui_colour( k_ui_bg+3 );
@@ -825,8 +828,7 @@ static u32 ui_colourcont( enum ui_scheme_colour id )
    else                                   return ui_colour( k_ui_fg+1 );
 }
 
-static void ui_hex_to_norm( u32 hex, v4f norm )
-{
+static void ui_hex_to_norm( u32 hex, v4f norm ){
    norm[0] = ((hex    ) & 0xff);
    norm[1] = ((hex>>8 ) & 0xff);
    norm[2] = ((hex>>16) & 0xff);
@@ -834,9 +836,22 @@ static void ui_hex_to_norm( u32 hex, v4f norm )
    v4_muls( norm, 1.0f/255.0f, norm );
 }
 
+static void ui_text_glyph( const struct ui_font *font, ui_px scale,
+                           u8 glyph, ui_rect out_texcoords ){
+   glyph -= font->ascii_start;
+
+   ui_px per_row = font->sheet_size / font->glyph_width,
+         column  = (ui_px)glyph % per_row,
+         row     = (glyph - column) / per_row;
+   
+   out_texcoords[0] = column * font->glyph_width;
+   out_texcoords[1] = row * font->glyph_height + font->offset_y;
+   out_texcoords[2] = out_texcoords[0] + font->glyph_width;
+   out_texcoords[3] = out_texcoords[1] + font->glyph_height;
+}
+
 static u32 ui_ntext( ui_rect rect, const char *str, u32 len, ui_px scale, 
-                     enum ui_align align, u32 colour )
-{
+                     enum ui_align align, u32 colour ){
        ui_rect text_cursor;
    if( colour == 0 ) colour = ui_colour( k_ui_fg );
 
@@ -847,8 +862,8 @@ static u32 ui_ntext( ui_rect rect, const char *str, u32 len, ui_px scale,
 
    text_cursor[0] = ui_text_aligned_x( str, rect, scale, align );
        text_cursor[1] = rect[1];
-       text_cursor[2] = 8*scale;
-       text_cursor[3] = 14*scale;
+       text_cursor[2] = vg_ui.font->glyph_width*scale;
+       text_cursor[3] = vg_ui.font->glyph_height*scale;
 
    u32 printed_chars = 0;
 
@@ -864,52 +879,29 @@ static u32 ui_ntext( ui_rect rect, const char *str, u32 len, ui_px scale,
        while( (c = *(_c ++)) ){
       if( printed_chars >= len ){
          printed_chars = 0;
-                       text_cursor[1] += 14*scale;
+                       text_cursor[1] += vg_ui.font->line_height*scale;
          text_cursor[0] = ui_text_aligned_x( _c, rect, scale, align );
-         text_cursor[0] -= UI_GLYPH_SPACING_X*scale;
-
-                       u8 glyph_base[2];
-                       u8 glyph_index = '\xb6';
-                       glyph_base[0] = glyph_index & 0xf;
-                       glyph_base[1] = (glyph_index-glyph_base[0])>>4;
-                       glyph_base[0] *= 8;
-                       glyph_base[1] *= 8;
-
-         ui_fill_rect( text_cursor, 0x00ffffff, (ui_px[4])
-         {
-            glyph_base[0]+2,
-            glyph_base[1]+1,
-            glyph_base[0]+6,
-            glyph_base[1]+8
-         });
-
-         text_cursor[0] += UI_GLYPH_SPACING_X*scale;
+         text_cursor[0] -= vg_ui.font->spacing*scale;
+
+         ui_rect glyph;
+         ui_text_glyph( vg_ui.font, scale, '\xb6' /*FIXME*/, glyph );
+         ui_fill_rect( text_cursor, 0x00ffffff, glyph );
+         text_cursor[0] += vg_ui.font->spacing*scale;
       }
 
                if( c == '\n' ){
-                       text_cursor[1] += 14*scale;
+                       text_cursor[1] += vg_ui.font->line_height*scale;
          text_cursor[0] = ui_text_aligned_x( _c, rect, scale, align );
          printed_chars = 0;
                        continue;
                }
                else if( c >= 33 ){
-                       u8 glyph_base[2];
-                       u8 glyph_index = c;
-                       glyph_base[0] = glyph_index & 0xf;
-                       glyph_base[1] = (glyph_index-glyph_base[0])>>4;
-                       glyph_base[0] *= 8;
-                       glyph_base[1] *= 8;
-
-         ui_rect rect_char;
-
-         if( ui_clip( rect, text_cursor, rect_char ) ){
-            ui_fill_rect( rect_char, colour, (ui_px[4])
-            {
-               glyph_base[0]+2,
-               glyph_base[1]+1,
-               glyph_base[0]+6,
-               glyph_base[1]+8
-            });
+         ui_rect glyph;
+         ui_text_glyph( vg_ui.font, scale, c, glyph );
+
+         ui_rect cursor_clipped;
+         if( ui_clip( rect, text_cursor, cursor_clipped ) ){
+            ui_fill_rect( cursor_clipped, colour, glyph );
          }
                }
                else if( c == '\x1B' ){
@@ -948,12 +940,12 @@ static u32 ui_ntext( ui_rect rect, const char *str, u32 len, ui_px scale,
          continue;
                }
       else if( c == '\t' ){
-         text_cursor[0] += UI_GLYPH_SPACING_X*scale*4;
+         text_cursor[0] += vg_ui.font->spacing*scale*4;
          printed_chars += 4;
          continue;
       }
                
-       text_cursor[0] += UI_GLYPH_SPACING_X*scale;
+       text_cursor[0] += vg_ui.font->spacing*scale;
       printed_chars ++;
        }
 
@@ -961,13 +953,39 @@ static u32 ui_ntext( ui_rect rect, const char *str, u32 len, ui_px scale,
 }
 
 static void ui_text( ui_rect rect, const char *str, ui_px scale, 
-                      enum ui_align align, u32 colour )
-{
+                     enum ui_align align, u32 colour ){
    ui_ntext( rect, str, 1024, scale, align, colour );
 }
 
-static void ui_image( ui_rect rect, GLuint image )
-{
+/*
+ * Standard layout stuff
+ * -----------------------------------------------------------------------------
+ */
+
+static void ui_panel( ui_rect in_rect, ui_rect out_panel ){
+   ui_fill( in_rect, ui_colour( k_ui_bg+1 ) );
+   ui_outline( in_rect, 1, ui_colour( k_ui_bg+7 ), 0 );
+   rect_copy( in_rect, out_panel );
+   ui_rect_pad( out_panel, (ui_px[2]){ k_ui_padding, k_ui_padding } );
+}
+
+static void ui_label( ui_rect rect, const char *text, ui_px size,
+                      ui_px gap, ui_rect r ){
+   ui_rect l;
+   ui_px width = (ui_text_line_width(text)+vg_ui.font->spacing) * size;
+   ui_split( rect, k_ui_axis_v, width, gap, l, r );
+   ui_text( l, text, 1, k_ui_align_middle_left, 0 );
+}
+
+static void ui_standard_widget( ui_rect inout_panel, ui_rect out_rect, 
+                                ui_px count ){
+   ui_px height = (count * vg_ui.font->glyph_height + 18) * k_ui_scale;
+   ui_split( inout_panel, k_ui_axis_h, height, k_ui_padding, 
+             out_rect, inout_panel );
+}
+
+
+static void ui_image( ui_rect rect, GLuint image ){
    ui_flush( k_ui_shader_colour );
    glActiveTexture( GL_TEXTURE0 );
    glBindTexture( GL_TEXTURE_2D, image );
@@ -975,8 +993,7 @@ static void ui_image( ui_rect rect, GLuint image )
    ui_flush( k_ui_shader_image );
 }
 
-static u32 v4f_u32_colour( v4f colour )
-{
+static u32 v4f_u32_colour( v4f colour ){
    u32 r = colour[0] * 255.0f,
        g = colour[1] * 255.0f,
        b = colour[2] * 255.0f,
@@ -985,8 +1002,7 @@ static u32 v4f_u32_colour( v4f colour )
    return r | (g<<8) | (b<<16) | (a<<24);
 }
 
-static void ui_defocus_all(void)
-{
+static void ui_defocus_all(void){
    if( vg_ui.focused_control_type == k_ui_control_textbox ){
       SDL_StopTextInput();
    }
@@ -1049,7 +1065,7 @@ static enum ui_button_state ui_colourbutton( ui_rect rect,
          }
          else{
             ui_fill( rect, col_base );
-            ui_outline( rect, 1, col_highlight );
+            ui_outline( rect, 1, col_highlight, 0 );
             return k_ui_button_holding_outside;
          }
       }
@@ -1090,9 +1106,15 @@ static enum ui_button_state ui_button_text( ui_rect rect,
    return ui_colourbutton_text( rect, string, scale, k_ui_bg+4 );
 }
 
+static enum ui_button_state ui_button( ui_rect inout_panel, 
+                                       const char *string ){
+   ui_rect rect;
+   ui_standard_widget( inout_panel, rect, 1 );
+   return ui_colourbutton_text( rect, string, 1, k_ui_bg+4 );
+}
+
 static void ui_enum_post(void);
-static void ui_postrender(void)
-{
+static void ui_postrender(void){
    if( vg_ui.click_fade_opacity > 0.0f ){
       float scale = vg_ui.click_fade_opacity;
             scale = vg_maxf( 1.0f/255.0f, scale*scale );
@@ -1132,7 +1154,7 @@ static void ui_postrender(void)
 
       ui_rect_center( screen, box );
       ui_fill( box, ui_colour(k_ui_bg) );
-      ui_outline( box, -1, colour );
+      ui_outline( box, -1, colour, 0 );
 
       ui_rect message;
       rect_copy( box, message );
@@ -1141,8 +1163,8 @@ static void ui_postrender(void)
       
       ui_rect row0, row1, btn;
       ui_split_ratio( message, k_ui_axis_h, 0.5f, 0, row0, row1 );
-      row0[0] += UI_GLYPH_SPACING_X;
-      ui_ntext( row0, vg_ui.modal.message, (box[2]/UI_GLYPH_SPACING_X)-2, 1, 
+      row0[0] += vg_ui.font->spacing;
+      ui_ntext( row0, vg_ui.modal.message, (box[2]/vg_ui.font->spacing)-2, 1, 
                 k_ui_align_left, colour );
 
       rect_copy( row1, btn );
@@ -1176,48 +1198,6 @@ static void ui_postrender(void)
    SDL_ShowCursor(1);
 }
 
-static void ui_dev_colourview(void)
-{
-   ui_rect window = {vg.window_x-256,0,256,vg.window_y}, swatch;
-
-   const char *names[vg_list_size(vg_ui.scheme)] = {
-      [k_ui_bg] = "k_ui_bg",   "k_ui_bg+1", "k_ui_bg+2", "k_ui_bg+3",
-                  "k_ui_bg+4", "k_ui_bg+5", "k_ui_bg+6", "k_ui_bg+7",
-
-      [k_ui_fg] = "k_ui_fg",   "k_ui_fg+1", "k_ui_fg+2", "k_ui_fg+3",
-                  "k_ui_fg+4", "k_ui_fg+5", "k_ui_fg+6", "k_ui_fg+7",
-
-      [k_ui_red] = "k_ui_red", "k_ui_orange", "k_ui_yellow", "k_ui_green",
-                   "k_ui_aqua", "k_ui_blue", "k_ui_purple", "k_ui_gray",
-                   "k_ui_red+8","k_ui_orange+8","k_ui_yellow+8","k_ui_green+8",
-                   "k_ui_aqua+8","k_ui_blue+8","k_ui_purple+8","k_ui_gray+8" };
-
-   ui_rect col[2];
-   ui_split_ratio( window, k_ui_axis_v, 0.5f, 0, col[0], col[1] );
-
-   for( int i=0; i<vg_list_size(vg_ui.scheme); i++ ){
-      int which = (i/8)%2;
-
-      ui_split( col[which], k_ui_axis_h, 24, 0, swatch, col[which] );
-      ui_fill( swatch, ui_colour(i) );
-
-      if( names[i] )
-         ui_text(swatch, names[i], 1, k_ui_align_middle_left, ui_colourcont(i));
-   }
-}
-
-static void ui_standard_widget( ui_rect inout_panel, ui_rect out_rect ){
-   ui_split( inout_panel, k_ui_axis_h, k_ui_widget_height*k_ui_scale,
-             k_ui_padding, out_rect, inout_panel );
-}
-
-static void ui_panel( ui_rect in_rect, ui_rect out_panel ){
-   ui_fill( in_rect, ui_colour( k_ui_bg+1 ) );
-   ui_outline( in_rect, 1, ui_colour( k_ui_bg+7 ) );
-   rect_copy( in_rect, out_panel );
-   ui_rect_pad( out_panel, (ui_px[2]){ k_ui_padding, k_ui_padding } );
-}
-
 /*
  * checkbox
  * -----------------------------------------------------------------------------
@@ -1225,7 +1205,7 @@ static void ui_panel( ui_rect in_rect, ui_rect out_panel ){
 
 static int ui_checkbox( ui_rect inout_panel, const char *str_label, i32 *data ){
    ui_rect rect, label, box;
-   ui_standard_widget( inout_panel, rect );
+   ui_standard_widget( inout_panel, rect, 1 );
 
    ui_split( rect, k_ui_axis_v, -rect[3], 0, label, box );
    ui_text( label, str_label, k_ui_scale, k_ui_align_middle_left, 0 );
@@ -1252,18 +1232,17 @@ static int ui_checkbox( ui_rect inout_panel, const char *str_label, i32 *data ){
  * postrender step.
  */
 static void ui_enum( ui_rect inout_panel, const char *str_label, 
-                     struct ui_enum_opt *options, u32 len, i32 *value )
-{
+                     struct ui_enum_opt *options, u32 len, i32 *value ){
    ui_rect rect, label, box;
-   ui_standard_widget( inout_panel, rect );
-   ui_split( rect, k_ui_axis_v, (ui_text_line_width( str_label )+8)*k_ui_scale, 
-                0, label, box );
-   ui_text( label, str_label, k_ui_scale, k_ui_align_middle_left, 0 );
+   ui_standard_widget( inout_panel, rect, 1 );
+   ui_label( rect, str_label, k_ui_scale, 0, box );
 
    const char *display = "OUT OF RANGE";
+   int valid = 0;
    for( u32 i=0; i<len; i ++ ){
       if( *value == options[i].value ){
          display = options[i].alias;
+         valid = 1;
          break;
       }
    }
@@ -1275,6 +1254,9 @@ static void ui_enum( ui_rect inout_panel, const char *str_label,
       vg_ui._enum.options = options;
       rect_copy( box, vg_ui._enum.rect );
    }
+
+   if( !valid )
+      ui_outline( box, 1, ui_colour(k_ui_red), 0 );
 }
 
 static void ui_enum_post(void){
@@ -1321,15 +1303,13 @@ static void ui_enum_post(void){
  * -----------------------------------------------------------------------------
  */
 
-static void _ui_textbox_make_selection( int *start, int *end )
-{
+static void _ui_textbox_make_selection( int *start, int *end ){
        *start = VG_MIN( vg_ui.textbox.cursor_pos, vg_ui.textbox.cursor_user );
        *end   = VG_MAX( vg_ui.textbox.cursor_pos, vg_ui.textbox.cursor_user );
 }
 
 static void _ui_textbox_move_cursor( int *cursor0, int *cursor1, 
-                                     int dir, int snap_together )
-{
+                                     int dir, int snap_together ){
        *cursor0 = VG_MAX( 0, vg_ui.textbox.cursor_user + dir );
        *cursor0 = 
       VG_MIN( 
@@ -1340,8 +1320,7 @@ static void _ui_textbox_move_cursor( int *cursor0, int *cursor1,
                *cursor1 = *cursor0;
 }
 
-static int _ui_textbox_makeroom( int datastart, int length )
-{
+static int _ui_textbox_makeroom( int datastart, int length ){
        int move_to = VG_MIN( datastart+length, vg_ui.textbox.len-1 );
        int move_amount = strlen( vg_ui.textbuf )-datastart;
        int move_end = VG_MIN( move_to+move_amount, vg_ui.textbox.len-1 );
@@ -1357,8 +1336,7 @@ static int _ui_textbox_makeroom( int datastart, int length )
        return VG_MIN( length, vg_ui.textbox.len-datastart-1 );
 }
 
-static int _ui_textbox_delete_char( int direction )
-{
+static int _ui_textbox_delete_char( int direction ){
        int start, end;
        _ui_textbox_make_selection( &start, &end );
        
@@ -1380,8 +1358,7 @@ static int _ui_textbox_delete_char( int direction )
        return start;
 }
 
-static void _ui_textbox_to_clipboard(void)
-{
+static void _ui_textbox_to_clipboard(void){
        int start, end;
        _ui_textbox_make_selection( &start, &end );
        char buffer[512];
@@ -1393,8 +1370,8 @@ static void _ui_textbox_to_clipboard(void)
        }
 }
 
-static void _ui_textbox_clipboard_paste(void)
-{
+static void ui_start_modal( const char *message, u32 options );
+static void _ui_textbox_clipboard_paste(void){
    if( !SDL_HasClipboardText() )
       return;
 
@@ -1405,6 +1382,12 @@ static void _ui_textbox_clipboard_paste(void)
 
    int datastart = _ui_textbox_delete_char( 0 );
        int length = strlen( text );
+
+   if( (vg_ui.textbox.len - strlen(vg_ui.textbuf)) < length ){
+      ui_start_modal( "Clipboard content exceeds buffer size.", UI_MODAL_BAD );
+      return;
+   }
+
        int cpylength = _ui_textbox_makeroom( datastart, length );
 
        memcpy( vg_ui.textbuf + datastart, text, cpylength);
@@ -1413,10 +1396,10 @@ static void _ui_textbox_clipboard_paste(void)
    SDL_free( text );
 }
 
-static void _ui_textbox_put_char( char c )
-{
+static void _ui_textbox_put_char( char c ){
        vg_ui.textbox.cursor_user = _ui_textbox_delete_char(0);
-       
+   if( (vg_ui.textbox.len - strlen(vg_ui.textbuf)) <= 1 ) return;
+
        if( _ui_textbox_makeroom( vg_ui.textbox.cursor_user, 1 ) )
                vg_ui.textbuf[ vg_ui.textbox.cursor_user ] = c;
        
@@ -1425,22 +1408,19 @@ static void _ui_textbox_put_char( char c )
 }
 
 /* Receed secondary cursor */
-static void _ui_textbox_left_select(void)
-{
+static void _ui_textbox_left_select(void){
    _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, NULL, -1, 0 );
 }
 
 /* Match and receed both cursors */
-static void _ui_textbox_left(void)
-{
+static void _ui_textbox_left(void){
    int cursor_diff = vg_ui.textbox.cursor_pos - vg_ui.textbox.cursor_user? 0: 1;
 
    _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, 
                             &vg_ui.textbox.cursor_pos, -cursor_diff, 1 );
 }
 
-static void _ui_textbox_up(void)
-{
+static void _ui_textbox_up(void){
    if( vg_ui.textbox.flags & UI_TEXTBOX_MULTILINE ){
       int line_begin = vg_ui.textbox.cursor_user;
 
@@ -1483,8 +1463,7 @@ static void _ui_textbox_up(void)
    }
 }
 
-static void _ui_textbox_down(void)
-{
+static void _ui_textbox_down(void){
    if( vg_ui.textbox.flags & UI_TEXTBOX_MULTILINE ){
       int line_begin = vg_ui.textbox.cursor_user;
 
@@ -1538,21 +1517,18 @@ static void _ui_textbox_down(void)
    }
 }
 
-static void _ui_textbox_right_select(void)
-{
+static void _ui_textbox_right_select(void){
    _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, NULL, 1, 0 );
 }
 
-static void _ui_textbox_right(void)
-{
+static void _ui_textbox_right(void){
    int cursor_diff = vg_ui.textbox.cursor_pos - vg_ui.textbox.cursor_user? 0: 1;
 
    _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, 
                             &vg_ui.textbox.cursor_pos, +cursor_diff, 1 );
 }
 
-static void _ui_textbox_backspace(void)
-{
+static void _ui_textbox_backspace(void){
    if( vg_ui.focused_control_type == k_ui_control_textbox ){
       vg_ui.textbox.cursor_user = _ui_textbox_delete_char( -1 );
       vg_ui.textbox.cursor_pos = vg_ui.textbox.cursor_user;
@@ -1563,8 +1539,7 @@ static void _ui_textbox_backspace(void)
    }
 }
 
-static void _ui_textbox_delete(void)
-{
+static void _ui_textbox_delete(void){
    if( vg_ui.focused_control_type == k_ui_control_textbox ){
       vg_ui.textbox.cursor_user = _ui_textbox_delete_char( 1 );
       vg_ui.textbox.cursor_pos = vg_ui.textbox.cursor_user;
@@ -1575,44 +1550,62 @@ static void _ui_textbox_delete(void)
    }
 }
 
-static void _ui_textbox_home_select(void)
-{
-   _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, NULL, -10000, 0 );
+static void _ui_textbox_home_select(void){
+   i32 start = vg_ui.textbox.cursor_user;
+
+   if( vg_ui.textbox.flags & UI_TEXTBOX_MULTILINE ){
+      while( start ){
+         if( vg_ui.textbuf[start-1] == '\n' )
+            break;
+         else
+            start --;
+      }
+   }
+   else
+      start = 0;
+
+   vg_ui.textbox.cursor_user = start;
 }
 
-static void _ui_textbox_home(void)
-{
-   _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, 
-                            &vg_ui.textbox.cursor_pos, -10000, 1 );
+static void _ui_textbox_home(void){
+   _ui_textbox_home_select();
+   vg_ui.textbox.cursor_pos = vg_ui.textbox.cursor_user;
 }
 
-static void _ui_textbox_end_select(void)
-{
-   _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, NULL, 10000, 0 );
+static void _ui_textbox_end_select(void){
+   i32 end = vg_ui.textbox.cursor_user;
+
+   if( vg_ui.textbox.flags & UI_TEXTBOX_MULTILINE ){
+      while( vg_ui.textbuf[end] ){
+         if( vg_ui.textbuf[end] == '\n' )
+            break;
+         else
+            end ++;
+      }
+   }
+   else
+      end = VG_MIN( vg_ui.textbox.len-1, strlen(vg_ui.textbuf) );
+
+   vg_ui.textbox.cursor_user = end;
 }
 
-static void _ui_textbox_end(void)
-{
-   _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, 
-                            &vg_ui.textbox.cursor_pos, 
-                            vg_ui.textbox.len-1, 1 );
+static void _ui_textbox_end(void){
+   _ui_textbox_end_select();
+   vg_ui.textbox.cursor_pos = vg_ui.textbox.cursor_user;
 }
 
-static void _ui_textbox_select_all(void)
-{
+static void _ui_textbox_select_all(void){
    _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user, NULL,  10000, 0);
    _ui_textbox_move_cursor( &vg_ui.textbox.cursor_pos,  NULL, -10000, 0);
 }
 
-static void _ui_textbox_cut(void)
-{
+static void _ui_textbox_cut(void){
    _ui_textbox_to_clipboard();
    vg_ui.textbox.cursor_user = _ui_textbox_delete_char(0);
    vg_ui.textbox.cursor_pos = vg_ui.textbox.cursor_user;
 }
 
-static void _ui_textbox_enter(void)
-{
+static void _ui_textbox_enter(void){
    if( vg_ui.focused_control_type == k_ui_control_textbox ){
       if( vg_ui.textbox.callbacks.enter )
          vg_ui.textbox.callbacks.enter( vg_ui.textbuf, vg_ui.textbox.len );
@@ -1634,8 +1627,7 @@ static void _ui_textbox_enter(void)
  *
  * input coordinates go in co[0], co[1], and the result index is in co[2]
  */
-static void _ui_textbox_calc_index_from_grid( int co[3], int wrap_length )
-{
+static void _ui_textbox_calc_index_from_grid( int co[3], int wrap_length ){
    int i[3] = {0,0,0};
 
    char c;
@@ -1671,8 +1663,7 @@ static void _ui_textbox_calc_index_from_grid( int co[3], int wrap_length )
  * based on the index specied in co[2], work out the visual character
  * coordinates and store them in co[0], co[1]
  */
-static void _ui_textbox_index_calc_coords( int co[3], int wrap_length )
-{
+static void _ui_textbox_index_calc_coords( int co[3], int wrap_length ){
    co[0] = 0;
    co[1] = 0;
 
@@ -1700,8 +1691,7 @@ static void _ui_textbox_index_calc_coords( int co[3], int wrap_length )
  *
  * index must be fully populated with visual X/Y, and linear index
  */
-static int _ui_textbox_run_remaining( int index[3], int wrap_length )
-{
+static int _ui_textbox_run_remaining( int index[3], int wrap_length ){
    int i=0, printed_chars=0;
    char c;
    while( (c = vg_ui.textbuf[index[2] + (i ++)]) ){
@@ -1713,9 +1703,20 @@ static int _ui_textbox_run_remaining( int index[3], int wrap_length )
    return printed_chars+1;
 }
 
-static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
-                       struct ui_textbox_callbacks *callbacks )
-{
+static int ui_textbox( ui_rect inout_panel, const char *label,
+                       char *buf, u32 len, u32 lines, u32 flags,
+                       struct ui_textbox_callbacks *callbacks ){
+   assert( lines > 0 );
+   assert( buf );
+
+   if( lines > 1 ) flags |= UI_TEXTBOX_MULTILINE;
+
+   ui_rect rect;
+   ui_standard_widget( inout_panel, rect, lines );
+
+   if( label )
+      ui_label( rect, label, 1, 0, rect );
+
    int clickup= ui_click_up(UI_MOUSE_LEFT),
        clickdown = ui_click_down(UI_MOUSE_LEFT),
        click  = ui_clicking(UI_MOUSE_LEFT) | clickup,
@@ -1743,7 +1744,7 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
    rect_copy( rect, text_rect );
 
    if( flags & UI_TEXTBOX_MULTILINE ) text_rect[3] = rect[3]-16;
-   else text_rect[3] = 14;
+   else text_rect[3] = vg_ui.font->line_height;
 
    text_rect[2] -= 16;
    ui_rect_center( rect, text_rect );
@@ -1751,7 +1752,7 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
    ui_px wrap_length = 1024;
 
    if( flags & UI_TEXTBOX_WRAP ) 
-      wrap_length = text_rect[2] / UI_GLYPH_SPACING_X;
+      wrap_length = text_rect[2] / vg_ui.font->spacing;
 
    if( hover ){
       vg_ui.cursor = k_ui_cursor_ibeam;
@@ -1768,13 +1769,13 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
          vg_ui.focused_control_hit = 1;
          if( click && target ){
             int p0[3] ={
-               (vg_ui.mouse_click[0] - text_rect[0]) / UI_GLYPH_SPACING_X,
-               (vg_ui.mouse_click[1] - text_rect[1]) / 14,
+               (vg_ui.mouse_click[0] - text_rect[0]) / vg_ui.font->spacing,
+               (vg_ui.mouse_click[1] - text_rect[1]) / vg_ui.font->line_height,
                -1
             }, 
             p1[3] = {
-               (vg_ui.mouse[0] - text_rect[0]) / UI_GLYPH_SPACING_X,
-               (vg_ui.mouse[1] - text_rect[1]) / 14,
+               (vg_ui.mouse[0] - text_rect[0]) / vg_ui.font->spacing,
+               (vg_ui.mouse[1] - text_rect[1]) / vg_ui.font->line_height,
                -1
             };
 
@@ -1792,7 +1793,7 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
             }
          }
 
-         ui_outline( rect, -2, vg_ui.scheme[ k_ui_orange ] );
+         ui_outline( rect, -2, vg_ui.scheme[ k_ui_orange ], 0 );
 
          ui_rect cursor;
 
@@ -1802,15 +1803,14 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
              end   = VG_MAX( c0, c1 ),
              chars = end-start;
 
-         if( flags & (UI_TEXTBOX_MULTILINE|UI_TEXTBOX_WRAP) ){
-
+         if( flags & (UI_TEXTBOX_WRAP|UI_TEXTBOX_MULTILINE) ){
             int pos[3], remaining = chars;
 
             pos[2] = start;
             _ui_textbox_index_calc_coords( pos, wrap_length );
 
             if( start==end ){
-               cursor[0] = text_rect[0] + pos[0]*UI_GLYPH_SPACING_X-1;
+               cursor[0] = text_rect[0] + pos[0]*vg_ui.font->spacing-1;
                cursor[1] = text_rect[1] + pos[1]*14;
                cursor[2] = 2;
                cursor[3] = 13;
@@ -1822,9 +1822,9 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
                   int run = _ui_textbox_run_remaining( pos, wrap_length );
                       run = VG_MIN( run, remaining );
 
-                  cursor[0] = text_rect[0] + pos[0]*UI_GLYPH_SPACING_X-1;
+                  cursor[0] = text_rect[0] + pos[0]*vg_ui.font->spacing-1;
                   cursor[1] = text_rect[1] + pos[1]*14;
-                  cursor[2] = (float)(run)*(float)UI_GLYPH_SPACING_X;
+                  cursor[2] = (float)(run)*(float)vg_ui.font->spacing;
                   cursor[3] = 13;
 
                   ui_fill( cursor, col_cursor );
@@ -1838,7 +1838,7 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
             }
          }
          else{
-            cursor[0] = text_rect[0] + start*UI_GLYPH_SPACING_X-1;
+            cursor[0] = text_rect[0] + start*vg_ui.font->spacing-1;
             cursor[1] = text_rect[1];
             cursor[3] = 13;
 
@@ -1846,7 +1846,7 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
                cursor[2] = 2;
             }
             else{
-               cursor[2] = (float)(chars)*(float)UI_GLYPH_SPACING_X;
+               cursor[2] = (float)(chars)*(float)vg_ui.font->spacing;
             }
 
             if( (vg_ui.click_fade_opacity<=0.0f) && 
@@ -1896,13 +1896,59 @@ static int ui_textbox( ui_rect rect, char *buf, u32 len, u32 flags,
    ui_fill( rect, col_base );
 
    if( hover ){
-      ui_outline( rect, -1, col_highlight );
+      ui_outline( rect, -1, col_highlight, 0 );
    }
 
    ui_ntext( text_rect, buf, wrap_length, 1, k_ui_align_left, 0 );
    return 0;
 }
 
+/*
+ * Tabs
+ * -----------------------------------------------------------------------------
+ */
+
+static void ui_tabs( ui_rect inout_panel, ui_rect out_content_panel,
+                     const char **titles, u32 count, i32 *page ){
+   ui_rect bar;
+   ui_standard_widget( inout_panel, bar, 1 );
+
+   i32 cur_page = *page;
+
+   f32 width = (f32)inout_panel[2] / (f32)count;
+
+   ui_px h = (inout_panel[1] + inout_panel[3]) - (bar[1]+bar[3]);
+   inout_panel[1] = bar[1]+bar[3];
+   inout_panel[3] = h;
+
+   ui_fill( inout_panel, ui_colour( k_ui_bg+2 ) );
+   ui_outline( inout_panel, 1, ui_colour( k_ui_bg+5 ), 0 );
+
+   rect_copy( inout_panel, out_content_panel );
+   ui_rect_pad( out_content_panel, (ui_px[2]){ k_ui_padding, k_ui_padding } );
+
+   /* place buttons */
+   for( i32 i=0; i<count; i++ ){
+      ui_rect button = {
+         bar[0] + ((f32)i*width),
+         bar[1],
+         width,
+         bar[3]-1
+      };
+
+      enum ui_scheme_colour colour = k_ui_bg+4;
+      if( i == cur_page ){
+         colour = k_ui_bg+2;
+         ui_outline( button, 1, ui_colour( k_ui_bg+5 ), 
+                     UI_TOP|UI_LEFT|UI_RIGHT );
+         button[3] ++;
+      }
+
+      if( ui_colourbutton_text( button, titles[i], 1, colour ) == 1 )
+         *page = i;
+   }
+}
+
 /* 
  * Modal UI
  * -----------------------------------------------------------------------------
@@ -1928,14 +1974,12 @@ static void ui_start_modal( const char *message, u32 options ){
 /*
  * Handles binds
  */
-static void _ui_proc_key( SDL_Keysym ev )
-{
+static void _ui_proc_key( SDL_Keysym ev ){
    if( vg_ui.focused_control_type != k_ui_control_textbox ){
       return;
    }
 
-   struct textbox_mapping
-   {
+   struct textbox_mapping{
       u16 mod;
       SDL_Keycode key;
       
@@ -1997,8 +2041,7 @@ static void _ui_proc_key( SDL_Keysym ev )
 /*
  * Callback for text entry mode
  */
-VG_STATIC void ui_proc_utf8( const char *text )
-{
+VG_STATIC void ui_proc_utf8( const char *text ){
    if( vg_ui.focused_control_type == k_ui_control_textbox ){
       const char *ptr = text;
 
@@ -2013,13 +2056,38 @@ VG_STATIC void ui_proc_utf8( const char *text )
    }
 }
 
-static void ui_label( ui_rect rect, const char *text, ui_px size,
-                      ui_px gap, ui_rect r )
-{
-   ui_rect l;
-   ui_px width = (ui_text_line_width(text)+UI_GLYPH_SPACING_X) * size;
-   ui_split( rect, k_ui_axis_v, width, gap, l, r );
-   ui_text( l, text, 1, k_ui_align_middle_left, 0 );
+/*
+ * Development utils
+ * -----------------------------------------------------------------------------
+ */
+
+static void ui_dev_colourview(void){
+   ui_rect window = {vg.window_x-256,0,256,vg.window_y}, swatch;
+
+   const char *names[vg_list_size(vg_ui.scheme)] = {
+      [k_ui_bg] = "k_ui_bg",   "k_ui_bg+1", "k_ui_bg+2", "k_ui_bg+3",
+                  "k_ui_bg+4", "k_ui_bg+5", "k_ui_bg+6", "k_ui_bg+7",
+
+      [k_ui_fg] = "k_ui_fg",   "k_ui_fg+1", "k_ui_fg+2", "k_ui_fg+3",
+                  "k_ui_fg+4", "k_ui_fg+5", "k_ui_fg+6", "k_ui_fg+7",
+
+      [k_ui_red] = "k_ui_red", "k_ui_orange", "k_ui_yellow", "k_ui_green",
+                   "k_ui_aqua", "k_ui_blue", "k_ui_purple", "k_ui_gray",
+                   "k_ui_red+8","k_ui_orange+8","k_ui_yellow+8","k_ui_green+8",
+                   "k_ui_aqua+8","k_ui_blue+8","k_ui_purple+8","k_ui_gray+8" };
+
+   ui_rect col[2];
+   ui_split_ratio( window, k_ui_axis_v, 0.5f, 0, col[0], col[1] );
+
+   for( int i=0; i<vg_list_size(vg_ui.scheme); i++ ){
+      int which = (i/8)%2;
+
+      ui_split( col[which], k_ui_axis_h, 24, 0, swatch, col[which] );
+      ui_fill( swatch, ui_colour(i) );
+
+      if( names[i] )
+         ui_text(swatch, names[i], 1, k_ui_align_middle_left, ui_colourcont(i));
+   }
 }
 
 #endif /* VG_IMGUI_H */
index d3d8847974d39fe9d5346e5ba2b7e15cc9485497..198c9cd85787f7a13e9b3edb6ac8bb33f7bfff31 100644 (file)
 /* Font buffer generated from source file: 'vg/src/fonts/vg_font_thin.png' */
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,
-0xffff0810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0040,0x8000c0,0x1000140,0x18001c0,0x2000240,0x28002c0,0x3000340,0x38003c0,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,
-0xffff0c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,
-0xffff0000,0,0,0,0,0,0,0,
-0xffff0000,0,0,0,0,0,0,0,
+0xc3002800,0x8000020,0x8100000,0,0,0,0,0,
+0x81102800,0x1c000020,0x10080010,0x2,0x3c103c7c,0x407c387c,0x38380000,0,
+0x102822,0x22202020,0x20040010,0x2,0x46304208,0x48404404,0x44440000,0x38,
+0x100022,0x20525000,0x20045410,0x4,0x46504210,0x48404008,0x44440000,0x8001044,
+0x10007f,0x20245000,0x200438fe,0x8,0x4a100420,0x48404008,0x44441010,0x10000804,
+0x100022,0x1c086000,0x20043810,0x8,0x5a100878,0x48787810,0x7c3c0000,0x20000404,
+0x100022,0x2109400,0x20045410,0x3c0010,0x52101004,0x3c044410,0x44040000,0x403c0208,
+0x22,0x2248800,0x20040010,0x20,0x62102004,0x8044420,0x44040000,0x40000210,
+0x7f,0x224a9400,0x10080000,0x20,0x62104004,0x8444420,0x44440010,0x203c0400,
+0x100022,0x1c046200,0x8100000,0x10002000,0x3c7c7e78,0x8383820,0x38381010,0x10000810,
+0x22,0x8000000,0,0x20000000,0,0,0x20,0x8001000,
 0,0,0,0,0,0,0,0,
+0x81000000,0,0,0,0,0,0,0,
+0xc3000000,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0x3c,0x3c1800,
+0x1818303c,0x707c3838,0x447c7844,0x4044443c,0x7838387c,0xfe428282,0x8282fe20,0x80042400,
+0x24244840,0x48404044,0x44100848,0x40444442,0x44444482,0x10428282,0x82820220,0x80044200,
+0x44244840,0x44404040,0x44100848,0x40aa6442,0x44444480,0x10424492,0x44820420,0x40040000,
+0x44424840,0x44404040,0x44100850,0x40aa5442,0x44444480,0x10424492,0x28820820,0x20040000,
+0x54427840,0x4478705c,0x7c100860,0x40aa5442,0x7854787c,0x10424492,0x107e1020,0x20040000,
+0x547e4440,0x44404044,0x44100850,0x40924c42,0x404c4402,0x104228aa,0x28022020,0x10040000,
+0x5c424440,0x44404044,0x44100848,0x40924c42,0x40444402,0x104228aa,0x44024020,0x8040000,
+0x424440,0x48404044,0x44101048,0x40924442,0x40424482,0x104228aa,0x82828020,0x8040000,
+0x42783c,0x707c4038,0x447c6044,0x7c82443c,0x403a447c,0x103c1044,0x827cfe20,0x40000,
+0,0,0,0,0,0,0x3c,0x3c00ff,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
-0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,
-0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,
-0x400040,0x400040,0x400040,0x400040,0x400040,0x400040,0x400040,0x400040,
-0x40,0x8000c0,0x1000140,0x18001c0,0x2000240,0x28002c0,0x3000340,0x38003c0,
+0x10000000,0,0,0,0,0,0,0x18000000,
+0x18004000,0x4000000,0x40000040,0x60000000,0,0x40000000,0xc,0x18300000,
+0x8004000,0x4003800,0x40100840,0x20000000,0,0x40000000,0x10,0x18080000,
+0x4000,0x4004400,0x40000040,0x20000000,0,0x40000000,0x10,0x180800fe,
+0x38783c,0x3c384038,0x78303848,0x206c3838,0x3838383c,0x78444282,0x44447c20,0x18046282,
+0x44440,0x44444044,0x44100850,0x20924444,0x44444440,0x40444292,0x28440840,0x18029282,
+0x3c4440,0x44447844,0x44100860,0x20924444,0x44444038,0x40442492,0x10441040,0x18028c82,
+0x444440,0x44784044,0x44100860,0x20824444,0x44444004,0x40442492,0x28442020,0x18040082,
+0x444440,0x44404044,0x44100850,0x20824444,0x64444044,0x404424aa,0x44444010,0x18080082,
+0x3c783c,0x3c3c403c,0x44380848,0x1c824438,0x583c4038,0x38381844,0x443c7c10,0x180800fe,
+0,0x4004,0x800,0,0x40040000,0,0x4000c,0x300000,
+0,0x4004,0x3000,0,0x40060000,0,0x80000,0,
+0,0x8078,0,0,0x40040000,0,0x700000,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0,0,0x181800,0x18187c,0x1e3c3c00,0,0,0,
+0x10388282,0x4410603c,0x24243c,0x242482,0x21424218,0x180000,0,0x100000,
+0x28444444,0x44289042,0x42,0x80,0x1000038,0x181c7e3c,0x7c6c6c6c,0x6c2810dc,
+0x28822828,0x28449052,0x5210525a,0x5a185aae,0xdd886878,0x3c1e7e00,0x40eaaeee,0x82822888,
+0x44821010,0x1044f052,0x91109152,0x911091a4,0x89888878,0x7e1e3c3c,0x5eeaaeee,0x101044c8,
+0x44822828,0x107c885a,0x5a185a52,0x521052b4,0x898e8e38,0x7e1c1800,0x12eaaeee,0x92928200,
+0x82444444,0x10828842,0x42,0x80,0x18a8a18,0x18003c,0x1eeeeeee,0x1000eed0,
+0xfe388282,0x1082f03c,0x24243c,0x242480,0x16e8e00,0,0x828282,0x82aa2890,
+0,0,0x181800,0x181800,0,0,0,0x10389c,
 0,0,0,0,0,0,0,0,
-0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,0x8100810,
-0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,0xc300c30,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0xc300000,0x2200000,0x800000,0x200,0x800100,0,0,0,
-0x8100100,0x2200000,0x1c00000,0x200,0x1000080,0x100,0,0x20,
-0x800100,0x2200220,0x2200200,0x2000200,0x2000040,0x100,0,0x20,
-0x100,0x220,0x2000520,0x5000000,0x2000040,0x5400100,0,0x40,
-0x100,0x7f0,0x2000240,0x5000000,0x2000040,0x3800fe0,0,0x80,
-0x100,0x220,0x1c00080,0x6000000,0x2000040,0x3800100,0,0x80,
-0x100,0x220,0x200100,0x9400000,0x2000040,0x5400100,0x3c0,0x100,
-0,0x220,0x200240,0x8800000,0x2000040,0x100,0,0x200,
-0x8100000,0x7f0,0x22004a0,0x9400000,0x1000080,0,0,0x200,
-0xc300100,0x220,0x1c00040,0x6200000,0x800100,0,0x1000000,0x2000000,
-0,0x220,0x800000,0,0,0,0x2000000,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0x3c00100,0x3c007c0,0x40007c0,0x38007c0,0x3800700,0,0,0,
-0x4600300,0x4200080,0x4800400,0x4400040,0x4400880,0,0,0x380,
-0x4600500,0x4200100,0x4800400,0x4000080,0x4400880,0,0x800000,0x1000440,
-0x4a00100,0x400200,0x4800400,0x4000080,0x4400880,0x1000100,0x1000000,0x800040,
-0x5a00100,0x800780,0x4800780,0x7800100,0x7c00780,0,0x2000000,0x400040,
-0x5200100,0x1000040,0x3c00040,0x4400100,0x4400080,0,0x40003c0,0x200080,
-0x6200100,0x2000040,0x800040,0x4400200,0x4400080,0,0x4000000,0x200100,
-0x6200100,0x4000040,0x800440,0x4400200,0x4400880,0x100,0x20003c0,0x400000,
-0x3c007c0,0x7e00780,0x800380,0x3800200,0x3800700,0x1000100,0x1000000,0x800100,
-0,0,0,0,0,0x200,0x800000,0x1000000,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0x1800180,0x30003c0,0x70007c0,0x3800380,0x44007c0,0x7800440,0x4000440,0x44003c0,
-0x2400240,0x4800400,0x4800400,0x4000440,0x4400100,0x800480,0x4000440,0x4400420,
-0x4400240,0x4800400,0x4400400,0x4000400,0x4400100,0x800480,0x4000aa0,0x6400420,
-0x4400420,0x4800400,0x4400400,0x4000400,0x4400100,0x800500,0x4000aa0,0x5400420,
-0x5400420,0x7800400,0x4400780,0x70005c0,0x7c00100,0x800600,0x4000aa0,0x5400420,
-0x54007e0,0x4400400,0x4400400,0x4000440,0x4400100,0x800500,0x4000920,0x4c00420,
-0x5c00420,0x4400400,0x4400400,0x4000440,0x4400100,0x800480,0x4000920,0x4c00420,
-0x420,0x4400400,0x4800400,0x4000440,0x4400100,0x1000480,0x4000920,0x4400420,
-0x420,0x78003c0,0x70007c0,0x4000380,0x44007c0,0x6000440,0x7c00820,0x44003c0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0x3c0,0x3c0,0x1800000,
-0x7800380,0x38007c0,0xfe00420,0x8200820,0x8200820,0xfe00200,0x8000040,0x2400000,
-0x4400440,0x4400820,0x1000420,0x8200820,0x8200820,0x200200,0x8000040,0x4200000,
-0x4400440,0x4400800,0x1000420,0x4400920,0x4400820,0x400200,0x4000040,0,
-0x4400440,0x4400800,0x1000420,0x4400920,0x2800820,0x800200,0x2000040,0,
-0x7800540,0x78007c0,0x1000420,0x4400920,0x10007e0,0x1000200,0x2000040,0,
-0x40004c0,0x4400020,0x1000420,0x2800aa0,0x2800020,0x2000200,0x1000040,0,
-0x4000440,0x4400020,0x1000420,0x2800aa0,0x4400020,0x4000200,0x800040,0,
-0x4000420,0x4400820,0x1000420,0x2800aa0,0x8200820,0x8000200,0x800040,0,
-0x40003a0,0x44007c0,0x10003c0,0x1000440,0x82007c0,0xfe00200,0x40,0,
-0,0,0,0,0,0x3c0,0x3c0,0xff0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0x1000000,0,0,0,0,0,0,0,
-0x1800000,0x4000000,0x400000,0,0x4000000,0x400,0x6000000,0,
-0x800000,0x4000000,0x400000,0x3800000,0x4000100,0x800400,0x2000000,0,
-0,0x4000000,0x400000,0x4400000,0x4000000,0x400,0x2000000,0,
-0x380,0x78003c0,0x3c00380,0x4000380,0x7800300,0x3800480,0x20006c0,0x3800380,
-0x40,0x4400400,0x4400440,0x4000440,0x4400100,0x800500,0x2000920,0x4400440,
-0x3c0,0x4400400,0x4400440,0x7800440,0x4400100,0x800600,0x2000920,0x4400440,
-0x440,0x4400400,0x4400780,0x4000440,0x4400100,0x800600,0x2000820,0x4400440,
-0x440,0x4400400,0x4400400,0x4000440,0x4400100,0x800500,0x2000820,0x4400440,
-0x3c0,0x78003c0,0x3c003c0,0x40003c0,0x4400380,0x800480,0x1c00820,0x4400380,
-0,0,0,0x4000040,0,0x800000,0,0,
-0,0,0,0x4000040,0,0x3000000,0,0,
-0,0,0,0x8000780,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0x1800000,0,
-0,0,0x4000000,0,0,0xc0,0x1800300,0,
-0,0,0x4000000,0,0,0x100,0x1800080,0,
-0,0,0x4000000,0,0,0x100,0x1800080,0xfe0,
-0x3800380,0x38003c0,0x7800440,0x4200820,0x4400440,0x7c00200,0x1800040,0x6200820,
-0x4400440,0x4400400,0x4000440,0x4200920,0x2800440,0x800400,0x1800020,0x9200820,
-0x4400440,0x4000380,0x4000440,0x2400920,0x1000440,0x1000400,0x1800020,0x8c00820,
-0x4400440,0x4000040,0x4000440,0x2400920,0x2800440,0x2000200,0x1800040,0x820,
-0x6400440,0x4000440,0x4000440,0x2400aa0,0x4400440,0x4000100,0x1800080,0x820,
-0x58003c0,0x4000380,0x3800380,0x1800440,0x44003c0,0x7c00100,0x1800080,0xfe0,
-0x4000040,0,0,0,0x40,0xc0,0x300,0,
-0x4000060,0,0,0,0x80,0,0,0,
-0x4000040,0,0,0,0x700,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0x180,0x1800000,0x180,0x18007c0,
-0x1000380,0x8200820,0x4400100,0x60003c0,0x240,0x24003c0,0x240,0x2400820,
-0x2800440,0x4400440,0x4400280,0x9000420,0,0x420,0,0x800,
-0x2800820,0x2800280,0x2800440,0x9000520,0x5200100,0x52005a0,0x5a00180,0x5a00ae0,
-0x4400820,0x1000100,0x1000440,0xf000520,0x9100100,0x9100520,0x9100100,0x9100a40,
-0x4400820,0x2800280,0x10007c0,0x88005a0,0x5a00180,0x5a00520,0x5200100,0x5200b40,
-0x8200440,0x4400440,0x1000820,0x8800420,0,0x420,0,0x800,
-0xfe00380,0x8200820,0x1000820,0xf0003c0,0x240,0x24003c0,0x240,0x2400800,
-0,0,0,0,0x180,0x1800000,0x180,0x1800000,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0x1e003c0,0x3c00000,0,0,0,0,0,0,
-0x2100420,0x4200180,0x180,0,0,0,0x100,0,
-0x100000,0x380,0x18001c0,0x7e003c0,0x7c006c0,0x6c006c0,0x6c00280,0x1000dc0,
-0xdd00880,0x6800780,0x3c001e0,0x7e00000,0x4000ea0,0xae00ee0,0x8200820,0x2800880,
-0x8900880,0x8800780,0x7e001e0,0x3c003c0,0x5e00ea0,0xae00ee0,0x1000100,0x4400c80,
-0x89008e0,0x8e00380,0x7e001c0,0x1800000,0x1200ea0,0xae00ee0,0x9200920,0x8200000,
-0x1008a0,0x8a00180,0x180,0x3c0,0x1e00ee0,0xee00ee0,0x1000000,0xee00d00,
-0x1006e0,0x8e00000,0,0,0x820,0x8200820,0x8200aa0,0x2800900,
-0,0,0,0,0,0,0x100,0x38009c0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0xdc0,0,0,0,0,0,0,
-0xe800000,0x900,0,0,0,0,0,0,
-0xa800000,0xdc0,0x6c00000,0,0,0,0,0,
-0xe800000,0x2200840,0xaa00000,0,0,0,0,0,
-0xae00000,0x4200dc0,0xaa00000,0,0,0,0,0,
-0x420,0x9e00000,0xaa00000,0,0,0,0,0,
-0xe000420,0x4000700,0xee00000,0,0,0,0,0,
-0x40007e0,0x2000400,0x8200000,0,0,0,0,0,
-0x4000000,0x700,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0x400070,
-0,0,0,0,0,0,0,0x800730,
-0,0,0,0,0,0,0,0x1000450,
-0,0,0,0,0,0,0,0x1000480,
-0,0,0,0,0,0,0,0x1000420,
-0,0,0,0,0,0,0,0xe00420,
-0,0,0,0,0,0,0,0x7e0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0,0x40700,0,0,0,0,0,0,
+0xdc,0x87300,0,0,0,0,0,0,
+0xe8000090,0x104500,0,0,0,0,0,0,
+0xa80000dc,0x6c104800,0,0,0,0,0,0,
+0xe8002284,0xaa104200,0,0,0,0,0,0,
+0xae0042dc,0xaa0e4200,0,0,0,0,0,0,
+0x429e00,0xaa007e00,0,0,0,0,0,0,
+0xe0424070,0xee000000,0,0,0,0,0,0,
+0x407e2040,0x82000000,0,0,0,0,0,0,
+0x40000070,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0xe0700000,0,0,0,0,0,0,0,
+0x8010800a,0x200,0x100,0x2008000,0,0,0,0,
+0x8010800a,0x703,0x100,0x4004000,0,0x4,0x1e00c01e,0x7f84000,
+0x800a,0x1040884,0x80380100,0x8002000,0,0x8,0x21014021,0x104200,
+0x8000,0x1041044,0x84440000,0x8002000,0x400000,0x8,0x42824040,0x80204200,
+0x8000,0x1041004,0x88440000,0x10001008,0x400000,0x10,0x42804040,0x80404200,
+0x8000,0x7ff1003,0x10440000,0x1000102a,0x400000,0x20,0x44804000,0x80804200,
+0x8000,0x1040800,0x20440000,0x1000101c,0x400000,0x20,0x44804001,0x1004200,
+0x8000,0x1040700,0x40780000,0x1000101c,0x7fc0001,0xf8000040,0x48804002,0x3e02200,
+0x8000,0x1040080,0x80880000,0x1000102a,0x400000,0x80,0x48804004,0x101f80,
+0x8000,0x1040041,0x18850000,0x10001008,0x400000,0x80,0x50804008,0x80200,
+0,0x1040042,0x24820000,0x10001000,0x400000,0x100,0x50804010,0x80200,
+0x80100000,0x7ff1044,0x24850000,0x8002000,0x400000,0x200,0x60804020,0x80200,
+0x80108000,0x1040880,0x24888000,0x8002000,0xc00,0x180200,0x21004040,0x100200,
+0xe0708000,0x1040700,0x18704000,0x4004000,0x800,0x180400,0x1e03f87f,0x87e00200,
+0,0x1040200,0,0x2008000,0x1000,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0x7f81f07f,0x81e01e00,0,0x1e,0xc03,0xe01f87c0,0x7f83f01f,0x4107f00,
+0x40020800,0x82102100,0,0x21,0x1204,0x10200420,0x40040020,0x84100800,
+0x40040001,0x4084080,0,0x40,0x80002104,0x10400410,0x40040040,0x4100800,
+0x40040002,0x4084080,0x20,0x8040,0x81e02104,0x10400410,0x40040040,0x4100800,
+0x40040002,0x2104080,0x80080040,0x4000,0x82104084,0x10400410,0x40040040,0x4100800,
+0x7e05e004,0x1e04080,0x80,0x2000,0x84084087,0xe0400410,0x40040040,0x4100800,
+0x1061004,0x2102180,0x100,0x1001,0x4c84084,0x10400410,0x7e07e04f,0x87f00800,
+0x840808,0x4081e80,0x200,0x1f800806,0x5287f84,0x8400410,0x40040040,0x84100800,
+0x840808,0x4080080,0x400,0x408,0x5284084,0x8400410,0x40040040,0x84100800,
+0x840810,0x4080080,0x200,0x800,0x5284084,0x8400410,0x40040040,0x84100800,
+0x40840810,0x4080080,0x100,0x1f801000,0x5284084,0x8400410,0x40040040,0x84100800,
+0x21021010,0x2104100,0x80080,0x2008,0x4d04084,0x10200420,0x40040021,0x4100800,
+0x1e01e010,0x1e03e00,0x80080040,0x4008,0x4087,0xe01f87c0,0x7f84001e,0x4107f00,
+0,0,0x100020,0x8000,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0x800,
+0,0,0,0,0,0,0x1f800,0x1f81400,
+0x7e041840,0x6304081,0xe07e01c0,0x3e01f8ff,0x84088088,0x8808808,0xffc10040,0x82200,
+0x2042040,0x9486082,0x10410220,0x41020408,0x4088088,0x8808808,0x410020,0x84100,
+0x2042040,0x9486084,0x8408410,0x40840008,0x4084108,0x8410808,0x810020,0x80000,
+0x2044040,0x9485084,0x8408410,0x40840008,0x4084108,0x88220808,0x1010010,0x80000,
+0x2048040,0x9485084,0x8408410,0x40840008,0x4084108,0x88140808,0x2010008,0x80000,
+0x2070040,0x9484884,0x8410490,0x41020008,0x4084108,0x88080418,0x4010008,0x80000,
+0x2070040,0x9484c84,0x87e0450,0x7e01f008,0x4084108,0x880803e8,0x8010004,0x80000,
+0x2048040,0x8884484,0x8400430,0x41000808,0x4082209,0x48080008,0x10010002,0x80000,
+0x2044040,0x8884284,0x8400410,0x40800408,0x4082209,0x48140008,0x20010002,0x80000,
+0x2042040,0x8884284,0x8400408,0x40800408,0x4082209,0x48220008,0x40010001,0x80000,
+0x2042040,0x8884184,0x8400400,0x40800408,0x4082209,0x48410808,0x80010000,0x80080000,
+0x4041020,0x8084182,0x10400220,0x40840808,0x2101409,0x48808410,0x80010000,0x80080000,
+0x7804081f,0x88084081,0xe04001c0,0x4083f008,0x1e00806,0x308083e0,0xffc10000,0x40080000,
+0,0,0,0,0,0,0x1f800,0x1f80000,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0x8000,0,0,0,0,0,0,0,
+0xc000,0x4000000,0x8000000,0x40000,0x4006,0,0,0,
+0x6000,0x4000000,0x8000000,0x40000,0x4002,0,0,0,
+0x2000,0x4000000,0x80001e0,0x40004,0x204002,0,0,0,
+0,0x4000000,0x8000210,0x40000,0x4002,0,0,0,
+0,0x4000000,0x8000408,0x40000,0x4002,0,0,0,
+0x3e,0x5e01e01,0xe81e0400,0x1e85c00c,0xe04202,0x3b85e0,0x1e05e01e,0x85f03f00,
+0x1,0x6102102,0x18210400,0x21862004,0x204402,0x444610,0x21061021,0x86084080,
+0x1,0x4084084,0x8408400,0x40841004,0x204802,0x444408,0x40840840,0x84004000,
+0x3d,0x4084004,0x84087e0,0x40841004,0x207002,0x444408,0x40840840,0x84003e00,
+0x43,0x4084004,0x87f0400,0x40841004,0x205002,0x444408,0x40840840,0x84000100,
+0x41,0x4084004,0x8400400,0x40841004,0x204802,0x404408,0x40840840,0x84000080,
+0x41,0x4084084,0x8400400,0x40841004,0x204402,0x404408,0x40840840,0x84000080,
+0x43,0x6102102,0x18208400,0x21841004,0x204201,0x404408,0x21061021,0x84004100,
+0x3c,0x85e01e01,0xe81f0400,0x1e84100e,0x204100,0xf0404408,0x1e05e01e,0x84003e00,
+0xfff00000,0,0x400,0x800000,0x200000,0,0x40000,0x80000000,
+0,0,0x400,0x800000,0x400000,0,0x40000,0x80000000,
+0,0,0x400,0x41000000,0x1800000,0,0x40000,0xc0000000,
+0,0,0x800,0x3e000000,0,0,0x40000,0x80000000,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
+0x40000000,0,0x70,0x4038000,0,0,0,0,
+0x40000000,0,0x80,0x4004000,0,0,0,0,
+0x40000000,0,0x80,0x4004000,0,0,0,0,
+0x40000000,0,0x80,0x4004000,0xc03,0xf0804804,0xc0c0c07f,0x1f00000,
+0x40000000,0,0x80,0x4004000,0xffc1e07,0xf8c0cc0c,0xe1c1e0ff,0x82080000,
+0x7e040840,0x48084104,0x87f8100,0x4002038,0x4ffc1e0e,0x1c618618,0x618330c1,0x84040000,
+0x40040840,0x48084104,0x8010100,0x4002044,0x4c0c330c,0xc330330,0x330330c1,0x84842880,
+0x40040820,0x88882204,0x8020600,0x4001842,0x4c0c330c,0xc1e01e0,0x3f0618c3,0x84844840,
+0x40040820,0x88881404,0x8040100,0x4002041,0x8c0c618c,0xc0c00c0,0x1e0618ff,0x84848820,
+0x40040811,0x8880804,0x8080100,0x4002000,0xc0c618c,0xc1e01e0,0xc0ffcff,0xc4844840,
+0x40040811,0x8881404,0x8100080,0x4004000,0xc0c618c,0xc330330,0xc0ffcc0,0xc4e42680,
+0x40040811,0x9482204,0x8200080,0x4004000,0xc0cc0ce,0x1c618618,0xc0c0cc0,0xc4040000,
+0x2002100a,0xa284102,0x18400080,0x4004000,0xffcffc7,0xf8c0cc0c,0xc0c0cff,0xc2080000,
+0x1e01e004,0x4104101,0xe87f8080,0x4004000,0xffcffc3,0xf0804804,0xc0c0c7f,0x81f00000,
+0,0,0x8000070,0x38000,0,0,0,0,
+0,0,0x8000000,0,0,0,0,0,
+0,0x4,0x10000000,0,0,0,0,0,
+0,0x3,0xe0000000,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0x4004000,0x400,0x40000000,0,0,0,0,0,
+0xa00a01f,0xa00,0xa03f81fc,0x3fc3fc0e,0x1c00,0,0,0,
+0x11011020,0x80001101,0x10404202,0x4024021e,0x1e00,0,0,0x800,
+0x40,0x40000000,0x404202,0x4024023e,0xe01f07,0xfc1f87f8,0x73873873,0x87701400,
+0x8028846,0x42680602,0x68400002,0x7e,0x1f01f87,0xfc000400,0xf2493cf3,0xc8088080,
+0x8048448,0x44840804,0x845381ba,0x1100d07e,0x3f81f87,0xfc000400,0xf2493cf3,0xc8088080,
+0x8088248,0x48820808,0x82510212,0x1101107e,0x7fc1f83,0xf81f84fc,0xf2493cf3,0xc0800800,
+0x8048448,0x44840804,0x84510212,0x11c11c3e,0x7fc1f01,0xf0000084,0xf2493cf3,0xc8888880,
+0x6026848,0x42880802,0x88510212,0x1141141e,0x7fc1e00,0xe0000084,0xf2493cf3,0xc8888880,
+0x40,0x40000000,0x4d0212,0xdc11c0e,0x1c00,0x1f80fc,0xf3cf3cf3,0xc0800000,
+0x11011020,0x80001101,0x10400002,0,0,0,0x80480480,0x48088080,
+0xa00a01f,0xa00,0xa0400002,0,0,0,0x80480480,0x48089480,
+0x4004000,0x400,0x40000000,0,0,0,0,0x800,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,
+0,0,0x8,0,0,0,0,0,
+0,0,0x10,0x1e00000,0,0,0,0,
+0,0,0x20,0x7c600000,0,0,0,0,
+0,0,0x40,0x60a00000,0,0,0,0,
+0,0,0x80,0x61200000,0,0,0,0,
+0xc01b800,0,0x738080,0x62000000,0,0,0,0,
+0x12021000,0,0x924080,0x60400000,0,0,0,0,
+0x21021000,0x1040,0x924040,0x60400000,0,0,0,0,
+0x40819024,0xe0002042,0x6692403c,0x60400000,0,0,0,0,
+0x80400054,0x40004044,0x88924000,0x7fc00000,0,0,0,0,
+0x8041a054,0x40008f86,0x48924000,0x7fc00000,0,0,0,0,
+0xf3c22074,0x44044004,0x28f3c000,0,0,0,0,0,
+0x12022053,0x44042002,0xc6804000,0,0,0,0,0,
+0x12021800,0x7fc1000,0x804000,0,0,0,0,0,
+0x1e000000,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,