summaryrefslogtreecommitdiff
path: root/examples/tablet.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tablet.c')
-rw-r--r--examples/tablet.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/examples/tablet.c b/examples/tablet.c
index f392cdc..01dcdfc 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -140,44 +140,40 @@ static void stroke(struct app *app)
app->previous = true;
}
-static int input(void *ud, const struct yasl_event *event)
+static enum yasl_app_result input(void *ud, const struct yasl_event *event)
{
struct app *app = ud;
- if (event->type == YASL_EVENT_WINDOW_CLOSE_REQUEST)
+ if (event->type == YASL_EVENT_WINDOW_CLOSE)
return YASL_APP_QUIT;
if (event->type == YASL_EVENT_WINDOW_RESIZE) {
- if (!resize_canvas(app, (struct yasl_geometry){event->resize.size, event->resize.scale_120})) {
+ if (!resize_canvas(app, event->resize.geometry)) {
app->failed = true;
return YASL_APP_QUIT;
}
- } else if (event->type == YASL_EVENT_INPUT_RESET || event->type == YASL_EVENT_MOUSE_LEAVE ||
- (event->type == YASL_EVENT_WINDOW_FOCUS && !event->focus.focused)) {
+ } else if (event->type == YASL_EVENT_INPUT_RESET || event->type == YASL_EVENT_POINTER_LEAVE ||
+ (event->type == YASL_EVENT_FOCUS && !event->focus.focused)) {
cancel_stroke(app);
} else if (event->type == YASL_EVENT_KEY && event->key.action == YASL_KEY_PRESS) {
if (event->key.key == YASL_KEY_ESCAPE) return YASL_APP_QUIT;
if (event->key.key == YASL_KEY_C || event->key.key == YASL_KEY_SPACE)
clear_canvas(app);
- } else if (event->type == YASL_EVENT_MOUSE_BUTTON) {
- if (app->pointer.device != event->mouse_button.device) cancel_stroke(app);
- app->pointer.pos = event->mouse_button.pos;
- app->pointer.device = event->mouse_button.device;
- app->pointer.pen = event->mouse_button.pen;
+ } else if (event->type == YASL_EVENT_POINTER_DOWN || event->type == YASL_EVENT_POINTER_UP ||
+ event->type == YASL_EVENT_POINTER_MOTION) {
+ if (app->pointer.device != event->pointer.device) cancel_stroke(app);
+ app->pointer.pos = event->pointer.pos;
+ app->pointer.device = event->pointer.device;
+ app->pointer.pen = event->pointer.pen;
app->visible = true;
- if (event->mouse_button.pressed && event->mouse_button.button == 0) {
+ if (event->type == YASL_EVENT_POINTER_DOWN && event->pointer.button == YASL_BUTTON_PRIMARY) {
app->down = true;
app->previous = false;
stroke(app);
- } else if (!event->mouse_button.pressed && event->mouse_button.button == 0) {
+ } else if (event->type == YASL_EVENT_POINTER_UP && event->pointer.button == YASL_BUTTON_PRIMARY) {
app->down = app->previous = false;
app->pointer.pen.pressure = 0;
+ } else if (event->type == YASL_EVENT_POINTER_MOTION) {
+ if (app->down) stroke(app);
}
- } else if (event->type == YASL_EVENT_MOUSE_MOTION) {
- if (app->pointer.device != event->mouse_motion.device) cancel_stroke(app);
- app->pointer.pos = event->mouse_motion.pos;
- app->pointer.device = event->mouse_motion.device;
- app->pointer.pen = event->mouse_motion.pen;
- app->visible = true;
- if (app->down) stroke(app);
} else {
return YASL_APP_CONTINUE;
}
@@ -293,7 +289,7 @@ static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_conte
}
}
-static int init(void *ud, struct yasl_display *display)
+static enum yasl_app_result init(void *ud, struct yasl_display *display)
{
struct app *app = ud;
app->backend = yasl_display_backend(display);
@@ -307,7 +303,7 @@ static int init(void *ud, struct yasl_display *display)
app->failed = true;
return YASL_APP_QUIT;
}
- yasl_surface_set_mouse_mode(app->surface, YASL_MOUSE_HIDDEN);
+ yasl_surface_set_cursor(app->surface, YASL_CURSOR_HIDDEN);
yasl_surface_request_frame(app->surface);
printf("YASL tablet on %s: pressure changes brush width; eraser removes ink.\n"
"Mouse: fixed-width drawing. C/Space: clear. Escape: quit.\n",