[window] more structured way of doing 'demo drawing'

This commit is contained in:
Milo Turner 2020-03-04 20:32:01 -05:00
parent 9ef6fc0b12
commit b221fff192
5 changed files with 31 additions and 4 deletions

View File

@ -57,6 +57,8 @@ void ax_set_window_size(
int ax_select_window(struct ax_ctxt* ax, struct ax_window* win);
int ax_show_demo(struct ax_ctxt* ax);
/* -----------------------------------------------------------------------------
* Cursor
* -------------------------------------------------------------------------- */

View File

@ -252,6 +252,23 @@ int ax_select_window(struct ax_ctxt* ax, struct ax_window* win)
return 0;
}
int ax_show_demo(struct ax_ctxt* ax)
{
if (ax->sel_win == NULL) {
ax->err = "no window slected";
return 1;
}
if (ax->sel_thm == NULL) {
ax->err = "no theme slected";
return 1;
}
log_writelnf(ax->root_lg,
"drawing demo graphics (win=%p, thm=%p)",
ax->sel_win, ax->sel_thm);
ax__window_draw_demo(ax->sel_win, ax->sel_thm);
return 0;
}
/* -----------------------------------------------------------------------------
* Backend worker thread
* -------------------------------------------------------------------------- */

View File

@ -2,6 +2,7 @@
#include "../concurrent/msg.h"
#include "../concurrent/msgq.h"
#include "../geom/graphics.h"
#include "../ctxt/theme.h"
static inline const char* default_title(struct rgn* rgn)
{
@ -25,8 +26,6 @@ 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,
@ -37,7 +36,7 @@ struct ax_window* ax__window_builder_finish(
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);
// draw_demo(win->graphics);
struct ax_msg_make_window* m =
msgq_begin_send_typed(req_window_mq, ax_msg_make_window);
@ -51,8 +50,11 @@ struct ax_window* ax__window_builder_finish(
return win;
}
static void draw_demo(struct ax_graphics* gr)
void ax__window_draw_demo(
struct ax_window* win,
struct ax_theme* thm)
{
struct ax_graphics* gr = win->graphics;
struct ax_glyph* g;
ax__graphics_clear(gr, 0xffffff);

View File

@ -7,6 +7,7 @@
struct msgq;
struct ax_backend;
struct ax_theme;
struct ax_graphics;
#define WINDOW_BUILDER_DESIRED_REGION_SIZE SMALL
@ -61,3 +62,7 @@ static inline void ax__window_set_flag(
winb->flags &= ~((int) f);
}
}
void ax__window_draw_demo(
struct ax_window* win,
struct ax_theme* thm);

View File

@ -69,6 +69,7 @@ int main(void)
GUARD(ax_select_theme(ax, thm));
GUARD(ax_select_window(ax, win));
GUARD(ax_show_demo(ax));
struct sub* ev_sub = ax__backend_sub_events(ax->bac, rgn);
for (bool quit = false; !quit; ) {