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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-10 07:44:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-10 07:44:50 +0400
commit5caf6e9070ce3694b62be9b8599f93d063470dd6 (patch)
tree69e00a915ba7562a979b0ff4de8f10e30411d6cc /source/blender/editors/interface
parent08cc1c6bb96084bcd9e70b19edf9048fffe1fd3d (diff)
presets now work from non-redo popups,
ended up having to add a new pointer into the uiBlock (which I'd rather have avoided), but setting the uiLayoutSetContextPointer(..) was complicated to properly use for submenus and popus.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_handlers.c32
-rw-r--r--source/blender/editors/interface/interface_intern.h5
-rw-r--r--source/blender/editors/interface/interface_layout.c2
3 files changed, 38 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c871c87983c..06a05740585 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5471,6 +5471,38 @@ void uiContextActivePropertyHandle(bContext *C)
}
}
+wmOperator *uiContextActiveOperator(const struct bContext *C)
+{
+ ARegion *ar_ctx= CTX_wm_region(C);
+ uiBlock *block;
+
+ /* scan active regions ui */
+ for(block=ar_ctx->uiblocks.first; block; block=block->next) {
+ if (block->ui_operator) {
+ return block->ui_operator;
+ }
+ }
+
+ /* scan popups */
+ {
+ bScreen *sc= CTX_wm_screen(C);
+ ARegion *ar;
+
+ for (ar= sc->regionbase.first; ar; ar= ar->next) {
+ if (ar == ar_ctx) {
+ continue;
+ }
+ for(block=ar->uiblocks.first; block; block=block->next) {
+ if (block->ui_operator) {
+ return block->ui_operator;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
/* helper function for insert keyframe, reset to default, etc operators */
void uiContextAnimUpdate(const bContext *C)
{
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index aa4158ad4b7..16e0153b910 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -314,7 +314,10 @@ struct uiBlock {
ListBase saferct; // uiSafetyRct list
uiPopupBlockHandle *handle; // handle
-
+
+ struct wmOperator *ui_operator;// use so presets can find the operator,
+ // across menus and from nested popups which fail for operator context.
+
void *evil_C; // XXX hack for dynamic operator enums
struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time.
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index add023c940b..32bcfe51afc 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2767,6 +2767,8 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
PointerRNA op_ptr;
uiLayout *row;
+ uiLayoutGetBlock(layout)->ui_operator= op;
+
row= uiLayoutRow(layout, TRUE);
uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE);