Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 7ad59b9..fd95b3a 100644 static bool draw_title(struct screen *display, struct gui_synclist *list) if (!list_display_title(list, screen)) return false; *title_text_vp = *(list->parent[screen]); - title_text_vp->height = font_get(title_text_vp->font)->height; + title_text_vp->height = viewport_get_line_height(title_text_vp); if (list->title_icon != Icon_NOICON && global_settings.show_icons) { struct viewport title_icon = *title_text_vp; title_icon.width = get_icon_width(screen) + ICON_PADDING * 2; + title_icon.y += (title_icon.height - get_icon_height(screen)) / 2; + title_icon.height = get_icon_height(screen); if (VP_IS_RTL(&title_icon)) { title_icon.x += title_text_vp->width - title_icon.width; static bool draw_title(struct screen *display, struct gui_synclist *list) title_text_vp->width -= title_icon.width; display->set_viewport(&title_icon); - screen_put_icon(display, 0, 0, list->title_icon); + screen_put_iconxy(display, 0, 0, list->title_icon); } #ifdef HAVE_LCD_COLOR if (list->title_color >= 0) static bool draw_title(struct screen *display, struct gui_synclist *list) void list_draw(struct screen *display, struct gui_synclist *list) { struct viewport list_icons; - int start, end, line_height, style, i; + int start, end, line_height, icon_yoffset, style, i; const int screen = display->screen_type; const int list_start_item = list->start_item[screen]; const int icon_width = get_icon_width(screen) + ICON_PADDING; void list_draw(struct screen *display, struct gui_synclist *list) bool show_title; struct viewport *list_text_vp = &list_text[screen]; - line_height = font_get(parent->font)->height; + line_height = viewport_get_line_height(parent); display->set_viewport(parent); display->clear_viewport(); display->scroll_stop(list_text_vp); *list_text_vp = *parent; if ((show_title = draw_title(display, list))) { - list_text_vp->y += line_height; - list_text_vp->height -= line_height; + int title_height = title_text[screen].height; + list_text_vp->y += title_height; + list_text_vp->height -= title_height; } const int nb_lines = viewport_get_nb_lines(list_text_vp); void list_draw(struct screen *display, struct gui_synclist *list) list_icons.x += list_text_vp->width + ICON_PADDING; else list_text_vp->x += list_icons.width + ICON_PADDING; + icon_yoffset = (line_height - get_icon_height(screen)) / 2; } for (i=start; i<end && i<list->nb_items; i++) void list_draw(struct screen *display, struct gui_synclist *list) display->puts_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } +#ifdef HAVE_TOUCHSCREEN + /* do the line separator */ + int oldcolor = display->get_foreground(); + display->set_foreground(LCD_RGBPACK_LCD(RGB_UNPACK_RED_LCD(oldcolor)/2, + RGB_UNPACK_GREEN_LCD(oldcolor)/2, + RGB_UNPACK_BLUE_LCD(oldcolor)/2)); + //~ if (!i) + display->hline(0+3, list_text_vp->width-3, line*line_height+draw_offset); + display->hline(0+3, list_text_vp->width-3, (line+1)*line_height+draw_offset); + display->set_foreground(oldcolor); +#endif /* do the icon */ display->set_viewport(&list_icons); if (list->callback_get_item_icon != NULL) { - screen_put_icon_with_offset(display, show_cursor?1:0, - (line),show_cursor?ICON_PADDING:0,draw_offset, - list->callback_get_item_icon(i, list->data)); + int xoff = show_cursor ? get_icon_width(screen) + ICON_PADDING : 0; + screen_put_iconxy(display, xoff, + line*line_height + draw_offset + icon_yoffset, + list->callback_get_item_icon(i, list->data)); } + /* do the cursor */ if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { - screen_put_icon_with_offset(display, 0, line, 0, draw_offset, Icon_Cursor); + screen_put_iconxy(display, 0, + line*line_height + draw_offset + icon_yoffset, + Icon_Cursor); } } display->set_viewport(parent); static int scrollbar_scroll(struct gui_synclist * gui_list, /* scrollbar scrolling is still line based */ y_offset = 0; int scrollbar_size = nb_lines* - font_get(gui_list->parent[screen]->font)->height; + viewport_get_line_height(gui_list->parent[screen]); int actual_y = y - list_text[screen].y; int new_selection = (actual_y * gui_list->nb_items) static int kinetic_callback(struct timeout *tmo) return 0; struct cb_data *data = (struct cb_data*)tmo->data; - int line_height = font_get(data->list->parent[0]->font)->height; + int line_height = viewport_get_line_height(data->list->parent[0]); /* ds = v*dt */ int pixel_diff = data->velocity * RELOAD_INTERVAL / HZ; /* remember signedness to detect stopping */ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) struct viewport *info_vp = sb_skin_get_info_vp(screen); const int button = action_get_touchscreen_press_in_vp(&x, &y, info_vp); const int list_start_item = gui_list->start_item[screen]; - const int line_height = font_get(gui_list->parent[screen]->font)->height; + const int line_height = viewport_get_line_height(gui_list->parent[screen]); const struct viewport *list_text_vp = &list_text[screen]; const bool old_released = released; const bool show_title = list_display_title(gui_list, screen); diff --git a/apps/gui/icon.c b/apps/gui/icon.c index 628196a..87ea071 100644 int get_icon_width(enum screen_type screen_type) { return ICON_WIDTH(screen_type); } + +int get_icon_height(enum screen_type screen_type) +{ + return ICON_HEIGHT(screen_type); +} diff --git a/apps/gui/icon.h b/apps/gui/icon.h index e79defe..ca7f048 100644 void icons_init(void); #ifdef HAVE_LCD_CHARCELLS # define CURSOR_CHAR 0xe10c # define get_icon_width(a) 6 +# define get_icon_height(a) 1 /* needs to be verified */ #else int get_icon_width(enum screen_type screen_type); +int get_icon_height(enum screen_type screen_type); #endif + #endif /*_GUI_ICON_H_*/ diff --git a/apps/gui/list.c b/apps/gui/list.c index fbcdcb2..18ec5a1 100644 void list_init(void) add_event(GUI_EVENT_THEME_CHANGED, false, list_force_reinit); } +#ifdef HAVE_TOUCHSCREEN +static int line_height_from_lcd_dpi(const struct viewport *vp) +{ + /* the 4/11 factor is designed so that 8 lines fit perfectly on a + * 160 dpi screen, may not be perfect for other sizes */ + return MAX(lcd_get_dpi()*4/13, (int)font_get(vp->font)->height); +} + +static int line_height_from_settings(const struct viewport *vp) +{ + return font_get(vp->font)->height + global_settings.list_item_padding; +} + +void on_list_padding_setting_changed(int value) +{ + (void)value; + list_need_reinit = true; +} +#endif + static void list_init_viewports(struct gui_synclist *list) { int i, parent_used; static void list_init_viewports(struct gui_synclist *list) if (screens[i].has_buttonbar) list->parent[i]->height -= BUTTONBAR_HEIGHT; #endif +#ifdef HAVE_TOUCHSCREEN + switch (global_settings.list_item_padding) + { + case -1: /* from screen density */ + list->parent[i]->get_line_height = + line_height_from_lcd_dpi; + break; + case 0: /* none / from font */ + list->parent[i]->get_line_height = + viewport_get_line_height_from_font; + break; + default: /* from settings */ + list->parent[i]->get_line_height = + line_height_from_settings; + break; + } +#endif } } list_need_reinit = false; bool list_display_title(struct gui_synclist *list, enum screen_type screen) static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen) { - struct viewport vp = *list->parent[screen]; - int skin_count = skinlist_get_line_count(screen, list); - if (skin_count >= 0) - return skin_count; - if (list_display_title(list, screen)) - vp.height -= font_get(list->parent[screen]->font)->height; - return viewport_get_nb_lines(&vp); + struct viewport *vp = list->parent[screen]; + int lines = skinlist_get_line_count(screen, list); + if (lines < 0) + { + lines = viewport_get_nb_lines(vp); + if (list_display_title(list, screen)) + lines -= 1; + } + return lines; } #else #define list_display_title(l, i) false diff --git a/apps/gui/list.h b/apps/gui/list.h index d40cfe9..c1c4d4a 100644 int skinlist_get_line_count(enum screen_type screen, struct gui_synclist *list); extern unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list); /* only for private use in gui/list.c */ extern void _gui_synclist_stop_kinetic_scrolling(void); +/* notifier when the item padding seting changed */ +extern void on_list_padding_setting_changed(int value); #endif /* If the list has a pending postponed scheduled announcement, that diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index df8093d..9622376 100644 static bool is_theme_enabled(enum screen_type screen) int viewport_get_nb_lines(const struct viewport *vp) { #ifdef HAVE_LCD_BITMAP - return vp->height/font_get(vp->font)->height; + return vp->height/vp->get_line_height(vp); #else (void)vp; return 2; void viewport_set_fullscreen(struct viewport *vp, set_default_align_flags(vp); #endif vp->font = global_status.font_id[screen]; + vp->get_line_height = viewport_get_line_height_from_font; vp->drawmode = DRMODE_SOLID; #if LCD_DEPTH > 1 #ifdef HAVE_REMOTE_LCD diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index 51ab35e..723f1e7 100644 #include "lcd.h" #include "system.h" #include "screen_access.h" +#include "font.h" /* return the number of text lines in the vp viewport */ int viewport_get_nb_lines(const struct viewport *vp); void viewport_set_defaults(struct viewport *vp, const enum screen_type screen); void viewport_set_fullscreen(struct viewport *vp, const enum screen_type screen); + +static inline +int viewport_get_line_height(struct viewport *vp) +{ + return vp->get_line_height(vp); +} + +static inline +int viewport_get_line_height_from_font(const struct viewport *vp) +{ + return font_get(vp->font)->height; +} + int get_viewport_default_colour(enum screen_type screen, bool fgcolour); #ifdef HAVE_LCD_BITMAP diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 5ee087e..9e9a63d 100644 multidrive_usb: "USB Hide Internal Drive" </voice> </phrase> +<phrase> + id: LANG_LIST_ITEM_PADDING + desc: list padding, in display settings + user: core + <source> + *: none + touchscreen: "Item Padding in Lists" + </source> + <dest> + *: none + touchscreen: "Item Padding in Lists" + </dest> + <voice> + *: none + touchscreen: "Item Padding in Lists" + </voice> +</phrase> +<phrase> + id: LANG_AUTOMATIC + desc: generic automatic + user: core + <source> + *: "Automatic" + </source> + <dest> + *: "Automatic" + </dest> + <voice> + *: "Automatic" + </voice> +</phrase> diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index 7e7b5a6..548c1b9 100644 MENUITEM_FUNCTION(touchscreen_menu_calibrate, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE NULL, NULL, Icon_NOICON); MENUITEM_FUNCTION(touchscreen_menu_reset_calibration, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION), reset_mapping, NULL, NULL, Icon_NOICON); +MENUITEM_SETTING(list_item_padding, &global_settings.list_item_padding, NULL); -MAKE_MENU(touchscreen_menu, ID2P(LANG_TOUCHSCREEN_SETTINGS), NULL, Icon_NOICON, &touch_mode, +MAKE_MENU(touchscreen_menu, ID2P(LANG_TOUCHSCREEN_SETTINGS), NULL, Icon_NOICON, &list_item_padding, &touch_mode, &touchscreen_menu_calibrate, &touchscreen_menu_reset_calibration); #endif diff --git a/apps/settings.h b/apps/settings.h index 36e403b..a0aff1b 100644 struct user_settings int scrollbar_width; #endif +#ifdef HAVE_TOUCHSCREEN + int list_item_padding; +#endif + /* goto current song when exiting WPS */ bool browse_current; /* 1=goto current song, 0=goto previous location */ diff --git a/apps/settings_list.c b/apps/settings_list.c index 2f452e6..5043adf 100644 static const char graphic_numeric[] = "graphic,numeric"; #endif /* HAVE_RECORDING */ +static const char* list_pad_formatter(char *buffer, size_t buffer_size, + int val, const char *unit) +{ + switch (val) + { + case -1: return str(LANG_AUTOMATIC); + case 0: return str(LANG_OFF); + default: break; + } + snprintf(buffer, buffer_size, "%d %s", val, unit); + return buffer; +} + +static int32_t list_pad_getlang(int value, int unit) +{ + switch (value) + { + case -1: return LANG_AUTOMATIC; + case 0: return LANG_OFF; + default: return TALK_ID(value, unit); + } +} + static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size, int val, const char *unit) { const struct settings_list settings[] = { INT_SETTING(F_THEMESETTING, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, "scrollbar width",UNIT_INT, 3, MAX(LCD_WIDTH/10,25), 1, NULL, NULL, NULL), + TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, list_item_padding, LANG_LIST_ITEM_PADDING, + -1, "list padding", "off,auto", UNIT_PIXEL, list_pad_formatter, + list_pad_getlang, on_list_padding_setting_changed, 16, + -1,0,2,4,6,8,10,12,16,20,24,28,32,38,44,50), #if CONFIG_KEYPAD == RECORDER_PAD OFFON_SETTING(F_THEMESETTING,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL), #endif diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index fc84fdd..b405a91 100644 void LCDFN(putsxyf)(int x, int y, const unsigned char *fmt, ...) static void LCDFN(putsxyofs_style)(int xpos, int ypos, const unsigned char *str, int style, - int w, int h, int offset) + int h, int offset) { int lastmode = current_vp->drawmode; - int xrect = xpos + MAX(w - offset, 0); - int x = VP_IS_RTL(current_vp) ? xpos : xrect; + int text_ypos = ypos; + int line_height = font_get(current_vp->font)->height; + text_ypos += h/2 - line_height/2; /* center the text in the line */ #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) int oldfgcolor = current_vp->fg_pattern; int oldbgcolor = current_vp->bg_pattern; static void LCDFN(putsxyofs_style)(int xpos, int ypos, current_vp->fg_pattern = current_vp->lst_pattern; } else { - lcd_fillrect(x, ypos, current_vp->width - xrect, h); + lcd_fillrect(xpos, ypos, current_vp->width - xpos, h); current_vp->drawmode = (style & STYLE_INVERT) ? (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; } if (str[0]) - lcd_putsxyofs(xpos, ypos, offset, str); + lcd_putsxyofs(xpos, text_ypos, offset, str); current_vp->fg_pattern = oldfgcolor; current_vp->bg_pattern = oldbgcolor; #else current_vp->drawmode = DRMODE_SOLID | ((style & STYLE_INVERT) ? 0 : DRMODE_INVERSEVID); - LCDFN(fillrect)(x, ypos, current_vp->width - xrect, h); + LCDFN(fillrect)(xpos, ypos, current_vp->width - xpos, h); current_vp->drawmode ^= DRMODE_INVERSEVID; if (str[0]) - LCDFN(putsxyofs)(xpos, ypos, offset, str); + LCDFN(putsxyofs)(xpos, text_ypos, offset, str); #endif current_vp->drawmode = lastmode; } static void LCDFN(putsxyofs_style)(int xpos, int ypos, void LCDFN(puts_style_xyoffset)(int x, int y, const unsigned char *str, int style, int x_offset, int y_offset) { - int xpos, ypos, w, h; + int xpos, ypos, h; LCDFN(scroll_stop_line)(current_vp, y); if(!str) return; - LCDFN(getstringsize)(str, &w, &h); + h = current_vp->get_line_height(current_vp); xpos = x * LCDFN(getstringsize)(" ", NULL, NULL); ypos = y * h + y_offset; - LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, x_offset); + LCDFN(putsxyofs_style)(xpos, ypos, str, style, h, x_offset); } void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, void LCDFN(puts_scroll_offset)(int x, int y, const unsigned char *string, void LCDFN(scroll_fn)(void) { - struct font* pf; struct scrollinfo* s; int index; - int xpos, ypos; + int xpos, ypos, height; struct viewport* old_vp = current_vp; bool makedelay; void LCDFN(scroll_fn)(void) continue; LCDFN(set_viewport)(s->vp); + height = s->vp->get_line_height(s->vp); if (s->backward) s->offset -= LCDFN(scroll_info).step; else s->offset += LCDFN(scroll_info).step; - pf = font_get(current_vp->font); xpos = s->startx; - ypos = s->y * pf->height + s->y_offset; + ypos = s->y * height + s->y_offset; makedelay = false; if (s->bidir) { /* scroll bidirectional */ void LCDFN(scroll_fn)(void) s->start_tick = current_tick + LCDFN(scroll_info).delay + LCDFN(scroll_info).ticks; - LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, s->width, - pf->height, s->offset); - LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, - pf->height); + LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, height, s->offset); + LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width-xpos, height); } LCDFN(set_viewport)(old_vp); } diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index e6e19b1..3457a9e 100644 struct viewport { unsigned lst_pattern; #endif #endif + int (*get_line_height)(const struct viewport* vp); }; /* Frame buffer stride |