diff --git a/src/ctxt.h b/src/ctxt.h index 747477e..f9b591a 100644 --- a/src/ctxt.h +++ b/src/ctxt.h @@ -11,6 +11,7 @@ struct ax_window; struct ax_window_builder; struct ax_backend; struct ax_evt_list; +struct ax_graphics; struct ax_ctxt { struct rgn* init_rgn; diff --git a/src/ctxt/window.c b/src/ctxt/window.c index 1c9aa6a..a41d22d 100644 --- a/src/ctxt/window.c +++ b/src/ctxt/window.c @@ -1,6 +1,7 @@ +#include "window.h" #include "../concurrent/msg.h" #include "../concurrent/msgq.h" -#include "window.h" +#include "../geom/graphics.h" static inline const char* default_title(struct rgn* rgn) { @@ -24,6 +25,8 @@ struct ax_window_builder* ax__window_builder_new(struct rgn* rgn) return winb; } +static void draw_demo(struct ax_graphics* gr); + struct ax_window* ax__window_builder_finish( struct ax_window_builder* winb, struct rgn* dst_rgn, @@ -33,6 +36,8 @@ struct ax_window* ax__window_builder_finish( ralloc_typed(dst_rgn, struct ax_window, 1); pthread_mutex_init(&win->mx, NULL); rgn_pin(dst_rgn, &win->mx, (void*) pthread_mutex_destroy); + win->graphics = ax__graphics_new(dst_rgn); + draw_demo(win->graphics); struct ax_msg_make_window* m = msgq_begin_send_typed(req_window_mq, ax_msg_make_window); @@ -45,3 +50,26 @@ struct ax_window* ax__window_builder_finish( return win; } + +static void draw_demo(struct ax_graphics* gr) +{ + struct ax_glyph* g; + + ax__graphics_clear(gr, 0xffffff); + + g = ax__graphics_push(gr); + g->ty = AX_GLYPH_RECT; + g->d.rect.x = 5; + g->d.rect.y = 5; + g->d.rect.w = 300; + g->d.rect.h = 200; + g->d.rect.f = 0xcc0044; + + g = ax__graphics_push(gr); + g->ty = AX_GLYPH_RECT; + g->d.rect.x = 75; + g->d.rect.y = 23; + g->d.rect.w = 150; + g->d.rect.h = 400; + g->d.rect.f = 0x4444ff; +} diff --git a/src/ctxt/window.h b/src/ctxt/window.h index e116405..b09eb8c 100644 --- a/src/ctxt/window.h +++ b/src/ctxt/window.h @@ -7,7 +7,7 @@ struct msgq; struct ax_backend; -struct ax_window_h; +struct ax_graphics; #define WINDOW_BUILDER_DESIRED_REGION_SIZE SMALL @@ -17,6 +17,7 @@ enum ax_window_flags { struct ax_window { pthread_mutex_t mx; + struct ax_graphics* graphics; }; struct ax_window_builder { diff --git a/src/util.h b/src/util.h index 412fc63..35238e2 100644 --- a/src/util.h +++ b/src/util.h @@ -19,7 +19,7 @@ ASSERT(0, "not implemented") #define IMPOSSIBLE_(what) \ - ASSERT(0, "unreachable: " what) + ASSERT(0, "unreachable: %s", what) // hard to explain why this is necessary ... #define IMPOSSIBLE(x) IMPOSSIBLE_(x)