Added a system for adding a "local" context in a UI layout.
This way you can define for example within a modifier panel
all operators to get the modifier in the context.

In the layout code:

uiLayoutSetContextPointer(layout, "modifier", &ptr)
layout.set_context_pointer("modifier", md)

In the operator:

ptr = CTX_data_pointer_get(C, "modifier")
md = context.modifier
This commit is contained in:
2009-05-28 23:13:42 +00:00
parent a843d7e316
commit 9cc638fb16
7 changed files with 129 additions and 8 deletions

View File

@@ -126,6 +126,7 @@ struct uiLayout {
uiItem item;
uiLayoutRoot *root;
bContextStore *context;
ListBase items;
int x, y, w, h;
@@ -1731,6 +1732,11 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but)
bitem->item.type= ITEM_BUTTON;
bitem->but= but;
BLI_addtail(&layout->items, bitem);
if(layout->context) {
but->context= layout->context;
but->context->used= 1;
}
}
void uiLayoutContext(uiLayout *layout, int opcontext)
@@ -1769,8 +1775,9 @@ void uiBlockLayoutResolve(const bContext *C, uiBlock *block, int *x, int *y)
}
}
float uiBlockAspect(uiBlock *block)
void uiLayoutSetContextPointer(uiLayout *layout, char *name, PointerRNA *ptr)
{
return block->aspect; /* temporary */
uiBlock *block= layout->root->block;
layout->context= CTX_store_add(&block->contexts, name, ptr);
}