screen_access add set_drawinfo

Change-Id: I32e4932eb3a6f06d45aff2cd767484d254a1c9ff
This commit is contained in:
William Wilgus 2025-02-08 00:35:43 -05:00 committed by William Wilgus
parent b94b0d3bf4
commit e09b466554
4 changed files with 15 additions and 24 deletions

View file

@ -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_WIDTH get_icon_width(display->screen_type)
#define SELECTOR_HEIGHT 8 /* Height of > and < bitmaps */ #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 - /* Figure out widest label character in case they vary -
this function assumes labels are one character */ this function assumes labels are one character */
static int label_get_max_width(struct screen *display) 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 */ /* 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; vp.flags |= VP_FLAG_ALIGN_CENTER;
display->putsxy(0, MARGIN_TOP, title); display->putsxy(0, MARGIN_TOP, title);
@ -212,7 +200,7 @@ static void draw_screen(struct screen *display, char *title,
if (i == row) 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) if (global_settings.cursor_style != 0)
{ {
@ -249,7 +237,7 @@ static void draw_screen(struct screen *display, char *title,
else if (!display_three_rows) else if (!display_three_rows)
continue; continue;
set_drawinfo(display, mode, fg, bg); display->set_drawinfo(mode, fg, bg);
/* Draw label */ /* Draw label */
vp.flags &= ~VP_FLAG_ALIGNMENT_MASK; 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); display->fillrect(text_x, top, width, height);
/* Draw RGB: #rrggbb in middle of swatch */ /* 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); background_color);
/* Format RGB: #rrggbb */ /* Format RGB: #rrggbb */
display->putsxyf(0, top + (height - char_height) / 2, display->putsxyf(0, top + (height - char_height) / 2,
str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue); str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue);
/* Draw border around the rect */ /* 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); display->drawrect(text_x, top, width, height);
} }
} }
@ -313,7 +301,7 @@ static void draw_screen(struct screen *display, char *title,
if (height >= char_height) 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 */ /* Format RGB: #rrggbb */
display->putsxyf(0, top + (height - char_height) / 2, display->putsxyf(0, top + (height - char_height) / 2,
str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue); str(LANG_COLOR_RGB_VALUE), rgb->red, rgb->green, rgb->blue);

View file

@ -345,10 +345,10 @@ static void style_line(struct screen *display,
height*line->line); height*line->line);
break; break;
case STYLE_COLORBAR: case STYLE_COLORBAR:
display->set_drawmode(DRMODE_FG); /*display->set_drawmode(DRMODE_FG);*/
display->set_foreground(line->line_color); display->set_foreground(line->line_color);
display->fillrect(x, y, width - x, bar_height); /*display->fillrect(x, y, width - x, bar_height);*/
break; /* Fall through */
#endif #endif
case STYLE_INVERT: case STYLE_INVERT:
display->set_drawmode(DRMODE_FG); display->set_drawmode(DRMODE_FG);
@ -396,10 +396,10 @@ void vput_line(struct screen *display,
print_line(display, x, y, line, fmt, ap); print_line(display, x, y, line, fmt, ap);
#if (LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1)) #if (LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1))
if (display->depth > 1 && line->style > STYLE_INVERT) if (display->depth > 1 && line->style > STYLE_INVERT)
{ {
display->set_foreground(fg); display->set_drawinfo(DRMODE_SOLID, fg, bg);
display->set_background(bg);
} }
else
#endif #endif
display->set_drawmode(DRMODE_SOLID); display->set_drawmode(DRMODE_SOLID);
} }

View file

@ -201,6 +201,7 @@ struct screen screens[NB_SCREENS] =
.get_foreground=&lcd_get_foreground, .get_foreground=&lcd_get_foreground,
.set_background=&lcd_set_background, .set_background=&lcd_set_background,
.set_foreground=&lcd_set_foreground, .set_foreground=&lcd_set_foreground,
.set_drawinfo = &lcd_set_drawinfo,
#endif /* LCD_DEPTH > 1 */ #endif /* LCD_DEPTH > 1 */
.update_rect=&lcd_update_rect, .update_rect=&lcd_update_rect,
.update_viewport_rect=&lcd_update_viewport_rect, .update_viewport_rect=&lcd_update_viewport_rect,
@ -289,6 +290,7 @@ struct screen screens[NB_SCREENS] =
.get_foreground=&lcd_remote_get_foreground, .get_foreground=&lcd_remote_get_foreground,
.set_background=&lcd_remote_set_background, .set_background=&lcd_remote_set_background,
.set_foreground=&lcd_remote_set_foreground, .set_foreground=&lcd_remote_set_foreground,
.set_drawinfo = &lcd_remote_set_drawinfo,
#endif /* LCD_REMOTE_DEPTH > 1 */ #endif /* LCD_REMOTE_DEPTH > 1 */
.update_rect=&lcd_remote_update_rect, .update_rect=&lcd_remote_update_rect,
.update_viewport_rect=&lcd_remote_update_viewport_rect, .update_viewport_rect=&lcd_remote_update_viewport_rect,

View file

@ -94,6 +94,7 @@ struct screen
unsigned (*get_foreground)(void); unsigned (*get_foreground)(void);
void (*set_background)(unsigned background); void (*set_background)(unsigned background);
void (*set_foreground)(unsigned foreground); void (*set_foreground)(unsigned foreground);
void (*set_drawinfo)(int mode, unsigned foreground, unsigned background);
#endif /* (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) */ #endif /* (LCD_DEPTH > 1) || (LCD_REMOTE_DEPTH > 1) */
void (*update_rect)(int x, int y, int width, int height); void (*update_rect)(int x, int y, int width, int height);
void (*update_viewport_rect)(int x, int y, int width, int height); void (*update_viewport_rect)(int x, int y, int width, int height);