Hash :
753fe464
Author :
Thomas de Grivel
Date :
2023-12-04T20:11:58
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
/* c3
* Copyright 2022,2023 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include <assert.h>
#include <stdlib.h>
#include <xkbcommon/xkbcommon.h>
#include <libc3/tag.h>
#include "window_cairo.h"
void c3_window_cairo_clean (void)
{
}
void c3_window_cairo_init (void)
{
}
s_window_cairo * window_cairo_init (s_window_cairo *window,
sw x, sw y, uw w, uw h,
const s8 *title,
uw sequence_count)
{
assert(window);
window->x = x;
window->y = y;
window->w = w;
window->h = h;
window->button = window_cairo_button_default;
window->key = window_cairo_key_default;
window->load = window_cairo_load_default;
window->motion = window_cairo_motion_default;
window->render = window_cairo_render_default;
window->resize = window_cairo_resize_default;
window->cr = NULL;
window->sequence = calloc(sequence_count, sizeof(s_sequence));
window->sequence_count = sequence_count;
window->sequence_pos = 0;
window->title = title ? title : "C3.Window.Cairo";
return window;
}
bool window_cairo_button_default (s_window_cairo *window, u8 button,
sw x, sw y)
{
assert(window);
(void) window;
(void) button;
(void) x;
(void) y;
printf("window_cairo_button_default: %d (%ld, %ld)\n",
(int) button, x, y);
return true;
}
bool window_cairo_key_default (s_window_cairo *window, uw keysym)
{
char keysym_name[64];
assert(window);
(void) window;
xkb_keysym_get_name(keysym, keysym_name, sizeof(keysym_name));
printf("window_cairo_key_default: %lu %s\n", keysym, keysym_name);
return true;
}
bool window_cairo_load_default (s_window_cairo *window)
{
assert(window);
(void) window;
printf("window_cairo_load_default\n");
return true;
}
bool window_cairo_motion_default (s_window_cairo *window, sw x, sw y)
{
assert(window);
(void) window;
(void) x;
(void) y;
/*
printf("window_cairo_motion_default (%ld, %ld)\n", x, y);
*/
return true;
}
bool window_cairo_render_default (s_window_cairo *window, cairo_t *cr)
{
assert(window);
assert(cr);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_rectangle(cr, 0, 0, window->w, window->h);
cairo_fill(cr);
printf("window_cairo_render_default\n");
return true;
}
bool window_cairo_resize_default (s_window_cairo *window, uw w, uw h)
{
assert(window);
(void) window;
(void) w;
(void) h;
printf("window_cairo_resize_default: %lu x %lu\n", w, h);
return true;
}
s_sequence * window_cairo_sequence_init
(s_sequence *seq, f64 duration, const s8 *title,
f_window_cairo_sequence_load load,
f_window_cairo_sequence_render render)
{
assert(seq);
seq->t = 0.0;
seq->duration = duration;
seq->title = title;
seq->load = (f_sequence_load) load;
seq->render = (f_sequence_render) render;
tag_init_void(&seq->tag);
return seq;
}