summaryrefslogtreecommitdiff
path: root/src/gui/desktop.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-30 16:45:12 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-30 16:45:12 +0200
commitc1bbac52d78b2e3e93fa43a5a7b3907073493216 (patch)
tree13ec009562358d01b1845dd08135f4ac8d384551 /src/gui/desktop.c
parent915dd4b023d0826166d4887100dbed64d46821a9 (diff)
downloadabaos-c1bbac52d78b2e3e93fa43a5a7b3907073493216.tar.gz
abaos-c1bbac52d78b2e3e93fa43a5a7b3907073493216.tar.bz2
text widget has a constant buffer and owns the string to draw now
(passing a const char * from a local stack context is not really a good idea!) added more efficiet draw method for characters in vga driver protected desktop for now against too often redraws (boolean global variable needs_redraw, this is later a soffisticated set-of-areas-to -redraw algorithm)
Diffstat (limited to 'src/gui/desktop.c')
-rw-r--r--src/gui/desktop.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gui/desktop.c b/src/gui/desktop.c
index 6592b52..ad4aad9 100644
--- a/src/gui/desktop.c
+++ b/src/gui/desktop.c
@@ -28,6 +28,7 @@ void desktop_init( desktop_t *desktop, const int w, const int h, const vga_color
desktop->mouse_x = w / 2;
desktop->mouse_y = h / 2;
+ desktop->needs_redrawing = true;
desktop->base.base.vtable = (widget_vtable_t *)&desktop_vtable;
desktop->base.vtable = (composite_widget_vtable_t *)&desktop_vtable;
@@ -38,6 +39,10 @@ void desktop_draw( void *obj, graphics_context_t *context )
{
desktop_t *desktop = obj;
+ if( !desktop->needs_redrawing ) {
+ return;
+ }
+
vga_clear_screen( context, desktop->base.base.background_color );
composite_widget_draw( obj, context );
@@ -56,16 +61,26 @@ void desktop_draw( void *obj, graphics_context_t *context )
vga_set_pixel( context, desktop->mouse_x, desktop->mouse_y + i, VGA_COLOR_WHITE );
}
}
+
+ desktop->needs_redrawing = false;
}
void desktop_on_mouse_down( void *obj, const int x, const int y )
{
+ desktop_t *desktop = obj;
+
composite_widget_on_mouse_down( obj, x, y );
+
+ desktop->needs_redrawing = true;
}
void desktop_on_mouse_up( void *obj, const int x, const int y )
{
+ desktop_t *desktop = obj;
+
composite_widget_on_mouse_up( obj, x, y );
+
+ desktop->needs_redrawing = true;
}
void desktop_on_mouse_move( void *obj, const int old_x, const int old_y, const int x, const int y )
@@ -76,4 +91,6 @@ void desktop_on_mouse_move( void *obj, const int old_x, const int old_y, const i
desktop->mouse_y = y;
composite_widget_on_mouse_move( obj, old_x, old_y, x, y );
+
+ desktop->needs_redrawing = true;
}