From 044c012e79d030936c8debf820b4fc0e623ce62e Mon Sep 17 00:00:00 2001 From: Leonard Ritter Date: Mon, 22 Sep 2014 17:35:23 +0200 Subject: [PATCH] fixed uiSetLayout(), added uiAddLayout() for accumulative flags --- example.cpp | 10 +++++----- oui.h | 12 +++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/example.cpp b/example.cpp index ec1c2f5..5c5a561 100644 --- a/example.cpp +++ b/example.cpp @@ -354,7 +354,7 @@ int panel() { int column_append(int parent, int item) { uiAppend(parent, item); // fill parent horizontally, anchor to previous item vertically - uiSetLayout(item, UI_HFILL); + uiAddLayout(item, UI_HFILL); // if not the first item, add a margin of 1 uiSetMargins(item, 0, 1, 0, 0); return item; @@ -369,7 +369,7 @@ int column() { int vgroup_append(int parent, int item) { uiAppend(parent, item); // fill parent horizontally, anchor to previous item vertically - uiSetLayout(item, UI_HFILL); + uiAddLayout(item, UI_HFILL); return item; } @@ -381,7 +381,7 @@ int vgroup() { int hgroup_append(int parent, int item) { uiAppend(parent, item); - uiSetLayout(item, UI_HFILL); + uiAddLayout(item, UI_HFILL); return item; } @@ -398,7 +398,7 @@ int hgroup() { int row_append(int parent, int item) { uiAppend(parent, item); - uiSetLayout(item, UI_HFILL); + uiAddLayout(item, UI_HFILL); return item; } @@ -658,7 +658,7 @@ void draw(NVGcontext *vg, float w, float h) { int col = column(); uiAppend(root, col); uiSetMargins(col, 10, 10, 10, 10); - uiSetLayout(col, UI_TOP|UI_HFILL); + uiAddLayout(col, UI_TOP|UI_HFILL); column_append(col, button(BND_ICONID(6,3), "Item 1", demohandler)); diff --git a/oui.h b/oui.h index f747d4a..42f5839 100644 --- a/oui.h +++ b/oui.h @@ -516,6 +516,9 @@ OUI_EXPORT void uiSetSize(int item, int w, int h); // set the anchoring behavior of the item to one or multiple UIlayoutFlags OUI_EXPORT void uiSetLayout(int item, int flags); +// like uiSetLayout, but accumulates to the existing flags +OUI_EXPORT void uiAddLayout(int item, int flags); + // set the left, top, right and bottom margins of an item; when the item is // anchored to the parent or another item, the margin controls the distance // from the neighboring element. @@ -1000,7 +1003,14 @@ int uiGetHeight(int item) { } void uiSetLayout(int item, int flags) { - uiItemPtr(item)->flags |= flags & UI_ITEM_LAYOUT_MASK; + UIitem *pitem = uiItemPtr(item); + pitem->flags &= ~UI_ITEM_LAYOUT_MASK; + pitem->flags |= flags & UI_ITEM_LAYOUT_MASK; +} + +void uiAddLayout(int item, int flags) { + UIitem *pitem = uiItemPtr(item); + pitem->flags |= flags & UI_ITEM_LAYOUT_MASK; } int uiGetLayout(int item) {