Browse Source

fixed uiSetLayout(), added uiAddLayout() for accumulative flags

pull/1/head
Leonard Ritter 10 years ago
parent
commit
044c012e79
2 changed files with 16 additions and 6 deletions
  1. +5
    -5
      example.cpp
  2. +11
    -1
      oui.h

+ 5
- 5
example.cpp View File

@@ -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));


+ 11
- 1
oui.h View File

@@ -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) {


Loading…
Cancel
Save