Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pinzon Fernandez <apinzonf@gmail.com>2013-12-11 20:10:22 +0400
committerAlexander Pinzon Fernandez <apinzonf@gmail.com>2013-12-11 20:10:22 +0400
commit2658a3c1b44717f497f187a38000c804eb37bbba (patch)
treeee55c673feabced8b6ec8bf9a8aa4d82a3cda3db /source/blender/editors/screen/screen_edit.c
parent4005cb1c6a63a217df0e887c741beee2c1359301 (diff)
parent09b859d03f0ee138c4273ef8460e91d9888387a1 (diff)
Merge branch 'master' into soc-2013-sketch_meshsoc-2013-sketch_mesh
Conflicts: release/scripts/addons source/blender/blenloader/intern/readfile.c source/blender/blenloader/intern/writefile.c source/blender/editors/object/object_modifier.c source/blender/makesrna/intern/rna_modifier.c source/blender/modifiers/intern/MOD_laplaciandeform.c
Diffstat (limited to 'source/blender/editors/screen/screen_edit.c')
-rw-r--r--source/blender/editors/screen/screen_edit.c194
1 files changed, 149 insertions, 45 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 356db174c2f..61d28a45fac 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -264,7 +264,10 @@ int scredge_is_horizontal(ScrEdge *se)
return (se->v1->vec.y == se->v2->vec.y);
}
-ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
+/* need win size to make sure not to include edges along screen edge */
+ScrEdge *screen_find_active_scredge(bScreen *sc,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my)
{
ScrEdge *se;
int safety = U.widget_unit / 10;
@@ -273,20 +276,24 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
for (se = sc->edgebase.first; se; se = se->next) {
if (scredge_is_horizontal(se)) {
- short min, max;
- min = MIN2(se->v1->vec.x, se->v2->vec.x);
- max = MAX2(se->v1->vec.x, se->v2->vec.x);
-
- if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max)
- return se;
+ if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) {
+ short min, max;
+ min = MIN2(se->v1->vec.x, se->v2->vec.x);
+ max = MAX2(se->v1->vec.x, se->v2->vec.x);
+
+ if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max)
+ return se;
+ }
}
else {
- short min, max;
- min = MIN2(se->v1->vec.y, se->v2->vec.y);
- max = MAX2(se->v1->vec.y, se->v2->vec.y);
-
- if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max)
- return se;
+ if (se->v1->vec.x > 0 && se->v1->vec.x < winsize_x - 1) {
+ short min, max;
+ min = MIN2(se->v1->vec.y, se->v2->vec.y);
+ max = MAX2(se->v1->vec.y, se->v2->vec.y);
+
+ if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max)
+ return se;
+ }
}
}
@@ -453,6 +460,9 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
/* uses window size */
bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name)
{
+ const int winsize_x = WM_window_pixels_x(win);
+ const int winsize_y = WM_window_pixels_y(win);
+
bScreen *sc;
ScrVert *sv1, *sv2, *sv3, *sv4;
@@ -463,9 +473,9 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name)
sc->winid = win->winid;
sv1 = screen_addvert(sc, 0, 0);
- sv2 = screen_addvert(sc, 0, WM_window_pixels_y(win) - 1);
- sv3 = screen_addvert(sc, WM_window_pixels_x(win) - 1, WM_window_pixels_y(win) - 1);
- sv4 = screen_addvert(sc, WM_window_pixels_x(win) - 1, 0);
+ sv2 = screen_addvert(sc, 0, winsize_y - 1);
+ sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1);
+ sv4 = screen_addvert(sc, winsize_x - 1, 0);
screen_addedge(sc, sv1, sv2);
screen_addedge(sc, sv2, sv3);
@@ -655,11 +665,16 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
}
/* test if screen vertices should be scaled */
-static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
+static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
{
+ /* clamp Y size of header sized areas when expanding windows
+ * avoids annoying empty space around file menu */
+#define USE_HEADER_SIZE_CLAMP
+
+ const int headery_init = ED_area_headersize();
ScrVert *sv = NULL;
ScrArea *sa;
- int sizex, sizey;
+ int winsize_x_prev, winsize_y_prev;
float facx, facy, tempf, min[2], max[2];
/* calculate size */
@@ -677,14 +692,41 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
sv->vec.y -= min[1];
}
- sizex = max[0] - min[0];
- sizey = max[1] - min[1];
-
- if (sizex != winsizex || sizey != winsizey) {
- facx = winsizex;
- facx /= (float)sizex;
- facy = winsizey;
- facy /= (float)sizey;
+ winsize_x_prev = (max[0] - min[0]) + 1;
+ winsize_y_prev = (max[1] - min[1]) + 1;
+
+
+#ifdef USE_HEADER_SIZE_CLAMP
+#define TEMP_BOTTOM 1
+#define TEMP_TOP 2
+
+ /* if the window's Y axis grows, clamp header sized areas */
+ if (winsize_y_prev < winsize_y) { /* growing? */
+ const int headery_margin_max = headery_init + 4;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ sa->temp = 0;
+
+ if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
+ if (sa->v2->vec.y == winsize_y_prev - 1) {
+ if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
+ sa->temp = TEMP_TOP;
+ }
+ }
+ else if (sa->v1->vec.y == 0) {
+ if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
+ sa->temp = TEMP_BOTTOM;
+ }
+ }
+ }
+ }
+ }
+#endif
+
+
+ if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) {
+ facx = ((float)winsize_x) / ((float)winsize_x_prev - 1);
+ facy = ((float)winsize_y) / ((float)winsize_y_prev - 1);
/* make sure it fits! */
for (sv = sc->vertbase.first; sv; sv = sv->next) {
@@ -695,25 +737,79 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
//sv->vec.x += AREAGRID - 1;
//sv->vec.x -= (sv->vec.x % AREAGRID);
- CLAMP(sv->vec.x, 0, winsizex);
+ CLAMP(sv->vec.x, 0, winsize_x - 1);
tempf = ((float)sv->vec.y) * facy;
sv->vec.y = (short)(tempf + 0.5f);
//sv->vec.y += AREAGRID - 1;
//sv->vec.y -= (sv->vec.y % AREAGRID);
- CLAMP(sv->vec.y, 0, winsizey);
+ CLAMP(sv->vec.y, 0, winsize_y - 1);
}
}
-
+
+
+#ifdef USE_HEADER_SIZE_CLAMP
+ if (winsize_y_prev < winsize_y) { /* growing? */
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ ScrEdge *se = NULL;
+
+ if (sa->temp == 0)
+ continue;
+
+ if (sa->v1 == sa->v2)
+ continue;
+
+ /* adjust headery if verts are along the edge of window */
+ if (sa->temp == TEMP_TOP) {
+ /* lower edge */
+ const int yval = sa->v2->vec.y - headery_init;
+ se = screen_findedge(sc, sa->v4, sa->v1);
+ select_connected_scredge(sc, se);
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ if (sv != sa->v2 && sv != sa->v3) {
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
+ }
+ }
+ }
+ else {
+ /* upper edge */
+ const int yval = sa->v1->vec.y + headery_init;
+ se = screen_findedge(sc, sa->v2, sa->v3);
+ select_connected_scredge(sc, se);
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
+ if (sv != sa->v1 && sv != sa->v4) {
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#undef USE_HEADER_SIZE_CLAMP
+#undef TEMP_BOTTOM
+#undef TEMP_TOP
+#endif
+
+
/* test for collapsed areas. This could happen in some blender version... */
/* ton: removed option now, it needs Context... */
/* make each window at least ED_area_headersize() high */
for (sa = sc->areabase.first; sa; sa = sa->next) {
- int headery = ED_area_headersize() + U.pixelsize;
+ int headery = headery_init;
+
+ /* adjust headery if verts are along the edge of window */
+ if (sa->v1->vec.y > 0)
+ headery += U.pixelsize;
+ if (sa->v2->vec.y < winsize_y - 1)
+ headery += U.pixelsize;
- if (sa->v1->vec.y + headery > sa->v2->vec.y) {
+ if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) {
/* lower edge */
ScrEdge *se = screen_findedge(sc, sa->v4, sa->v1);
if (se && sa->v1 != sa->v2) {
@@ -722,14 +818,14 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
select_connected_scredge(sc, se);
/* all selected vertices get the right offset */
- yval = sa->v2->vec.y - headery;
- sv = sc->vertbase.first;
- while (sv) {
+ yval = sa->v2->vec.y - headery + 1;
+ for (sv = sc->vertbase.first; sv; sv = sv->next) {
/* if is a collapsed area */
if (sv != sa->v2 && sv != sa->v3) {
- if (sv->flag) sv->vec.y = yval;
+ if (sv->flag) {
+ sv->vec.y = yval;
+ }
}
- sv = sv->next;
}
}
}
@@ -947,7 +1043,7 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center)
if (U.pixelsize > 1.0f) {
glColor3ub(0x50, 0x50, 0x50);
- glLineWidth(1.5f * U.pixelsize);
+ glLineWidth((2.0f * U.pixelsize) - 1);
drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, 0);
glLineWidth(1.0f);
}
@@ -1022,6 +1118,9 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note)
/* only for edge lines between areas, and the blended join arrows */
void ED_screen_draw(wmWindow *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;
@@ -1035,10 +1134,10 @@ void ED_screen_draw(wmWindow *win)
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;
- drawscredge_area(sa, WM_window_pixels_x(win), WM_window_pixels_y(win), 0);
+ drawscredge_area(sa, winsize_x, winsize_y, 0);
}
for (sa = win->screen->areabase.first; sa; sa = sa->next)
- drawscredge_area(sa, WM_window_pixels_x(win), WM_window_pixels_y(win), 1);
+ drawscredge_area(sa, winsize_x, winsize_y, 1);
/* blended join arrow */
if (sa1 && sa2) {
@@ -1107,18 +1206,20 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
{
/* exception for bg mode, we only need the screen context */
if (!G.background) {
+ const int winsize_x = WM_window_pixels_x(win);
+ const int winsize_y = WM_window_pixels_y(win);
ScrArea *sa;
rcti winrct;
winrct.xmin = 0;
- winrct.xmax = WM_window_pixels_x(win) - 1;
+ winrct.xmax = winsize_x - 1;
winrct.ymin = 0;
- winrct.ymax = WM_window_pixels_y(win) - 1;
+ winrct.ymax = winsize_y - 1;
/* header size depends on DPI, let's verify */
screen_refresh_headersizes();
- screen_test_scale(win->screen, WM_window_pixels_x(win), WM_window_pixels_y(win));
+ screen_test_scale(win->screen, winsize_x, winsize_y);
if (win->screen->mainwin == 0)
win->screen->mainwin = wm_subwindow_open(win, &winrct);
@@ -1133,7 +1234,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* wake up animtimer */
if (win->screen->animtimer)
- WM_event_timer_sleep(wm, win, win->screen->animtimer, 0);
+ WM_event_timer_sleep(wm, win, win->screen->animtimer, false);
}
if (G.debug & G_DEBUG_EVENTS) {
@@ -1245,6 +1346,9 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
/* case when on area-edge or in azones, or outside window */
static void screen_cursor_set(wmWindow *win, wmEvent *event)
{
+ const int winsize_x = WM_window_pixels_x(win);
+ const int winsize_y = WM_window_pixels_y(win);
+
AZone *az = NULL;
ScrArea *sa;
@@ -1263,7 +1367,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event)
}
}
else {
- ScrEdge *actedge = screen_find_active_scredge(win->screen, event->x, event->y);
+ ScrEdge *actedge = screen_find_active_scredge(win->screen, winsize_x, winsize_y, event->x, event->y);
if (actedge) {
if (scredge_is_horizontal(actedge))
@@ -1410,7 +1514,7 @@ void ED_screen_set(bContext *C, bScreen *sc)
/* we put timer to sleep, so screen_exit has to think there's no timer */
oldscreen->animtimer = NULL;
if (wt)
- WM_event_timer_sleep(wm, win, wt, 1);
+ WM_event_timer_sleep(wm, win, wt, true);
ED_screen_exit(C, win, oldscreen);
oldscreen->animtimer = wt;