summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-21 17:39:00 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-21 17:39:00 +0200
commitf05524445914e31891ec227520d9bb3fe5857e2c (patch)
tree219f38ac0d3be60dda3613b892b51cae0fee9ec9 /src/gui
parente158c4832aa1d5dc8603fb9c33cac3f7cc19abc9 (diff)
downloadabaos-f05524445914e31891ec227520d9bb3fe5857e2c.tar.gz
abaos-f05524445914e31891ec227520d9bb3fe5857e2c.tar.bz2
improved VGA colors
added basics of a desktop widget class
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/composite_widget.c2
-rw-r--r--src/gui/desktop.c54
-rw-r--r--src/gui/desktop.h24
3 files changed, 80 insertions, 0 deletions
diff --git a/src/gui/composite_widget.c b/src/gui/composite_widget.c
index e9cc166..afef28c 100644
--- a/src/gui/composite_widget.c
+++ b/src/gui/composite_widget.c
@@ -98,6 +98,8 @@ void composite_widget_on_mouse_move( void *obj, const int old_x, const int old_y
composite_widget_t *widget = obj;
widget_t *moved_out_from = NULL;
+ // TODO: have a mouse leave and mouse enter event instead
+
for( int i = 0; i < widget->nof_children; i++ ) {
widget_t *child = widget->children[i];
if( child->vtable->contains_coordinate( child, old_x - widget->base.x, old_y - widget->base.y ) ) {
diff --git a/src/gui/desktop.c b/src/gui/desktop.c
new file mode 100644
index 0000000..39235d2
--- /dev/null
+++ b/src/gui/desktop.c
@@ -0,0 +1,54 @@
+#include "desktop.h"
+
+#include "string.h"
+#include "stddef.h"
+
+static desktop_vtable_t desktop_vtable = {
+ {
+ desktop_draw,
+ composite_widget_get_focus,
+ widget_model_to_screen,
+ widget_contains_coordinate,
+ desktop_on_mouse_down,
+ desktop_on_mouse_up,
+ desktop_on_mouse_move,
+ composite_widget_on_key_down,
+ composite_widget_on_key_up
+ }
+};
+
+void desktop_init( desktop_t *desktop, const int w, const int h )
+{
+ memset( desktop, 0, sizeof( desktop_t ) );
+
+ composite_widget_init( &desktop->base, NULL, 0, 0, w, h );
+
+ desktop->vtable = &desktop_vtable;
+}
+
+void desktop_draw( void *obj, graphics_context_t *context )
+{
+ desktop_t *desktop = obj;
+
+ ((widget_vtable_t *)(desktop->base.vtable))->draw( obj, context );
+
+ // TODO: use a mouse bitmap and copy it
+/*
+ for( int i = 0; i < 4; i++ ) {
+ vga_set_pixel( context,
+void vga_set_pixel( vga_t *vga, const int x, const int y, const vga_color_t color );
+ }
+*/
+}
+
+void desktop_on_mouse_down( void *obj, const int x, const int y )
+{
+}
+
+void desktop_on_mouse_up( void *obj, const int x, const int y )
+{
+}
+
+void desktop_on_mouse_move( void *obj, const int old_x, const int old_y, const int x, const int y )
+{
+}
diff --git a/src/gui/desktop.h b/src/gui/desktop.h
new file mode 100644
index 0000000..b160dc0
--- /dev/null
+++ b/src/gui/desktop.h
@@ -0,0 +1,24 @@
+#ifndef DESKTOP_H
+#define DESKTOP_H
+
+#include "composite_widget.h"
+
+#define MAX_NOF_WIDGET_CHILDREN 100
+
+typedef struct {
+ composite_widget_vtable_t base;
+} desktop_vtable_t;
+
+typedef struct {
+ composite_widget_t base;
+ desktop_vtable_t *vtable;
+} desktop_t;
+
+void desktop_init( desktop_t *widget, const int w, const int h );
+
+void desktop_draw( void *obj, graphics_context_t *context );
+void desktop_on_mouse_down( void *obj, const int x, const int y );
+void desktop_on_mouse_up( void *obj, const int x, const int y );
+void desktop_on_mouse_move( void *obj, const int old_x, const int old_y, const int x, const int y );
+
+#endif // DESKTOP_H