Added custom data pointer to custom region_draw_cb
Also removed the test with green rect.
This commit is contained in:
Ton Roosendaal
2009-01-10 16:49:22 +00:00
parent f26d9b8771
commit 446933c73f
3 changed files with 8 additions and 19 deletions

View File

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

View File

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

View File

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