Moved everything up a directory level.
This commit is contained in:
parent
4405001f07
commit
8213eac2d7
|
@ -8,6 +8,8 @@ IDLFILES = \
|
||||||
$(baseIDLFILES)
|
$(baseIDLFILES)
|
||||||
|
|
||||||
xHFILES = \
|
xHFILES = \
|
||||||
|
uipriv.h \
|
||||||
|
$(IDLFILES:%.idl=$(OUTDIR)/%.h) \
|
||||||
$(baseHFILES)
|
$(baseHFILES)
|
||||||
|
|
||||||
OFILES = \
|
OFILES = \
|
||||||
|
@ -61,6 +63,11 @@ $(OBJDIR)/%.o: %.rc $(xHFILES) | $$(dir $$@).phony
|
||||||
@touch $@
|
@touch $@
|
||||||
.PRECIOUS: %/.phony
|
.PRECIOUS: %/.phony
|
||||||
|
|
||||||
|
$(OUTDIR)/%.h: %.idl tools/idl2h.go | $(OUTDIR)/.phony
|
||||||
|
@go run tools/idl2h.go -extern _UI_EXTERN -guard __UI_UI_H__ < $< > $@
|
||||||
|
@echo ====== Generated `basename $@`
|
||||||
|
.PRECIOUS: $(OUTDIR)/%.h
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OUTDIR) $(OBJDIR) z*
|
rm -rf $(OUTDIR) $(OBJDIR) z*
|
||||||
.PHONY: clean
|
.PHONY: clean
|
|
@ -16,8 +16,11 @@ endif
|
||||||
|
|
||||||
include $(OS)/GNUmakeinc.mk
|
include $(OS)/GNUmakeinc.mk
|
||||||
|
|
||||||
|
baseIDLFILES = \
|
||||||
|
ui.idl
|
||||||
|
# ui_$(OS).idl
|
||||||
|
|
||||||
baseHFILES = \
|
baseHFILES = \
|
||||||
ui.h \
|
|
||||||
uipriv.h \
|
uipriv.h \
|
||||||
ui_$(OS).h \
|
ui_$(OS).h \
|
||||||
$(osHFILES)
|
$(osHFILES)
|
|
@ -0,0 +1,153 @@
|
||||||
|
// 26 may 2015
|
||||||
|
#include "out/ui.h"
|
||||||
|
#include "uipriv.h"
|
||||||
|
|
||||||
|
struct controlBase {
|
||||||
|
uiControl *parent;
|
||||||
|
int hidden;
|
||||||
|
int disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
static uintmax_t type_uiControl = 0;
|
||||||
|
|
||||||
|
uintmax_t uiTypeControl(void)
|
||||||
|
{
|
||||||
|
if (type_uiControl == 0)
|
||||||
|
type_uiControl = uiRegisterType("uiControl", 0, 0);
|
||||||
|
return type_uiControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define controlBase(c) ((struct controlBase *) (c->Internal))
|
||||||
|
|
||||||
|
static void controlBaseDestroy(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
if (cb->parent != NULL)
|
||||||
|
complain("attempt to destroy uiControl %p while it has a parent", c);
|
||||||
|
uiControlCommitDestroy(c);
|
||||||
|
uiFree(cb);
|
||||||
|
uiFree(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uiControl *controlBaseParent(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
return cb->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseSetParent(uiControl *c, uiControl *parent)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
if (parent != NULL && cb->parent != NULL)
|
||||||
|
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
||||||
|
if (parent == NULL && cb->parent == NULL)
|
||||||
|
complain("attempt to double unparent uiControl %p", c);
|
||||||
|
// this must come first; GTK+ CommitSetParent() needs the old parent
|
||||||
|
uiControlCommitSetParent(c, parent);
|
||||||
|
cb->parent = parent;
|
||||||
|
// for situations such as where the old parent was disabled but the new one is not, etc.
|
||||||
|
uiControlUpdateState(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseQueueResize(uiControl *c)
|
||||||
|
{
|
||||||
|
queueResize(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int controlBaseContainerVisible(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
if (cb->hidden)
|
||||||
|
return 0;
|
||||||
|
if (cb->parent == NULL)
|
||||||
|
return 1;
|
||||||
|
return uiControlContainerVisible(cb->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseShow(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
cb->hidden = 0;
|
||||||
|
uiControlUpdateState(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseHide(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
cb->hidden = 1;
|
||||||
|
uiControlUpdateState(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int controlBaseContainerEnabled(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
if (cb->disabled)
|
||||||
|
return 0;
|
||||||
|
if (cb->parent == NULL)
|
||||||
|
return 1;
|
||||||
|
return uiControlContainerEnabled(cb->parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseEnable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
cb->disabled = 0;
|
||||||
|
uiControlUpdateState(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseDisable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
cb->disabled = 1;
|
||||||
|
uiControlUpdateState(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseUpdateState(uiControl *c)
|
||||||
|
{
|
||||||
|
if (uiControlContainerVisible(c))
|
||||||
|
uiControlCommitShow(c);
|
||||||
|
else
|
||||||
|
uiControlCommitHide(c);
|
||||||
|
if (uiControlContainerEnabled(c))
|
||||||
|
uiControlCommitEnable(c);
|
||||||
|
else
|
||||||
|
uiControlCommitDisable(c);
|
||||||
|
uiControlContainerUpdateState(c);
|
||||||
|
// and queue a resize, just in case we showed/hid something
|
||||||
|
uiControlQueueResize(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void controlBaseContainerUpdateState(uiControl *c)
|
||||||
|
{
|
||||||
|
// by default not a container; do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
uiControl *uiNewControl(uintmax_t type)
|
||||||
|
{
|
||||||
|
uiControl *c;
|
||||||
|
|
||||||
|
c = uiControl(newTyped(type));
|
||||||
|
uiControl(c)->Internal = uiNew(struct controlBase);
|
||||||
|
uiControl(c)->Destroy = controlBaseDestroy;
|
||||||
|
uiControl(c)->Parent = controlBaseParent;
|
||||||
|
uiControl(c)->SetParent = controlBaseSetParent;
|
||||||
|
uiControl(c)->QueueResize = controlBaseQueueResize;
|
||||||
|
uiControl(c)->ContainerVisible = controlBaseContainerVisible;
|
||||||
|
uiControl(c)->Show = controlBaseShow;
|
||||||
|
uiControl(c)->Hide = controlBaseHide;
|
||||||
|
uiControl(c)->ContainerEnabled = controlBaseContainerEnabled;
|
||||||
|
uiControl(c)->Enable = controlBaseEnable;
|
||||||
|
uiControl(c)->Disable = controlBaseDisable;
|
||||||
|
uiControl(c)->UpdateState = controlBaseUpdateState;
|
||||||
|
uiControl(c)->ContainerUpdateState = controlBaseContainerUpdateState;
|
||||||
|
return uiControl(c);
|
||||||
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
// 29 may 2015
|
// 29 may 2015
|
||||||
#include "ui.h"
|
#include "out/ui.h"
|
||||||
|
|
||||||
static uintmax_t type_uiMenu = 0;
|
static uintmax_t type_uiMenu = 0;
|
||||||
static uintmax_t type_uiMenuItem = 0;
|
static uintmax_t type_uiMenuItem = 0;
|
||||||
|
|
||||||
uintmax_t uiMenuType(void)
|
uintmax_t uiTypeMenu(void)
|
||||||
{
|
{
|
||||||
if (type_uiMenu == 0)
|
if (type_uiMenu == 0)
|
||||||
type_uiMenu = uiRegisterType("uiMenu", 0, 0);
|
type_uiMenu = uiRegisterType("uiMenu", 0, 0);
|
||||||
return type_uiMenu;
|
return type_uiMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintmax_t uiMenuItemType(void)
|
uintmax_t uiTypeMenuItem(void)
|
||||||
{
|
{
|
||||||
if (type_uiMenuItem == 0)
|
if (type_uiMenuItem == 0)
|
||||||
type_uiMenuItem = uiRegisterType("uiMenuItem", 0, 0);
|
type_uiMenuItem = uiRegisterType("uiMenuItem", 0, 0);
|
|
@ -1,6 +1,6 @@
|
||||||
// 5 may 2015
|
// 5 may 2015
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "ui.h"
|
#include "out/ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
struct ptrArray *newPtrArray(void)
|
struct ptrArray *newPtrArray(void)
|
|
@ -8,8 +8,6 @@ IDLFILES = \
|
||||||
$(baseIDLFILES)
|
$(baseIDLFILES)
|
||||||
|
|
||||||
xHFILES = \
|
xHFILES = \
|
||||||
uipriv.h \
|
|
||||||
$(IDLFILES:%.idl=$(OUTDIR)/%.h) \
|
|
||||||
$(baseHFILES)
|
$(baseHFILES)
|
||||||
|
|
||||||
OFILES = \
|
OFILES = \
|
||||||
|
@ -63,11 +61,6 @@ $(OBJDIR)/%.o: %.rc $(xHFILES) | $$(dir $$@).phony
|
||||||
@touch $@
|
@touch $@
|
||||||
.PRECIOUS: %/.phony
|
.PRECIOUS: %/.phony
|
||||||
|
|
||||||
$(OUTDIR)/%.h: %.idl tools/idl2h.go | $(OUTDIR)/.phony
|
|
||||||
@go run tools/idl2h.go -extern _UI_EXTERN -guard __UI_UI_H__ < $< > $@
|
|
||||||
@echo ====== Generated `basename $@`
|
|
||||||
.PRECIOUS: $(OUTDIR)/%.h
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OUTDIR) $(OBJDIR) z*
|
rm -rf $(OUTDIR) $(OBJDIR) z*
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
|
@ -16,11 +16,8 @@ endif
|
||||||
|
|
||||||
include $(OS)/GNUmakeinc.mk
|
include $(OS)/GNUmakeinc.mk
|
||||||
|
|
||||||
baseIDLFILES = \
|
|
||||||
ui.idl
|
|
||||||
# ui_$(OS).idl
|
|
||||||
|
|
||||||
baseHFILES = \
|
baseHFILES = \
|
||||||
|
ui.h \
|
||||||
uipriv.h \
|
uipriv.h \
|
||||||
ui_$(OS).h \
|
ui_$(OS).h \
|
||||||
$(osHFILES)
|
$(osHFILES)
|
||||||
|
|
113
redo/control.c
113
redo/control.c
|
@ -1,5 +1,5 @@
|
||||||
// 26 may 2015
|
// 26 may 2015
|
||||||
#include "out/ui.h"
|
#include "ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
struct controlBase {
|
struct controlBase {
|
||||||
|
@ -10,54 +10,74 @@ struct controlBase {
|
||||||
|
|
||||||
static uintmax_t type_uiControl = 0;
|
static uintmax_t type_uiControl = 0;
|
||||||
|
|
||||||
uintmax_t uiTypeControl(void)
|
uintmax_t uiControlType(void)
|
||||||
{
|
{
|
||||||
if (type_uiControl == 0)
|
if (type_uiControl == 0)
|
||||||
type_uiControl = uiRegisterType("uiControl", 0, 0);
|
type_uiControl = uiRegisterType("uiControl", 0, sizeof (uiControl));
|
||||||
return type_uiControl;
|
return type_uiControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define controlBase(c) ((struct controlBase *) (c->Internal))
|
#define controlBase(c) ((struct controlBase *) (c->Internal))
|
||||||
|
|
||||||
static void controlBaseDestroy(uiControl *c)
|
void uiControlDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
if (cb->parent != NULL)
|
if (cb->parent != NULL)
|
||||||
complain("attempt to destroy uiControl %p while it has a parent", c);
|
complain("attempt to destroy uiControl %p while it has a parent", c);
|
||||||
uiControlCommitDestroy(c);
|
(*(c->CommitDestroy))(c);
|
||||||
uiFree(cb);
|
uiFree(cb);
|
||||||
uiFree(c);
|
uiFree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uiControl *controlBaseParent(uiControl *c)
|
uintptr_t uiControlHandle(uiControl *c)
|
||||||
|
{
|
||||||
|
return (*(c->Handle))(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
uiControl *uiControlParent(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
return cb->parent;
|
return cb->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseSetParent(uiControl *c, uiControl *parent)
|
int isToplevel(uiControl *c)
|
||||||
|
{
|
||||||
|
return uiIsA(c, uiWindowType(), 0) != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns self if self is a window
|
||||||
|
uiControl *toplevelOwning(uiControl *c)
|
||||||
|
{
|
||||||
|
struct controlBase *cb;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
if (isToplevel(c))
|
||||||
|
return c;
|
||||||
|
cb = controlBase(c);
|
||||||
|
if (cb->parent == NULL)
|
||||||
|
return NULL;
|
||||||
|
c = cb->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiControlSetParent(uiControl *c, uiControl *parent)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
if (isToplevel(c))
|
||||||
|
complain("cannot set a parent on a toplevel (uiWindow)");
|
||||||
if (parent != NULL && cb->parent != NULL)
|
if (parent != NULL && cb->parent != NULL)
|
||||||
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
||||||
if (parent == NULL && cb->parent == NULL)
|
if (parent == NULL && cb->parent == NULL)
|
||||||
complain("attempt to double unparent uiControl %p", c);
|
complain("attempt to double unparent uiControl %p", c);
|
||||||
// this must come first; GTK+ CommitSetParent() needs the old parent
|
|
||||||
uiControlCommitSetParent(c, parent);
|
|
||||||
cb->parent = parent;
|
cb->parent = parent;
|
||||||
// for situations such as where the old parent was disabled but the new one is not, etc.
|
// for situations such as where the old parent was disabled but the new one is not, etc.
|
||||||
uiControlUpdateState(c);
|
controlUpdateState(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseQueueResize(uiControl *c)
|
static int controlContainerVisible(uiControl *c)
|
||||||
{
|
|
||||||
queueResize(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int controlBaseContainerVisible(uiControl *c)
|
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
@ -65,26 +85,26 @@ static int controlBaseContainerVisible(uiControl *c)
|
||||||
return 0;
|
return 0;
|
||||||
if (cb->parent == NULL)
|
if (cb->parent == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
return uiControlContainerVisible(cb->parent);
|
return controlContainerVisible(cb->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseShow(uiControl *c)
|
void uiControlShow(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
cb->hidden = 0;
|
cb->hidden = 0;
|
||||||
uiControlUpdateState(c);
|
controlUpdateState(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseHide(uiControl *c)
|
void uiControlHide(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
cb->hidden = 1;
|
cb->hidden = 1;
|
||||||
uiControlUpdateState(c);
|
controlUpdateState(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int controlBaseContainerEnabled(uiControl *c)
|
static int controlContainerEnabled(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
|
@ -92,43 +112,38 @@ static int controlBaseContainerEnabled(uiControl *c)
|
||||||
return 0;
|
return 0;
|
||||||
if (cb->parent == NULL)
|
if (cb->parent == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
return uiControlContainerEnabled(cb->parent);
|
return controlContainerEnabled(cb->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseEnable(uiControl *c)
|
void uiControlEnable(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
cb->disabled = 0;
|
cb->disabled = 0;
|
||||||
uiControlUpdateState(c);
|
controlUpdateState(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseDisable(uiControl *c)
|
void uiControlDisable(uiControl *c)
|
||||||
{
|
{
|
||||||
struct controlBase *cb = controlBase(c);
|
struct controlBase *cb = controlBase(c);
|
||||||
|
|
||||||
cb->disabled = 1;
|
cb->disabled = 1;
|
||||||
uiControlUpdateState(c);
|
controlUpdateState(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void controlBaseUpdateState(uiControl *c)
|
void controlUpdateState(uiControl *c)
|
||||||
{
|
{
|
||||||
if (uiControlContainerVisible(c))
|
if (controlContainerVisible(c))
|
||||||
uiControlCommitShow(c);
|
(*(c->CommitShow))(c);
|
||||||
else
|
else
|
||||||
uiControlCommitHide(c);
|
(*(c->CommitHide))(c);
|
||||||
if (uiControlContainerEnabled(c))
|
if (controlContainerEnabled(c))
|
||||||
uiControlCommitEnable(c);
|
osCommitEnable(c);
|
||||||
else
|
else
|
||||||
uiControlCommitDisable(c);
|
osCommitDisable(c);
|
||||||
uiControlContainerUpdateState(c);
|
(*(c->ContainerUpdateState))(c);
|
||||||
// and queue a resize, just in case we showed/hid something
|
// and queue a resize, just in case we showed/hid something
|
||||||
uiControlQueueResize(c);
|
//TODO uiControlQueueResize(c);
|
||||||
}
|
|
||||||
|
|
||||||
static void controlBaseContainerUpdateState(uiControl *c)
|
|
||||||
{
|
|
||||||
// by default not a container; do nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiControl *uiNewControl(uintmax_t type)
|
uiControl *uiNewControl(uintmax_t type)
|
||||||
|
@ -136,18 +151,6 @@ uiControl *uiNewControl(uintmax_t type)
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
|
|
||||||
c = uiControl(newTyped(type));
|
c = uiControl(newTyped(type));
|
||||||
uiControl(c)->Internal = uiNew(struct controlBase);
|
c->Internal = uiNew(struct controlBase);
|
||||||
uiControl(c)->Destroy = controlBaseDestroy;
|
return c;
|
||||||
uiControl(c)->Parent = controlBaseParent;
|
|
||||||
uiControl(c)->SetParent = controlBaseSetParent;
|
|
||||||
uiControl(c)->QueueResize = controlBaseQueueResize;
|
|
||||||
uiControl(c)->ContainerVisible = controlBaseContainerVisible;
|
|
||||||
uiControl(c)->Show = controlBaseShow;
|
|
||||||
uiControl(c)->Hide = controlBaseHide;
|
|
||||||
uiControl(c)->ContainerEnabled = controlBaseContainerEnabled;
|
|
||||||
uiControl(c)->Enable = controlBaseEnable;
|
|
||||||
uiControl(c)->Disable = controlBaseDisable;
|
|
||||||
uiControl(c)->UpdateState = controlBaseUpdateState;
|
|
||||||
uiControl(c)->ContainerUpdateState = controlBaseContainerUpdateState;
|
|
||||||
return uiControl(c);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
// 29 may 2015
|
// 29 may 2015
|
||||||
#include "out/ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
static uintmax_t type_uiMenu = 0;
|
static uintmax_t type_uiMenu = 0;
|
||||||
static uintmax_t type_uiMenuItem = 0;
|
static uintmax_t type_uiMenuItem = 0;
|
||||||
|
|
||||||
uintmax_t uiTypeMenu(void)
|
uintmax_t uiMenuType(void)
|
||||||
{
|
{
|
||||||
if (type_uiMenu == 0)
|
if (type_uiMenu == 0)
|
||||||
type_uiMenu = uiRegisterType("uiMenu", 0, 0);
|
type_uiMenu = uiRegisterType("uiMenu", 0, 0);
|
||||||
return type_uiMenu;
|
return type_uiMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintmax_t uiTypeMenuItem(void)
|
uintmax_t uiMenuItemType(void)
|
||||||
{
|
{
|
||||||
if (type_uiMenuItem == 0)
|
if (type_uiMenuItem == 0)
|
||||||
type_uiMenuItem = uiRegisterType("uiMenuItem", 0, 0);
|
type_uiMenuItem = uiRegisterType("uiMenuItem", 0, 0);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// 5 may 2015
|
// 5 may 2015
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "out/ui.h"
|
#include "ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
struct ptrArray *newPtrArray(void)
|
struct ptrArray *newPtrArray(void)
|
||||||
|
|
|
@ -1,156 +0,0 @@
|
||||||
// 26 may 2015
|
|
||||||
#include "ui.h"
|
|
||||||
#include "uipriv.h"
|
|
||||||
|
|
||||||
struct controlBase {
|
|
||||||
uiControl *parent;
|
|
||||||
int hidden;
|
|
||||||
int disabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
static uintmax_t type_uiControl = 0;
|
|
||||||
|
|
||||||
uintmax_t uiControlType(void)
|
|
||||||
{
|
|
||||||
if (type_uiControl == 0)
|
|
||||||
type_uiControl = uiRegisterType("uiControl", 0, sizeof (uiControl));
|
|
||||||
return type_uiControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define controlBase(c) ((struct controlBase *) (c->Internal))
|
|
||||||
|
|
||||||
void uiControlDestroy(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
if (cb->parent != NULL)
|
|
||||||
complain("attempt to destroy uiControl %p while it has a parent", c);
|
|
||||||
(*(c->CommitDestroy))(c);
|
|
||||||
uiFree(cb);
|
|
||||||
uiFree(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
uintptr_t uiControlHandle(uiControl *c)
|
|
||||||
{
|
|
||||||
return (*(c->Handle))(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
uiControl *uiControlParent(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
return cb->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
int isToplevel(uiControl *c)
|
|
||||||
{
|
|
||||||
return uiIsA(c, uiWindowType(), 0) != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns self if self is a window
|
|
||||||
uiControl *toplevelOwning(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (isToplevel(c))
|
|
||||||
return c;
|
|
||||||
cb = controlBase(c);
|
|
||||||
if (cb->parent == NULL)
|
|
||||||
return NULL;
|
|
||||||
c = cb->parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiControlSetParent(uiControl *c, uiControl *parent)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
if (isToplevel(c))
|
|
||||||
complain("cannot set a parent on a toplevel (uiWindow)");
|
|
||||||
if (parent != NULL && cb->parent != NULL)
|
|
||||||
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, cb->parent, parent);
|
|
||||||
if (parent == NULL && cb->parent == NULL)
|
|
||||||
complain("attempt to double unparent uiControl %p", c);
|
|
||||||
cb->parent = parent;
|
|
||||||
// for situations such as where the old parent was disabled but the new one is not, etc.
|
|
||||||
controlUpdateState(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int controlContainerVisible(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
if (cb->hidden)
|
|
||||||
return 0;
|
|
||||||
if (cb->parent == NULL)
|
|
||||||
return 1;
|
|
||||||
return controlContainerVisible(cb->parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiControlShow(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
cb->hidden = 0;
|
|
||||||
controlUpdateState(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiControlHide(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
cb->hidden = 1;
|
|
||||||
controlUpdateState(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int controlContainerEnabled(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
if (cb->disabled)
|
|
||||||
return 0;
|
|
||||||
if (cb->parent == NULL)
|
|
||||||
return 1;
|
|
||||||
return controlContainerEnabled(cb->parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiControlEnable(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
cb->disabled = 0;
|
|
||||||
controlUpdateState(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void uiControlDisable(uiControl *c)
|
|
||||||
{
|
|
||||||
struct controlBase *cb = controlBase(c);
|
|
||||||
|
|
||||||
cb->disabled = 1;
|
|
||||||
controlUpdateState(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
void controlUpdateState(uiControl *c)
|
|
||||||
{
|
|
||||||
if (controlContainerVisible(c))
|
|
||||||
(*(c->CommitShow))(c);
|
|
||||||
else
|
|
||||||
(*(c->CommitHide))(c);
|
|
||||||
if (controlContainerEnabled(c))
|
|
||||||
osCommitEnable(c);
|
|
||||||
else
|
|
||||||
osCommitDisable(c);
|
|
||||||
(*(c->ContainerUpdateState))(c);
|
|
||||||
// and queue a resize, just in case we showed/hid something
|
|
||||||
//TODO uiControlQueueResize(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
uiControl *uiNewControl(uintmax_t type)
|
|
||||||
{
|
|
||||||
uiControl *c;
|
|
||||||
|
|
||||||
c = uiControl(newTyped(type));
|
|
||||||
c->Internal = uiNew(struct controlBase);
|
|
||||||
return c;
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
// 9 may 2015
|
// 9 may 2015
|
||||||
#include "out/ui.h"
|
#include "ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
static int defaultOnShouldQuit(void *data)
|
static int defaultOnShouldQuit(void *data)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../out/ui.h"
|
#include "../ui.h"
|
||||||
|
|
||||||
// main.c
|
// main.c
|
||||||
extern void die(const char *, ...);
|
extern void die(const char *, ...);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// 17 may 2015
|
// 17 may 2015
|
||||||
#include "out/ui.h"
|
#include "ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
struct typeinfo {
|
struct typeinfo {
|
||||||
|
@ -19,6 +19,7 @@ uintmax_t uiRegisterType(const char *name, uintmax_t parent, size_t size)
|
||||||
// reserve ID 0
|
// reserve ID 0
|
||||||
ptrArrayAppend(types, NULL);
|
ptrArrayAppend(types, NULL);
|
||||||
}
|
}
|
||||||
|
// TODO prevent our size from being smaller than our parent's
|
||||||
ti = uiNew(struct typeinfo);
|
ti = uiNew(struct typeinfo);
|
||||||
ti->name = name;
|
ti->name = name;
|
||||||
ti->parent = parent;
|
ti->parent = parent;
|
||||||
|
|
|
@ -15,7 +15,12 @@ extern void uiFree(void *);
|
||||||
|
|
||||||
extern void complain(const char *, ...);
|
extern void complain(const char *, ...);
|
||||||
|
|
||||||
extern void queueResize(uiControl *);
|
extern int isToplevel(uiControl *);
|
||||||
|
extern uiControl *toplevelOwning(uiControl *);
|
||||||
|
extern void controlUpdateState(uiControl *);
|
||||||
|
|
||||||
|
extern void osCommitEnable(uiControl *);
|
||||||
|
extern void osCommitDisable(uiControl *);
|
||||||
|
|
||||||
// ptrarray.c
|
// ptrarray.c
|
||||||
struct ptrArray {
|
struct ptrArray {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// 9 may 2015
|
// 9 may 2015
|
||||||
#include "ui.h"
|
#include "out/ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
static int defaultOnShouldQuit(void *data)
|
static int defaultOnShouldQuit(void *data)
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../ui.h"
|
#include "../out/ui.h"
|
||||||
|
|
||||||
// main.c
|
// main.c
|
||||||
extern void die(const char *, ...);
|
extern void die(const char *, ...);
|
|
@ -1,5 +1,5 @@
|
||||||
// 17 may 2015
|
// 17 may 2015
|
||||||
#include "ui.h"
|
#include "out/ui.h"
|
||||||
#include "uipriv.h"
|
#include "uipriv.h"
|
||||||
|
|
||||||
struct typeinfo {
|
struct typeinfo {
|
||||||
|
@ -19,7 +19,6 @@ uintmax_t uiRegisterType(const char *name, uintmax_t parent, size_t size)
|
||||||
// reserve ID 0
|
// reserve ID 0
|
||||||
ptrArrayAppend(types, NULL);
|
ptrArrayAppend(types, NULL);
|
||||||
}
|
}
|
||||||
// TODO prevent our size from being smaller than our parent's
|
|
||||||
ti = uiNew(struct typeinfo);
|
ti = uiNew(struct typeinfo);
|
||||||
ti->name = name;
|
ti->name = name;
|
||||||
ti->parent = parent;
|
ti->parent = parent;
|
|
@ -15,12 +15,7 @@ extern void uiFree(void *);
|
||||||
|
|
||||||
extern void complain(const char *, ...);
|
extern void complain(const char *, ...);
|
||||||
|
|
||||||
extern int isToplevel(uiControl *);
|
extern void queueResize(uiControl *);
|
||||||
extern uiControl *toplevelOwning(uiControl *);
|
|
||||||
extern void controlUpdateState(uiControl *);
|
|
||||||
|
|
||||||
extern void osCommitEnable(uiControl *);
|
|
||||||
extern void osCommitDisable(uiControl *);
|
|
||||||
|
|
||||||
// ptrarray.c
|
// ptrarray.c
|
||||||
struct ptrArray {
|
struct ptrArray {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue