2.5
Added custom data pointer to custom region_draw_cb Also removed the test with green rect.
This commit is contained in:
@@ -61,8 +61,8 @@ void ED_file_exit(void);
|
||||
#define REGION_DRAW_POST 0
|
||||
|
||||
void *ED_region_draw_cb_activate(struct ARegionType *,
|
||||
void (*draw)(const struct bContext *, struct ARegion *),
|
||||
int type);
|
||||
void (*draw)(const struct bContext *, struct ARegion *, void *),
|
||||
void *custumdata, int type);
|
||||
void ED_region_draw_cb_draw(const struct bContext *, struct ARegion *, int);
|
||||
void ED_region_draw_cb_exit(struct ARegionType *, void *);
|
||||
|
||||
|
||||
@@ -132,20 +132,22 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
|
||||
typedef struct RegionDrawCB {
|
||||
struct RegionDrawCB *next, *prev;
|
||||
|
||||
void (*draw)(const struct bContext *, struct ARegion *);
|
||||
void (*draw)(const struct bContext *, struct ARegion *, void *);
|
||||
void *customdata;
|
||||
|
||||
int type;
|
||||
|
||||
} RegionDrawCB;
|
||||
|
||||
void *ED_region_draw_cb_activate(ARegionType *art,
|
||||
void (*draw)(const struct bContext *, struct ARegion *),
|
||||
int type)
|
||||
void (*draw)(const struct bContext *, struct ARegion *, void *),
|
||||
void *customdata, int type)
|
||||
{
|
||||
RegionDrawCB *rdc= MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB");
|
||||
|
||||
BLI_addtail(&art->drawcalls, rdc);
|
||||
rdc->draw= draw;
|
||||
rdc->customdata= customdata;
|
||||
rdc->type= type;
|
||||
|
||||
return rdc;
|
||||
@@ -170,7 +172,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
|
||||
|
||||
for(rdc= ar->type->drawcalls.first; rdc; rdc= rdc->next) {
|
||||
if(rdc->type==type)
|
||||
rdc->draw(C, ar);
|
||||
rdc->draw(C, ar, rdc->customdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ typedef struct ViewOpsData {
|
||||
int origx, origy, oldx, oldy;
|
||||
int origkey;
|
||||
|
||||
void *vh; // XXX temp
|
||||
} ViewOpsData;
|
||||
|
||||
#define TRACKBALLSIZE (1.1)
|
||||
@@ -364,10 +363,6 @@ static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
default:
|
||||
if(event->type==vod->origkey && event->val==0) {
|
||||
|
||||
if(vod->vh) {
|
||||
ED_region_draw_cb_exit(CTX_wm_region(C)->type, vod->vh);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
}
|
||||
MEM_freeN(vod);
|
||||
op->customdata= NULL;
|
||||
|
||||
@@ -378,12 +373,6 @@ static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
static void vh_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
glColor3ub(100, 200, 100);
|
||||
glRectf(-0.2, -0.2, 0.2, 0.2);
|
||||
}
|
||||
|
||||
static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ViewOpsData *vod;
|
||||
@@ -392,8 +381,6 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
viewops_data(C, op, event);
|
||||
vod= op->customdata;
|
||||
|
||||
vod->vh= ED_region_draw_cb_activate(CTX_wm_region(C)->type, vh_draw, REGION_DRAW_POST);
|
||||
|
||||
/* switch from camera view when: */
|
||||
if(vod->v3d->persp != V3D_PERSP) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user