Merge branch 'master' into blender2.8
This commit is contained in:
commit
4444ea42f2
|
@ -125,7 +125,9 @@ int ED_area_headersize(void);
|
|||
|
||||
/* screens */
|
||||
void ED_screens_initialize(struct wmWindowManager *wm);
|
||||
void ED_screen_draw(struct wmWindow *win);
|
||||
void ED_screen_draw_edges(struct wmWindow *win);
|
||||
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
|
||||
void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
|
||||
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
|
||||
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
|
||||
bool ED_screen_change(struct bContext *C, struct bScreen *sc);
|
||||
|
|
|
@ -291,16 +291,13 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, unsigned int pos
|
|||
/**
|
||||
* Only for edge lines between areas, and the blended join arrows.
|
||||
*/
|
||||
void ED_screen_draw(wmWindow *win)
|
||||
void ED_screen_draw_edges(wmWindow *win)
|
||||
{
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
const int winsize_x = WM_window_pixels_x(win);
|
||||
const int winsize_y = WM_window_pixels_y(win);
|
||||
|
||||
ScrArea *sa;
|
||||
ScrArea *sa1 = NULL;
|
||||
ScrArea *sa2 = NULL;
|
||||
ScrArea *sa3 = NULL;
|
||||
|
||||
wmSubWindowSet(win, screen->mainwin);
|
||||
|
||||
|
@ -323,36 +320,41 @@ void ED_screen_draw(wmWindow *win)
|
|||
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
drawscredge_area(sa, winsize_x, winsize_y, pos);
|
||||
|
||||
/* gather area split/join info */
|
||||
if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa;
|
||||
if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa;
|
||||
if (sa->flag & (AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V)) sa3 = sa;
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
screen->do_draw = false;
|
||||
}
|
||||
|
||||
void ED_screen_draw_join_shape(ScrArea *sa1, ScrArea *sa2)
|
||||
{
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
glLineWidth(1);
|
||||
|
||||
/* blended join arrow */
|
||||
if (sa1 && sa2) {
|
||||
int dir = area_getorientation(sa1, sa2);
|
||||
int dira = -1;
|
||||
if (dir != -1) {
|
||||
switch (dir) {
|
||||
case 0: /* W */
|
||||
dir = 'r';
|
||||
dira = 'l';
|
||||
break;
|
||||
case 1: /* N */
|
||||
dir = 'd';
|
||||
dira = 'u';
|
||||
break;
|
||||
case 2: /* E */
|
||||
dir = 'l';
|
||||
dira = 'r';
|
||||
break;
|
||||
case 3: /* S */
|
||||
dir = 'u';
|
||||
dira = 'd';
|
||||
break;
|
||||
}
|
||||
int dir = area_getorientation(sa1, sa2);
|
||||
int dira = -1;
|
||||
if (dir != -1) {
|
||||
switch (dir) {
|
||||
case 0: /* W */
|
||||
dir = 'r';
|
||||
dira = 'l';
|
||||
break;
|
||||
case 1: /* N */
|
||||
dir = 'd';
|
||||
dira = 'u';
|
||||
break;
|
||||
case 2: /* E */
|
||||
dir = 'l';
|
||||
dira = 'r';
|
||||
break;
|
||||
case 3: /* S */
|
||||
dir = 'u';
|
||||
dira = 'd';
|
||||
break;
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -363,48 +365,59 @@ void ED_screen_draw(wmWindow *win)
|
|||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
void ED_screen_draw_split_preview(ScrArea *sa, const int dir, const float fac)
|
||||
{
|
||||
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
/* splitpoint */
|
||||
if (sa3) {
|
||||
glEnable(GL_BLEND);
|
||||
immUniformColor4ub(255, 255, 255, 100);
|
||||
glEnable(GL_BLEND);
|
||||
immUniformColor4ub(255, 255, 255, 100);
|
||||
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
if (sa3->flag & AREA_FLAG_DRAWSPLIT_H) {
|
||||
immVertex2f(pos, sa3->totrct.xmin, win->eventstate->y);
|
||||
immVertex2f(pos, sa3->totrct.xmax, win->eventstate->y);
|
||||
if (dir == 'h') {
|
||||
const float y = (1 - fac) * sa->totrct.ymin + fac * sa->totrct.ymax;
|
||||
|
||||
immEnd();
|
||||
|
||||
immUniformColor4ub(0, 0, 0, 100);
|
||||
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
immVertex2f(pos, sa3->totrct.xmin, win->eventstate->y + 1);
|
||||
immVertex2f(pos, sa3->totrct.xmax, win->eventstate->y + 1);
|
||||
}
|
||||
else {
|
||||
immVertex2f(pos, win->eventstate->x, sa3->totrct.ymin);
|
||||
immVertex2f(pos, win->eventstate->x, sa3->totrct.ymax);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUniformColor4ub(0, 0, 0, 100);
|
||||
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
immVertex2f(pos, win->eventstate->x + 1, sa3->totrct.ymin);
|
||||
immVertex2f(pos, win->eventstate->x + 1, sa3->totrct.ymax);
|
||||
}
|
||||
immVertex2f(pos, sa->totrct.xmin, y);
|
||||
immVertex2f(pos, sa->totrct.xmax, y);
|
||||
|
||||
immEnd();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
immUniformColor4ub(0, 0, 0, 100);
|
||||
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
immVertex2f(pos, sa->totrct.xmin, y + 1);
|
||||
immVertex2f(pos, sa->totrct.xmax, y + 1);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
else {
|
||||
BLI_assert(dir == 'v');
|
||||
const float x = (1 - fac) * sa->totrct.xmin + fac * sa->totrct.xmax;
|
||||
|
||||
immVertex2f(pos, x, sa->totrct.ymin);
|
||||
immVertex2f(pos, x, sa->totrct.ymax);
|
||||
|
||||
immEnd();
|
||||
|
||||
immUniformColor4ub(0, 0, 0, 100);
|
||||
|
||||
immBegin(GWN_PRIM_LINES, 2);
|
||||
|
||||
immVertex2f(pos, x + 1, sa->totrct.ymin);
|
||||
immVertex2f(pos, x + 1, sa->totrct.ymax);
|
||||
|
||||
immEnd();
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
screen->do_draw = false;
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -589,8 +589,6 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
|
|||
/*printf("dir is : %i\n", dir);*/
|
||||
|
||||
if (dir == -1) {
|
||||
if (sa1) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
||||
if (sa2) sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -621,7 +619,7 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
|
|||
|
||||
screen_delarea(C, scr, sa2);
|
||||
removedouble_scrverts(scr);
|
||||
sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
||||
|
||||
/* Update preview thumbnail */
|
||||
BKE_icon_changed(scr->id.icon_id);
|
||||
|
||||
|
|
|
@ -1197,18 +1197,15 @@ static int area_snap_calc_location(
|
|||
|
||||
const int m_loc = origval + delta;
|
||||
const int axis = (dir == 'v') ? 0 : 1;
|
||||
int snap_dist = INT_MAX;
|
||||
int snap_dist;
|
||||
int dist;
|
||||
{
|
||||
/* Test the snap to middle. */
|
||||
int middle = origval + (bigger - smaller) / 2;
|
||||
middle -= (middle % AREAGRID);
|
||||
|
||||
dist = abs(m_loc - middle);
|
||||
if (dist <= snap_dist) {
|
||||
snap_dist = dist;
|
||||
final_loc = middle;
|
||||
}
|
||||
snap_dist = abs(m_loc - middle);
|
||||
final_loc = middle;
|
||||
}
|
||||
|
||||
for (const ScrVert *v1 = sc->vertbase.first; v1; v1 = v1->next) {
|
||||
|
@ -1452,6 +1449,7 @@ typedef struct sAreaSplitData {
|
|||
int delta; /* delta move edge */
|
||||
int origmin, origsize; /* to calculate fac, for property storage */
|
||||
int previewmode; /* draw previewline, then split */
|
||||
void *draw_callback; /* call `ED_screen_draw_split_preview` */
|
||||
bool do_snap;
|
||||
|
||||
ScrEdge *nedge; /* new edge */
|
||||
|
@ -1460,6 +1458,19 @@ typedef struct sAreaSplitData {
|
|||
|
||||
} sAreaSplitData;
|
||||
|
||||
static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdata)
|
||||
{
|
||||
const wmOperator *op = userdata;
|
||||
|
||||
sAreaSplitData *sd = op->customdata;
|
||||
if (sd->sarea) {
|
||||
int dir = RNA_enum_get(op->ptr, "direction");
|
||||
float fac = RNA_float_get(op->ptr, "factor");
|
||||
|
||||
ED_screen_draw_split_preview(sd->sarea, dir, fac);
|
||||
}
|
||||
}
|
||||
|
||||
/* generic init, menu case, doesn't need active area */
|
||||
static int area_split_menu_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
|
@ -1470,15 +1481,7 @@ static int area_split_menu_init(bContext *C, wmOperator *op)
|
|||
op->customdata = sd;
|
||||
|
||||
sd->sarea = CTX_wm_area(C);
|
||||
|
||||
if (sd->sarea) {
|
||||
int dir = RNA_enum_get(op->ptr, "direction");
|
||||
|
||||
if (dir == 'h')
|
||||
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H;
|
||||
else
|
||||
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1589,9 +1592,9 @@ static void area_split_exit(bContext *C, wmOperator *op)
|
|||
if (sd->sarea) ED_area_tag_redraw(sd->sarea);
|
||||
if (sd->narea) ED_area_tag_redraw(sd->narea);
|
||||
|
||||
if (sd->sarea)
|
||||
sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V);
|
||||
|
||||
if (sd->draw_callback)
|
||||
WM_draw_cb_exit(CTX_wm_window(C), sd->draw_callback);
|
||||
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
@ -1698,6 +1701,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
}
|
||||
else {
|
||||
sd->previewmode = 1;
|
||||
sd->draw_callback = WM_draw_cb_activate(win, area_split_draw_cb, op);
|
||||
/* add temp handler for edge move or cancel */
|
||||
WM_event_add_modal_handler(C, op);
|
||||
|
||||
|
@ -1755,9 +1759,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
if (sd->previewmode == 0)
|
||||
area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, sd->do_snap);
|
||||
else {
|
||||
/* TODO: Snap in preview mode too. */
|
||||
if (sd->sarea) {
|
||||
sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V);
|
||||
ED_area_tag_redraw(sd->sarea);
|
||||
}
|
||||
/* area context not set */
|
||||
|
@ -1768,22 +1770,31 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
if (dir == 'v') {
|
||||
sd->origsize = sd->sarea->winx;
|
||||
sd->origmin = sd->sarea->totrct.xmin;
|
||||
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V;
|
||||
}
|
||||
else {
|
||||
sd->origsize = sd->sarea->winy;
|
||||
sd->origmin = sd->sarea->totrct.ymin;
|
||||
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H;
|
||||
}
|
||||
|
||||
if (sd->do_snap) {
|
||||
ScrArea *sa = sd->sarea;
|
||||
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
|
||||
|
||||
int snap_loc = area_snap_calc_location(
|
||||
CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin);
|
||||
|
||||
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
|
||||
fac = snap_loc - sd->origmin;
|
||||
}
|
||||
else {
|
||||
fac = (dir == 'v') ? event->x - sd->origmin : event->y - sd->origmin;
|
||||
}
|
||||
RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize);
|
||||
}
|
||||
|
||||
|
||||
CTX_wm_screen(C)->do_draw = true;
|
||||
|
||||
}
|
||||
|
||||
fac = (dir == 'v') ? event->x - sd->origmin : event->y - sd->origmin;
|
||||
RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize);
|
||||
|
||||
break;
|
||||
|
||||
case LEFTMOUSE:
|
||||
|
@ -1809,19 +1820,14 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
|
||||
if (event->val == KM_PRESS) {
|
||||
if (sd->sarea) {
|
||||
sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V);
|
||||
ED_area_tag_redraw(sd->sarea);
|
||||
|
||||
if (dir == 'v') {
|
||||
RNA_enum_set(op->ptr, "direction", 'h');
|
||||
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H;
|
||||
|
||||
WM_cursor_set(CTX_wm_window(C), CURSOR_X_MOVE);
|
||||
}
|
||||
else {
|
||||
RNA_enum_set(op->ptr, "direction", 'v');
|
||||
sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V;
|
||||
|
||||
WM_cursor_set(CTX_wm_window(C), CURSOR_Y_MOVE);
|
||||
}
|
||||
}
|
||||
|
@ -2562,13 +2568,23 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
|
|||
*/
|
||||
|
||||
typedef struct sAreaJoinData {
|
||||
ScrArea *sa1; /* first area to be considered */
|
||||
ScrArea *sa2; /* second area to be considered */
|
||||
ScrArea *scr; /* designed for removal */
|
||||
ScrArea *sa1; /* first area to be considered */
|
||||
ScrArea *sa2; /* second area to be considered */
|
||||
void *draw_callback; /* call `ED_screen_draw_join_shape` */
|
||||
|
||||
} sAreaJoinData;
|
||||
|
||||
|
||||
static void area_join_draw_cb(const struct wmWindow *UNUSED(win), void *userdata)
|
||||
{
|
||||
const wmOperator *op = userdata;
|
||||
|
||||
sAreaJoinData *sd = op->customdata;
|
||||
if (sd->sa1 && sd->sa2) {
|
||||
ED_screen_draw_join_shape(sd->sa1, sd->sa2);
|
||||
}
|
||||
}
|
||||
|
||||
/* validate selection inside screen, set variables OK */
|
||||
/* return 0: init failed */
|
||||
/* XXX todo: find edge based on (x,y) and set other area? */
|
||||
|
@ -2602,14 +2618,14 @@ static int area_join_init(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join");
|
||||
|
||||
|
||||
jd->sa1 = sa1;
|
||||
jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
|
||||
jd->sa2 = sa2;
|
||||
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
||||
|
||||
|
||||
op->customdata = jd;
|
||||
|
||||
|
||||
jd->draw_callback = WM_draw_cb_activate(CTX_wm_window(C), area_join_draw_cb, op);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2633,8 +2649,13 @@ static int area_join_apply(bContext *C, wmOperator *op)
|
|||
/* finish operation */
|
||||
static void area_join_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
if (op->customdata) {
|
||||
MEM_freeN(op->customdata);
|
||||
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
|
||||
|
||||
if (jd) {
|
||||
if (jd->draw_callback)
|
||||
WM_draw_cb_exit(CTX_wm_window(C), jd->draw_callback);
|
||||
|
||||
MEM_freeN(jd);
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
||||
|
@ -2693,17 +2714,6 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
|
||||
static void area_join_cancel(bContext *C, wmOperator *op)
|
||||
{
|
||||
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
|
||||
|
||||
if (jd->sa1) {
|
||||
jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
||||
jd->sa1->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
}
|
||||
if (jd->sa2) {
|
||||
jd->sa2->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
||||
jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
||||
area_join_exit(C, op);
|
||||
|
@ -2727,9 +2737,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
if (jd->sa1 != sa) {
|
||||
dir = area_getorientation(jd->sa1, sa);
|
||||
if (dir != -1) {
|
||||
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
jd->sa2 = sa;
|
||||
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
||||
}
|
||||
else {
|
||||
/* we are not bordering on the previously selected area
|
||||
|
@ -2738,15 +2746,10 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
*/
|
||||
dir = area_getorientation(sa, jd->sa2);
|
||||
if (dir != -1) {
|
||||
if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
||||
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
jd->sa1 = jd->sa2;
|
||||
jd->sa2 = sa;
|
||||
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
|
||||
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
||||
}
|
||||
else {
|
||||
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
jd->sa2 = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2756,12 +2759,8 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
/* we are back in the area previously selected for keeping
|
||||
* we swap the areas if possible to allow user to choose */
|
||||
if (jd->sa2 != NULL) {
|
||||
if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
|
||||
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
jd->sa1 = jd->sa2;
|
||||
jd->sa2 = sa;
|
||||
if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
|
||||
if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
||||
dir = area_getorientation(jd->sa1, jd->sa2);
|
||||
if (dir == -1) {
|
||||
printf("oops, didn't expect that!\n");
|
||||
|
@ -2770,9 +2769,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
else {
|
||||
dir = area_getorientation(jd->sa1, sa);
|
||||
if (dir != -1) {
|
||||
if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
|
||||
jd->sa2 = sa;
|
||||
jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
|
||||
}
|
||||
}
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
|
|
|
@ -290,11 +290,11 @@ typedef struct ARegion {
|
|||
/* area->flag */
|
||||
enum {
|
||||
HEADER_NO_PULLDOWN = (1 << 0),
|
||||
AREA_FLAG_DRAWJOINTO = (1 << 1),
|
||||
AREA_FLAG_DRAWJOINFROM = (1 << 2),
|
||||
// AREA_FLAG_DEPRECATED_1 = (1 << 1),
|
||||
// AREA_FLAG_DEPRECATED_2 = (1 << 2),
|
||||
AREA_TEMP_INFO = (1 << 3),
|
||||
AREA_FLAG_DRAWSPLIT_H = (1 << 4),
|
||||
AREA_FLAG_DRAWSPLIT_V = (1 << 5),
|
||||
// AREA_FLAG_DEPRECATED_4 = (1 << 4),
|
||||
// AREA_FLAG_DEPRECATED_5 = (1 << 5),
|
||||
/* used to check if we should switch back to prevspace (of a different type) */
|
||||
AREA_FLAG_TEMP_TYPE = (1 << 6),
|
||||
/* for temporary fullscreens (file browser, image editor render) that are opened above user set fullscreens */
|
||||
|
|
|
@ -227,6 +227,9 @@ typedef struct wmWindow {
|
|||
ListBase gesture; /* gesture stuff */
|
||||
|
||||
struct Stereo3dFormat *stereo3d_format; /* properties for stereoscopic displays */
|
||||
|
||||
/* custom drawing callbacks */
|
||||
ListBase drawcalls;
|
||||
} wmWindow;
|
||||
|
||||
#ifdef ime_data
|
||||
|
|
|
@ -539,6 +539,11 @@ void WM_progress_set(struct wmWindow *win, float progress);
|
|||
void WM_progress_clear(struct wmWindow *win);
|
||||
|
||||
/* Draw (for screenshot) */
|
||||
void *WM_draw_cb_activate(
|
||||
struct wmWindow *win,
|
||||
void (*draw)(const struct wmWindow *, void *),
|
||||
void *customdata);
|
||||
void WM_draw_cb_exit(struct wmWindow *win, void *handle);
|
||||
void WM_redraw_windows(struct bContext *C);
|
||||
|
||||
void WM_main_playanim(int argc, const char **argv);
|
||||
|
|
|
@ -162,6 +162,46 @@ static void wm_region_test_render_do_draw(const Scene *scene, ScrArea *sa, ARegi
|
|||
/********************** draw all **************************/
|
||||
/* - reference method, draw all each time */
|
||||
|
||||
typedef struct WindowDrawCB {
|
||||
struct WindowDrawCB *next, *prev;
|
||||
|
||||
void(*draw)(const struct wmWindow *, void *);
|
||||
void *customdata;
|
||||
|
||||
} WindowDrawCB;
|
||||
|
||||
void *WM_draw_cb_activate(
|
||||
wmWindow *win,
|
||||
void(*draw)(const struct wmWindow *, void *),
|
||||
void *customdata)
|
||||
{
|
||||
WindowDrawCB *wdc = MEM_callocN(sizeof(*wdc), "WindowDrawCB");
|
||||
|
||||
BLI_addtail(&win->drawcalls, wdc);
|
||||
wdc->draw = draw;
|
||||
wdc->customdata = customdata;
|
||||
|
||||
return wdc;
|
||||
}
|
||||
|
||||
void WM_draw_cb_exit(wmWindow *win, void *handle)
|
||||
{
|
||||
for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) {
|
||||
if (wdc == (WindowDrawCB *)handle) {
|
||||
BLI_remlink(&win->drawcalls, wdc);
|
||||
MEM_freeN(wdc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wm_draw_callbacks(wmWindow *win)
|
||||
{
|
||||
for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) {
|
||||
wdc->draw(win, wdc->customdata);
|
||||
}
|
||||
}
|
||||
|
||||
static void wm_method_draw_full(bContext *C, wmWindow *win)
|
||||
{
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
|
@ -186,8 +226,9 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
|
|||
CTX_wm_area_set(C, NULL);
|
||||
}
|
||||
|
||||
ED_screen_draw(win);
|
||||
ED_screen_draw_edges(win);
|
||||
screen->do_draw = false;
|
||||
wm_draw_callbacks(win);
|
||||
|
||||
/* draw overlapping regions */
|
||||
for (ar = screen->regionbase.first; ar; ar = ar->next) {
|
||||
|
@ -323,17 +364,19 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
|||
|
||||
/* after area regions so we can do area 'overlay' drawing */
|
||||
if (screen->do_draw) {
|
||||
ED_screen_draw(win);
|
||||
ED_screen_draw_edges(win);
|
||||
screen->do_draw = false;
|
||||
wm_draw_callbacks(win);
|
||||
|
||||
if (exchange)
|
||||
screen->swap = WIN_FRONT_OK;
|
||||
}
|
||||
else if (exchange) {
|
||||
if (screen->swap == WIN_FRONT_OK) {
|
||||
ED_screen_draw(win);
|
||||
ED_screen_draw_edges(win);
|
||||
screen->do_draw = false;
|
||||
screen->swap = WIN_BOTH_OK;
|
||||
wm_draw_callbacks(win);
|
||||
}
|
||||
else if (screen->swap == WIN_BACK_OK)
|
||||
screen->swap = WIN_FRONT_OK;
|
||||
|
@ -627,8 +670,9 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
|||
}
|
||||
|
||||
/* after area regions so we can do area 'overlay' drawing */
|
||||
ED_screen_draw(win);
|
||||
ED_screen_draw_edges(win);
|
||||
WM_window_get_active_screen(win)->do_draw = false;
|
||||
wm_draw_callbacks(win);
|
||||
|
||||
/* draw floating regions (menus) */
|
||||
for (ar = screen->regionbase.first; ar; ar = ar->next) {
|
||||
|
@ -802,10 +846,12 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
|
|||
}
|
||||
|
||||
/* after area regions so we can do area 'overlay' drawing */
|
||||
ED_screen_draw(win);
|
||||
ED_screen_draw_edges(win);
|
||||
if (sview == STEREO_RIGHT_ID)
|
||||
screen->do_draw = false;
|
||||
|
||||
wm_draw_callbacks(win);
|
||||
|
||||
/* draw floating regions (menus) */
|
||||
for (ar = screen->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->swinid) {
|
||||
|
|
Loading…
Reference in New Issue