Skip to content
Browse files

[wiki] Update from Symbio: ok button size increase

Enlarge the ok button when typing the parental control password.  It
will be good for 4 low-case characters.  It will also be good for 3
Chinese/Japanese characters.

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
1 parent e664c2e commit 0252051777a07e221d2b7d4e194a181c22fd2671 @hxw hxw committed
Showing with 41 additions and 10 deletions.
  1. +28 −0 wiki/glyph.c
  2. +2 −0 wiki/glyph.h
  3. +4 −3 wiki/keyboard.c
  4. +7 −7 wiki/restricted.c
View
28 wiki/glyph.c
@@ -343,3 +343,31 @@ int render_string_right(const int font, int start_x,
guilib_clear_area(x, start_y, LCD_BUF_WIDTH_PIXELS - 1, start_y + GetFontLinespace(font));
return rc;
}
+
+void render_string_centered(const int font, int start_x, int start_y, int max_width,
+ const unsigned char *string, int text_length, int inverted)
+{
+ int x;
+ int width = 0;
+ long len = text_length;
+ const unsigned char *p = string;
+ int nCharBytes;
+ ucs4_t c;
+
+ while (len > 0)
+ {
+ width += get_UTF8_char_width(font, &p, &len, &nCharBytes);
+ }
+
+ if (width < max_width)
+ start_x += (max_width - width) / 2;
+
+ x = start_x;
+ const unsigned char *q = (const unsigned char *)string;
+ while (*q) {
+ c = UTF8_to_UCS4(&q);
+ x = draw_bmf_char(c,font-1,x,start_y, inverted, 1);
+ if(x<0)
+ return;
+ }
+}
View
2 wiki/glyph.h
@@ -39,5 +39,7 @@ int draw_glyphs_to_buf(const int font, int start_x, int start_y, const char *str
int render_string_and_clear(const int font, int start_x,
int start_y, const unsigned char *string, int text_length, int inverted,
int clear_start_x, int clear_start_y, int clear_end_x, int clear_end_y);
+void render_string_centered(const int font, int start_x, int start_y, int max_width,
+ const unsigned char *string, int text_length, int inverted);
#endif /* GLYPH_H */
View
7 wiki/keyboard.c
@@ -392,7 +392,7 @@ static struct keyboard_key phone_tw_123[] = {
KEY(198, 84, 233, 119, 198, 84, 233, 119, WL_KEY_NLS_STR),
};
static struct keyboard_key password_char[] = {
- KEY(175, 81, 204, 105, 177, 83, 202, 103, "Y"),
+ KEY(175, 81, 228, 105, 177, 83, 226, 103, "Y"),
KEY( 0, 126, 23, 152, 3, 128, 21, 150, "q"),
KEY( 0, 153, 23, 180, 3, 156, 21, 178, "a"),
@@ -434,7 +434,7 @@ static struct keyboard_key password_char[] = {
KEY(216, 181, 239, 207, 218, 183, 236, 205, WL_KEY_SWITCH_KEYBOARD_STR),
};
static struct keyboard_key password_num[] = {
- KEY(175, 81, 204, 105, 175, 81, 204, 105, "Y"),
+ KEY(175, 81, 228, 105, 177, 83, 226, 103, "Y"),
KEY( 0, 126, 23, 152, 3, 128, 21, 150, "1"),
KEY( 0, 153, 23, 180, 3, 156, 21, 178, "*"),
@@ -579,7 +579,8 @@ int keyboard_get_mode()
int nls_button_enabled()
{
- return (get_search_string_len() == 0 && get_wiki_count() > 1);
+ return (get_search_string_len() == 0 && get_wiki_count() > 1 &&
+ kb_mode != KEYBOARD_PASSWORD_CHAR && kb_mode != KEYBOARD_PASSWORD_NUM);
}
View
14 wiki/restricted.c
@@ -153,8 +153,8 @@ void enter_password_screen(const unsigned char *msg)
framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 21] = 0x07;
framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 22] = 0x80;
- memset(&framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 23], 0, 2);
- framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 25] = 0x1F;
+ memset(&framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 23], 0, 5);
+ framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 28] = 0x1F;
for (i = 83; i <= 103; i++)
{
@@ -163,8 +163,8 @@ void enter_password_screen(const unsigned char *msg)
framebuffer[i * LCD_BUFFER_WIDTH / 8 + 21] = 0x03;
framebuffer[i * LCD_BUFFER_WIDTH / 8 + 22] = 0x00;
- memset(&framebuffer[i * LCD_BUFFER_WIDTH / 8 + 23], 0, 2);
- framebuffer[i * LCD_BUFFER_WIDTH / 8 + 25] = 0x0F;
+ memset(&framebuffer[i * LCD_BUFFER_WIDTH / 8 + 23], 0, 5);
+ framebuffer[i * LCD_BUFFER_WIDTH / 8 + 28] = 0x0F;
}
framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 4] = 0xFC;
@@ -172,11 +172,11 @@ void enter_password_screen(const unsigned char *msg)
framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 21] = 0x07;
framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 22] = 0x80;
- memset(&framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 23], 0, 2);
- framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 25] = 0x1F;
+ memset(&framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 23], 0, 5);
+ framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 28] = 0x1F;
pText = get_nls_text("ok");
- render_string(SUBTITLE_FONT_IDX, 180, 85, pText, ustrlen(pText), 0);
+ render_string_centered(SUBTITLE_FONT_IDX, 177, 85, 50, pText, ustrlen(pText), 0);
guilib_fb_unlock();
}

0 comments on commit 0252051

Please sign in to comment.
Something went wrong with that request. Please try again.