From 752ff17265f23d4fa9084368d2a90f66521a98e2 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 22 Jul 2017 16:14:14 +0200 Subject: separated video driver in a virtual video driver and a specific VGA video driver --- src/gui/desktop.c | 19 ++++++++++++------- src/gui/graphics_context.h | 4 ++-- src/gui/text_widget.c | 3 ++- src/gui/widget.c | 2 +- src/gui/window.c | 8 ++++---- 5 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src/gui') diff --git a/src/gui/desktop.c b/src/gui/desktop.c index 33afed6..d560e8a 100644 --- a/src/gui/desktop.c +++ b/src/gui/desktop.c @@ -41,22 +41,27 @@ void desktop_draw( void *obj, graphics_context_t *context ) return; } - vga_clear_screen( context, desktop->base.base.background_color ); + ((video_vtable_t *)(context->base.vtable))->clear_screen( context, + desktop->base.base.background_color ); composite_widget_draw( obj, context ); for( int i = 0; i < 4; i++ ) { if( desktop->mouse_x > i ) { - vga_set_pixel( context, desktop->mouse_x - i, desktop->mouse_y, VIDEO_RGB_COLOR_WHITE ); + ((video_vtable_t *)(context->base.vtable))->set_pixel( context, + desktop->mouse_x - i, desktop->mouse_y, VIDEO_RGB_COLOR_WHITE ); } - if( desktop->mouse_x < context->mode->base.x - i ) { - vga_set_pixel( context, desktop->mouse_x + i, desktop->mouse_y, VIDEO_RGB_COLOR_WHITE ); + if( desktop->mouse_x < context->mode->x - i ) { + ((video_vtable_t *)(context->base.vtable))->set_pixel( context, + desktop->mouse_x + i, desktop->mouse_y, VIDEO_RGB_COLOR_WHITE ); } if( desktop->mouse_y > i ) { - vga_set_pixel( context, desktop->mouse_x, desktop->mouse_y - i, VIDEO_RGB_COLOR_WHITE ); + ((video_vtable_t *)(context->base.vtable))->set_pixel( context, + desktop->mouse_x, desktop->mouse_y - i, VIDEO_RGB_COLOR_WHITE ); } - if( desktop->mouse_y < context->mode->base.y - i ) { - vga_set_pixel( context, desktop->mouse_x, desktop->mouse_y + i, VIDEO_RGB_COLOR_WHITE ); + if( desktop->mouse_y < context->mode->y - i ) { + ((video_vtable_t *)(context->base.vtable))->set_pixel( context, + desktop->mouse_x, desktop->mouse_y + i, VIDEO_RGB_COLOR_WHITE ); } } diff --git a/src/gui/graphics_context.h b/src/gui/graphics_context.h index ba08273..65792d0 100644 --- a/src/gui/graphics_context.h +++ b/src/gui/graphics_context.h @@ -1,8 +1,8 @@ #ifndef GRAPHICS_CONTEXT_H #define GRAPHICS_CONTEXT_H -#include "vga.h" +#include "video.h" -typedef vga_t graphics_context_t; +typedef video_t graphics_context_t; #endif //GRAPHICS_CONTEXT_H diff --git a/src/gui/text_widget.c b/src/gui/text_widget.c index 3aa09cc..d9c96e0 100644 --- a/src/gui/text_widget.c +++ b/src/gui/text_widget.c @@ -45,7 +45,8 @@ void text_widget_draw( void *obj, graphics_context_t *context ) ((widget_t *)widget)->vtable->model_to_screen( widget, &x, &y ); for( const char *p = widget->s; *p != '\0'; p++ ) { - vga_draw_char( context, *p, x + w, y + h, + ((video_vtable_t *)(context->base.vtable))->draw_char( + context, *p, x + w, y + h, ((widget_t *)widget)->background_color, VIDEO_RGB_COLOR_WHITE ); w += 9; diff --git a/src/gui/widget.c b/src/gui/widget.c index 70e0dbc..cac4dfb 100644 --- a/src/gui/widget.c +++ b/src/gui/widget.c @@ -37,7 +37,7 @@ void widget_draw( void *obj, graphics_context_t *context ) widget->vtable->model_to_screen( widget, &x, &y ); - vga_draw_rectangle( context, x, y, widget->w, widget->h, + ((video_vtable_t *)(context->base.vtable))->draw_rectangle( context, x, y, widget->w, widget->h, widget->background_color ); } diff --git a/src/gui/window.c b/src/gui/window.c index 1cb1fb1..132dd89 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -39,14 +39,14 @@ void window_draw( void *obj, graphics_context_t *context ) if( ((widget_t *)widget)->x < 0 ) { ((widget_t *)widget)->x = 0; } - if( ((widget_t *)widget)->x > context->mode->base.x - ((widget_t *)widget)->w ) { - ((widget_t *)widget)->x = context->mode->base.x - ((widget_t *)widget)->w; + if( ((widget_t *)widget)->x > context->mode->x - ((widget_t *)widget)->w ) { + ((widget_t *)widget)->x = context->mode->x - ((widget_t *)widget)->w; } if( ((widget_t *)widget)->y < 0 ) { ((widget_t *)widget)->y = 0; } - if( ((widget_t *)widget)->y > context->mode->base.y - ((widget_t *)widget)->h ) { - ((widget_t *)widget)->y = context->mode->base.y - ((widget_t *)widget)->h; + if( ((widget_t *)widget)->y > context->mode->y - ((widget_t *)widget)->h ) { + ((widget_t *)widget)->y = context->mode->y - ((widget_t *)widget)->h; } composite_widget_draw( obj, context ); -- cgit v1.2.3-54-g00ecf