aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/gwin.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2014-01-05 00:46:36 +0100
committerJoel Bodenmann <joel@unormal.org>2014-01-05 00:46:36 +0100
commit9f5d14cf5d17ac0b2b16943da4a1347f695d109b (patch)
tree3fa2ca59050f5a9139c3a339d0c515e574a46011 /src/gwin/gwin.c
parent463a7031832725cbd4cb16935b6ecc899db20ef8 (diff)
downloaduGFX-9f5d14cf5d17ac0b2b16943da4a1347f695d109b.tar.gz
uGFX-9f5d14cf5d17ac0b2b16943da4a1347f695d109b.tar.bz2
uGFX-9f5d14cf5d17ac0b2b16943da4a1347f695d109b.zip
fixed gwinDestroy() and added gwinGetAbsoluteCoordinates()
Diffstat (limited to 'src/gwin/gwin.c')
-rw-r--r--src/gwin/gwin.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 5c164444..1ec8280c 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -181,11 +181,16 @@ GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pI
void gwinDestroy(GHandle gh) {
#if GWIN_NEED_HIERARCHY
- // kill your children as long as you have any
- while (gh->child) {
- GHandle tmp = gh->child;
- gh->child = gh->child->sibling;
- gwinDestroy(tmp);
+ // fix hierarchy structure
+ if (gh->parent->child == gh) {
+ // we are the first child
+ gh->parent->child = gh->sibling;
+ } else {
+ // find our predecessor
+ GHandle tmp = gh->parent->child;
+ while (tmp->sibling != gh)
+ tmp = tmp->sibling;
+ tmp->sibling = gh->sibling;
}
#endif
@@ -269,6 +274,22 @@ bool_t gwinGetEnabled(GHandle gh) {
#endif
}
+void gwinGetAbsoluteCoordinates(GHandle gh, coord_t *x, coord_t *y) {
+ #if GWIN_NEED_HIERARCHY
+ GHandle tmp;
+
+ // sum up all relative coordinates up to the root parent
+ for (*x = 0, *y = 0, tmp = gh; tmp; tmp = tmp->parent) {
+ *x += tmp->x;
+ *y += tmp->y;
+ }
+
+ #else
+ *x = gh->x;
+ *y = gh->y;
+ #endif
+}
+
void gwinMove(GHandle gh, coord_t x, coord_t y) {
_gwm_redim(gh, x, y, gh->width, gh->height);
}