UI: don't use operators anymore for handling user interface events, but rather
a special UI handler which makes the code clearer. This UI handler is attached to the region along with other handlers, and also gets a callback when all handlers for the region are removed to ensure things are properly cleaned up. This should fix XXX's in the UI code related to events and context switching. Most of the changes are in interface_handlers.c, which was renamed from interface_ops.c, to convert operators to the UI handler. UI code notes: * uiBeginBlock/uiEndBlock/uiFreeBlocks now takes a context argument, this is required to properly cancel things like timers or tooltips when the region gets removed. * UI_add_region_handlers will add the region level UI handlers, to be used when adding keymap handlers etc. This replaces the UI keymap. * When the UI code starts a modal interaction (number sliding, text editing, opening a menu, ..), it will add an UI handler at the window level which will block events. Windowmanager changes: * Added an UI handler next to the existing keymap and operator modal handlers. It has an event handling and remove callback, and like operator modal handlers will remember the area and region if it is registered at the window level. * Removed the MESSAGE event. * Operator cancel and UI handler remove callbacks now get the window/area/region restored in the context, like the operator modal and UI handler event callbacks. * Regions now receive MOUSEMOVE events for the mouse going outside of the region. This was already happening for areas, but UI buttons are at the region level so we need it there. Issues: * Tooltips and menus stay open when switching to another window, and button highlight doesn't work without moving the mouse first when Blender starts up. I tried using some events like Q_FIRSTTIME, WINTHAW, but those don't seem to arrive.. * Timeline header buttons seem to be moving one pixel or so sometimes when interacting with them. * Seems not due to this commit, but UI and keymap handlers are leaking. It seems that handlers are being added to regions in all screens, also in regions of areas that are not visible, but these handlers are not removed. Probably there should only be handlers in visible regions?
This commit is contained in:
@@ -37,6 +37,8 @@ struct wmWindow;
|
||||
struct wmWindowManager;
|
||||
struct AutoComplete;
|
||||
struct bContext;
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
|
||||
/* uiBlock->dt */
|
||||
#define UI_EMBOSS 0 /* use one of the themes for drawing */
|
||||
@@ -72,7 +74,7 @@ struct bContext;
|
||||
#define UI_BLOCK_MOVEMOUSE_QUIT 128
|
||||
#define UI_BLOCK_KEEP_OPEN 256
|
||||
|
||||
/* uiMenuBlockHandle->blockretval */
|
||||
/* uiMenuBlockHandle->menuretval */
|
||||
#define UI_RETURN_CANCEL 1 /* cancel all menus cascading */
|
||||
#define UI_RETURN_OK 2 /* choice made */
|
||||
#define UI_RETURN_OUT 4 /* left the menu */
|
||||
@@ -167,50 +169,69 @@ struct bContext;
|
||||
#define NUMABS (36<<9)
|
||||
#define BUTTYPE (63<<9)
|
||||
|
||||
/* Menu Block Handle */
|
||||
typedef struct uiMenuBlockHandle {
|
||||
struct ARegion *region;
|
||||
int butretval;
|
||||
int blockretval;
|
||||
|
||||
float retvalue;
|
||||
float retvec[3];
|
||||
} uiMenuBlockHandle;
|
||||
|
||||
typedef struct uiBut uiBut;
|
||||
typedef struct uiBlock uiBlock;
|
||||
|
||||
/* Common Drawing Functions */
|
||||
|
||||
void uiEmboss(float x1, float y1, float x2, float y2, int sel);
|
||||
void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad, int active);
|
||||
void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
|
||||
void uiSetRoundBox(int type);
|
||||
void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
|
||||
|
||||
void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag);
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval);
|
||||
void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
|
||||
|
||||
/* Popup Menu's */
|
||||
|
||||
typedef struct uiMenuBlockHandle {
|
||||
struct ARegion *region;
|
||||
int butretval;
|
||||
int menuretval;
|
||||
|
||||
float retvalue;
|
||||
float retvec[3];
|
||||
} uiMenuBlockHandle;
|
||||
|
||||
typedef uiBlock* (*uiBlockFuncFP)(struct bContext *C, struct uiMenuBlockHandle *handle, void *arg1);
|
||||
|
||||
extern void pupmenu_set_active(int val);
|
||||
extern uiMenuBlockHandle *pupmenu_col(struct bContext *C, char *instr, int mx, int my, int maxrow);
|
||||
extern uiMenuBlockHandle *pupmenu(struct bContext *C, char *instr, int mx, int my);
|
||||
extern void pupmenu_free(struct bContext *C, uiMenuBlockHandle *handle);
|
||||
|
||||
/* Block */
|
||||
|
||||
uiBlock *uiBeginBlock(const struct bContext *C, struct ARegion *region, char *name, short dt, short font);
|
||||
void uiEndBlock(const struct bContext *C, uiBlock *block);
|
||||
uiBlock *uiGetBlock(char *name, struct ARegion *ar);
|
||||
void uiFreeBlock(const struct bContext *C, uiBlock *block);
|
||||
void uiFreeBlocks(const struct bContext *C, struct ListBase *lb);
|
||||
|
||||
void uiBoundsBlock(struct uiBlock *block, int addval);
|
||||
void uiDrawBlock(struct uiBlock *block);
|
||||
void uiGetMouse(int win, short *adr);
|
||||
void uiComposeLinks(uiBlock *block);
|
||||
void uiSetButLock(int val, char *lockstr);
|
||||
uiBut *uiFindInlink(uiBlock *block, void *poin);
|
||||
void uiClearButLock(void);
|
||||
int uiDoBlocks(struct ListBase *lb, int event, int movemouse_quit);
|
||||
void uiSetCurFont(uiBlock *block, int index);
|
||||
void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
|
||||
void uiFreeBlock(uiBlock *block);
|
||||
void uiFreeBlocks(struct ListBase *lb);
|
||||
uiBlock *uiBeginBlock(struct wmWindow *window, struct ARegion *region, char *name, short dt, short font);
|
||||
void uiEndBlock(uiBlock *block);
|
||||
uiBlock *uiGetBlock(char *name, struct ARegion *ar);
|
||||
|
||||
void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
|
||||
void uiTextBoundsBlock(uiBlock *block, int addval);
|
||||
|
||||
void uiBlockSetButLock(uiBlock *block, int val, char *lockstr);
|
||||
void uiBlockClearButLock(uiBlock *block);
|
||||
|
||||
/* automatic aligning, horiz or verical */
|
||||
void uiBlockBeginAlign(uiBlock *block);
|
||||
void uiBlockEndAlign(uiBlock *block);
|
||||
|
||||
/* Misc */
|
||||
|
||||
void uiSetCurFont(uiBlock *block, int index);
|
||||
void *uiSetCurFont_ext(float aspect);
|
||||
void uiDefFont(unsigned int index, void *xl, void *large, void *medium, void *small);
|
||||
|
||||
void uiComposeLinks(uiBlock *block);
|
||||
uiBut *uiFindInlink(uiBlock *block, void *poin);
|
||||
|
||||
void uiBlockPickerButtons(struct uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval);
|
||||
|
||||
/* Defining Buttons */
|
||||
|
||||
uiBut *uiDefBut(uiBlock *block,
|
||||
int type, int retval, char *str,
|
||||
short x1, short y1,
|
||||
@@ -258,7 +279,6 @@ typedef void (*uiIDPoinFuncFP) (char *str, struct ID **idpp);
|
||||
uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
|
||||
short x1, short y1, short x2, short y2, void *idpp, char *tip);
|
||||
|
||||
typedef uiBlock* (*uiBlockFuncFP) (struct wmWindow *window, struct uiMenuBlockHandle *handle, void *arg1);
|
||||
uiBut *uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockFuncFP func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
|
||||
@@ -267,8 +287,6 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retv
|
||||
|
||||
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
|
||||
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
uiBut *uiDefRNABut(uiBlock *block, int retval, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, short x1, short y1, short x2, short y2);
|
||||
void uiButSetFunc3(uiBut *but, void (*func)(void *arg1, void *arg2, void *arg3), void *arg1, void *arg2, void *arg3);
|
||||
|
||||
@@ -306,11 +324,7 @@ void uiButSetCompleteFunc(uiBut *but, void (*func)(char *str, void *arg), void
|
||||
|
||||
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(struct ScrArea *sa, uiBlock *block));
|
||||
|
||||
|
||||
extern void pupmenu_set_active(int val);
|
||||
extern uiMenuBlockHandle *pupmenu_col(struct bContext *C, char *instr, int mx, int my, int maxrow);
|
||||
extern uiMenuBlockHandle *pupmenu(struct bContext *C, char *instr, int mx, int my);
|
||||
extern void pupmenu_free(struct bContext *C, uiMenuBlockHandle *handle);
|
||||
/* Panels */
|
||||
|
||||
extern void uiFreePanels(struct ListBase *lb);
|
||||
extern void uiNewPanelTabbed(char *, char *);
|
||||
@@ -329,8 +343,7 @@ extern int uiAlignPanelStep(struct ScrArea *sa, float fac);
|
||||
extern void uiPanelControl(int);
|
||||
extern void uiSetPanelHandler(int);
|
||||
|
||||
extern void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
|
||||
extern void *uiSetCurFont_ext(float aspect);
|
||||
/* Autocomplete */
|
||||
|
||||
typedef struct AutoComplete AutoComplete;
|
||||
|
||||
@@ -338,13 +351,17 @@ AutoComplete *autocomplete_begin(char *startname, int maxlen);
|
||||
void autocomplete_do_name(AutoComplete *autocpl, const char *name);
|
||||
void autocomplete_end(AutoComplete *autocpl, char *autoname);
|
||||
|
||||
void uiTestRegion(const struct bContext *C); /* XXX 2.50 temporary test */
|
||||
/* Handlers for regions with UI blocks */
|
||||
|
||||
void UI_add_region_handlers(struct ListBase *handlers);
|
||||
|
||||
/* Module initialization and exit */
|
||||
|
||||
void UI_keymap(struct wmWindowManager *wm);
|
||||
void UI_operatortypes(void);
|
||||
void UI_init(void);
|
||||
void UI_init_userdef(void);
|
||||
void UI_exit(void);
|
||||
|
||||
void uiTestRegion(const struct bContext *C); /* XXX 2.50 temporary test */
|
||||
|
||||
#endif /* UI_INTERFACE_H */
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
* ui_blah_blah() internal function
|
||||
*/
|
||||
|
||||
static void ui_free_but(uiBut *but);
|
||||
static void ui_free_but(const bContext *C, uiBut *but);
|
||||
|
||||
/* ************ GLOBALS ************* */
|
||||
|
||||
@@ -109,8 +109,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y
|
||||
float gx, gy;
|
||||
int sx, sy, getsizex, getsizey;
|
||||
|
||||
getsizex= ar->winrct.xmax-ar->winrct.xmin;
|
||||
getsizey= ar->winrct.ymax-ar->winrct.ymin;
|
||||
getsizex= ar->winrct.xmax-ar->winrct.xmin+1;
|
||||
getsizey= ar->winrct.ymax-ar->winrct.ymin+1;
|
||||
sx= ar->winrct.xmin;
|
||||
sy= ar->winrct.ymin;
|
||||
|
||||
@@ -152,8 +152,8 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
|
||||
float a, b, c, d, e, f, px, py;
|
||||
int sx, sy, getsizex, getsizey;
|
||||
|
||||
getsizex= ar->winrct.xmax-ar->winrct.xmin;
|
||||
getsizey= ar->winrct.ymax-ar->winrct.ymin;
|
||||
getsizex= ar->winrct.xmax-ar->winrct.xmin+1;
|
||||
getsizey= ar->winrct.ymax-ar->winrct.ymin+1;
|
||||
sx= ar->winrct.xmin;
|
||||
sy= ar->winrct.ymin;
|
||||
|
||||
@@ -426,7 +426,7 @@ static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ui_but_update_from_old_block(uiBlock *block, uiBut *but)
|
||||
static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut *but)
|
||||
{
|
||||
uiBlock *oldblock;
|
||||
uiBut *oldbut;
|
||||
@@ -438,9 +438,9 @@ static int ui_but_update_from_old_block(uiBlock *block, uiBut *but)
|
||||
|
||||
for(oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) {
|
||||
if(ui_but_equals_old(oldbut, but)) {
|
||||
if(oldbut->activate) {
|
||||
if(oldbut->active) {
|
||||
but->flag= oldbut->flag;
|
||||
but->activate= oldbut->activate;
|
||||
but->active= oldbut->active;
|
||||
but->pos= oldbut->pos;
|
||||
but->editstr= oldbut->editstr;
|
||||
but->editval= oldbut->editval;
|
||||
@@ -450,12 +450,14 @@ static int ui_but_update_from_old_block(uiBlock *block, uiBut *but)
|
||||
but->selsta= oldbut->selsta;
|
||||
but->selend= oldbut->selend;
|
||||
found= 1;
|
||||
|
||||
oldbut->active= NULL;
|
||||
}
|
||||
|
||||
/* ensures one button can get activated, and in case the buttons
|
||||
* draw are the same this gives O(1) lookup for each button */
|
||||
BLI_remlink(&oldblock->buttons, oldbut);
|
||||
ui_free_but(oldbut);
|
||||
ui_free_but(C, oldbut);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -464,7 +466,7 @@ static int ui_but_update_from_old_block(uiBlock *block, uiBut *but)
|
||||
return found;
|
||||
}
|
||||
|
||||
void uiEndBlock(uiBlock *block)
|
||||
void uiEndBlock(const bContext *C, uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
@@ -473,14 +475,15 @@ void uiEndBlock(uiBlock *block)
|
||||
* blocking, while still alowing buttons to be remade each redraw as it
|
||||
* is expected by blender code */
|
||||
for(but=block->buttons.first; but; but=but->next)
|
||||
if(ui_but_update_from_old_block(block, but))
|
||||
if(ui_but_update_from_old_block(C, block, but))
|
||||
ui_check_but(but);
|
||||
|
||||
if(block->oldblock) {
|
||||
block->auto_open= block->oldblock->auto_open;
|
||||
block->auto_open_last= block->oldblock->auto_open_last;
|
||||
block->tooltipdisabled= block->oldblock->tooltipdisabled;
|
||||
|
||||
uiFreeBlock(block->oldblock);
|
||||
uiFreeBlock(C, block->oldblock);
|
||||
block->oldblock= NULL;
|
||||
}
|
||||
|
||||
@@ -1340,21 +1343,22 @@ static void ui_free_link(uiLink *link)
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_free_but(uiBut *but)
|
||||
static void ui_free_but(const bContext *C, uiBut *but)
|
||||
{
|
||||
if(but->active) ui_button_active_cancel(C, but);
|
||||
if(but->str && but->str != but->strdata) MEM_freeN(but->str);
|
||||
ui_free_link(but->link);
|
||||
|
||||
MEM_freeN(but);
|
||||
}
|
||||
|
||||
void uiFreeBlock(uiBlock *block)
|
||||
void uiFreeBlock(const bContext *C, uiBlock *block)
|
||||
{
|
||||
uiBut *but;
|
||||
|
||||
while( (but= block->buttons.first) ) {
|
||||
BLI_remlink(&block->buttons, but);
|
||||
ui_free_but(but);
|
||||
ui_free_but(C, but);
|
||||
}
|
||||
|
||||
if(block->panel) block->panel->active= 0;
|
||||
@@ -1364,22 +1368,24 @@ void uiFreeBlock(uiBlock *block)
|
||||
MEM_freeN(block);
|
||||
}
|
||||
|
||||
void uiFreeBlocks(ListBase *lb)
|
||||
void uiFreeBlocks(const bContext *C, ListBase *lb)
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
while( (block= lb->first) ) {
|
||||
BLI_remlink(lb, block);
|
||||
uiFreeBlock(block);
|
||||
uiFreeBlock(C, block);
|
||||
}
|
||||
}
|
||||
|
||||
uiBlock *uiBeginBlock(wmWindow *window, ARegion *region, char *name, short dt, short font)
|
||||
uiBlock *uiBeginBlock(const bContext *C, ARegion *region, char *name, short dt, short font)
|
||||
{
|
||||
ListBase *lb;
|
||||
uiBlock *block, *oldblock= NULL;
|
||||
wmWindow *window;
|
||||
int getsizex, getsizey;
|
||||
|
||||
window= C->window;
|
||||
lb= ®ion->uiblocks;
|
||||
|
||||
/* each listbase only has one block with this name, free block
|
||||
@@ -2071,7 +2077,7 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname)
|
||||
/* autocomplete callback for ID buttons */
|
||||
static void autocomplete_id(char *str, void *arg_v)
|
||||
{
|
||||
/* XXX 2.48 int blocktype= (intptr_t)arg_v; */
|
||||
/* int blocktype= (intptr_t)arg_v; */
|
||||
ListBase *listb= NULL /* XXX 2.50 needs context, wich_libbase(G.main, blocktype) */;
|
||||
|
||||
if(listb==NULL) return;
|
||||
@@ -2510,7 +2516,7 @@ uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int
|
||||
ui_check_but(but);
|
||||
|
||||
if(blocktype)
|
||||
uiButSetCompleteFunc(but, autocomplete_id, 0 /* XXX 2.48 (void *)(intptr_t)blocktype*/);
|
||||
uiButSetCompleteFunc(but, autocomplete_id, (void *)(intptr_t)blocktype);
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
#include "UI_resources.h"
|
||||
#include "RNA_types.h"
|
||||
|
||||
struct uiActivateBut;
|
||||
struct uiHandleButtonData;
|
||||
struct wmWindow;
|
||||
struct ARegion;
|
||||
struct bContext;
|
||||
|
||||
/* general defines */
|
||||
|
||||
@@ -54,12 +55,6 @@ struct ARegion;
|
||||
#define UI_HAS_ICON 8
|
||||
/* warn: rest of uiBut->flag in BIF_interface.c */
|
||||
|
||||
/* uiBut->activateflag */
|
||||
#define UI_ACTIVATE 1
|
||||
#define UI_ACTIVATE_APPLY 2
|
||||
#define UI_ACTIVATE_TEXT_EDITING 4
|
||||
#define UI_ACTIVATE_OPEN 8
|
||||
|
||||
/* internal panel drawing defines */
|
||||
#define PNL_GRID 4
|
||||
#define PNL_DIST 8
|
||||
@@ -170,9 +165,8 @@ struct uiBut {
|
||||
struct PropertyRNA *rnaprop;
|
||||
int rnaindex;
|
||||
|
||||
/* Activation data */
|
||||
struct uiActivateBut *activate;
|
||||
int activateflag;
|
||||
/* activation button data */
|
||||
struct uiHandleButtonData *active;
|
||||
|
||||
char *editstr;
|
||||
double *editval;
|
||||
@@ -222,9 +216,12 @@ struct uiBlock {
|
||||
char *lockstr;
|
||||
|
||||
float xofs, yofs; // offset to parent button
|
||||
|
||||
rctf safety; // pulldowns, to detect outside, can differ per case how it is created
|
||||
ListBase saferct; // uiSafetyRct list
|
||||
|
||||
uiMenuBlockHandle *handle; // handle
|
||||
int tooltipdisabled; // to avoid tooltip after click
|
||||
};
|
||||
|
||||
typedef struct uiSafetyRct {
|
||||
@@ -260,10 +257,10 @@ extern int ui_is_but_float(uiBut *but);
|
||||
extern void ui_update_block_buts_hsv(uiBlock *block, float *hsv);
|
||||
|
||||
/* interface_regions.c */
|
||||
uiBlock *ui_block_func_MENU(struct wmWindow *window, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONROW(struct wmWindow *window, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONTEXTROW(struct wmWindow *window, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_COL(struct wmWindow *window, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_MENU(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONROW(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
uiBlock *ui_block_func_COL(struct bContext *C, uiMenuBlockHandle *handle, void *arg_but);
|
||||
|
||||
struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
|
||||
void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
|
||||
@@ -289,5 +286,8 @@ extern void ui_draw_tria_icon(float x, float y, float aspect, char dir);
|
||||
extern void ui_draw_anti_x(float x1, float y1, float x2, float y2);
|
||||
extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select);
|
||||
|
||||
/* interface_handlers.c */
|
||||
extern void ui_button_active_cancel(const struct bContext *C, uiBut *but);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -590,15 +590,9 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar)
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_block_region_free(ARegion *ar)
|
||||
{
|
||||
uiFreeBlocks(&ar->uiblocks);
|
||||
}
|
||||
|
||||
uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *but, uiBlockFuncFP block_func, void *arg)
|
||||
{
|
||||
static ARegionType type;
|
||||
ListBase *keymap= WM_keymap_listbase(C->wm, "Interface", 0, 0);
|
||||
ARegion *ar;
|
||||
uiBlock *block;
|
||||
uiBut *bt;
|
||||
@@ -613,16 +607,15 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *
|
||||
|
||||
memset(&type, 0, sizeof(ARegionType));
|
||||
type.draw= ui_block_region_draw;
|
||||
type.free= ui_block_region_free;
|
||||
ar->type= &type;
|
||||
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
UI_add_region_handlers(&ar->handlers);
|
||||
|
||||
handle->region= ar;
|
||||
ar->regiondata= handle;
|
||||
|
||||
/* create ui block */
|
||||
block= block_func(C->window, handle, arg);
|
||||
block= block_func(C, handle, arg);
|
||||
block->handle= handle;
|
||||
|
||||
/* if this is being created from a button */
|
||||
@@ -674,10 +667,6 @@ uiMenuBlockHandle *ui_menu_block_create(bContext *C, ARegion *butregion, uiBut *
|
||||
WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
|
||||
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
||||
|
||||
SWAP(ARegion*, C->region, ar); /* XXX 2.50 bad context swapping */
|
||||
WM_operator_invoke(C, WM_operatortype_find("ED_UI_OT_menu_block_handle"), NULL);
|
||||
SWAP(ARegion*, C->region, ar);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -692,7 +681,7 @@ void ui_menu_block_free(bContext *C, uiMenuBlockHandle *handle)
|
||||
|
||||
/***************************** Menu Button ***************************/
|
||||
|
||||
uiBlock *ui_block_func_MENU(wmWindow *window, uiMenuBlockHandle *handle, void *arg_but)
|
||||
uiBlock *ui_block_func_MENU(bContext *C, uiMenuBlockHandle *handle, void *arg_but)
|
||||
{
|
||||
uiBut *but= arg_but;
|
||||
uiBlock *block;
|
||||
@@ -703,7 +692,7 @@ uiBlock *ui_block_func_MENU(wmWindow *window, uiMenuBlockHandle *handle, void *a
|
||||
int width, height, boxh, columns, rows, startx, starty, x1, y1, xmax, a;
|
||||
|
||||
/* create the block */
|
||||
block= uiBeginBlock(window, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block->dt= UI_EMBOSSP;
|
||||
block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
|
||||
block->themecol= TH_MENU_ITEM;
|
||||
@@ -803,18 +792,18 @@ uiBlock *ui_block_func_MENU(wmWindow *window, uiMenuBlockHandle *handle, void *a
|
||||
block->buttons= lb;
|
||||
|
||||
block->direction= UI_TOP;
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
uiBlock *ui_block_func_ICONROW(wmWindow *window, uiMenuBlockHandle *handle, void *arg_but)
|
||||
uiBlock *ui_block_func_ICONROW(bContext *C, uiMenuBlockHandle *handle, void *arg_but)
|
||||
{
|
||||
uiBut *but= arg_but;
|
||||
uiBlock *block;
|
||||
int a;
|
||||
|
||||
block= uiBeginBlock(window, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
|
||||
block->themecol= TH_MENU_ITEM;
|
||||
|
||||
@@ -824,19 +813,19 @@ uiBlock *ui_block_func_ICONROW(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
|
||||
block->direction= UI_TOP;
|
||||
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
uiBlock *ui_block_func_ICONTEXTROW(wmWindow *window, uiMenuBlockHandle *handle, void *arg_but)
|
||||
uiBlock *ui_block_func_ICONTEXTROW(bContext *C, uiMenuBlockHandle *handle, void *arg_but)
|
||||
{
|
||||
uiBut *but= arg_but;
|
||||
uiBlock *block;
|
||||
MenuData *md;
|
||||
int width, xmax, ypos, a;
|
||||
|
||||
block= uiBeginBlock(window, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
|
||||
block->themecol= TH_MENU_ITEM;
|
||||
|
||||
@@ -885,7 +874,7 @@ uiBlock *ui_block_func_ICONTEXTROW(wmWindow *window, uiMenuBlockHandle *handle,
|
||||
block->direction= UI_TOP;
|
||||
|
||||
uiBoundsBlock(block, 3);
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
@@ -1234,14 +1223,14 @@ void uiBlockPickerButtons(uiBlock *block, float *col, float *hsv, float *old, ch
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
uiBlock *ui_block_func_COL(wmWindow *window, uiMenuBlockHandle *handle, void *arg_but)
|
||||
uiBlock *ui_block_func_COL(bContext *C, uiMenuBlockHandle *handle, void *arg_but)
|
||||
{
|
||||
uiBut *but= arg_but;
|
||||
uiBlock *block;
|
||||
static float hsvcol[3], oldcol[3];
|
||||
static char hexcol[128];
|
||||
|
||||
block= uiBeginBlock(window, handle->region, "colorpicker", UI_EMBOSS, UI_HELV);
|
||||
block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS, UI_HELV);
|
||||
block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_KEEP_OPEN;
|
||||
block->themecol= TH_BUT_NUM;
|
||||
|
||||
@@ -1294,7 +1283,7 @@ typedef struct uiPupMenuInfo {
|
||||
int maxrow;
|
||||
} uiPupMenuInfo;
|
||||
|
||||
uiBlock *ui_block_func_PUPMENU(wmWindow *window, uiMenuBlockHandle *handle, void *arg_info)
|
||||
uiBlock *ui_block_func_PUPMENU(bContext *C, uiMenuBlockHandle *handle, void *arg_info)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiPupMenuInfo *info;
|
||||
@@ -1309,7 +1298,7 @@ uiBlock *ui_block_func_PUPMENU(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
height= 0;
|
||||
|
||||
/* block stuff first, need to know the font */
|
||||
block= uiBeginBlock(window, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT);
|
||||
block->themecol= TH_MENU_ITEM;
|
||||
|
||||
@@ -1336,7 +1325,7 @@ uiBlock *ui_block_func_PUPMENU(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
width+= 10;
|
||||
if (width<50) width=50;
|
||||
|
||||
wm_window_get_size(window, &xmax, &ymax);
|
||||
wm_window_get_size(C->window, &xmax, &ymax);
|
||||
|
||||
/* set first item */
|
||||
lastselected= 0;
|
||||
@@ -1428,7 +1417,7 @@ uiBlock *ui_block_func_PUPMENU(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
}
|
||||
|
||||
uiBoundsBlock(block, 1);
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
menudata_free(md);
|
||||
|
||||
@@ -1455,7 +1444,7 @@ uiBlock *ui_block_func_PUPMENU(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
return block;
|
||||
}
|
||||
|
||||
uiBlock *ui_block_func_PUPMENUCOL(wmWindow *window, uiMenuBlockHandle *handle, void *arg_info)
|
||||
uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiMenuBlockHandle *handle, void *arg_info)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiPupMenuInfo *info;
|
||||
@@ -1470,7 +1459,7 @@ uiBlock *ui_block_func_PUPMENUCOL(wmWindow *window, uiMenuBlockHandle *handle, v
|
||||
height= 0;
|
||||
|
||||
/* block stuff first, need to know the font */
|
||||
block= uiBeginBlock(window, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP, UI_HELV);
|
||||
uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT);
|
||||
block->themecol= TH_MENU_ITEM;
|
||||
|
||||
@@ -1508,7 +1497,7 @@ uiBlock *ui_block_func_PUPMENUCOL(wmWindow *window, uiMenuBlockHandle *handle, v
|
||||
height= rows*MENU_BUTTON_HEIGHT;
|
||||
if (md->title) height+= MENU_BUTTON_HEIGHT;
|
||||
|
||||
wm_window_get_size(window, &xmax, &ymax);
|
||||
wm_window_get_size(C->window, &xmax, &ymax);
|
||||
|
||||
/* find active item */
|
||||
fvalue= handle->retvalue;
|
||||
@@ -1596,7 +1585,7 @@ uiBlock *ui_block_func_PUPMENUCOL(wmWindow *window, uiMenuBlockHandle *handle, v
|
||||
}
|
||||
|
||||
uiBoundsBlock(block, 1);
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
#if 0
|
||||
event= uiDoBlocks(&listb, 0, 1);
|
||||
@@ -1646,13 +1635,13 @@ void pupmenu_free(bContext *C, uiMenuBlockHandle *handle)
|
||||
|
||||
/*************** Temporary Buttons Tests **********************/
|
||||
|
||||
static uiBlock *test_submenu(wmWindow *window, uiMenuBlockHandle *handle, void *arg)
|
||||
static uiBlock *test_submenu(bContext *C, uiMenuBlockHandle *handle, void *arg)
|
||||
{
|
||||
ARegion *ar= handle->region;
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(window, ar, "test_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "test_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
//uiBlockSetButmFunc(block, do_test_viewmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
|
||||
@@ -1682,19 +1671,19 @@ static uiBlock *test_submenu(wmWindow *window, uiMenuBlockHandle *handle, void *
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
|
||||
uiTextBoundsBlock(block, 50);
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static uiBlock *test_viewmenu(wmWindow *window, uiMenuBlockHandle *handle, void *arg_area)
|
||||
static uiBlock *test_viewmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_area)
|
||||
{
|
||||
ScrArea *area= arg_area;
|
||||
ARegion *ar= handle->region;
|
||||
uiBlock *block;
|
||||
short yco= 0, menuwidth=120;
|
||||
|
||||
block= uiBeginBlock(window, ar, "test_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
block= uiBeginBlock(C, ar, "test_viewmenu", UI_EMBOSSP, UI_HELV);
|
||||
//uiBlockSetButmFunc(block, do_test_viewmenu, NULL);
|
||||
|
||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation", 0, yco-=20,
|
||||
@@ -1722,6 +1711,7 @@ static uiBlock *test_viewmenu(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
"Lock Time to Other Windows|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, "");
|
||||
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefIconTextBlockBut(block, test_submenu, NULL, ICON_RIGHTARROW_THIN, "Sub Menu", 0, yco-=20, 120, 19, "");
|
||||
uiDefIconTextBlockBut(block, test_submenu, NULL, ICON_RIGHTARROW_THIN, "Sub Menu", 0, yco-=20, 120, 19, "");
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
@@ -1734,7 +1724,7 @@ static uiBlock *test_viewmenu(wmWindow *window, uiMenuBlockHandle *handle, void
|
||||
}
|
||||
|
||||
uiTextBoundsBlock(block, 50);
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
|
||||
return block;
|
||||
}
|
||||
@@ -1754,7 +1744,7 @@ void uiTestRegion(const bContext *C)
|
||||
static ColorBand *coba= NULL;
|
||||
#endif
|
||||
|
||||
block= uiBeginBlock(C->window, C->region, "header buttons", UI_EMBOSS, UI_HELV);
|
||||
block= uiBeginBlock(C, C->region, "header buttons", UI_EMBOSS, UI_HELV);
|
||||
|
||||
uiDefPulldownBut(block, test_viewmenu, C->area, "View",
|
||||
13, 1, 50, 24, "");
|
||||
@@ -1796,7 +1786,7 @@ void uiTestRegion(const bContext *C)
|
||||
13+400+100+10, 33, 150, 30, coba, 0.0f, 1.0f, 0, 0, "");
|
||||
#endif
|
||||
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(block);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,9 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
|
||||
glColor3f(fac, fac, fac);
|
||||
glRecti(20, 2, 30, 12);
|
||||
}
|
||||
region_draw_emboss(ar);
|
||||
|
||||
if(C->area)
|
||||
region_draw_emboss(ar);
|
||||
|
||||
/* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
|
||||
ED_region_pixelspace(C, ar);
|
||||
|
||||
@@ -920,24 +920,33 @@ void ED_screens_initialize(wmWindowManager *wm)
|
||||
|
||||
void ED_region_exit(bContext *C, ARegion *ar)
|
||||
{
|
||||
ARegion *prevar= C->region;
|
||||
|
||||
C->region= ar;
|
||||
WM_event_remove_handlers(C, &ar->handlers);
|
||||
C->region= prevar;
|
||||
}
|
||||
|
||||
void ED_area_exit(bContext *C, ScrArea *sa)
|
||||
{
|
||||
ScrArea *prevsa= C->area;
|
||||
ARegion *ar;
|
||||
|
||||
C->area= sa;
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
ED_region_exit(C, ar);
|
||||
|
||||
WM_event_remove_handlers(C, &sa->handlers);
|
||||
C->area= prevsa;
|
||||
}
|
||||
|
||||
void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
|
||||
{
|
||||
wmWindow *prevwin= C->window;
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
C->window= window;
|
||||
for(ar= screen->regionbase.first; ar; ar= ar->next)
|
||||
ED_region_exit(C, ar);
|
||||
|
||||
@@ -945,6 +954,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
|
||||
ED_area_exit(C, sa);
|
||||
|
||||
WM_event_remove_handlers(C, &window->handlers);
|
||||
C->window= prevwin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ void ED_spacetypes_init(void)
|
||||
|
||||
/* register operator types for screen and all spaces */
|
||||
ED_operatortypes_screen();
|
||||
UI_operatortypes();
|
||||
ui_view2d_operatortypes();
|
||||
|
||||
spacetypes = BKE_spacetypes_list();
|
||||
@@ -89,7 +88,6 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
|
||||
|
||||
ED_keymap_screen(wm);
|
||||
UI_view2d_keymap(wm);
|
||||
UI_keymap(wm);
|
||||
|
||||
spacetypes = BKE_spacetypes_list();
|
||||
for(type=spacetypes->first; type; type=type->next)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_oops_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
@@ -105,17 +106,17 @@ void UI_table_free(uiTable *table)
|
||||
MEM_freeN(table);
|
||||
}
|
||||
|
||||
void UI_table_draw(wmWindow *window, ARegion *region, uiTable *table)
|
||||
void UI_table_draw(const bContext *C, uiTable *table)
|
||||
{
|
||||
uiBlock *block;
|
||||
View2D *v2d;
|
||||
rcti *rct, cellrct;
|
||||
int y, row, col;
|
||||
|
||||
v2d= ®ion->v2d;
|
||||
v2d= &C->region->v2d;
|
||||
rct= &table->rct;
|
||||
|
||||
block= uiBeginBlock(window, region, "table outliner", UI_EMBOSST, UI_HELV);
|
||||
block= uiBeginBlock(C, C->region, "table outliner", UI_EMBOSST, UI_HELV);
|
||||
|
||||
for(y=rct->ymax, row=0; y>rct->ymin; y-=ROW_HEIGHT, row++) {
|
||||
if(row%2 == 0) {
|
||||
@@ -141,7 +142,7 @@ void UI_table_draw(wmWindow *window, ARegion *region, uiTable *table)
|
||||
for(col=0; col<table->cols; col++)
|
||||
fdrawline(rct->xmin+COLUMN_WIDTH*(col+1), rct->ymin, rct->xmin+COLUMN_WIDTH*(col+1), rct->ymax);
|
||||
|
||||
uiEndBlock(block);
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(block);
|
||||
}
|
||||
|
||||
@@ -416,7 +417,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar)
|
||||
table= UI_table_create(rows, 2, &rct, rna_table_cell_func, &cell);
|
||||
|
||||
RNA_property_collection_begin(&cell.ptr, iterprop, &cell.iter);
|
||||
UI_table_draw(C->window, ar, table);
|
||||
UI_table_draw(C, table);
|
||||
RNA_property_collection_end(&cell.iter);
|
||||
|
||||
UI_table_free(table);
|
||||
@@ -432,7 +433,6 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
static void outliner_main_area_free(ARegion *ar)
|
||||
{
|
||||
uiFreeBlocks(&ar->uiblocks);
|
||||
}
|
||||
|
||||
/* ************************ header outliner area region *********************** */
|
||||
@@ -466,7 +466,6 @@ static void outliner_header_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
static void outliner_header_area_free(ARegion *ar)
|
||||
{
|
||||
uiFreeBlocks(&ar->uiblocks);
|
||||
}
|
||||
|
||||
/* ******************** default callbacks for outliner space ***************** */
|
||||
@@ -506,8 +505,7 @@ static void outliner_init(wmWindowManager *wm, ScrArea *sa)
|
||||
|
||||
/* XXX fixme, should be smarter */
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "Interface", 0, 0);
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
UI_add_region_handlers(&ar->handlers);
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "View2D", 0, 0);
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
|
||||
@@ -182,7 +182,6 @@ static void time_header_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
static void time_header_area_free(ARegion *ar)
|
||||
{
|
||||
uiFreeBlocks(&ar->uiblocks);
|
||||
}
|
||||
|
||||
/* ******************** default callbacks for time space ***************** */
|
||||
@@ -246,8 +245,7 @@ static void time_init(wmWindowManager *wm, ScrArea *sa)
|
||||
|
||||
/* XXX fixme, should be smarter */
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "Interface", 0, 0);
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
UI_add_region_handlers(&ar->handlers);
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "View2D", 0, 0);
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
|
||||
@@ -109,7 +109,7 @@ typedef struct ScrArea {
|
||||
struct SpaceType *type; /* callbacks for this space type */
|
||||
|
||||
ListBase spacedata;
|
||||
ListBase uiblocks;
|
||||
ListBase uiblocks; /* uiBlock */
|
||||
ListBase panels;
|
||||
ListBase regionbase; /* ARegion */
|
||||
ListBase handlers; /* wmEventHandler */
|
||||
|
||||
@@ -132,7 +132,7 @@ void rna_def_brush(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "clone.image");
|
||||
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Image", "Image for clone tool.");
|
||||
RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool.");
|
||||
|
||||
prop= RNA_def_property(srna, "clone_opacity", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "clone.alpha");
|
||||
|
||||
@@ -216,7 +216,7 @@ static void rna_def_image(BlenderRNA *brna)
|
||||
|
||||
prop= RNA_def_property(srna, "clamp_y", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V);
|
||||
RNA_def_property_ui_text(prop, "Clamp y", "Disable texture repeating vertically.");
|
||||
RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically.");
|
||||
}
|
||||
|
||||
void RNA_def_image(BlenderRNA *brna)
|
||||
|
||||
@@ -74,11 +74,13 @@ ListBase *WM_keymap_listbase (wmWindowManager *wm, const char *nameid,
|
||||
struct wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap);
|
||||
void WM_event_remove_keymap_handler(ListBase *handlers, ListBase *keymap);
|
||||
|
||||
struct wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOperator *op);
|
||||
void WM_event_remove_handlers (bContext *C, ListBase *handlers);
|
||||
struct wmEventHandler *WM_event_add_ui_handler(bContext *C, ListBase *handlers,
|
||||
int (*func)(bContext *C, struct wmEvent *event), void (*remove)(bContext *C));
|
||||
void WM_event_remove_ui_handler(ListBase *handlers);
|
||||
|
||||
struct wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOperator *op);
|
||||
void WM_event_remove_handlers(bContext *C, ListBase *handlers);
|
||||
|
||||
void WM_event_add_message(wmWindowManager *wm, void *customdata,
|
||||
short customdatafree);
|
||||
void WM_event_add_mousemove(bContext *C);
|
||||
|
||||
void WM_event_add_notifier(bContext *C, int type, int value, void *data);
|
||||
|
||||
@@ -86,8 +86,15 @@ typedef struct wmEvent {
|
||||
#define KM_RELEASE 0
|
||||
#define KM_PRESS 1
|
||||
|
||||
/* ************** UI Handler ***************** */
|
||||
|
||||
/* ************** notifiers ****************** */
|
||||
#define WM_UI_HANDLER_CONTINUE 0
|
||||
#define WM_UI_HANDLER_BREAK 1
|
||||
|
||||
typedef int (*wmUIHandlerFunc)(bContext *C, struct wmEvent *event);
|
||||
typedef void (*wmUIHandlerRemoveFunc)(bContext *C);
|
||||
|
||||
/* ************** Notifiers ****************** */
|
||||
|
||||
typedef struct wmNotifier {
|
||||
struct wmNotifier *prev, *next;
|
||||
|
||||
@@ -337,11 +337,35 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers)
|
||||
while((handler=handlers->first)) {
|
||||
BLI_remlink(handlers, handler);
|
||||
|
||||
if(C && handler->op) {
|
||||
if(handler->op->type->cancel)
|
||||
if(handler->op) {
|
||||
if(handler->op->type->cancel) {
|
||||
ScrArea *area= C->area;
|
||||
ARegion *region= C->region;
|
||||
|
||||
C->area= handler->op_area;
|
||||
C->region= handler->op_region;
|
||||
|
||||
handler->op->type->cancel(C, handler->op);
|
||||
|
||||
C->area= area;
|
||||
C->region= region;
|
||||
}
|
||||
|
||||
wm_operator_free(handler->op);
|
||||
}
|
||||
else if(handler->ui_remove) {
|
||||
ScrArea *area= C->area;
|
||||
ARegion *region= C->region;
|
||||
|
||||
if(handler->ui_area) C->area= handler->ui_area;
|
||||
if(handler->ui_region) C->region= handler->ui_region;
|
||||
|
||||
handler->ui_remove(C);
|
||||
|
||||
C->area= area;
|
||||
C->region= region;
|
||||
}
|
||||
|
||||
wm_event_free_handler(handler);
|
||||
MEM_freeN(handler);
|
||||
}
|
||||
@@ -428,10 +452,32 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
|
||||
return WM_HANDLER_BREAK;
|
||||
}
|
||||
|
||||
static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *event)
|
||||
{
|
||||
ScrArea *area= C->area;
|
||||
ARegion *region= C->region;
|
||||
int retval;
|
||||
|
||||
/* we set context to where ui handler came from */
|
||||
if(handler->ui_area) C->area= handler->ui_area;
|
||||
if(handler->ui_region) C->region= handler->ui_region;
|
||||
|
||||
retval= handler->ui_handle(C, event);
|
||||
|
||||
/* putting back screen context */
|
||||
C->area= area;
|
||||
C->region= region;
|
||||
|
||||
if(retval == WM_UI_HANDLER_BREAK)
|
||||
return WM_HANDLER_BREAK;
|
||||
|
||||
return WM_HANDLER_CONTINUE;
|
||||
}
|
||||
|
||||
static int wm_event_always_pass(wmEvent *event)
|
||||
{
|
||||
/* some events we always pass on, to ensure proper communication */
|
||||
return (event->type == TIMER || event->type == MESSAGE);
|
||||
return (event->type == TIMER);
|
||||
}
|
||||
|
||||
static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
@@ -465,6 +511,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(handler->ui_handle) {
|
||||
action= wm_handler_ui_call(C, handler, event);
|
||||
}
|
||||
else {
|
||||
/* modal, swallows all */
|
||||
action= wm_handler_operator_call(C, handlers, handler, event);
|
||||
@@ -543,26 +592,6 @@ void wm_event_do_handlers(bContext *C)
|
||||
|
||||
action= wm_handlers_do(C, event, &win->handlers);
|
||||
|
||||
/* modal menus in Blender use (own) regions linked to screen */
|
||||
if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) {
|
||||
ARegion *ar;
|
||||
|
||||
/* region are in drawing order, i.e. frontmost region last so
|
||||
* we handle events in the opposite order last to first */
|
||||
for(ar=win->screen->regionbase.last; ar; ar= ar->prev) {
|
||||
if(wm_event_always_pass(event) || wm_event_inside_i(event, &ar->winrct)) {
|
||||
C->region= ar;
|
||||
wm_handlers_do(C, event, &ar->handlers);
|
||||
C->region= NULL;
|
||||
|
||||
if(!wm_event_always_pass(event)) {
|
||||
action= WM_HANDLER_BREAK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) {
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
@@ -576,7 +605,7 @@ void wm_event_do_handlers(bContext *C)
|
||||
|
||||
if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) {
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(wm_event_always_pass(event) || wm_event_inside_i(event, &ar->winrct)) {
|
||||
if(wm_event_always_pass(event) || wm_event_inside_i(event, &ar->winrct) || wm_event_prev_inside_i(event, &ar->winrct)) {
|
||||
C->region= ar;
|
||||
action= wm_handlers_do(C, event, &ar->handlers);
|
||||
C->region= NULL;
|
||||
@@ -616,13 +645,13 @@ void WM_event_set_handler_flag(wmEventHandler *handler, int flag)
|
||||
|
||||
wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOperator *op)
|
||||
{
|
||||
wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event handler");
|
||||
wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event modal handler");
|
||||
handler->op= op;
|
||||
handler->op_area= C->area; /* means frozen screen context for modal handlers! */
|
||||
handler->op_region= C->region;
|
||||
|
||||
BLI_addhead(handlers, handler);
|
||||
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
@@ -635,7 +664,7 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap
|
||||
if(handler->keymap==keymap)
|
||||
return handler;
|
||||
|
||||
handler= MEM_callocN(sizeof(wmEventHandler), "event handler");
|
||||
handler= MEM_callocN(sizeof(wmEventHandler), "event keymap handler");
|
||||
BLI_addtail(handlers, handler);
|
||||
handler->keymap= keymap;
|
||||
|
||||
@@ -656,21 +685,30 @@ void WM_event_remove_keymap_handler(ListBase *handlers, ListBase *keymap)
|
||||
}
|
||||
}
|
||||
|
||||
void WM_event_add_message(wmWindowManager *wm, void *customdata, short customdatafree)
|
||||
wmEventHandler *WM_event_add_ui_handler(bContext *C, ListBase *handlers, wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove)
|
||||
{
|
||||
wmEvent event;
|
||||
wmWindow *win;
|
||||
wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event ui handler");
|
||||
handler->ui_handle= func;
|
||||
handler->ui_remove= remove;
|
||||
handler->ui_area= (C)? C->area: NULL;
|
||||
handler->ui_region= (C)? C->region: NULL;
|
||||
|
||||
BLI_addhead(handlers, handler);
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
for(win=wm->windows.first; win; win=win->next) {
|
||||
event= *(win->eventstate);
|
||||
|
||||
event.type= MESSAGE;
|
||||
if(customdata) {
|
||||
event.custom= EVT_DATA_MESSAGE;
|
||||
event.customdata= customdata;
|
||||
event.customdatafree= customdatafree;
|
||||
void WM_event_remove_ui_handler(ListBase *handlers)
|
||||
{
|
||||
wmEventHandler *handler;
|
||||
|
||||
for(handler= handlers->first; handler; handler= handler->next) {
|
||||
if(handler->ui_handle) {
|
||||
BLI_remlink(handlers, handler);
|
||||
wm_event_free_handler(handler);
|
||||
MEM_freeN(handler);
|
||||
break;
|
||||
}
|
||||
wm_event_add(win, &event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,8 +716,9 @@ void WM_event_add_mousemove(bContext *C)
|
||||
{
|
||||
wmEvent event= *(C->window->eventstate);
|
||||
event.type= MOUSEMOVE;
|
||||
event.prevx= event.x;
|
||||
event.prevy= event.y;
|
||||
wm_event_add(C->window, &event);
|
||||
|
||||
}
|
||||
|
||||
/* ********************* ghost stuff *************** */
|
||||
|
||||
@@ -40,15 +40,21 @@ struct ARegion;
|
||||
typedef struct wmEventHandler {
|
||||
struct wmEventHandler *next, *prev;
|
||||
|
||||
int type, flag; /* type default=0, rest is custom */
|
||||
int type, flag; /* type default=0, rest is custom */
|
||||
|
||||
ListBase *keymap; /* pointer to builtin/custom keymaps */
|
||||
/* keymap handler */
|
||||
ListBase *keymap; /* pointer to builtin/custom keymaps */
|
||||
|
||||
rctf boundbox; /* float, in bContext space (window, area, region) */
|
||||
|
||||
wmOperator *op; /* for derived/modal handlers */
|
||||
/* modal operator handler */
|
||||
wmOperator *op; /* for derived/modal handlers */
|
||||
struct ScrArea *op_area; /* for derived/modal handlers */
|
||||
struct ARegion *op_region; /* for derived/modal handlers */
|
||||
|
||||
/* ui handler */
|
||||
wmUIHandlerFunc ui_handle; /* callback receiving events */
|
||||
wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */
|
||||
struct ScrArea *ui_area; /* for derived/modal handlers */
|
||||
struct ARegion *ui_region; /* for derived/modal handlers */
|
||||
|
||||
} wmEventHandler;
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#define EVT_DATA_TABLET 1
|
||||
#define EVT_DATA_GESTURE 2
|
||||
#define EVT_DATA_TIMER 3
|
||||
#define EVT_DATA_MESSAGE 4
|
||||
|
||||
#define MOUSEX 0x004
|
||||
#define MOUSEY 0x005
|
||||
@@ -69,7 +68,6 @@
|
||||
#define WINQUIT 0x0108 /* signal from user that app is to go away */
|
||||
#define Q_FIRSTTIME 0x0109 /* on startup */
|
||||
#define TIMER 0x0110 /* timer event */
|
||||
#define MESSAGE 0x0111 /* message event */
|
||||
|
||||
/* standard keyboard */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user