|
@@ -39,6 +39,8 @@ typedef int zori_id;
|
|
|
#define zori_font_drawstr(FONT, COLOR, X, Y, ATTR, TEXT) al_draw_ustr(FONT, COLOR, X, Y, ATTR, TEXT)
|
|
|
|
|
|
|
|
|
+
|
|
|
+/* Zori ID's. */
|
|
|
#define ZORI_ID_OK_P(ID) ((ID) > -1)
|
|
|
#define ZORI_ID_OK ((zori_id)(0))
|
|
|
#define ZORI_ID_ERROR ((zori_id)(-1))
|
|
@@ -51,10 +53,9 @@ typedef int zori_id;
|
|
|
This macro returns, for the given pointer, a pointer to a containing struct
|
|
|
of type TYPE, in which PTR is a member named MEMBER.
|
|
|
This enables cool ways of type genericity and extension in plain C.
|
|
|
- It does not run afoul of strict aliasing since it passes over a char * pointer
|
|
|
+ It should not run afoul of strict aliasing since it passes over a char * pointer
|
|
|
and a pointer of a containing struct or union.
|
|
|
*/
|
|
|
-
|
|
|
#define ZORI_CONTAINER_OF(PTR, TYPE, MEMBER) \
|
|
|
((TYPE *)(((char *)(PTR)) - offsetof(TYPE, MEMBER)))
|
|
|
|
|
@@ -151,7 +152,6 @@ static inline zori_system_event * zori_event_system_event(union zori_event * eve
|
|
|
return event->sys.sysev;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/* Helper functions to set widget for an event. */
|
|
|
static inline struct zori_widget *
|
|
|
zori_event_set_widget(union zori_event * event, struct zori_widget * widget) {
|
|
@@ -159,20 +159,20 @@ zori_event_set_widget(union zori_event * event, struct zori_widget * widget) {
|
|
|
return event->any.widget = widget;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/* Helper functions to set data for an event. */
|
|
|
static inline void * zori_event_set_data(union zori_event * event, void * data) {
|
|
|
if (!event) return NULL;
|
|
|
return event->any.data = data;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+/* A style part is a color, image and font applied to a part of the GUI. */
|
|
|
struct zori_stylepart {
|
|
|
zori_color color;
|
|
|
zori_bitmap * image;
|
|
|
zori_font * font;
|
|
|
};
|
|
|
|
|
|
+/* A style is a set of style parts for different parts of the GUI. */
|
|
|
struct zori_style {
|
|
|
struct zori_stylepart fore;
|
|
|
struct zori_stylepart back;
|
|
@@ -309,18 +309,6 @@ struct zori_root {
|
|
|
/* Forward declaration of a page. */
|
|
|
struct zori_page;
|
|
|
|
|
|
-/* The top level widget for a single display. */
|
|
|
-struct zori_screen {
|
|
|
- /* A screen is a widget. */
|
|
|
- struct zori_widget widget;
|
|
|
- /* It also manages the cursors. */
|
|
|
- struct zori_cursors cursors;
|
|
|
- /* Display this screen is on. */
|
|
|
- zori_display * display;
|
|
|
- /* The GUI page that is active on this screen if any. */
|
|
|
- struct zori_page * active_page;
|
|
|
-};
|
|
|
-
|
|
|
|
|
|
/* In Zori, the GUI is paginated. This means that on any
|
|
|
* screen, only a single GUI page can be active. The intent is to
|
|
@@ -331,6 +319,9 @@ struct zori_page {
|
|
|
struct zori_widget widget;
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+struct zori_root * zori_get_root(void);
|
|
|
+
|
|
|
/* Initializes Zori and creates a top level widget. Returns 0 on success
|
|
|
* or negative on error. The style will be copied and set as default
|
|
|
* if it is not NULL. Otherwise a built-in style will be used.
|
|
@@ -345,7 +336,6 @@ zori_id zori_shutdown();
|
|
|
|
|
|
/* Creates a new screen widget. Normally this should be the first widget
|
|
|
* you create after zori_start. */
|
|
|
-zori_id zori_new_screen(zori_display * display);
|
|
|
|
|
|
/* Creates a new page widget on the given screen. The page is not
|
|
|
* made the active page, unless if it is the first one created. */
|
|
@@ -420,9 +410,9 @@ zori_id zori_start(struct zori_style *default_style);
|
|
|
struct zori_widget *zori_widget_done(struct zori_widget *widget);
|
|
|
void zori_widget_free(struct zori_widget *widget);
|
|
|
struct zori_widget *zori_widget_add_child(struct zori_widget *parent, struct zori_widget *child);
|
|
|
-struct zori_widget *zori_widget_init(struct zori_widget *widget, struct zori_widget *parent, zori_rebox *box, struct zori_style *style);
|
|
|
+struct zori_widget *zori_widget_init(struct zori_widget *widget, zori_id id, struct zori_widget *parent, zori_rebox *box, struct zori_style *style);
|
|
|
zori_id zori_shutdown(void);
|
|
|
-struct zori_widget *zori_widget_initall(struct zori_widget *widget, struct zori_widget *parent, zori_rebox *box, struct zori_style *style, size_t amount, struct zori_handler *handlers);
|
|
|
+struct zori_widget *zori_widget_initall(struct zori_widget *widget, zori_id id, struct zori_widget *parent, zori_rebox *box, struct zori_style *style, size_t amount, struct zori_handler *handlers);
|
|
|
void zori_draw_all(void);
|
|
|
int zori_widget_visible(struct zori_widget *widget);
|
|
|
int zori_widget_active(struct zori_widget *widget);
|