summaryrefslogtreecommitdiff
path: root/guifs.h
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2024-02-11 00:04:31 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2024-02-11 00:04:31 +0000
commit7c6a945996a1d5510ff1412320ac7d07a0f82851 (patch)
treef77259f26b5c33307ba8ebc670951ed0acce1b00 /guifs.h
parentb5a96b97ee2f3fd30e5935d2b3c2c6e0d96c4640 (diff)
Start working on it
Diffstat (limited to 'guifs.h')
-rw-r--r--guifs.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/guifs.h b/guifs.h
new file mode 100644
index 0000000..6b5ef53
--- /dev/null
+++ b/guifs.h
@@ -0,0 +1,87 @@
+enum {
+ Pbackground,
+ Pmax,
+};
+
+enum {
+ Gnone,
+ Gcontainer,
+ Gmax,
+};
+typedef struct Colour Colour;
+typedef union PropVal PropVal;
+typedef struct PropSpec PropSpec;
+typedef struct Prop Prop;
+typedef struct GuiSpec GuiSpec;
+typedef struct GuiElement GuiElement;
+
+struct Colour {
+ Image *image;
+ ulong code;
+};
+
+union PropVal {
+ Colour *colour;
+};
+
+struct PropSpec {
+ char *name;
+ PropVal (*def)(void);
+ char *(*print)(PropVal);
+ char *(*parse)(char *, PropVal *);
+};
+
+struct Prop {
+ int tag;
+ PropVal val;
+ Qid qid;
+};
+
+struct GuiSpec {
+ char *name;
+ void (*draw)(GuiElement *);
+ void (*layout)(GuiElement *, Rectangle);
+ int nprops;
+ int proptags[];
+};
+
+struct GuiElement {
+ int type;
+ int id;
+
+ Qid qid;
+ Qid qclone;
+ Qid qevent;
+ Qid qtype;
+ Qid qprops;
+
+ int nchildren;
+ GuiElement **children;
+
+ GuiElement *parent;
+
+ int nprops;
+ Prop *props;
+
+ Rectangle rect;
+
+};
+
+extern GuiElement *root;
+extern PropSpec propspecs[Pmax];
+extern GuiSpec guispecs[Gmax];
+
+void *emalloc(ulong);
+
+Colour *mkcolour(ulong);
+void initgraphics(void);
+void layout(GuiElement *, Rectangle);
+void updategui(int);
+void drawnone(GuiElement *);
+void drawcontainer(GuiElement *);
+
+void layoutnone(GuiElement *, Rectangle);
+void layoutcontainer(GuiElement *, Rectangle);
+
+PropVal getprop(GuiElement *, int);
+void setprop(GuiElement *, int, PropVal); \ No newline at end of file