Author: titmuss
Date: Thu Jan 24 03:31:14 2008
New Revision: 1601
URL: http://svn.slimdevices.com?rev=1601&root=Jive&view=rev
Log:
[EMAIL PROTECTED] (orig r1594): titmuss | 2008-01-24 10:42:23 +0000
Bug: 6311
Description:
Fixed text area, text input and Classic Clock for the new font rendering.
Modified:
trunk/ (props changed)
trunk/jive/src/pkg/jive/share/applets/Clock/ClockApplet.lua
trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua
trunk/jive/src/pkg/jive/src/ui/jive.h
trunk/jive/src/pkg/jive/src/ui/jive_font.c
trunk/jive/src/pkg/jive/src/ui/jive_label.c
trunk/jive/src/pkg/jive/src/ui/jive_textarea.c
trunk/jive/src/pkg/jive/src/ui/jive_textinput.c
trunk/jive/src/pkg/jive/src/ui/lua_jiveui.c
trunk/jive/src/pkg/jive/src/ui/lua_jiveui.pkg
Propchange: trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Thu Jan 24 03:31:14 2008
@@ -1,3 +1,3 @@
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1593
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1594
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
Modified: trunk/jive/src/pkg/jive/share/applets/Clock/ClockApplet.lua
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/Clock/ClockApplet.lua?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/Clock/ClockApplet.lua (original)
+++ trunk/jive/src/pkg/jive/share/applets/Clock/ClockApplet.lua Thu Jan 24
03:31:14 2008
@@ -326,12 +326,12 @@
return obj;
end
-local CLOCKY = 48
+local CLOCKY = 52
function DigitalDetailed:DrawTime(x, y, bw, bh, useAmPm)
local screenMidpointX = (self.screen_width/2)
- local digitStartY = y + CLOCKY
+ local digitStartY = y + CLOCKY - self.mainfont:offset()
-- ampm variables, needed before drawing dots
local ampm = os.date("%p")
@@ -367,7 +367,7 @@
-- x position for hour is half the screen width - 10 pixels - width of
hour digits
local hourStartX = adjMidpointX - 10 - hw
- hourSrf:blit(self.bg, hourStartX, digitStartY)
+ hourSrf:blit(self.bg, hourStartX, digitStartY)
-- Draw Minute
@@ -387,7 +387,7 @@
if useAmPm then
- local ampmStartY = digitStartY + 5
+ local ampmStartY = y + CLOCKY - self.ampmfont:offset() + 3
-- x position of ampm is minute start X + minute width + 5
local ampmStartX = minStartX + mw + 5
@@ -397,7 +397,7 @@
end
-local DATEY = 10
+local DATEY = 12
function DigitalDetailed:Draw()
@@ -436,7 +436,7 @@
local dateStartY = y + DATEY
local dateStartX = x + ((bw/2) - (dw/2))
- dateSrf:blit(self.bg, dateStartX, dateStartY)
+ dateSrf:blit(self.bg, dateStartX, dateStartY - self.datefont:offset())
self.bgicon:reDraw()
end
@@ -444,7 +444,7 @@
local PADDINGX = 6
local PADDINGY = 10
-local DAYFIXY = 2
+local DAYFIXY = 0
local DAYS_SUN = { "S", "M", "T", "W", "T", "F", "S" }
local DAYS_MON = { "M", "T", "W", "T", "F", "S", "S" }
@@ -473,9 +473,10 @@
local c = self.daysfont_color
local daySrf = Surface:drawText(self.daysfont, c, days[i+1])
- local dayw, dayh = daySrf:getSize()
-
- daySrf:blit(self.bg, newx + ((dw/2)-(dayw/2)), y + bh - (dh +
PADDINGY) + ((dh/2)-(dayh/2)) + DAYFIXY)
+ local dayw = daySrf:getSize()
+ local dayh = self.daysfont:capheight()
+
+ daySrf:blit(self.bg, newx + ((dw/2)-(dayw/2)), y + bh - (dh +
PADDINGY) + ((dh/2)-(dayh/2)) + DAYFIXY - self.daysfont:offset())
i = i + 1
end
Modified:
trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua
(original)
+++ trunk/jive/src/pkg/jive/share/applets/DefaultSkin/DefaultSkinApplet.lua Thu
Jan 24 03:31:14 2008
@@ -348,7 +348,7 @@
s.title.position = LAYOUT_NORTH
s.title.bgImg = titleBox
s.title.text = {}
- s.title.text.padding = { 10, 7, 8, 9 }
+ s.title.text.padding = { 10, 8, 8, 8 }
s.title.text.align = "top-left"
s.title.text.font = FONT_BOLD_18px
s.title.text.fg = SELECT_COLOR
Modified: trunk/jive/src/pkg/jive/src/ui/jive.h
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive.h?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive.h (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive.h Thu Jan 24 03:31:14 2008
@@ -339,6 +339,7 @@
int jive_font_height(JiveFont *font);
int jive_font_capheight(JiveFont *font);
int jive_font_ascend(JiveFont *font);
+int jive_font_offset(JiveFont *font);
JiveSurface *jive_font_draw_text(JiveFont *font, Uint32 color, const char
*str);
JiveSurface *jive_font_ndraw_text(JiveFont *font, Uint32 color, const char
*str, size_t len);
Modified: trunk/jive/src/pkg/jive/src/ui/jive_font.c
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive_font.c?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive_font.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive_font.c Thu Jan 24 03:31:14 2008
@@ -147,8 +147,14 @@
return font->ascend;
}
+int jive_font_offset(JiveFont *font) {
+ assert(font && font->magic == JIVE_FONT_MAGIC);
+
+ return font->ascend - font->capheight;
+}
+
static int load_ttf_font(JiveFont *font, const char *name, Uint16 size) {
- int maxy;
+ int miny, maxy, descent;
char *fullpath = malloc(PATH_MAX);
if (!jive_find_file(name, fullpath) ) {
@@ -165,7 +171,6 @@
}
free(fullpath);
- font->height = TTF_FontHeight(font->ttf);
font->ascend = TTF_FontAscent(font->ttf);
/* calcualte the cap height using H */
@@ -175,6 +180,17 @@
else {
font->capheight = font->ascend;
}
+
+ /* calcualte the non diacritical descent using g */
+ if (TTF_GlyphMetrics(font->ttf, 'g', NULL, NULL, &miny, NULL, NULL) ==
0) {
+ descent = miny;
+ }
+ else {
+ descent = TTF_FontDescent(font->ttf);
+ }
+
+ /* calculate the font height, using the capheight and descent */
+ font->height = font->capheight - descent + 1;
font->width = width_ttf_font;
font->draw = draw_ttf_font;
Modified: trunk/jive/src/pkg/jive/src/ui/jive_label.c
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive_label.c?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive_label.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive_label.c Thu Jan 24 03:31:14 2008
@@ -85,7 +85,7 @@
peer->base.font = jive_font_ref(jive_style_font(L, 1, "font"));
peer->base.lineHeight = jive_style_int(L, 1, "lineHeight",
jive_font_capheight(peer->base.font));
- peer->base.textOffset = jive_font_ascend(peer->base.font) -
jive_font_capheight(peer->base.font);
+ peer->base.textOffset = jive_font_offset(peer->base.font);
peer->base.fg = jive_style_color(L, 1, "fg", JIVE_COLOR_BLACK, NULL);
peer->base.sh = jive_style_color(L, 1, "sh", JIVE_COLOR_WHITE,
&(peer->base.is_sh));
@@ -98,7 +98,7 @@
peer->format[i].font = jive_font_ref(jive_style_array_font(L,
1, "line", i+1, "font"));
if (peer->format[i].font) {
peer->format[i].lineHeight = jive_style_array_int(L, 1,
"line", i+1, "height", jive_font_capheight(peer->format[i].font));
- peer->format[i].textOffset =
jive_font_ascend(peer->base.font) - jive_font_capheight(peer->base.font);
+ peer->format[i].textOffset =
jive_font_offset(peer->base.font);
}
// peer->format[i].fg = jive_style_color(L, 1, "fg",
JIVE_COLOR_BLACK, &(peer->format[i].is_fg);
// peer->format[i].sh = jive_style_color(L, 1, "sh",
JIVE_COLOR_BLACK, &(peer->format[i].is_sh);
Modified: trunk/jive/src/pkg/jive/src/ui/jive_textarea.c
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive_textarea.c?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive_textarea.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive_textarea.c Thu Jan 24 03:31:14 2008
@@ -19,6 +19,7 @@
// style
JiveFont *font;
Uint16 line_height;
+ Uint16 text_offset;
JiveAlign align;
bool is_sh;
Uint32 sh;
@@ -68,6 +69,7 @@
}
peer->line_height = jive_style_int(L, 1, "lineHeight",
jive_font_height(peer->font));
+ peer->text_offset = jive_font_offset(peer->font);
peer->align = jive_style_align(L, 1, "textAlign", JIVE_ALIGN_LEFT);
@@ -270,7 +272,7 @@
text = (char *) lua_tostring(L, -1);
- y = peer->w.bounds.y + peer->w.padding.top;
+ y = peer->w.bounds.y + peer->w.padding.top - peer->text_offset;
lua_getfield(L, 1, "topLine");
top_line = lua_tointeger(L, -1);
Modified: trunk/jive/src/pkg/jive/src/ui/jive_textinput.c
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/jive_textinput.c?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/jive_textinput.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/jive_textinput.c Thu Jan 24 03:31:14 2008
@@ -131,6 +131,7 @@
Uint16 text_h, text_x, text_y, text_cy, text_w, cursor_x, cursor_w,
cursor_h;
const char *validchars, *validchars_end;
int len_1, len_2, len_3;
+ int text_offset, cursor_offset;
int i;
@@ -212,9 +213,12 @@
lua_pushinteger(L, indent);
lua_setfield(L, 1, "indent");
+ text_offset = jive_font_offset(peer->font);
+ cursor_offset = jive_font_offset(peer->cursor_font);
+
cursor_x = text_x + len_1;
- offset_y = ((cursor_h / 2) - jive_font_height(peer->font)) / 2;
- offset_cursor_y = ((cursor_h / 2) -
jive_font_height(peer->cursor_font)) / 2;
+ offset_y = (((cursor_h / 2) - jive_font_height(peer->font)) / 2) -
text_offset;
+ offset_cursor_y = (((cursor_h / 2) -
jive_font_height(peer->cursor_font)) / 2) - cursor_offset;
/* Valid characters */
jive_getmethod(L, 1, "_getChars");
Modified: trunk/jive/src/pkg/jive/src/ui/lua_jiveui.c
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/lua_jiveui.c?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/lua_jiveui.c (original)
+++ trunk/jive/src/pkg/jive/src/ui/lua_jiveui.c Thu Jan 24 03:31:14 2008
@@ -1,6 +1,6 @@
/*
** Lua binding: jive
-** Generated automatically by tolua++-1.0.92 on Sat Aug 25 13:34:31 2007.
+** Generated automatically by tolua++-1.0.92 on Tue Jan 22 12:52:24 2008.
*/
#ifndef __cplusplus
@@ -623,9 +623,9 @@
Surface* dst = ((Surface*) tolua_tousertype(tolua_S,2,0));
short dx = (( short) tolua_tointeger(tolua_S,3,0));
short dy = (( short) tolua_tointeger(tolua_S,4,0));
- short alpha = (( short) tolua_tointeger(tolua_S,5,0));
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function
'jive_surface_blitAlpha'",NULL);
+ unsigned char alpha = (( unsigned char) tolua_tointeger(tolua_S,5,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function
'jive_surface_blit_alpha'",NULL);
#endif
{
jive_surface_blit_alpha(self,dst,dx,dy,alpha);
@@ -634,7 +634,7 @@
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'blit'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'blitAlpha'.",&tolua_err);
return 0;
#endif
}
@@ -1936,6 +1936,38 @@
}
#endif //#ifndef TOLUA_DISABLE
+/* method: jive_font_capheight of class Font */
+#ifndef TOLUA_DISABLE_tolua_jive_jive_ui_Font_capheight00
+static int tolua_jive_jive_ui_Font_capheight00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Font* self = (Font*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function
'jive_font_capheight'",NULL);
+#endif
+ {
+ tolua_outside int tolua_ret = (tolua_outside int) jive_font_capheight(self);
+ tolua_pushinteger(tolua_S,(lua_Integer)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'capheight'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: jive_font_height of class Font */
#ifndef TOLUA_DISABLE_tolua_jive_jive_ui_Font_height00
static int tolua_jive_jive_ui_Font_height00(lua_State* tolua_S)
@@ -1995,6 +2027,38 @@
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'ascend'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: jive_font_offset of class Font */
+#ifndef TOLUA_DISABLE_tolua_jive_jive_ui_Font_offset00
+static int tolua_jive_jive_ui_Font_offset00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"Font",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ Font* self = (Font*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function
'jive_font_offset'",NULL);
+#endif
+ {
+ tolua_outside int tolua_ret = (tolua_outside int) jive_font_offset(self);
+ tolua_pushinteger(tolua_S,(lua_Integer)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'offset'.",&tolua_err);
return 0;
#endif
}
@@ -2143,8 +2207,10 @@
tolua_function(tolua_S,"load",tolua_jive_jive_ui_Font_load00);
tolua_function(tolua_S,"_free",tolua_jive_jive_ui_Font__free00);
tolua_function(tolua_S,"width",tolua_jive_jive_ui_Font_width00);
+ tolua_function(tolua_S,"capheight",tolua_jive_jive_ui_Font_capheight00);
tolua_function(tolua_S,"height",tolua_jive_jive_ui_Font_height00);
tolua_function(tolua_S,"ascend",tolua_jive_jive_ui_Font_ascend00);
+ tolua_function(tolua_S,"offset",tolua_jive_jive_ui_Font_offset00);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
Modified: trunk/jive/src/pkg/jive/src/ui/lua_jiveui.pkg
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/src/ui/lua_jiveui.pkg?rev=1601&root=Jive&r1=1600&r2=1601&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/src/ui/lua_jiveui.pkg (original)
+++ trunk/jive/src/pkg/jive/src/ui/lua_jiveui.pkg Thu Jan 24 03:31:14 2008
@@ -163,7 +163,7 @@
tolua_outside void jive_surface_blit @ blit(Surface *dst, Sint16 dx,
Sint16 dy);
tolua_outside void jive_surface_blit_clip @ blitClip(Uint16 sx, Uint16
sy, Uint16 sw, Uint16 sh,
Surface* dst, Uint16 dx, Uint16 dy);
- tolua_outside void jive_surface_blit_alpha @ blit(Surface *dst, Sint16
dx, Sint16 dy, Uint8 alpha);
+ tolua_outside void jive_surface_blit_alpha @ blitAlpha(Surface *dst,
Sint16 dx, Sint16 dy, Uint8 alpha);
tolua_outside void jive_surface_get_size @ getSize(Uint16 *w=0, Uint16
*h=0);
tolua_create Surface *jive_surface_rotozoomSurface @ rotozoom(double
angle, double zoom, int smooth=1);
@@ -216,8 +216,10 @@
tolua_destroy void jive_font_free @ _free();
tolua_outside int jive_font_width @ width(const char *str);
+ tolua_outside int jive_font_capheight @ capheight();
tolua_outside int jive_font_height @ height();
tolua_outside int jive_font_ascend @ ascend();
+ tolua_outside int jive_font_offset @ offset();
};
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins