[api] header outlining the desired API

This commit is contained in:
Milo Turner 2020-02-07 16:36:50 -05:00
commit 187cc164cb
2 changed files with 106 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*-prototyping
**/compiled
_build
.dir-locals.el

102
src/ax.h Normal file
View File

@ -0,0 +1,102 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
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