[draw] windows store their graphics

This commit is contained in:
Milo Turner 2020-03-03 16:03:28 -05:00
parent a53264e4fc
commit bf8bcd7017
4 changed files with 33 additions and 3 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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 {

View File

@ -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)