GUI: UI refinements, fixes
Jeffrey Pfau jeffrey@endrift.com
Sat, 30 Jan 2016 14:02:35 -0800
5 files changed,
81 insertions(+),
15 deletions(-)
M
src/platform/3ds/gui-font.c
→
src/platform/3ds/gui-font.c
@@ -124,3 +124,14 @@ ctrAddRect(color, x, y, metric.x, metric.y, metric.width, metric.height);
break; } } + +void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon) { + ctrActivateTexture(&font->icons); + + if (icon >= GUI_ICON_MAX) { + return; + } + + struct GUIIconMetric metric = defaultIconMetrics[icon]; + ctrAddRectScaled(color, x, y, w, h, metric.x, metric.y, metric.width, metric.height); +}
M
src/platform/psp2/gui-font.c
→
src/platform/psp2/gui-font.c
@@ -54,12 +54,12 @@ if (glyph > 0x7F) {
glyph = '?'; } struct GUIFontGlyphMetric metric = defaultFontMetrics[glyph]; - vita2d_draw_texture_tint_part_scale(font->tex, x, y - GLYPH_HEIGHT + metric.padding.top * 2, + vita2d_draw_texture_tint_part(font->tex, x, y - GLYPH_HEIGHT + metric.padding.top * 2, (glyph & 15) * CELL_WIDTH + metric.padding.left * 2, (glyph >> 4) * CELL_HEIGHT + metric.padding.top * 2, CELL_WIDTH - (metric.padding.left + metric.padding.right) * 2, CELL_HEIGHT - (metric.padding.top + metric.padding.bottom) * 2, - 1, 1, color); + color); } void GUIFontDrawIcon(const struct GUIFont* font, int x, int y, enum GUIAlignment align, enum GUIOrientation orient, uint32_t color, enum GUIIcon icon) {@@ -86,13 +86,13 @@ }
switch (orient) { case GUI_ORIENT_HMIRROR: - vita2d_draw_texture_tint_part_scale(font->icons, x, y, + vita2d_draw_texture_tint_part_scale(font->icons, x + metric.width * 2, y, metric.x * 2, metric.y * 2, metric.width * 2, metric.height * 2, -1, 1, color); return; case GUI_ORIENT_VMIRROR: - vita2d_draw_texture_tint_part_scale(font->icons, x, y, + vita2d_draw_texture_tint_part_scale(font->icons, x, y + metric.height * 2, metric.x * 2, metric.y * 2, metric.width * 2, metric.height * 2, 1, -1, color);@@ -107,3 +107,14 @@ color);
break; } } + +void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon) { + if (icon >= GUI_ICON_MAX) { + return; + } + struct GUIIconMetric metric = defaultIconMetrics[icon]; + vita2d_draw_texture_tint_part_scale(font->icons, x, y, + metric.x * 2, metric.y * 2, + metric.width * 2, metric.height * 2, + w / (float) metric.width, h / (float) metric.height, color); +}
M
src/platform/wii/gui-font.c
→
src/platform/wii/gui-font.c
@@ -180,3 +180,48 @@ GX_Color1u32(color);
GX_TexCoord2f32(u[3], v[3]); GX_End(); } + +void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon) { + if (icon >= GUI_ICON_MAX) { + return; + } + + color = (color >> 24) | (color << 8); + GXTexObj tex; + + struct GUIFont* ncfont = font; + TPL_GetTexture(&ncfont->iconsTdf, 0, &tex); + GX_LoadTexObj(&tex, GX_TEXMAP0); + + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + + struct GUIIconMetric metric = defaultIconMetrics[icon]; + + float u[4]; + float v[4]; + + u[0] = u[3] = metric.x / 256.f; + u[1] = u[2] = (metric.x + metric.width) / 256.f; + v[0] = v[1] = (metric.y + metric.height) / 64.f; + v[2] = v[3] = metric.y / 64.f; + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(x, y + h); + GX_Color1u32(color); + GX_TexCoord2f32(u[0], v[0]); + + GX_Position2s16(x + w, y + h); + GX_Color1u32(color); + GX_TexCoord2f32(u[1], v[1]); + + GX_Position2s16(x + w, y); + GX_Color1u32(color); + GX_TexCoord2f32(u[2], v[2]); + + GX_Position2s16(x, y); + GX_Color1u32(color); + GX_TexCoord2f32(u[3], v[3]); + GX_End(); +}
M
src/util/gui/font.h
→
src/util/gui/font.h
@@ -81,5 +81,6 @@ void GUIFontPrintf(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text, ...);
void GUIFontPrint(const struct GUIFont*, int x, int y, enum GUIAlignment, uint32_t color, const char* text); void GUIFontDrawGlyph(const struct GUIFont*, int x, int y, uint32_t color, uint32_t glyph); void GUIFontDrawIcon(const struct GUIFont*, int x, int y, enum GUIAlignment, enum GUIOrientation, uint32_t color, enum GUIIcon); +void GUIFontDrawIconSize(const struct GUIFont* font, int x, int y, int w, int h, uint32_t color, enum GUIIcon icon); #endif