diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-09 15:59:40 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-09 15:59:40 -0400 |
| commit | 3f05be544ce9e57e8b00dfe99a64f223c6c2539b (patch) | |
| tree | d4fb2bfd61fb790525b0cfc631595bac068d9a89 /new/stack.c | |
| parent | 8d64f695e0c34d6801bc9422f7a56ddca7df5b81 (diff) | |
Implemented padding in uiStack.
Diffstat (limited to 'new/stack.c')
| -rw-r--r-- | new/stack.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/new/stack.c b/new/stack.c index fa28e59..eaa7a7e 100644 --- a/new/stack.c +++ b/new/stack.c @@ -13,6 +13,7 @@ struct stack { uintmax_t cap; int vertical; uintptr_t parent; + int padded; }; #define S(c) ((stack *) (c)) @@ -58,16 +59,22 @@ static uiSize stackPreferredSize(uiControl *c, uiSizing *d) intmax_t maxswid, maxsht; uintmax_t i; uiSize size, preferred; + uiSizingComm *dd = (uiSizingComm *) d; size.width = 0; size.height = 0; if (s->len == 0) return size; - // 1) add in padding - // TODO padding + // 0) get this Stack's padding xpadding = 0; ypadding = 0; + if (s->padded) { + xpadding = dd->xPadding; + ypadding = dd->yPadding; + } + + // 1) initialize the desired rect with the needed padding if (s->vertical) size.height = (s->len - 1) * ypadding; else @@ -117,13 +124,18 @@ static void stackResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, in intmax_t stretchywid, stretchyht; uintmax_t i; uiSize preferred; + uiSizingComm *dd = (uiSizingComm *) d; if (s->len == 0) return; - // TODO padding + // -1) get this Stack's padding xpadding = 0; ypadding = 0; + if (s->padded) { + xpadding = dd->xPadding; + ypadding = dd->yPadding; + } // 0) inset the available rect by the needed padding if (s->vertical) @@ -220,3 +232,13 @@ void uiStackAdd(uiControl *st, uiControl *c, int stretchy) s->len++; updateParent(s->parent); } + +// TODO get padded + +void uiStackSetPadded(uiControl *st, int padded) +{ + stack *s = S(st); + + s->padded = padded; + updateParent(s->parent); +} |
