Big change time: decided to stop playing around with hiding and made both uiControl and uiSizing public. Also restructured uiSizing to make system-dependent data in another structure.

This commit is contained in:
Pietro Gagliardi 2015-04-09 16:37:04 -04:00
parent b60ff74a9e
commit 6d600f08cd
2 changed files with 21 additions and 27 deletions

21
ui.h
View File

@ -17,9 +17,30 @@ void uiQuit(void);
void uiFreeText(char *); void uiFreeText(char *);
typedef struct uiSizing uiSizing;
struct uiSizing {
intmax_t xPadding;
intmax_t yPadding;
struct uiSizingSys *sys;
};
typedef struct uiControl uiControl; typedef struct uiControl uiControl;
struct uiControl {
void *data; // for use by implementations only
void *internal; // for use by ui only
void (*destroy)(uiControl *);
uintptr_t (*handle)(uiControl *);
void (*setParent)(uiControl *, uintptr_t);
void (*removeParent)(uiControl *);
void (*preferredSize)(uiControl *, uiSizing *, intmax_t *, intmax_t *);
void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
};
void uiControlDestroy(uiControl *); void uiControlDestroy(uiControl *);
uintptr_t uiControlHandle(uiControl *); uintptr_t uiControlHandle(uiControl *);
void uiControlSetParent(uiControl *, uintptr_t);
void uiControlRemoveParent(uiControl *);
void uiControlPreferredSize(uiControl *, uiSizing *, intmax_t *width, intmax_t *height);
void uiControlResize(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
typedef struct uiWindow uiWindow; typedef struct uiWindow uiWindow;
uiWindow *uiNewWindow(char *, int, int); uiWindow *uiNewWindow(char *, int, int);

View File

@ -2,33 +2,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "ui.h" #include "ui.h"
typedef struct uiSize uiSize;
typedef struct uiSizing uiSizing;
typedef struct uiSizingComm uiSizingComm;
struct uiSize {
intmax_t width;
intmax_t height;
};
// TODO this is a bit iffy; clean it up
#define uiSizingCommon \
intmax_t xPadding; \
intmax_t yPadding;
struct uiSizingComm {
uiSizingCommon
};
struct uiControl {
void (*destroy)(uiControl *);
uintptr_t (*handle)(uiControl *);
void (*setParent)(uiControl *, uintptr_t);
void (*removeParent)(uiControl *);
uiSize (*preferredSize)(uiControl *, uiSizing *);
void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
};
// uncomment the following line to enable memory logging; see leaks.awk // uncomment the following line to enable memory logging; see leaks.awk
#define uiLogAllocations #define uiLogAllocations