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.
This commit is contained in:
Campbell Barton 2011-11-10 03:44:50 +00:00
parent 08cc1c6bb9
commit 5caf6e9070
6 changed files with 44 additions and 1 deletions

@ -507,6 +507,7 @@ if(UNIX AND NOT APPLE)
if(NOT BOOST_CUSTOM)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.34 COMPONENTS filesystem regex system thread)
mark_as_advanced(Boost_DIR) # why doesnt boost do this?
endif()
set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})

@ -802,6 +802,7 @@ void UI_buttons_operatortypes(void);
uiBut *uiContextActiveButton(const struct bContext *C);
void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index);
void uiContextActivePropertyHandle(struct bContext *C);
struct wmOperator *uiContextActiveOperator(const struct bContext *C);
void uiContextAnimUpdate(const struct bContext *C);
void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);
void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop);

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

@ -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.

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

@ -53,6 +53,7 @@
#include "ED_armature.h"
#include "WM_api.h"
#include "UI_interface.h"
#include "screen_intern.h"
@ -399,6 +400,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if(sfile) {
op= sfile->op;
}
else if ((op= uiContextActiveOperator(C))) {
/* do nothign */
}
else {
/* note, this checks poll, could be a problem, but this also
* happens for the toolbar */