// VERTEX
"layout (location=0) in vec2 a_co;" // i16, i16, .. ?
- "layout (location=1) in vec2 a_uv;" // i8, i8
+ "layout (location=1) in vec2 a_uv;" // i16, i16
"layout (location=2) in vec4 a_colour;" // u32
"layout (location=3) in vec4 a_clip;" // i16, i16, i16, i16
"uniform mat3 uPv;"
"void main()"
"{"
"gl_Position = vec4( uPv * vec3( a_co, 1.0 ), 1.0 );"
- "aTexCoords = a_uv * 0.0078125;"
+ "aTexCoords = a_uv * 0.01388888888;"
"aColour = a_colour;"
"aWsp = a_co;"
"void main()"
"{"
"float clip_blend = step( aWsp.x, aClip.z ) * step( aWsp.y, aClip.w ) * step( aClip.x, aWsp.x ) * step( aClip.y, aWsp.y );"
-
- "vec4 glyph = texture( uTexGlyphs, aTexCoords );"
- "FragColor = vec4( aColour.rgb * glyph.rgb, aColour.a*glyph.a*clip_blend );"
+ "vec4 glyph = vec4(1.0,1.0,1.0,1.0);"
+
+ "if( aColour.a == 0.0 )"
+ "{"
+ "glyph = texture( uTexGlyphs, aTexCoords );"
+ "glyph.a = smoothstep( 0.47, 0.53, glyph.r );"
+ "}"
+ "else"
+ "{"
+ "glyph.a = aColour.a;"
+ "}"
+
+ "FragColor = vec4( aColour.rgb, glyph.a*clip_blend );"
"}"
,
UNIFORMS({ "uPv", "uTexGlyphs" })
if( parent->mouse_over )
{
- if( ctx->mouse[0] >= node->rect[0] && ctx->mouse[0] <= node->rect[0]+node->rect[2] &&
- ctx->mouse[1] >= node->rect[1] && ctx->mouse[1] <= node->rect[1]+node->rect[3] )
+ if( ctx->mouse[0] >= node->rect[0] && ctx->mouse[0] < node->rect[0]+node->rect[2] &&
+ ctx->mouse[1] >= node->rect[1] && ctx->mouse[1] < node->rect[1]+node->rect[3] )
node->mouse_over = 1;
else
node->mouse_over = 0;
return ui_fill_rect_uv( ctx, rect, colour, (ui_px[4]){ 4,124,4,124 } );
}
-static void ui_text_use_title( ui_ctx *ctx )
-{
- ctx->glyph_base = 0;
-}
-
-static void ui_text_use_paragraph( ui_ctx *ctx )
-{
- ctx->glyph_base = 6;
-}
-
-enum text_alignment
-{
- k_text_alignment_left = 0,
- k_text_alignment_center,
- k_text_alignment_right
-};
-
-static ui_px ui_text( ui_ctx *ctx, const char *str, ui_px scale, enum text_alignment alignment )
+static void ui_text( ui_ctx *ctx, const char *str, ui_px scale )
{
ui_rect text_cursor;
text_cursor[0] = ctx->cursor[0];
text_cursor[1] = ctx->cursor[1];
- text_cursor[2] = (scale*8)/2;
- text_cursor[3] = (scale*8)/2;
+ text_cursor[2] = 7*scale;
+ text_cursor[3] = 7*scale;
- u32 current_colour = ctx->override_colour;
-
- ui_px offset = 0;
- if( alignment != k_text_alignment_left )
- {
- const char *pch = str;
- for(;;)
- {
- offset += (ui_glyph_spacing_x*scale)/4;
- if( !(*pch) || *pch == '\n' )
- break;
- pch ++;
- }
-
- if( alignment == k_text_alignment_right )
- text_cursor[0] = ctx->cursor[0]+ctx->cursor[2]-offset;
- else
- text_cursor[0] = (ctx->cursor[0]+(ctx->cursor[2]/2))-(offset/2);
- }
+ u32 current_colour = 0x00ffffff;
const char *_c = str;
char c;
{
if( c == '\n' )
{
- text_cursor[1] += (7*scale)/2;
+ text_cursor[1] += 10*scale;
text_cursor[0] = ctx->cursor[0];
continue;
}
{
u8 glyph_base[2];
u8 glyph_index = c - 32;
- glyph_base[0] = (glyph_index&0xf);
- glyph_base[1] = ctx->glyph_base + ((glyph_index-glyph_base[0])>>4);
-
- glyph_base[0] *= 8;
- glyph_base[1] *= 8;
+ glyph_base[0] = glyph_index%10;
+ glyph_base[1] = (glyph_index-glyph_base[0])/10;
+
+ glyph_base[0] *= 7;
+ glyph_base[1] *= 7;
- ui_fill_rect_uv( ctx, text_cursor, current_colour,
- (ui_px[4]){
- glyph_base[0],
- 128-glyph_base[1],
- glyph_base[0]+8,
- 128-(glyph_base[1]+8)
- });
+ 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} );
}
else if( c == '\x1B' )
{
switch( colour_id )
{
- case '0': current_colour = 0xffffffff; break;
- case '3'|'1'<<8: current_colour = 0xff201fee; break;
- case '3'|'2'<<8: current_colour = 0xff37e420; break;
- case '3'|'3'<<8: current_colour = 0xff0ed8e2; break;
- case '3'|'4'<<8: current_colour = 0xfff15010; break;
- case '3'|'5'<<8: current_colour = 0xffee20ee; break;
- case '3'|'6'<<8: current_colour = 0xffeeee20; break;
- case '3'|'7'<<8: current_colour = 0xffffffff; break;
+ case '0': current_colour = 0x00ffffff; break;
+ case '3'|'1'<<8: current_colour = 0x00201fee; break;
+ case '3'|'2'<<8: current_colour = 0x0037e420; break;
+ case '3'|'3'<<8: current_colour = 0x000ed8e2; break;
+ case '3'|'4'<<8: current_colour = 0x00f15010; break;
+ case '3'|'5'<<8: current_colour = 0x00ee20ee; break;
+ case '3'|'6'<<8: current_colour = 0x00eeee20; break;
+ case '3'|'7'<<8: current_colour = 0x00ffffff; break;
}
break;
break;
}
}
- continue;
}
- text_cursor[0] += (ui_glyph_spacing_x*scale)/4;
+ text_cursor[0] += 6*scale;
}
-
- return text_cursor[0];
}
// API control
// title..
ctx->cursor[0] += 2;
ctx->cursor[1] += 2;
- ui_text( ctx, window->title, 2, 0 );
+ ui_text( ctx, window->title, 2 );
// Close button
ctx->cursor[3] = 25;
vg_info( "Click clacked\n" );
}
ctx->cursor[0] += 2;
- ui_text( ctx, "x", 2, 0 );
+ ui_text( ctx, "x", 2 );
ui_end( ctx );
if( ui_hasmouse( ctx ) )