From e09b466554cf4611b01bca143a81ca40bd1b208a Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 8 Feb 2025 00:35:43 -0500 Subject: [PATCH] screen_access add set_drawinfo Change-Id: I32e4932eb3a6f06d45aff2cd767484d254a1c9ff --- apps/gui/color_picker.c | 24 ++++++------------------ apps/gui/line.c | 12 ++++++------ apps/screen_access.c | 2 ++ apps/screen_access.h | 1 + 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index ef17c0a230..c8596a3f4d 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c @@ -119,18 +119,6 @@ static inline unsigned get_black_or_white(const struct rgb_pick *rgb) #define SELECTOR_WIDTH get_icon_width(display->screen_type) #define SELECTOR_HEIGHT 8 /* Height of > and < bitmaps */ -/* dunno why lcd_set_drawinfo should be left out of struct screen */ -static void set_drawinfo(struct screen *display, int mode, - unsigned foreground, unsigned background) -{ - display->set_drawmode(mode); - if (display->depth > 1) - { - display->set_foreground(foreground); - display->set_background(background); - } -} - /* Figure out widest label character in case they vary - this function assumes labels are one character */ static int label_get_max_width(struct screen *display) @@ -174,7 +162,7 @@ static void draw_screen(struct screen *display, char *title, } /* Draw title string */ - set_drawinfo(display, DRMODE_SOLID, text_color, background_color); + display->set_drawinfo(DRMODE_SOLID, text_color, background_color); vp.flags |= VP_FLAG_ALIGN_CENTER; display->putsxy(0, MARGIN_TOP, title); @@ -212,7 +200,7 @@ static void draw_screen(struct screen *display, char *title, if (i == row) { - set_drawinfo(display, DRMODE_SOLID, text_color, background_color); + display->set_drawinfo(DRMODE_SOLID, text_color, background_color); if (global_settings.cursor_style != 0) { @@ -249,7 +237,7 @@ static void draw_screen(struct screen *display, char *title, else if (!display_three_rows) continue; - set_drawinfo(display, mode, fg, bg); + display->set_drawinfo(mode, fg, bg); /* Draw label */ vp.flags &= ~VP_FLAG_ALIGNMENT_MASK; @@ -294,14 +282,14 @@ static void draw_screen(struct screen *display, char *title, display->fillrect(text_x, top, width, height); /* Draw RGB: #rrggbb in middle of swatch */ - set_drawinfo(display, DRMODE_FG, get_black_or_white(rgb), + display->set_drawinfo(DRMODE_FG, get_black_or_white(rgb), background_color); /* Format RGB: #rrggbb */ display->putsxyf(0, top + (height - char_height) / 2, str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue); /* Draw border around the rect */ - set_drawinfo(display, DRMODE_SOLID, text_color, background_color); + display->set_drawinfo(DRMODE_SOLID, text_color, background_color); display->drawrect(text_x, top, width, height); } } @@ -313,7 +301,7 @@ static void draw_screen(struct screen *display, char *title, if (height >= char_height) { - set_drawinfo(display, DRMODE_SOLID, text_color, background_color); + display->set_drawinfo(DRMODE_SOLID, text_color, background_color); /* Format RGB: #rrggbb */ display->putsxyf(0, top + (height - char_height) / 2, str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue); diff --git a/apps/gui/line.c b/apps/gui/line.c index 7e84aa7b31..39a87778a3 100644 --- a/apps/gui/line.c +++ b/apps/gui/line.c @@ -345,10 +345,10 @@ static void style_line(struct screen *display, height*line->line); break; case STYLE_COLORBAR: - display->set_drawmode(DRMODE_FG); + /*display->set_drawmode(DRMODE_FG);*/ display->set_foreground(line->line_color); - display->fillrect(x, y, width - x, bar_height); - break; + /*display->fillrect(x, y, width - x, bar_height);*/ + /* Fall through */ #endif case STYLE_INVERT: display->set_drawmode(DRMODE_FG); @@ -396,10 +396,10 @@ void vput_line(struct screen *display, print_line(display, x, y, line, fmt, ap); #if (LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)) if (display->depth > 1 && line->style > STYLE_INVERT) - { - display->set_foreground(fg); - display->set_background(bg); + { + display->set_drawinfo(DRMODE_SOLID, fg, bg); } + else #endif display->set_drawmode(DRMODE_SOLID); } diff --git a/apps/screen_access.c b/apps/screen_access.c index 1909ef277c..0db57cb442 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -201,6 +201,7 @@ struct screen screens[NB_SCREENS] = .get_foreground=&lcd_get_foreground, .set_background=&lcd_set_background, .set_foreground=&lcd_set_foreground, + .set_drawinfo = &lcd_set_drawinfo, #endif /* LCD_DEPTH > 1 */ .update_rect=&lcd_update_rect, .update_viewport_rect=&lcd_update_viewport_rect, @@ -289,6 +290,7 @@ struct screen screens[NB_SCREENS] = .get_foreground=&lcd_remote_get_foreground, .set_background=&lcd_remote_set_background, .set_foreground=&lcd_remote_set_foreground, + .set_drawinfo = &lcd_remote_set_drawinfo, #endif /* LCD_REMOTE_DEPTH > 1 */ .update_rect=&lcd_remote_update_rect, .update_viewport_rect=&lcd_remote_update_viewport_rect, diff --git a/apps/screen_access.h b/apps/screen_access.h index 3e24306636..f2f299a537 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h @@ -94,6 +94,7 @@ struct screen unsigned (*get_foreground)(void); void (*set_background)(unsigned background); void (*set_foreground)(unsigned foreground); + void (*set_drawinfo)(int mode, unsigned foreground, unsigned background); #endif /* (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) */ void (*update_rect)(int x, int y, int width, int height); void (*update_viewport_rect)(int x, int y, int width, int height);