summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-21 20:25:27 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-21 20:25:27 +0200
commitc8f2689dbeca2bf51d41bbf861c495bb4b0c29ce (patch)
tree4d50fcd52ce35f58a686f14055e2d198b66a41e7 /src/gui
parented983944d6d00a055ff90f04f6f1e12aca87bb86 (diff)
downloadabaos-c8f2689dbeca2bf51d41bbf861c495bb4b0c29ce.tar.gz
abaos-c8f2689dbeca2bf51d41bbf861c495bb4b0c29ce.tar.bz2
started to rewrite to use the main desktop widget
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/composite_widget.c4
-rw-r--r--src/gui/composite_widget.h3
-rw-r--r--src/gui/desktop.c9
-rw-r--r--src/gui/desktop.h2
-rw-r--r--src/gui/widget.c5
-rw-r--r--src/gui/widget.h3
6 files changed, 16 insertions, 10 deletions
diff --git a/src/gui/composite_widget.c b/src/gui/composite_widget.c
index afef28c..9f2d1c1 100644
--- a/src/gui/composite_widget.c
+++ b/src/gui/composite_widget.c
@@ -18,11 +18,11 @@ static composite_widget_vtable_t composite_widget_vtable = {
composite_widget_add_child
};
-void composite_widget_init( composite_widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h )
+void composite_widget_init( composite_widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h, const vga_color_t background_color )
{
memset( widget, 0, sizeof( composite_widget_t ) );
- widget_init( &widget->base, parent, x, y, w, h );
+ widget_init( &widget->base, parent, x, y, w, h, background_color );
widget->nof_children = 0;
widget->focused_child = NULL;
diff --git a/src/gui/composite_widget.h b/src/gui/composite_widget.h
index d3ba90a..2b27e32 100644
--- a/src/gui/composite_widget.h
+++ b/src/gui/composite_widget.h
@@ -16,9 +16,10 @@ typedef struct {
widget_t *children[MAX_NOF_WIDGET_CHILDREN];
int nof_children;
widget_t *focused_child;
+ vga_color_t background_color;
} composite_widget_t;
-void composite_widget_init( composite_widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h );
+void composite_widget_init( composite_widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h, const vga_color_t background_color );
void composite_widget_draw( void *obj, graphics_context_t *context );
void composite_widget_get_focus( void *obj, widget_t *widget );
diff --git a/src/gui/desktop.c b/src/gui/desktop.c
index 1a0a5a8..ee4a6e5 100644
--- a/src/gui/desktop.c
+++ b/src/gui/desktop.c
@@ -15,15 +15,16 @@ static desktop_vtable_t desktop_vtable = {
desktop_on_mouse_move,
composite_widget_on_key_down,
composite_widget_on_key_up
- }
+ },
+ composite_widget_add_child
}
};
-void desktop_init( desktop_t *desktop, const int w, const int h )
+void desktop_init( desktop_t *desktop, const int w, const int h, const vga_color_t background_color )
{
memset( desktop, 0, sizeof( desktop_t ) );
- composite_widget_init( &desktop->base, NULL, 0, 0, w, h );
+ composite_widget_init( &desktop->base, NULL, 0, 0, w, h, background_color );
desktop->vtable = &desktop_vtable;
}
@@ -32,6 +33,8 @@ void desktop_draw( void *obj, graphics_context_t *context )
{
desktop_t *desktop = obj;
+ vga_clear_screen( context, desktop->base.base.background_color );
+
((widget_vtable_t *)(desktop->base.vtable))->draw( obj, context );
// TODO: use a mouse bitmap and copy it
diff --git a/src/gui/desktop.h b/src/gui/desktop.h
index b160dc0..1f3ef93 100644
--- a/src/gui/desktop.h
+++ b/src/gui/desktop.h
@@ -14,7 +14,7 @@ typedef struct {
desktop_vtable_t *vtable;
} desktop_t;
-void desktop_init( desktop_t *widget, const int w, const int h );
+void desktop_init( desktop_t *widget, const int w, const int h, const vga_color_t background_color );
void desktop_draw( void *obj, graphics_context_t *context );
void desktop_on_mouse_down( void *obj, const int x, const int y );
diff --git a/src/gui/widget.c b/src/gui/widget.c
index cd77d03..1c26680 100644
--- a/src/gui/widget.c
+++ b/src/gui/widget.c
@@ -15,7 +15,7 @@ static widget_vtable_t widget_vtable = {
widget_on_key_up
};
-void widget_init( widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h )
+void widget_init( widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h, const vga_color_t background_color )
{
memset( widget, 0, sizeof( widget_t ) );
@@ -24,6 +24,7 @@ void widget_init( widget_t *widget, widget_t *parent, const int x, const int y,
widget->y = y;
widget->w = w;
widget->h = h;
+ widget->background_color = background_color;
widget->vtable = &widget_vtable;
}
@@ -37,7 +38,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,
- vga_make_RGB( 0xFF, 0xFF, 0xFF ) );
+ widget->background_color );
}
void widget_get_focus( void *obj, widget_t *widget )
diff --git a/src/gui/widget.h b/src/gui/widget.h
index 1fd23ac..ceb5b71 100644
--- a/src/gui/widget.h
+++ b/src/gui/widget.h
@@ -24,12 +24,13 @@ typedef struct widget_t {
int y;
int w;
int h;
+ vga_color_t background_color;
bool focusable;
struct widget_t *parent;
widget_vtable_t *vtable;
} widget_t;
-void widget_init( widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h );
+void widget_init( widget_t *widget, widget_t *parent, const int x, const int y, const int w, const int h, const vga_color_t background_color );
void widget_draw( void *obj, graphics_context_t *context );
void widget_get_focus( void *obj, widget_t *widget );