From 187cc164cb2da8a02f8fc2e0efa2aced47791f0b Mon Sep 17 00:00:00 2001 From: Milo Turner Date: Fri, 7 Feb 2020 16:36:50 -0500 Subject: [PATCH] [api] header outlining the desired API --- .gitignore | 4 +++ src/ax.h | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 .gitignore create mode 100644 src/ax.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ac080e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*-prototyping +**/compiled +_build +.dir-locals.el \ No newline at end of file diff --git a/src/ax.h b/src/ax.h new file mode 100644 index 0000000..fc04ccd --- /dev/null +++ b/src/ax.h @@ -0,0 +1,102 @@ +#pragma once +#include +#include +#include + +struct ax_ctxt; +struct ax_theme; +struct ax_window; + +/* ----------------------------------------------------------------------------- + * Context + * -------------------------------------------------------------------------- */ + +struct ax_ctxt* ax_new(void); +void ax_free(struct ax_ctxt* ax); + +const char* ax_get_error(struct ax_ctxt* ax); + +void ax_set_logger_fd(struct ax_ctxt* ax, int fd); +void ax_log(struct ax_ctxt* ax, const char* string); + +/* ----------------------------------------------------------------------------- + * Themes + * -------------------------------------------------------------------------- */ + +void ax_begin_theme(struct ax_ctxt* ax); +void ax_set_theme_color(struct ax_ctxt* ax, const char* name, + uint64_t rgb); +void ax_set_theme_font(struct ax_ctxt* ax, + const char* fnt_cat, + const char* fnt_path, + size_t fnt_size); +void ax_set_theme_iconset(struct ax_ctxt* ax, + const char* iconset_dir); +int ax_end_theme(struct ax_ctxt* ax, struct ax_theme** out_thm); + +void ax_select_theme(struct ax_ctxt* ax, struct ax_theme* thm); + +/* ----------------------------------------------------------------------------- + * Windows + * -------------------------------------------------------------------------- */ + +void ax_begin_window(struct ax_ctxt* ax); +void ax_set_window_title(struct ax_ctxt* ax, const char* text); +void ax_set_window_size(struct ax_ctxt* ax, uint64_t w, uint64_t h, bool resize); +int ax_end_window(struct ax_ctxt* ax, struct ax_window** out_win); + +void ax_select_window(struct ax_ctxt* ax, struct ax_window* win); + +/* ----------------------------------------------------------------------------- + * Cursor + * -------------------------------------------------------------------------- */ + +bool ax_is_cursor_valid(struct ax_ctxt* ax); + +void ax_root(struct ax_ctxt* ax); +int ax_up(struct ax_ctxt* ax); +int ax_down(struct ax_ctxt* ax, size_t child_idx); +int ax_commit(struct ax_ctxt* ax); + +/* ----------------------------------------------------------------------------- + * Nodes + * -------------------------------------------------------------------------- */ + +void ax_container(struct ax_ctxt* ax); + +void ax_text(struct ax_ctxt* ax, + struct ax_theme* thm, + const char* fnt_cat, + const char* text); + +void ax_icon(struct ax_ctxt* ax, + struct ax_theme* thm, + const char* icn_name); + +int ax_set_i(struct ax_ctxt* ax, int prop, int64_t v); +int ax_set_s(struct ax_ctxt* ax, int prop, const char* v); +int ax_unset(struct ax_ctxt* ax, int prop); + +// general properties +#define AX_PROP_HORI_PADDING 0x001 // default = 0 +#define AX_PROP_VERT_PADDING 0x002 // default = 0 +#define AX_PROP_COLUMNS 0x003 // default = (none) +#define AX_PROP_GROW 0x004 // default = 0 +#define AX_PROP_SHRINK 0x005 // default = 12 +#define AX_PROP_BG_COLOR 0x006 // default = (none) +#define AX_PROP_FG_COLOR 0x007 // default = "#000000" + +// container properties +#define AX_PROP_N_COLUMNS 0x101 // default = (none) +#define AX_PROP_COLUMN_SEP 0x102 // default = 0 + +// text properties +#define AX_PROP_TEXT_ALIGN 0x201 // default = left +#define AX_PROP_TEXT_WRAP_COLS 0x202 // default = (none) + +#define AX_TEXT_ALIGN_LEFT 0 +#define AX_TEXT_ALIGN_RIGHT 1 +#define AX_TEXT_ALIGN_CENTER 2 + +// icon properties +#define AX_PROP_ICON_SCALE 0x401 // default = 24