Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_context.h1
-rw-r--r--source/blender/blenkernel/intern/context.c29
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c6
-rw-r--r--source/blender/editors/interface/interface_regions.c6
5 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 5966f8e0ff0..944cce675cc 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -117,6 +117,7 @@ bContext *CTX_copy(const bContext *C);
/* Stored Context */
bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr);
+bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context);
void CTX_store_set(bContext *C, bContextStore *store);
bContextStore *CTX_store_copy(bContextStore *store);
void CTX_store_free(bContextStore *store);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index a725b5f4c52..e9dd4d01b0e 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -141,6 +141,35 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p
return ctx;
}
+bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
+{
+ bContextStoreEntry *entry, *tentry;
+ bContextStore *ctx, *lastctx;
+
+ /* ensure we have a context to put the entries in, if it was already used
+ * we have to copy the context to ensure */
+ ctx= contexts->last;
+
+ if (!ctx || ctx->used) {
+ if (ctx) {
+ lastctx= ctx;
+ ctx= MEM_dupallocN(lastctx);
+ BLI_duplicatelist(&ctx->entries, &lastctx->entries);
+ }
+ else
+ ctx= MEM_callocN(sizeof(bContextStore), "bContextStore");
+
+ BLI_addtail(contexts, ctx);
+ }
+
+ for (tentry= context->entries.first; tentry; tentry= tentry->next) {
+ entry= MEM_dupallocN(tentry);
+ BLI_addtail(&ctx->entries, entry);
+ }
+
+ return ctx;
+}
+
void CTX_store_set(bContext *C, bContextStore *store)
{
C->wm.store= store;
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 18e2af939fd..cdb2472706c 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -48,6 +48,7 @@ struct wmWindowManager;
struct wmOperator;
struct AutoComplete;
struct bContext;
+struct bContextStore;
struct Panel;
struct PanelType;
struct PointerRNA;
@@ -692,6 +693,7 @@ uiBlock *uiLayoutGetBlock(uiLayout *layout);
void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr);
+void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context);
const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing
void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag);
struct MenuType *uiButGetMenuType(uiBut *but);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 91e38e7d914..58b54fef0df 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2722,6 +2722,12 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *p
layout->context = CTX_store_add(&block->contexts, name, ptr);
}
+void uiLayoutContextCopy(uiLayout *layout, bContextStore *context)
+{
+ uiBlock *block= layout->root->block;
+ layout->context= CTX_store_add_all(&block->contexts, context);
+}
+
/* introspect funcs */
#include "BLI_dynstr.h"
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 1c37fcdd488..b5d56f278e5 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2404,16 +2404,18 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
/* some enums reversing is strange, currently we have no good way to
* reverse some enum's but not others, so reverse all so the first menu
* items are always close to the mouse cursor */
-#if 0
else {
+#if 0
/* if this is an rna button then we can assume its an enum
* flipping enums is generally not good since the order can be
* important [#28786] */
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
pup->block->flag |= UI_BLOCK_NO_FLIP;
}
- }
#endif
+ if (but->context)
+ uiLayoutContextCopy(pup->layout, but->context);
+ }
if (str) {
/* menu is created from a string */