Started splitting the shared control code into portable and non-portable files. This handles the portable part; the non-portable part comes next.
This commit is contained in:
parent
025b00a6ac
commit
2ff913cd58
1
TODO.md
1
TODO.md
|
@ -1,3 +1,4 @@
|
||||||
|
- make the various onDestroy() functions take the uiControl instead
|
||||||
- make sure all calls to uiControlResize() are preceded with calls to uiControlGetSizing()
|
- make sure all calls to uiControlResize() are preceded with calls to uiControlGetSizing()
|
||||||
|
|
||||||
- require explicit calls to uiContainerUpdate() everywhere, because sigh...
|
- require explicit calls to uiContainerUpdate() everywhere, because sigh...
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
// 6 april 2015
|
||||||
|
#include "uipriv_windows.h"
|
||||||
|
|
||||||
|
struct singleControl {
|
||||||
|
void *internal;
|
||||||
|
uiControl *parent;
|
||||||
|
int userHidden;
|
||||||
|
int containerHidden;
|
||||||
|
int userDisabled;
|
||||||
|
int containerDisabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void singleDestroy(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
if (s->parent != NULL)
|
||||||
|
complain("attempt to destroy a uiControl at %p while it still has a parent", c);
|
||||||
|
osOnDestroy(s->internal);
|
||||||
|
uiFree(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uintptr_t singleHandle(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
return osSingleHandle(s->internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uiControl *singleParent(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
return s->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleSetParent(uiControl *c, uiControl *parent)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
uiControl *oldparent;
|
||||||
|
|
||||||
|
oldparent = s->parent;
|
||||||
|
s->parent = parent;
|
||||||
|
osSingleSetParent(s->internal, oldparent, s->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
osSingleResize(s->internal, x, y, width, height, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleQueueResize(uiControl *c)
|
||||||
|
{
|
||||||
|
queueResize(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uiSizing *singleSizing(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
return osSingleSizing(s->internal, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int singleContainerVisible(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
return !s->userHidden && !s->containerHidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleShow(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->userHidden = 0;
|
||||||
|
if (!s->containerHidden)
|
||||||
|
osSingleShow(s->internal);
|
||||||
|
if (s->parent != NULL)
|
||||||
|
uiControlQueueResize(s->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleHide(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->userHidden = 1;
|
||||||
|
osSingleHide(s->internal);
|
||||||
|
if (s->parent != NULL)
|
||||||
|
uiControlQueueResize(s->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleContainerShow(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->containerHidden = 0;
|
||||||
|
if (!s->userHidden)
|
||||||
|
osSingleShow(s->internal);
|
||||||
|
if (s->parent != NULL)
|
||||||
|
uiControlQueueResize(s->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleContainerHide(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->containerHidden = 1;
|
||||||
|
osSingleHide(s->internal);
|
||||||
|
if (s->parent != NULL)
|
||||||
|
uiControlQueueResize(s->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleEnable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->userDisabled = 0;
|
||||||
|
if (!s->containerDisabled)
|
||||||
|
osSingleEnable(s->internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleDisable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->userDisabled = 1;
|
||||||
|
osSingleDisable(s->internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleContainerEnable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->containerDisabled = 0;
|
||||||
|
if (!s->userDisabled)
|
||||||
|
osSingleEnable(s->internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void singleContainerDisable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct singleControl *s = (struct singleControl *) (c->Internal);
|
||||||
|
|
||||||
|
s->containerDisabled = 1;
|
||||||
|
osSingleDisable(s->internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
void makeControl(uiControl *c, void *internal)
|
||||||
|
{
|
||||||
|
struct singleControl *s;
|
||||||
|
|
||||||
|
s = uiNew(struct singleControl);
|
||||||
|
|
||||||
|
s->internal = internal;
|
||||||
|
|
||||||
|
uiControl(c)->Internal = s;
|
||||||
|
uiControl(c)->Destroy = singleDestroy;
|
||||||
|
uiControl(c)->Handle = singleHandle;
|
||||||
|
uiControl(c)->Parent = singleParent;
|
||||||
|
uiControl(c)->SetParent = singleSetParent;
|
||||||
|
// PreferredSize() implemented by the individual controls
|
||||||
|
uiControl(c)->Resize = singleResize;
|
||||||
|
uiControl(c)->QueueResize = singleQueueResize;
|
||||||
|
uiControl(c)->Sizing = singleSizing;
|
||||||
|
uiControl(c)->ContainerVisible = singleContainerVisible;
|
||||||
|
uiControl(c)->Show = singleShow;
|
||||||
|
uiControl(c)->Hide = singleHide;
|
||||||
|
uiControl(c)->ContainerShow = singleContainerShow;
|
||||||
|
uiControl(c)->ContainerHide = singleContainerHide;
|
||||||
|
uiControl(c)->Enable = singleEnable;
|
||||||
|
uiControl(c)->Disable = singleDisable;
|
||||||
|
uiControl(c)->ContainerEnable = singleContainerEnable;
|
||||||
|
uiControl(c)->ContainerDisable = singleContainerDisable;
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ extern void uiFree(void *);
|
||||||
|
|
||||||
extern void complain(const char *, ...);
|
extern void complain(const char *, ...);
|
||||||
|
|
||||||
// array.c
|
// ptrarray.c
|
||||||
struct ptrArray {
|
struct ptrArray {
|
||||||
void **ptrs;
|
void **ptrs;
|
||||||
uintmax_t len;
|
uintmax_t len;
|
||||||
|
@ -25,3 +25,15 @@ void ptrArrayDelete(struct ptrArray *, uintmax_t);
|
||||||
|
|
||||||
// shouldquit.c
|
// shouldquit.c
|
||||||
int shouldQuit(void);
|
int shouldQuit(void);
|
||||||
|
|
||||||
|
// control.c
|
||||||
|
extern void osSingleDestroy(void *);
|
||||||
|
extern uintptr_t osSingleHandle(void *);
|
||||||
|
extern void osSingleSetParent(void *, uiControl *, uiControl *);
|
||||||
|
extern void osSingleResize(void *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
|
||||||
|
extern uiSizing *osSingleSizing(void *, uiControl *);
|
||||||
|
extern void osSingleShow(void *);
|
||||||
|
extern void osSingleHide(void *);
|
||||||
|
extern void osSingleEnable(void *);
|
||||||
|
extern void osSingleDisable(void *);
|
||||||
|
extern void makeControl(uiControl *, void *);
|
||||||
|
|
Loading…
Reference in New Issue