diff options
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 78 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 18 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 7 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 12 |
4 files changed, 91 insertions, 24 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index bed17048ea1..2a561a6bc6c 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -115,7 +115,7 @@ void ED_region_pixelspace(ARegion *ar) void ED_region_do_listen(ARegion *ar, wmNotifier *note) { /* generic notes first */ - switch(note->category) { + switch (note->category) { case NC_WM: if (note->data==ND_FILEREAD) ED_region_tag_redraw(ar); @@ -247,7 +247,7 @@ static void region_draw_azone_tab_plus(AZone *az) glEnable(GL_BLEND); /* add code to draw region hidden as 'too small' */ - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); break; @@ -282,7 +282,7 @@ static void region_draw_azone_tab(AZone *az) glColor4f(col[0], col[1], col[2], 0.5f); /* add code to draw region hidden as 'too small' */ - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA); @@ -325,7 +325,7 @@ static void region_draw_azone_tria(AZone *az) glColor4f(0.0f, 0.0f, 0.0f, 0.35f); /* add code to draw region hidden as 'too small' */ - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1+az->x2)/2, (float)az->y2); break; @@ -623,7 +623,7 @@ static void area_azone_initialize(ScrArea *sa) #define AZONEPAD_ICON 9 static void region_azone_edge(AZone *az, ARegion *ar) { - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: az->x1= ar->winrct.xmin; az->y1= ar->winrct.ymax - AZONEPAD_EDGE; @@ -665,7 +665,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) if (azt->edge == az->edge) tot++; } - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON; az->y1= ar->winrct.ymax + AZONEPAD_ICON; @@ -725,7 +725,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) if (azt->edge == az->edge) tot++; } - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; @@ -770,7 +770,7 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) if (azt->edge == az->edge) tot++; } - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW; @@ -815,7 +815,7 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) if (azt->edge == az->edge) tot++; } - switch(az->edge) { + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW; @@ -1813,3 +1813,63 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) BLF_position(fontid, 12, rect.ymin + 5, 0.0f); BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX); } + +void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) +{ + float gridsize, gridstep = 1.0f / 32.0f; + float fac, blendfac; + int x1, y1, x2, y2; + + /* the image is located inside (0,0),(1, 1) as set by view2d */ + UI_ThemeColorShade(TH_BACK, 20); + + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x1, &y1); + UI_view2d_to_region_no_clip(&ar->v2d, 1.0f, 1.0f, &x2, &y2); + glRectf(x1, y1, x2, y2); + + /* gridsize adapted to zoom level */ + gridsize = 0.5f * (zoomx + zoomy); + if (gridsize <= 0.0f) + return; + + if (gridsize < 1.0f) { + while (gridsize < 1.0f) { + gridsize *= 4.0f; + gridstep *= 4.0f; + } + } + else { + while (gridsize >= 4.0f) { + gridsize /= 4.0f; + gridstep /= 4.0f; + } + } + + /* the fine resolution level */ + blendfac = 0.25f * gridsize - floorf(0.25f * gridsize); + CLAMP(blendfac, 0.0f, 1.0f); + UI_ThemeColorShade(TH_BACK, (int)(20.0f * (1.0f - blendfac))); + + fac = 0.0f; + glBegin(GL_LINES); + while (fac < 1.0f) { + glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2); + fac += gridstep; + } + + /* the large resolution level */ + UI_ThemeColor(TH_BACK); + + fac = 0.0f; + while (fac < 1.0f) { + glVertex2f(x1, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x2, y1 * (1.0f - fac) + y2 * fac); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y1); + glVertex2f(x1 * (1.0f - fac) + x2 * fac, y2); + fac += 4.0f * gridstep; + } + glEnd(); +} diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 5ba0e86e0c1..5b73645abde 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -825,7 +825,7 @@ int bglPointHack(void) void bglVertex3fv(const float vec[3]) { - switch(curmode) { + switch (curmode) { case GL_POINTS: if (pointhack) { glRasterPos3fv(vec); @@ -838,7 +838,7 @@ void bglVertex3fv(const float vec[3]) void bglVertex3f(float x, float y, float z) { - switch(curmode) { + switch (curmode) { case GL_POINTS: if (pointhack) { glRasterPos3f(x, y, z); @@ -851,7 +851,7 @@ void bglVertex3f(float x, float y, float z) void bglVertex2fv(const float vec[2]) { - switch(curmode) { + switch (curmode) { case GL_POINTS: if (pointhack) { glRasterPos2fv(vec); @@ -882,11 +882,15 @@ void bgl_get_mats(bglMats *mats) /* Very strange code here - it seems that certain bad values in the * modelview matrix can cause gluUnProject to give bad results. */ if (mats->modelview[0] < badvalue && - mats->modelview[0] > -badvalue) - mats->modelview[0]= 0; + mats->modelview[0] > -badvalue) + { + mats->modelview[0] = 0; + } if (mats->modelview[5] < badvalue && - mats->modelview[5] > -badvalue) - mats->modelview[5]= 0; + mats->modelview[5] > -badvalue) + { + mats->modelview[5] = 0; + } /* Set up viewport so that gluUnProject will give correct values */ mats->viewport[0] = 0; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 03d8b3d3e9c..512cd404273 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -963,7 +963,7 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note) wmWindow *win= CTX_wm_window(C); /* generic notes */ - switch(note->category) { + switch (note->category) { case NC_WM: if (note->data==ND_FILEREAD) win->screen->do_draw= 1; @@ -1009,7 +1009,7 @@ void ED_screen_draw(wmWindow *win) if (sa1 && sa2) { dir = area_getorientation(sa1, sa2); if (dir >= 0) { - switch(dir) { + switch (dir) { case 0: /* W */ dir = 'r'; dira = 'l'; @@ -1154,6 +1154,9 @@ void ED_area_exit(bContext *C, ScrArea *sa) ED_fileselect_exit(C, (SpaceFile *)sl); } } + else if (sa->spacetype == SPACE_VIEW3D) { + ED_render_engine_area_exit(sa); + } CTX_wm_area_set(C, sa); for (ar= sa->regionbase.first; ar; ar= ar->next) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e427e1e21cf..3777547fa90 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -597,7 +597,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) int deltax, deltay; int mindelta= sad->az->type==AZONE_REGION?1:12; - switch(event->type) { + switch (event->type) { case MOUSEMOVE: /* calculate gesture direction */ deltax= (event->x - sad->x); @@ -735,7 +735,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) { sActionzoneData *sad= op->customdata; - switch(event->type) { + switch (event->type) { case MOUSEMOVE: /* second area, for join */ sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); @@ -1045,7 +1045,7 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) int delta, x, y; /* execute the events */ - switch(event->type) { + switch (event->type) { case MOUSEMOVE: x= RNA_int_get(op->ptr, "x"); @@ -1438,7 +1438,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) int dir; /* execute the events */ - switch(event->type) { + switch (event->type) { case MOUSEMOVE: dir= RNA_enum_get(op->ptr, "direction"); @@ -1711,7 +1711,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) int delta; /* execute the events */ - switch(event->type) { + switch (event->type) { case MOUSEMOVE: if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { @@ -2262,7 +2262,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) sAreaJoinData *jd = (sAreaJoinData *)op->customdata; /* execute the events */ - switch(event->type) { + switch (event->type) { case MOUSEMOVE: { |