~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/screen/area.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: area.c 29959 2010-07-05 03:02:57Z aligorith $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
26
24
 * ***** END GPL LICENSE BLOCK *****
27
25
 */
28
26
 
 
27
/** \file blender/editors/screen/area.c
 
28
 *  \ingroup edscr
 
29
 */
 
30
 
 
31
 
29
32
#include <string.h>
30
33
#include <stdio.h>
31
34
 
36
39
#include "BLI_blenlib.h"
37
40
#include "BLI_math.h"
38
41
#include "BLI_rand.h"
 
42
#include "BLI_utildefines.h"
 
43
 
 
44
#include "BLF_translation.h"
39
45
 
40
46
#include "BKE_context.h"
41
47
#include "BKE_global.h"
42
48
#include "BKE_screen.h"
43
 
#include "BKE_utildefines.h"
44
49
 
45
50
#include "WM_api.h"
46
51
#include "WM_types.h"
48
53
 
49
54
#include "ED_screen.h"
50
55
#include "ED_screen_types.h"
 
56
#include "ED_space_api.h"
51
57
#include "ED_types.h"
52
58
#include "ED_fileselect.h" 
53
59
 
68
74
        rcti rect;
69
75
        
70
76
        /* translate scissor rect to region space */
71
 
        rect.xmin= scirct->xmin - ar->winrct.xmin;
72
 
        rect.ymin= scirct->ymin - ar->winrct.ymin;
73
 
        rect.xmax= scirct->xmax - ar->winrct.xmin;
74
 
        rect.ymax= scirct->ymax - ar->winrct.ymin;
 
77
        rect.xmin = scirct->xmin - ar->winrct.xmin;
 
78
        rect.ymin = scirct->ymin - ar->winrct.ymin;
 
79
        rect.xmax = scirct->xmax - ar->winrct.xmin;
 
80
        rect.ymax = scirct->ymax - ar->winrct.ymin;
75
81
        
76
82
        /* set transp line */
77
83
        glEnable( GL_BLEND );
78
84
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
79
85
        
80
86
        /* right  */
81
 
        glColor4ub(0,0,0, 50);
 
87
        glColor4ub(0,0,0, 30);
82
88
        sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax);
83
89
        
84
90
        /* bottom  */
85
 
        glColor4ub(0,0,0, 80);
 
91
        glColor4ub(0,0,0, 30);
86
92
        sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin);
87
93
        
88
94
        /* top  */
89
 
        glColor4ub(255,255,255, 60);
 
95
        glColor4ub(255,255,255, 30);
90
96
        sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax);
91
97
 
92
98
        /* left  */
93
 
        glColor4ub(255,255,255, 50);
 
99
        glColor4ub(255,255,255, 30);
94
100
        sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax);
95
101
        
96
102
        glDisable( GL_BLEND );
101
107
        int width= ar->winrct.xmax-ar->winrct.xmin+1;
102
108
        int height= ar->winrct.ymax-ar->winrct.ymin+1;
103
109
        
104
 
        wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375);
 
110
        wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f);
105
111
        glLoadIdentity();
106
112
}
107
113
 
111
117
        /* generic notes first */
112
118
        switch(note->category) {
113
119
                case NC_WM:
114
 
                        if(note->data==ND_FILEREAD)
 
120
                        if (note->data==ND_FILEREAD)
115
121
                                ED_region_tag_redraw(ar);
116
122
                        break;
117
123
                case NC_WINDOW:
118
124
                        ED_region_tag_redraw(ar);
119
125
                        break;
120
 
#ifndef WM_FAST_DRAW
121
 
                case NC_SCREEN:
122
 
                        if(note->action==NA_EDITED)
123
 
                                ED_region_tag_redraw(ar);
124
 
                        break;
125
 
#endif
126
126
        }
127
127
 
128
 
        if(ar->type && ar->type->listener)
 
128
        if (ar->type && ar->type->listener)
129
129
                ar->type->listener(ar, note);
130
130
}
131
131
 
133
133
void ED_area_do_listen(ScrArea *sa, wmNotifier *note)
134
134
{
135
135
        /* no generic notes? */
136
 
        if(sa->type && sa->type->listener) {
 
136
        if (sa->type && sa->type->listener) {
137
137
                sa->type->listener(sa, note);
138
138
        }
139
139
}
142
142
void ED_area_do_refresh(bContext *C, ScrArea *sa)
143
143
{
144
144
        /* no generic notes? */
145
 
        if(sa->type && sa->type->refresh) {
 
145
        if (sa->type && sa->type->refresh) {
146
146
                sa->type->refresh(C, sa);
147
147
        }
148
148
        sa->do_refresh= 0;
150
150
 
151
151
/* based on screen region draw tags, set draw tags in azones, and future region tabs etc */
152
152
/* only exported for WM */
153
 
void ED_area_overdraw_flush(bContext *C, ScrArea *sa, ARegion *ar)
 
153
void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar)
154
154
{
155
155
        AZone *az;
156
156
        
157
 
        for(az= sa->actionzones.first; az; az= az->next) {
 
157
        for (az= sa->actionzones.first; az; az= az->next) {
158
158
                int xs, ys;
159
159
                
160
160
                xs= (az->x1+az->x2)/2;
161
161
                ys= (az->y1+az->y2)/2;
162
162
 
163
163
                /* test if inside */
164
 
                if(BLI_in_rcti(&ar->winrct, xs, ys)) {
 
164
                if (BLI_in_rcti(&ar->winrct, xs, ys)) {
165
165
                        az->do_draw= 1;
166
166
                }
167
167
        }
169
169
 
170
170
static void area_draw_azone(short x1, short y1, short x2, short y2)
171
171
{
172
 
        float xmin = x1;
173
 
        float xmax = x2-2;
174
 
        float ymin = y1-1;
175
 
        float ymax = y2-3;
176
 
        
177
 
        float dx= 0.3f*(xmax-xmin);
178
 
        float dy= 0.3f*(ymax-ymin);
 
172
        int dx = x2 - x1;
 
173
        int dy = y2 - y1;
 
174
 
 
175
        dx= copysign(ceil(0.3f*fabs(dx)), dx);
 
176
        dy= copysign(ceil(0.3f*fabs(dy)), dy);
 
177
 
 
178
        glEnable(GL_BLEND);
 
179
        glEnable(GL_LINE_SMOOTH);
179
180
        
180
181
        glColor4ub(255, 255, 255, 180);
181
 
        fdrawline(xmin, ymax, xmax, ymin);
 
182
        fdrawline(x1, y2, x2, y1);
182
183
        glColor4ub(255, 255, 255, 130);
183
 
        fdrawline(xmin, ymax-dy, xmax-dx, ymin);
 
184
        fdrawline(x1, y2-dy, x2-dx, y1);
184
185
        glColor4ub(255, 255, 255, 80);
185
 
        fdrawline(xmin, ymax-2*dy, xmax-2*dx, ymin);
 
186
        fdrawline(x1, y2-2*dy, x2-2*dx, y1);
186
187
        
187
188
        glColor4ub(0, 0, 0, 210);
188
 
        fdrawline(xmin, ymax+1, xmax+1, ymin);
 
189
        fdrawline(x1, y2+1, x2+1, y1);
189
190
        glColor4ub(0, 0, 0, 180);
190
 
        fdrawline(xmin, ymax-dy+1, xmax-dx+1, ymin);
 
191
        fdrawline(x1, y2-dy+1, x2-dx+1, y1);
191
192
        glColor4ub(0, 0, 0, 150);
192
 
        fdrawline(xmin, ymax-2*dy+1, xmax-2*dx+1, ymin);
 
193
        fdrawline(x1, y2-2*dy+1, x2-2*dx+1, y1);
 
194
 
 
195
        glDisable(GL_LINE_SMOOTH);
 
196
        glDisable(GL_BLEND);
193
197
}
194
198
 
195
 
 
196
 
static void region_draw_azone(ScrArea *sa, AZone *az)
 
199
static void region_draw_azone_icon(AZone *az)
197
200
{
198
201
        GLUquadricObj *qobj = NULL; 
199
202
        short midx = az->x1 + (az->x2 - az->x1)/2;
200
203
        short midy = az->y1 + (az->y2 - az->y1)/2;
201
 
        
202
 
        if(az->ar==NULL) return;
203
 
        
204
 
        /* only display action zone icons when the region is hidden */
205
 
        if (!(az->ar->flag & RGN_FLAG_HIDDEN)) return;
206
 
        
 
204
                
207
205
        qobj = gluNewQuadric();
208
206
        
209
 
        glPushMatrix();         
210
 
        glTranslatef(midx, midy, 0.); 
 
207
        glPushMatrix();
 
208
        glTranslatef(midx, midy, 0.0);
211
209
        
212
210
        /* outlined circle */
213
211
        glEnable(GL_LINE_SMOOTH);
232
230
        sdrawline(midx-2, midy, midx+3, midy);
233
231
}
234
232
 
 
233
static void draw_azone_plus(float x1, float y1, float x2, float y2)
 
234
{
 
235
        float width = 2.0f;
 
236
        float pad = 4.0f;
 
237
        
 
238
        glRectf((x1 + x2 - width)*0.5f, y1 + pad, (x1 + x2 + width)*0.5f, y2 - pad);
 
239
        glRectf(x1 + pad, (y1 + y2 - width)*0.5f, (x1 + x2 - width)*0.5f, (y1 + y2 + width)*0.5f);
 
240
        glRectf((x1 + x2 + width)*0.5f, (y1 + y2 - width)*0.5f, x2 - pad, (y1 + y2 + width)*0.5f);
 
241
}
 
242
 
 
243
static void region_draw_azone_tab_plus(AZone *az)
 
244
{
 
245
        extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */
 
246
        
 
247
        glEnable(GL_BLEND);
 
248
        
 
249
        /* add code to draw region hidden as 'too small' */
 
250
        switch(az->edge) {
 
251
                case AE_TOP_TO_BOTTOMRIGHT:
 
252
                        uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
 
253
                        break;
 
254
                case AE_BOTTOM_TO_TOPLEFT:
 
255
                        uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
 
256
                        break;
 
257
                case AE_LEFT_TO_TOPRIGHT:
 
258
                        uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
 
259
                        break;
 
260
                case AE_RIGHT_TO_TOPLEFT:
 
261
                        uiSetRoundBox(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
 
262
                        break;
 
263
        }
 
264
 
 
265
        glColor4f(0.05f, 0.05f, 0.05f, 0.4f);
 
266
        uiRoundBox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
 
267
 
 
268
        glEnable(GL_BLEND);
 
269
 
 
270
        glColor4f(0.8f, 0.8f, 0.8f, 0.4f);
 
271
        draw_azone_plus((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2);
 
272
 
 
273
        glDisable(GL_BLEND);
 
274
}
 
275
 
 
276
static void region_draw_azone_tab(AZone *az)
 
277
{
 
278
        float col[3];
 
279
        
 
280
        glEnable(GL_BLEND);
 
281
        UI_GetThemeColor3fv(TH_HEADER, col);
 
282
        glColor4f(col[0], col[1], col[2], 0.5f);
 
283
        
 
284
        /* add code to draw region hidden as 'too small' */
 
285
        switch(az->edge) {
 
286
                case AE_TOP_TO_BOTTOMRIGHT:
 
287
                        uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA);
 
288
                        
 
289
                        uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
 
290
                        glColor4ub(0, 0, 0, 255);
 
291
                        uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f);
 
292
                        break;
 
293
                case AE_BOTTOM_TO_TOPLEFT:
 
294
                        uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA);
 
295
                        
 
296
                        uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
 
297
                        glColor4ub(0, 0, 0, 255);
 
298
                        uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f);
 
299
                        break;
 
300
                case AE_LEFT_TO_TOPRIGHT:
 
301
                        uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA);
 
302
                        
 
303
                        uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
 
304
                        glColor4ub(0, 0, 0, 255);
 
305
                        uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
 
306
                        break;
 
307
                case AE_RIGHT_TO_TOPLEFT:
 
308
                        uiSetRoundBox(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_RB_ALPHA);
 
309
                        
 
310
                        uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f);
 
311
                        glColor4ub(0, 0, 0, 255);
 
312
                        uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f);
 
313
                        break;
 
314
        }
 
315
        
 
316
        glDisable(GL_BLEND);
 
317
}
 
318
 
 
319
static void region_draw_azone_tria(AZone *az)
 
320
{
 
321
        extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */
 
322
        
 
323
        glEnable(GL_BLEND);
 
324
        //UI_GetThemeColor3fv(TH_HEADER, col);
 
325
        glColor4f(0.0f, 0.0f, 0.0f, 0.35f);
 
326
        
 
327
        /* add code to draw region hidden as 'too small' */
 
328
        switch(az->edge) {
 
329
                case AE_TOP_TO_BOTTOMRIGHT:
 
330
                        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);
 
331
                        break;
 
332
                        
 
333
                case AE_BOTTOM_TO_TOPLEFT:
 
334
                        ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1+az->x2)/2, (float)az->y1);
 
335
                        break;
 
336
 
 
337
                case AE_LEFT_TO_TOPRIGHT:
 
338
                        ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1+az->y2)/2);
 
339
                        break;
 
340
                        
 
341
                case AE_RIGHT_TO_TOPLEFT:
 
342
                        ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1+az->y2)/2);
 
343
                        break;
 
344
                        
 
345
        }
 
346
        
 
347
        glDisable(GL_BLEND);
 
348
}
235
349
 
236
350
/* only exported for WM */
237
351
void ED_area_overdraw(bContext *C)
246
360
        glEnable( GL_BLEND );
247
361
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
248
362
        
249
 
        for(sa= screen->areabase.first; sa; sa= sa->next) {
 
363
        for (sa= screen->areabase.first; sa; sa= sa->next) {
250
364
                AZone *az;
251
 
                for(az= sa->actionzones.first; az; az= az->next) {
252
 
                        if(az->do_draw) {
253
 
                                if(az->type==AZONE_AREA) {
 
365
                for (az= sa->actionzones.first; az; az= az->next) {
 
366
                        if (az->do_draw) {
 
367
                                if (az->type==AZONE_AREA) {
254
368
                                        area_draw_azone(az->x1, az->y1, az->x2, az->y2);
255
 
                                } else if(az->type==AZONE_REGION) {
256
 
                                        region_draw_azone(sa, az);
 
369
                                }
 
370
                                else if (az->type==AZONE_REGION) {
 
371
                                        
 
372
                                        if (az->ar) {
 
373
                                                /* only display tab or icons when the region is hidden */
 
374
                                                if (az->ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
 
375
                                                        if (G.rt==3)
 
376
                                                                region_draw_azone_icon(az);
 
377
                                                        else if (G.rt==2)
 
378
                                                                region_draw_azone_tria(az);
 
379
                                                        else if (G.rt==1)
 
380
                                                                region_draw_azone_tab(az);
 
381
                                                        else
 
382
                                                                region_draw_azone_tab_plus(az);
 
383
                                                }
 
384
                                        }
257
385
                                }
258
386
                                
259
387
                                az->do_draw= 0;
269
397
{
270
398
        *winrct= ar->winrct;
271
399
        
272
 
        if(ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT))
 
400
        if (ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT))
273
401
                return;
274
402
 
275
 
        while(ar->prev) {
 
403
        while (ar->prev) {
276
404
                ar= ar->prev;
277
405
                
278
 
                if(BLI_isect_rcti(winrct, &ar->winrct, NULL)) {
279
 
                        if(ar->flag & RGN_FLAG_HIDDEN);
280
 
                        else if(ar->alignment & RGN_SPLIT_PREV);
281
 
                        else if(ar->alignment==RGN_OVERLAP_LEFT) {
282
 
                                winrct->xmin= ar->winrct.xmax + 1;
 
406
                if (BLI_isect_rcti(winrct, &ar->winrct, NULL)) {
 
407
                        if (ar->flag & RGN_FLAG_HIDDEN);
 
408
                        else if (ar->alignment & RGN_SPLIT_PREV);
 
409
                        else if (ar->alignment==RGN_OVERLAP_LEFT) {
 
410
                                winrct->xmin = ar->winrct.xmax + 1;
283
411
                        }
284
 
                        else if(ar->alignment==RGN_OVERLAP_RIGHT) {
285
 
                                winrct->xmax= ar->winrct.xmin - 1;
 
412
                        else if (ar->alignment==RGN_OVERLAP_RIGHT) {
 
413
                                winrct->xmax = ar->winrct.xmin - 1;
286
414
                        }
287
415
                        else break;
288
416
                }
319
447
        ARegionType *at= ar->type;
320
448
        rcti winrct;
321
449
        
 
450
        /* see BKE_spacedata_draw_locks() */
 
451
        if (at->do_lock)
 
452
                return;
 
453
        
322
454
        /* checks other overlapping regions */
323
455
        region_scissor_winrct(ar, &winrct);
324
456
        
325
457
        /* if no partial draw rect set, full rect */
326
 
        if(ar->drawrct.xmin == ar->drawrct.xmax)
 
458
        if (ar->drawrct.xmin == ar->drawrct.xmax)
327
459
                ar->drawrct= winrct;
328
460
        else {
329
461
                /* extra clip for safety */
330
 
                ar->drawrct.xmin= MAX2(winrct.xmin, ar->drawrct.xmin);
331
 
                ar->drawrct.ymin= MAX2(winrct.ymin, ar->drawrct.ymin);
332
 
                ar->drawrct.xmax= MIN2(winrct.xmax, ar->drawrct.xmax);
333
 
                ar->drawrct.ymax= MIN2(winrct.ymax, ar->drawrct.ymax);
 
462
                ar->drawrct.xmin = MAX2(winrct.xmin, ar->drawrct.xmin);
 
463
                ar->drawrct.ymin = MAX2(winrct.ymin, ar->drawrct.ymin);
 
464
                ar->drawrct.xmax = MIN2(winrct.xmax, ar->drawrct.xmax);
 
465
                ar->drawrct.ymax = MIN2(winrct.ymax, ar->drawrct.ymax);
334
466
        }
335
467
        
336
468
        /* note; this sets state, so we can use wmOrtho and friends */
339
471
        UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0);
340
472
        
341
473
        /* optional header info instead? */
342
 
        if(ar->headerstr) {
 
474
        if (ar->headerstr) {
343
475
                UI_ThemeClearColor(TH_HEADER);
344
476
                glClear(GL_COLOR_BUFFER_BIT);
345
477
                
346
478
                UI_ThemeColor(TH_TEXT);
347
 
                BLF_draw_default(20, 8, 0.0f, ar->headerstr);
 
479
                BLF_draw_default(20, 8, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
348
480
        }
349
 
        else if(at->draw) {
 
481
        else if (at->draw) {
350
482
                at->draw(C, ar);
351
483
        }
352
 
        
353
 
        uiFreeInactiveBlocks(C, &ar->uiblocks);
354
 
        
355
 
        if(sa)
356
 
                region_draw_emboss(ar, &winrct);
357
 
        
 
484
 
358
485
        /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
359
486
        ED_region_pixelspace(ar);
360
 
        
 
487
 
 
488
        ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
 
489
 
361
490
        ar->do_draw= 0;
362
491
        memset(&ar->drawrct, 0, sizeof(ar->drawrct));
 
492
        
 
493
        uiFreeInactiveBlocks(C, &ar->uiblocks);
 
494
 
 
495
        if (sa)
 
496
                region_draw_emboss(ar, &winrct);
363
497
}
364
498
 
365
499
/* **********************************
366
 
   maybe silly, but let's try for now
367
 
   to keep these tags protected
368
 
   ********************************** */
 
500
 * maybe silly, but let's try for now
 
501
 * to keep these tags protected
 
502
 * ********************************** */
369
503
 
370
504
void ED_region_tag_redraw(ARegion *ar)
371
505
{
372
 
        if(ar) {
 
506
        if (ar) {
373
507
                /* zero region means full region redraw */
374
508
                ar->do_draw= RGN_DRAW;
375
509
                memset(&ar->drawrct, 0, sizeof(ar->drawrct));
378
512
 
379
513
void ED_region_tag_redraw_overlay(ARegion *ar)
380
514
{
381
 
        if(ar)
 
515
        if (ar)
382
516
                ar->do_draw_overlay= RGN_DRAW;
383
517
}
384
518
 
385
519
void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct)
386
520
{
387
 
        if(ar) {
388
 
                if(!ar->do_draw) {
 
521
        if (ar) {
 
522
                if (!ar->do_draw) {
389
523
                        /* no redraw set yet, set partial region */
390
524
                        ar->do_draw= RGN_DRAW_PARTIAL;
391
525
                        ar->drawrct= *rct;
392
526
                }
393
 
                else if(ar->drawrct.xmin != ar->drawrct.xmax) {
 
527
                else if (ar->drawrct.xmin != ar->drawrct.xmax) {
394
528
                        /* partial redraw already set, expand region */
395
 
                        ar->drawrct.xmin= MIN2(ar->drawrct.xmin, rct->xmin);
396
 
                        ar->drawrct.ymin= MIN2(ar->drawrct.ymin, rct->ymin);
397
 
                        ar->drawrct.xmax= MAX2(ar->drawrct.xmax, rct->xmax);
398
 
                        ar->drawrct.ymax= MAX2(ar->drawrct.ymax, rct->ymax);
 
529
                        ar->drawrct.xmin = MIN2(ar->drawrct.xmin, rct->xmin);
 
530
                        ar->drawrct.ymin = MIN2(ar->drawrct.ymin, rct->ymin);
 
531
                        ar->drawrct.xmax = MAX2(ar->drawrct.xmax, rct->xmax);
 
532
                        ar->drawrct.ymax = MAX2(ar->drawrct.ymax, rct->ymax);
399
533
                }
400
534
        }
401
535
}
404
538
{
405
539
        ARegion *ar;
406
540
        
407
 
        if(sa)
408
 
                for(ar= sa->regionbase.first; ar; ar= ar->next)
 
541
        if (sa)
 
542
                for (ar= sa->regionbase.first; ar; ar= ar->next)
409
543
                        ED_region_tag_redraw(ar);
410
544
}
411
545
 
 
546
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
 
547
{
 
548
        ARegion *ar;
 
549
        
 
550
        if (sa) {
 
551
                for (ar= sa->regionbase.first; ar; ar= ar->next) {
 
552
                        if (ar->regiontype == regiontype) {
 
553
                                ED_region_tag_redraw(ar);
 
554
                        }
 
555
                }
 
556
        }
 
557
}
 
558
 
412
559
void ED_area_tag_refresh(ScrArea *sa)
413
560
{
414
 
        if(sa)
 
561
        if (sa)
415
562
                sa->do_refresh= 1;
416
563
}
417
564
 
421
568
void ED_area_headerprint(ScrArea *sa, const char *str)
422
569
{
423
570
        ARegion *ar;
424
 
        
425
 
        for(ar= sa->regionbase.first; ar; ar= ar->next) {
426
 
                if(ar->regiontype==RGN_TYPE_HEADER) {
427
 
                        if(str) {
428
 
                                if(ar->headerstr==NULL)
 
571
 
 
572
        /* happens when running transform operators in backround mode */
 
573
        if (sa == NULL)
 
574
                return;
 
575
 
 
576
        for (ar= sa->regionbase.first; ar; ar= ar->next) {
 
577
                if (ar->regiontype==RGN_TYPE_HEADER) {
 
578
                        if (str) {
 
579
                                if (ar->headerstr==NULL)
429
580
                                        ar->headerstr= MEM_mallocN(256, "headerprint");
430
581
                                BLI_strncpy(ar->headerstr, str, 256);
431
582
                        }
432
 
                        else if(ar->headerstr) {
 
583
                        else if (ar->headerstr) {
433
584
                                MEM_freeN(ar->headerstr);
434
585
                                ar->headerstr= NULL;
435
586
                        }
441
592
/* ************************************************************ */
442
593
 
443
594
 
444
 
#define AZONESPOT               12
445
595
static void area_azone_initialize(ScrArea *sa) 
446
596
{
447
597
        AZone *az;
453
603
        az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
454
604
        BLI_addtail(&(sa->actionzones), az);
455
605
        az->type= AZONE_AREA;
456
 
        az->x1= sa->totrct.xmin;
457
 
        az->y1= sa->totrct.ymin;
458
 
        az->x2= sa->totrct.xmin + AZONESPOT-1;
459
 
        az->y2= sa->totrct.ymin + AZONESPOT-1;
 
606
        az->x1= sa->totrct.xmin - 1;
 
607
        az->y1= sa->totrct.ymin - 1;
 
608
        az->x2= sa->totrct.xmin + (AZONESPOT-1);
 
609
        az->y2= sa->totrct.ymin + (AZONESPOT-1);
460
610
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
461
611
        
462
612
        az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
463
613
        BLI_addtail(&(sa->actionzones), az);
464
614
        az->type= AZONE_AREA;
465
 
        az->x1= sa->totrct.xmax+1;
466
 
        az->y1= sa->totrct.ymax+1;
467
 
        az->x2= sa->totrct.xmax-AZONESPOT+1;
468
 
        az->y2= sa->totrct.ymax-AZONESPOT+1;
 
615
        az->x1= sa->totrct.xmax + 1;
 
616
        az->y1= sa->totrct.ymax + 1;
 
617
        az->x2= sa->totrct.xmax - (AZONESPOT-1);
 
618
        az->y2= sa->totrct.ymax - (AZONESPOT-1);
469
619
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
470
620
}
471
621
 
472
622
#define AZONEPAD_EDGE   4
473
 
#define AZONEPAD_ICON   8
 
623
#define AZONEPAD_ICON   9
474
624
static void region_azone_edge(AZone *az, ARegion *ar)
475
625
{
476
 
        if(az->edge=='t') {
477
 
                az->x1= ar->winrct.xmin;
478
 
                az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
479
 
                az->x2= ar->winrct.xmax;
480
 
                az->y2= ar->winrct.ymax;
481
 
        }
482
 
        else if(az->edge=='b') {
483
 
                az->x1= ar->winrct.xmin;
484
 
                az->y1= ar->winrct.ymin + AZONEPAD_EDGE;
485
 
                az->x2= ar->winrct.xmax;
486
 
                az->y2= ar->winrct.ymin;
487
 
        }
488
 
        else if(az->edge=='l') {
489
 
                az->x1= ar->winrct.xmin;
490
 
                az->y1= ar->winrct.ymin;
491
 
                az->x2= ar->winrct.xmin + AZONEPAD_EDGE;
492
 
                az->y2= ar->winrct.ymax;
493
 
        }
494
 
        else { // if(az->edge=='r') {
495
 
                az->x1= ar->winrct.xmax;
496
 
                az->y1= ar->winrct.ymin;
497
 
                az->x2= ar->winrct.xmax - AZONEPAD_EDGE;
498
 
                az->y2= ar->winrct.ymax;
 
626
        switch(az->edge) {
 
627
                case AE_TOP_TO_BOTTOMRIGHT:
 
628
                        az->x1= ar->winrct.xmin;
 
629
                        az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
 
630
                        az->x2= ar->winrct.xmax;
 
631
                        az->y2= ar->winrct.ymax;
 
632
                        break;
 
633
                case AE_BOTTOM_TO_TOPLEFT:
 
634
                        az->x1= ar->winrct.xmin;
 
635
                        az->y1= ar->winrct.ymin + AZONEPAD_EDGE;
 
636
                        az->x2= ar->winrct.xmax;
 
637
                        az->y2= ar->winrct.ymin;
 
638
                        break;
 
639
                case AE_LEFT_TO_TOPRIGHT:
 
640
                        az->x1= ar->winrct.xmin;
 
641
                        az->y1= ar->winrct.ymin;
 
642
                        az->x2= ar->winrct.xmin + AZONEPAD_EDGE;
 
643
                        az->y2= ar->winrct.ymax;
 
644
                        break;
 
645
                case AE_RIGHT_TO_TOPLEFT:
 
646
                        az->x1= ar->winrct.xmax;
 
647
                        az->y1= ar->winrct.ymin;
 
648
                        az->x2= ar->winrct.xmax - AZONEPAD_EDGE;
 
649
                        az->y2= ar->winrct.ymax;
 
650
                        break;
499
651
        }
500
652
 
501
653
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
506
658
        AZone *azt;
507
659
        int tot=0;
508
660
        
509
 
        for(azt= sa->actionzones.first; azt; azt= azt->next) {
510
 
                if(azt->edge == az->edge) tot++;
 
661
        /* count how many actionzones with along same edge are available.
 
662
         * This allows for adding more action zones in the future without
 
663
         * having to worry about correct offset */
 
664
        for (azt= sa->actionzones.first; azt; azt= azt->next) {
 
665
                if (azt->edge == az->edge) tot++;
511
666
        }
512
667
        
513
 
        if(az->edge=='t') {
514
 
                az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
515
 
                az->y1= ar->winrct.ymax + AZONEPAD_ICON;
516
 
                az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON;
517
 
                az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON;
518
 
        }
519
 
        else if(az->edge=='b') {
520
 
                az->x1= ar->winrct.xmin + AZONEPAD_ICON;
521
 
                az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON;
522
 
                az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON;
523
 
                az->y2= ar->winrct.ymin - AZONEPAD_ICON;
524
 
        }
525
 
        else if(az->edge=='l') {
526
 
                az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON;
527
 
                az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
528
 
                az->x2= ar->winrct.xmin - AZONEPAD_ICON;
529
 
                az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
530
 
        }
531
 
        else { // if(az->edge=='r') {
532
 
                az->x1= ar->winrct.xmax + AZONEPAD_ICON;
533
 
                az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
534
 
                az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON;
535
 
                az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
 
668
        switch(az->edge) {
 
669
                case AE_TOP_TO_BOTTOMRIGHT:
 
670
                        az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
 
671
                        az->y1= ar->winrct.ymax + AZONEPAD_ICON;
 
672
                        az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON;
 
673
                        az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON;
 
674
                        break;
 
675
                case AE_BOTTOM_TO_TOPLEFT:
 
676
                        az->x1= ar->winrct.xmin + AZONEPAD_ICON;
 
677
                        az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON;
 
678
                        az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON;
 
679
                        az->y2= ar->winrct.ymin - AZONEPAD_ICON;
 
680
                        break;
 
681
                case AE_LEFT_TO_TOPRIGHT:
 
682
                        az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON;
 
683
                        az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
 
684
                        az->x2= ar->winrct.xmin - AZONEPAD_ICON;
 
685
                        az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
 
686
                        break;
 
687
                case AE_RIGHT_TO_TOPLEFT:
 
688
                        az->x1= ar->winrct.xmax + AZONEPAD_ICON;
 
689
                        az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON;
 
690
                        az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON;
 
691
                        az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON;
 
692
                        break;
536
693
        }
537
694
 
538
695
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
539
696
        
540
697
        /* if more azones on 1 spot, set offset */
541
 
        for(azt= sa->actionzones.first; azt; azt= azt->next) {
542
 
                if(az!=azt) {
543
 
                        if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) {
544
 
                                if(az->edge=='t' || az->edge=='b') {
 
698
        for (azt= sa->actionzones.first; azt; azt= azt->next) {
 
699
                if (az!=azt) {
 
700
                        if ( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) {
 
701
                                if (az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) {
545
702
                                        az->x1+= AZONESPOT;
546
703
                                        az->x2+= AZONESPOT;
547
 
                                        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
548
704
                                }
549
705
                                else {
550
706
                                        az->y1-= AZONESPOT;
551
707
                                        az->y2-= AZONESPOT;
552
 
                                        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
553
708
                                }
 
709
                                BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
554
710
                        }
555
711
                }
556
712
        }
557
713
}
558
714
 
559
 
static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) 
 
715
#define AZONEPAD_TAB_PLUSW      14
 
716
#define AZONEPAD_TAB_PLUSH      14
 
717
 
 
718
/* region already made zero sized, in shape of edge */
 
719
static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
 
720
{
 
721
        AZone *azt;
 
722
        int tot= 0, add;
 
723
        
 
724
        for (azt= sa->actionzones.first; azt; azt= azt->next) {
 
725
                if (azt->edge == az->edge) tot++;
 
726
        }
 
727
        
 
728
        switch(az->edge) {
 
729
                case AE_TOP_TO_BOTTOMRIGHT:
 
730
                        if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0;
 
731
                        az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW;
 
732
                        az->y1= ar->winrct.ymax - add;
 
733
                        az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW;
 
734
                        az->y2= ar->winrct.ymax - add + AZONEPAD_TAB_PLUSH;
 
735
                        break;
 
736
                case AE_BOTTOM_TO_TOPLEFT:
 
737
                        az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW;
 
738
                        az->y1= ar->winrct.ymin - AZONEPAD_TAB_PLUSH;
 
739
                        az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW;
 
740
                        az->y2= ar->winrct.ymin;
 
741
                        break;
 
742
                case AE_LEFT_TO_TOPRIGHT:
 
743
                        az->x1= ar->winrct.xmin - AZONEPAD_TAB_PLUSH;
 
744
                        az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW;
 
745
                        az->x2= ar->winrct.xmin;
 
746
                        az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW;
 
747
                        break;
 
748
                case AE_RIGHT_TO_TOPLEFT:
 
749
                        az->x1= ar->winrct.xmax - 1;
 
750
                        az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW;
 
751
                        az->x2= ar->winrct.xmax - 1 + AZONEPAD_TAB_PLUSH;
 
752
                        az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW;
 
753
                        break;
 
754
        }
 
755
        /* rect needed for mouse pointer test */
 
756
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
 
757
}       
 
758
 
 
759
 
 
760
#define AZONEPAD_TABW   18
 
761
#define AZONEPAD_TABH   7
 
762
 
 
763
/* region already made zero sized, in shape of edge */
 
764
static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
 
765
{
 
766
        AZone *azt;
 
767
        int tot= 0, add;
 
768
        
 
769
        for (azt= sa->actionzones.first; azt; azt= azt->next) {
 
770
                if (azt->edge == az->edge) tot++;
 
771
        }
 
772
        
 
773
        switch(az->edge) {
 
774
                case AE_TOP_TO_BOTTOMRIGHT:
 
775
                        if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0;
 
776
                        az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW;
 
777
                        az->y1= ar->winrct.ymax - add;
 
778
                        az->x2= ar->winrct.xmax - AZONEPAD_TABW;
 
779
                        az->y2= ar->winrct.ymax - add + AZONEPAD_TABH;
 
780
                        break;
 
781
                case AE_BOTTOM_TO_TOPLEFT:
 
782
                        az->x1= ar->winrct.xmin + AZONEPAD_TABW;
 
783
                        az->y1= ar->winrct.ymin - AZONEPAD_TABH;
 
784
                        az->x2= ar->winrct.xmin + 2*AZONEPAD_TABW;
 
785
                        az->y2= ar->winrct.ymin;
 
786
                        break;
 
787
                case AE_LEFT_TO_TOPRIGHT:
 
788
                        az->x1= ar->winrct.xmin + 1 - AZONEPAD_TABH;
 
789
                        az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW;
 
790
                        az->x2= ar->winrct.xmin + 1;
 
791
                        az->y2= ar->winrct.ymax - AZONEPAD_TABW;
 
792
                        break;
 
793
                case AE_RIGHT_TO_TOPLEFT:
 
794
                        az->x1= ar->winrct.xmax - 1;
 
795
                        az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW;
 
796
                        az->x2= ar->winrct.xmax - 1 + AZONEPAD_TABH;
 
797
                        az->y2= ar->winrct.ymax - AZONEPAD_TABW;
 
798
                        break;
 
799
        }
 
800
        /* rect needed for mouse pointer test */
 
801
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
 
802
}       
 
803
 
 
804
#define AZONEPAD_TRIAW  16
 
805
#define AZONEPAD_TRIAH  9
 
806
 
 
807
 
 
808
/* region already made zero sized, in shape of edge */
 
809
static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar)
 
810
{
 
811
        AZone *azt;
 
812
        int tot= 0, add;
 
813
        
 
814
        for (azt= sa->actionzones.first; azt; azt= azt->next) {
 
815
                if (azt->edge == az->edge) tot++;
 
816
        }
 
817
        
 
818
        switch(az->edge) {
 
819
                case AE_TOP_TO_BOTTOMRIGHT:
 
820
                        if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0;
 
821
                        az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW;
 
822
                        az->y1= ar->winrct.ymax - add;
 
823
                        az->x2= ar->winrct.xmax - AZONEPAD_TRIAW;
 
824
                        az->y2= ar->winrct.ymax - add + AZONEPAD_TRIAH;
 
825
                        break;
 
826
                        case AE_BOTTOM_TO_TOPLEFT:
 
827
                        az->x1= ar->winrct.xmin + AZONEPAD_TRIAW;
 
828
                        az->y1= ar->winrct.ymin - AZONEPAD_TRIAH;
 
829
                        az->x2= ar->winrct.xmin + 2*AZONEPAD_TRIAW;
 
830
                        az->y2= ar->winrct.ymin;
 
831
                        break;
 
832
                        case AE_LEFT_TO_TOPRIGHT:
 
833
                        az->x1= ar->winrct.xmin + 1 - AZONEPAD_TRIAH;
 
834
                        az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW;
 
835
                        az->x2= ar->winrct.xmin + 1;
 
836
                        az->y2= ar->winrct.ymax - AZONEPAD_TRIAW;
 
837
                        break;
 
838
                        case AE_RIGHT_TO_TOPLEFT:
 
839
                        az->x1= ar->winrct.xmax - 1;
 
840
                        az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW;
 
841
                        az->x2= ar->winrct.xmax - 1 + AZONEPAD_TRIAH;
 
842
                        az->y2= ar->winrct.ymax - AZONEPAD_TRIAW;
 
843
                        break;
 
844
        }
 
845
        /* rect needed for mouse pointer test */
 
846
        BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2);
 
847
}       
 
848
 
 
849
 
 
850
static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) 
560
851
{
561
852
        AZone *az;
562
853
        
566
857
        az->ar= ar;
567
858
        az->edge= edge;
568
859
        
569
 
        if (ar->flag & RGN_FLAG_HIDDEN) {
570
 
                region_azone_icon(sa, az, ar);
571
 
        } else {
 
860
        if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
 
861
                if (G.rt==3)
 
862
                        region_azone_icon(sa, az, ar);
 
863
                else if (G.rt==2)
 
864
                        region_azone_tria(sa, az, ar);
 
865
                else if (G.rt==1)
 
866
                        region_azone_tab(sa, az, ar);
 
867
                else
 
868
                        region_azone_tab_plus(sa, az, ar);
 
869
        }
 
870
        else {
572
871
                region_azone_edge(az, ar);
573
872
        }
574
873
        
579
878
 
580
879
static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
581
880
{
582
 
         /* edge code (t b l r) is where azone will be drawn */
 
881
         /* edge code (t b l r) is along which area edge azone will be drawn */
583
882
        
584
 
        if(alignment==RGN_ALIGN_TOP)
585
 
                region_azone_initialize(sa, ar, 'b');
586
 
        else if(alignment==RGN_ALIGN_BOTTOM)
587
 
                region_azone_initialize(sa, ar, 't');
588
 
        else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
589
 
                region_azone_initialize(sa, ar, 'l');
590
 
        else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
591
 
                region_azone_initialize(sa, ar, 'r');
592
 
                                                                
 
883
        if (alignment==RGN_ALIGN_TOP)
 
884
                region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT);
 
885
        else if (alignment==RGN_ALIGN_BOTTOM)
 
886
                region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT);
 
887
        else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
 
888
                region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT);
 
889
        else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
 
890
                region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT);
593
891
}
594
892
 
595
893
/* dir is direction to check, not the splitting edge direction! */
596
894
static int rct_fits(rcti *rect, char dir, int size)
597
895
{
598
 
        if(dir=='h') {
 
896
        if (dir=='h') {
599
897
                return rect->xmax-rect->xmin - size;
600
898
        }
601
899
        else { // 'v'
609
907
        int prefsizex, prefsizey;
610
908
        int alignment;
611
909
        
612
 
        if(ar==NULL)
 
910
        if (ar==NULL)
613
911
                return;
614
912
        
615
913
        /* no returns in function, winrct gets set in the end again */
616
914
        BLI_init_rcti(&ar->winrct, 0, 0, 0, 0);
617
915
        
618
916
        /* for test; allow split of previously defined region */
619
 
        if(ar->alignment & RGN_SPLIT_PREV)
620
 
                if(ar->prev)
 
917
        if (ar->alignment & RGN_SPLIT_PREV)
 
918
                if (ar->prev)
621
919
                        remainder= &ar->prev->winrct;
622
920
        
623
921
        alignment = ar->alignment & ~RGN_SPLIT_PREV;
625
923
        /* clear state flags first */
626
924
        ar->flag &= ~RGN_FLAG_TOO_SMALL;
627
925
        /* user errors */
628
 
        if(ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT)
 
926
        if (ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT)
629
927
                alignment= RGN_ALIGN_NONE;
630
928
        
 
929
        /* prefsize, for header we stick to exception */
631
930
        prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex;
632
 
        prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey;
 
931
        if (ar->regiontype==RGN_TYPE_HEADER)
 
932
                prefsizey= ar->type->prefsizey;
 
933
        else if (ar->regiontype==RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
 
934
                prefsizey= UI_UNIT_Y * 2 + (UI_UNIT_Y/2);
 
935
        }
 
936
        else
 
937
                prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey;
633
938
        
634
939
        /* hidden is user flag */
635
 
        if(ar->flag & RGN_FLAG_HIDDEN);
 
940
        if (ar->flag & RGN_FLAG_HIDDEN);
636
941
        /* XXX floating area region, not handled yet here */
637
 
        else if(alignment == RGN_ALIGN_FLOAT);
 
942
        else if (alignment == RGN_ALIGN_FLOAT);
638
943
        /* remainder is too small for any usage */
639
 
        else if( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) {
 
944
        else if ( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) {
640
945
                ar->flag |= RGN_FLAG_TOO_SMALL;
641
946
        }
642
 
        else if(alignment==RGN_ALIGN_NONE) {
 
947
        else if (alignment==RGN_ALIGN_NONE) {
643
948
                /* typically last region */
644
949
                ar->winrct= *remainder;
645
950
                BLI_init_rcti(remainder, 0, 0, 0, 0);
646
951
        }
647
 
        else if(alignment==RGN_ALIGN_TOP || alignment==RGN_ALIGN_BOTTOM) {
 
952
        else if (alignment==RGN_ALIGN_TOP || alignment==RGN_ALIGN_BOTTOM) {
648
953
                
649
 
                if( rct_fits(remainder, 'v', prefsizey) < 0 ) {
 
954
                if ( rct_fits(remainder, 'v', prefsizey) < 0 ) {
650
955
                        ar->flag |= RGN_FLAG_TOO_SMALL;
651
956
                }
652
957
                else {
653
958
                        int fac= rct_fits(remainder, 'v', prefsizey);
654
959
 
655
 
                        if(fac < 0 )
 
960
                        if (fac < 0 )
656
961
                                prefsizey += fac;
657
962
                        
658
963
                        ar->winrct= *remainder;
659
964
                        
660
 
                        if(alignment==RGN_ALIGN_TOP) {
661
 
                                ar->winrct.ymin= ar->winrct.ymax - prefsizey + 1;
662
 
                                remainder->ymax= ar->winrct.ymin - 1;
 
965
                        if (alignment==RGN_ALIGN_TOP) {
 
966
                                ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1;
 
967
                                remainder->ymax = ar->winrct.ymin - 1;
663
968
                        }
664
969
                        else {
665
 
                                ar->winrct.ymax= ar->winrct.ymin + prefsizey - 1;
666
 
                                remainder->ymin= ar->winrct.ymax + 1;
 
970
                                ar->winrct.ymax = ar->winrct.ymin + prefsizey - 1;
 
971
                                remainder->ymin = ar->winrct.ymax + 1;
667
972
                        }
668
973
                }
669
974
        }
670
 
        else if( ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) {
 
975
        else if ( ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) {
671
976
                
672
 
                if( rct_fits(remainder, 'h', prefsizex) < 0 ) {
 
977
                if ( rct_fits(remainder, 'h', prefsizex) < 0 ) {
673
978
                        ar->flag |= RGN_FLAG_TOO_SMALL;
674
979
                }
675
980
                else {
676
981
                        int fac= rct_fits(remainder, 'h', prefsizex);
677
982
                        
678
 
                        if(fac < 0 )
 
983
                        if (fac < 0 )
679
984
                                prefsizex += fac;
680
985
                        
681
986
                        ar->winrct= *remainder;
682
987
                        
683
 
                        if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) {
684
 
                                ar->winrct.xmin= ar->winrct.xmax - prefsizex + 1;
685
 
                                if(alignment==RGN_ALIGN_RIGHT)
686
 
                                        remainder->xmax= ar->winrct.xmin - 1;
 
988
                        if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) {
 
989
                                ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1;
 
990
                                if (alignment==RGN_ALIGN_RIGHT)
 
991
                                        remainder->xmax = ar->winrct.xmin - 1;
687
992
                        }
688
993
                        else {
689
 
                                ar->winrct.xmax= ar->winrct.xmin + prefsizex - 1;
690
 
                                if(alignment==RGN_ALIGN_LEFT)
691
 
                                        remainder->xmin= ar->winrct.xmax + 1;
 
994
                                ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1;
 
995
                                if (alignment==RGN_ALIGN_LEFT)
 
996
                                        remainder->xmin = ar->winrct.xmax + 1;
692
997
                        }
693
998
                }
694
999
        }
695
 
        else if(alignment==RGN_ALIGN_VSPLIT || alignment==RGN_ALIGN_HSPLIT) {
 
1000
        else if (alignment==RGN_ALIGN_VSPLIT || alignment==RGN_ALIGN_HSPLIT) {
696
1001
                /* percentage subdiv*/
697
1002
                ar->winrct= *remainder;
698
1003
                
699
 
                if(alignment==RGN_ALIGN_HSPLIT) {
700
 
                        if( rct_fits(remainder, 'h', prefsizex) > 4) {
701
 
                                ar->winrct.xmax= (remainder->xmin+remainder->xmax)/2;
702
 
                                remainder->xmin= ar->winrct.xmax+1;
 
1004
                if (alignment==RGN_ALIGN_HSPLIT) {
 
1005
                        if ( rct_fits(remainder, 'h', prefsizex) > 4) {
 
1006
                                ar->winrct.xmax = (remainder->xmin+remainder->xmax)/2;
 
1007
                                remainder->xmin = ar->winrct.xmax+1;
703
1008
                        }
704
1009
                        else {
705
1010
                                BLI_init_rcti(remainder, 0, 0, 0, 0);
706
1011
                        }
707
1012
                }
708
1013
                else {
709
 
                        if( rct_fits(remainder, 'v', prefsizey) > 4) {
710
 
                                ar->winrct.ymax= (remainder->ymin+remainder->ymax)/2;
711
 
                                remainder->ymin= ar->winrct.ymax+1;
 
1014
                        if ( rct_fits(remainder, 'v', prefsizey) > 4) {
 
1015
                                ar->winrct.ymax = (remainder->ymin+remainder->ymax)/2;
 
1016
                                remainder->ymin = ar->winrct.ymax+1;
712
1017
                        }
713
1018
                        else {
714
1019
                                BLI_init_rcti(remainder, 0, 0, 0, 0);
715
1020
                        }
716
1021
                }
717
1022
        }
718
 
        else if(alignment==RGN_ALIGN_QSPLIT) {
 
1023
        else if (alignment==RGN_ALIGN_QSPLIT) {
719
1024
                ar->winrct= *remainder;
720
1025
                
721
1026
                /* test if there's still 4 regions left */
722
 
                if(quad==0) {
 
1027
                if (quad==0) {
723
1028
                        ARegion *artest= ar->next;
724
1029
                        int count= 1;
725
1030
                        
726
 
                        while(artest) {
 
1031
                        while (artest) {
727
1032
                                artest->alignment= RGN_ALIGN_QSPLIT;
728
1033
                                artest= artest->next;
729
1034
                                count++;
730
1035
                        }
731
1036
                        
732
 
                        if(count!=4) {
 
1037
                        if (count!=4) {
733
1038
                                /* let's stop adding regions */
734
1039
                                BLI_init_rcti(remainder, 0, 0, 0, 0);
735
 
                                if (G.f & G_DEBUG)
 
1040
                                if (G.debug & G_DEBUG)
736
1041
                                        printf("region quadsplit failed\n");
737
1042
                        }
738
1043
                        else quad= 1;
739
1044
                }
740
 
                if(quad) {
741
 
                        if(quad==1) { /* left bottom */
 
1045
                if (quad) {
 
1046
                        if (quad==1) { /* left bottom */
742
1047
                                ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2;
743
1048
                                ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2;
744
1049
                        }
745
 
                        else if(quad==2) { /* left top */
 
1050
                        else if (quad==2) { /* left top */
746
1051
                                ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2;
747
1052
                                ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2;
748
1053
                        }
749
 
                        else if(quad==3) { /* right bottom */
 
1054
                        else if (quad==3) { /* right bottom */
750
1055
                                ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2;
751
1056
                                ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2;
752
1057
                        }
764
1069
        ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1;
765
1070
        ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1;
766
1071
        
767
 
        /* restore test exception */
768
 
        if(ar->alignment & RGN_SPLIT_PREV) {
769
 
                if(ar->prev) {
 
1072
        /* set winrect for azones */
 
1073
        if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
 
1074
                ar->winrct= *remainder;
 
1075
                
 
1076
                if (alignment==RGN_ALIGN_TOP)
 
1077
                        ar->winrct.ymin = ar->winrct.ymax;
 
1078
                else if (alignment==RGN_ALIGN_BOTTOM)
 
1079
                        ar->winrct.ymax = ar->winrct.ymin;
 
1080
                else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
 
1081
                        ar->winrct.xmin = ar->winrct.xmax;
 
1082
                else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
 
1083
                        ar->winrct.xmax = ar->winrct.xmin;
 
1084
                else /* prevent winrct to be valid */
 
1085
                        ar->winrct.xmax = ar->winrct.xmin;
 
1086
        }
 
1087
 
 
1088
        /* restore prev-split exception */
 
1089
        if (ar->alignment & RGN_SPLIT_PREV) {
 
1090
                if (ar->prev) {
770
1091
                        remainder= remainder_prev;
771
1092
                        ar->prev->winx= ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1;
772
1093
                        ar->prev->winy= ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1;
773
1094
                }
774
1095
        }
775
 
 
776
 
        /* set winrect for azones */
777
 
        if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
778
 
                ar->winrct= *remainder;
779
 
                
780
 
                if(alignment==RGN_ALIGN_TOP)
781
 
                        ar->winrct.ymin= ar->winrct.ymax;
782
 
                else if(alignment==RGN_ALIGN_BOTTOM)
783
 
                        ar->winrct.ymax= ar->winrct.ymin;
784
 
                else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
785
 
                        ar->winrct.xmin= ar->winrct.xmax;
786
 
                else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
787
 
                        ar->winrct.xmax= ar->winrct.xmin;
788
 
                else /* prevent winrct to be valid */
789
 
                        ar->winrct.xmax= ar->winrct.xmin;
790
 
        }
 
1096
        
791
1097
        /* in end, add azones, where appropriate */
792
 
        region_azone_add(sa, ar, alignment);
793
 
 
 
1098
        if (ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) {
 
1099
                /* The logic for this is: when the header takes up the full area,
 
1100
                 * disallow hiding it to view the main window.
 
1101
                 *
 
1102
                 * Without this, you can drag down the file selectors header and hide it
 
1103
                 * by accident very easily (highly annoying!), the value 6 is arbitrary
 
1104
                 * but accounts for small common rounding problems when scaling the UI,
 
1105
                 * must be minimum '4' */
 
1106
        }
 
1107
        else {
 
1108
                region_azone_add(sa, ar, alignment);
 
1109
        }
794
1110
 
795
1111
        region_rect_recursive(sa, ar->next, remainder, quad);
796
1112
}
797
1113
 
798
1114
static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
799
1115
{
800
 
        short rt= CLAMPIS(G.rt, 0, 16);
 
1116
        short rt= 0; // CLAMPIS(G.rt, 0, 16);
801
1117
 
802
 
        if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1+rt;
803
 
        else sa->totrct.xmin= sa->v1->vec.x;
804
 
        if(sa->v4->vec.x<sizex-1) sa->totrct.xmax= sa->v4->vec.x-1-rt;
805
 
        else sa->totrct.xmax= sa->v4->vec.x;
 
1118
        if (sa->v1->vec.x>0) sa->totrct.xmin = sa->v1->vec.x+1+rt;
 
1119
        else sa->totrct.xmin = sa->v1->vec.x;
 
1120
        if (sa->v4->vec.x<sizex-1) sa->totrct.xmax = sa->v4->vec.x-1-rt;
 
1121
        else sa->totrct.xmax = sa->v4->vec.x;
806
1122
        
807
 
        if(sa->v1->vec.y>0) sa->totrct.ymin= sa->v1->vec.y+1+rt;
808
 
        else sa->totrct.ymin= sa->v1->vec.y;
809
 
        if(sa->v2->vec.y<sizey-1) sa->totrct.ymax= sa->v2->vec.y-1-rt;
810
 
        else sa->totrct.ymax= sa->v2->vec.y;
 
1123
        if (sa->v1->vec.y>0) sa->totrct.ymin = sa->v1->vec.y+1+rt;
 
1124
        else sa->totrct.ymin = sa->v1->vec.y;
 
1125
        if (sa->v2->vec.y<sizey-1) sa->totrct.ymax = sa->v2->vec.y-1-rt;
 
1126
        else sa->totrct.ymax = sa->v2->vec.y;
811
1127
        
812
1128
        /* for speedup */
813
1129
        sa->winx= sa->totrct.xmax-sa->totrct.xmin+1;
816
1132
 
817
1133
 
818
1134
/* used for area initialize below */
819
 
static void region_subwindow(wmWindowManager *wm, wmWindow *win, ARegion *ar)
 
1135
static void region_subwindow(wmWindow *win, ARegion *ar)
820
1136
{
821
 
        if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
822
 
                if(ar->swinid)
 
1137
        if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
 
1138
                if (ar->swinid)
823
1139
                        wm_subwindow_close(win, ar->swinid);
824
1140
                ar->swinid= 0;
825
1141
        }
826
 
        else if(ar->swinid==0)
 
1142
        else if (ar->swinid==0)
827
1143
                ar->swinid= wm_subwindow_open(win, &ar->winrct);
828
1144
        else 
829
1145
                wm_subwindow_position(win, ar->swinid, &ar->winrct);
830
1146
}
831
1147
 
832
 
static void ed_default_handlers(wmWindowManager *wm, ListBase *handlers, int flag)
 
1148
static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *handlers, int flag)
833
1149
{
834
1150
        /* note, add-handler checks if it already exists */
835
1151
        
836
1152
        // XXX it would be good to have boundbox checks for some of these...
837
 
        if(flag & ED_KEYMAP_UI) {
 
1153
        if (flag & ED_KEYMAP_UI) {
838
1154
                /* user interface widgets */
839
1155
                UI_add_region_handlers(handlers);
840
1156
        }
841
 
        if(flag & ED_KEYMAP_VIEW2D) {
 
1157
        if (flag & ED_KEYMAP_VIEW2D) {
842
1158
                /* 2d-viewport handling+manipulation */
843
 
                wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "View2D", 0, 0);
 
1159
                wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "View2D", 0, 0);
844
1160
                WM_event_add_keymap_handler(handlers, keymap);
845
1161
        }
846
 
        if(flag & ED_KEYMAP_MARKERS) {
 
1162
        if (flag & ED_KEYMAP_MARKERS) {
847
1163
                /* time-markers */
848
 
                wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Markers", 0, 0);
849
 
                WM_event_add_keymap_handler(handlers, keymap);
850
 
                // XXX need boundbox check urgently!!!
 
1164
                wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0);
 
1165
                
 
1166
                /* time space only has this keymap, the others get a boundbox restricted map */
 
1167
                if (sa->spacetype!=SPACE_TIME) {
 
1168
                        ARegion *ar;
 
1169
                        static rcti rect= {0, 10000, 0, 30};    /* same local check for all areas */
 
1170
                        ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
 
1171
                        if (ar) {
 
1172
                                WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
 
1173
                        }
 
1174
                }
 
1175
                else
 
1176
                        WM_event_add_keymap_handler(handlers, keymap);
851
1177
        }
852
 
        if(flag & ED_KEYMAP_ANIMATION) {
 
1178
        if (flag & ED_KEYMAP_ANIMATION) {
853
1179
                /* frame changing and timeline operators (for time spaces) */
854
 
                wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Animation", 0, 0);
 
1180
                wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Animation", 0, 0);
855
1181
                WM_event_add_keymap_handler(handlers, keymap);
856
1182
        }
857
 
        if(flag & ED_KEYMAP_FRAMES) {
 
1183
        if (flag & ED_KEYMAP_FRAMES) {
858
1184
                /* frame changing/jumping (for all spaces) */
859
 
                wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Frames", 0, 0);
 
1185
                wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Frames", 0, 0);
860
1186
                WM_event_add_keymap_handler(handlers, keymap);
861
1187
        }
862
 
        if(flag & ED_KEYMAP_GPENCIL) {
 
1188
        if (flag & ED_KEYMAP_GPENCIL) {
863
1189
                /* grease pencil */
864
 
                wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0);
 
1190
                wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0);
865
1191
                WM_event_add_keymap_handler(handlers, keymap);
866
1192
        }
867
 
        if(flag & ED_KEYMAP_HEADER) {
 
1193
        if (flag & ED_KEYMAP_HEADER) {
868
1194
                /* standard keymap for headers regions */
869
 
                wmKeyMap *keymap= WM_keymap_find(wm->defaultconf, "Header", 0, 0);
 
1195
                wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Header", 0, 0);
870
1196
                WM_event_add_keymap_handler(handlers, keymap);
871
1197
        }
872
1198
}
881
1207
        /* set typedefinitions */
882
1208
        sa->type= BKE_spacetype_from_id(sa->spacetype);
883
1209
        
884
 
        if(sa->type==NULL) {
 
1210
        if (sa->type==NULL) {
885
1211
                sa->butspacetype= sa->spacetype= SPACE_VIEW3D;
886
1212
                sa->type= BKE_spacetype_from_id(sa->spacetype);
887
1213
        }
888
1214
        
889
 
        for(ar= sa->regionbase.first; ar; ar= ar->next)
 
1215
        for (ar= sa->regionbase.first; ar; ar= ar->next)
890
1216
                ar->type= BKE_regiontype_from_id(sa->type, ar->regiontype);
891
1217
        
892
1218
        /* area sizes */
900
1226
        region_rect_recursive(sa, sa->regionbase.first, &rect, 0);
901
1227
        
902
1228
        /* default area handlers */
903
 
        ed_default_handlers(wm, &sa->handlers, sa->type->keymapflag);
 
1229
        ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
904
1230
        /* checks spacedata, adds own handlers */
905
 
        if(sa->type->init)
 
1231
        if (sa->type->init)
906
1232
                sa->type->init(wm, sa);
907
1233
        
908
1234
        /* region windows, default and own handlers */
909
 
        for(ar= sa->regionbase.first; ar; ar= ar->next) {
910
 
                region_subwindow(wm, win, ar);
 
1235
        for (ar= sa->regionbase.first; ar; ar= ar->next) {
 
1236
                region_subwindow(win, ar);
911
1237
                
912
 
                if(ar->swinid) {
 
1238
                if (ar->swinid) {
913
1239
                        /* default region handlers */
914
 
                        ed_default_handlers(wm, &ar->handlers, ar->type->keymapflag);
 
1240
                        ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag);
915
1241
                        /* own handlers */
916
 
                        if(ar->type->init)
 
1242
                        if (ar->type->init)
917
1243
                                ar->type->init(wm, ar);
918
1244
                }
919
1245
                else {
921
1247
                        uiFreeBlocks(NULL, &ar->uiblocks);      
922
1248
                }
923
1249
                
 
1250
                /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */
 
1251
                if (ar->regiontype==RGN_TYPE_HEADER)
 
1252
                        ar->v2d.flag &= ~V2D_IS_INITIALISED;
924
1253
        }
925
1254
}
926
1255
 
930
1259
//      ARegionType *at= ar->type;
931
1260
        
932
1261
        /* refresh can be called before window opened */
933
 
        region_subwindow(CTX_wm_manager(C), CTX_wm_window(C), ar);
 
1262
        region_subwindow(CTX_wm_window(C), ar);
934
1263
        
935
1264
        ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1;
936
1265
        ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1;
945
1274
        ScrArea *sa= CTX_wm_area(C);
946
1275
 
947
1276
        ar->flag ^= RGN_FLAG_HIDDEN;
948
 
        ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
949
1277
 
950
 
        if(ar->flag & RGN_FLAG_HIDDEN)
 
1278
        if (ar->flag & RGN_FLAG_HIDDEN)
951
1279
                WM_event_remove_handlers(C, &ar->handlers);
952
1280
 
953
1281
        ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
966
1294
        sa1->spacetype= sa2->spacetype;
967
1295
        sa1->butspacetype= sa2->butspacetype;
968
1296
        
969
 
        if(swap_space == 1) {
 
1297
        if (swap_space == 1) {
970
1298
                SWAP(ListBase, sa1->spacedata, sa2->spacedata);
971
1299
                /* exception: ensure preview is reset */
972
 
//              if(sa1->spacetype==SPACE_VIEW3D)
 
1300
//              if (sa1->spacetype==SPACE_VIEW3D)
973
1301
// XXX                  BIF_view3d_previewrender_free(sa1->spacedata.first);
974
1302
        }
975
1303
        else if (swap_space == 2) {
983
1311
        /* Note; SPACE_EMPTY is possible on new screens */
984
1312
        
985
1313
        /* regions */
986
 
        if(swap_space == 1) {
 
1314
        if (swap_space == 1) {
987
1315
                SWAP(ListBase, sa1->regionbase, sa2->regionbase);
988
1316
        }
989
1317
        else {
990
 
                if(swap_space<2) {
 
1318
                if (swap_space<2) {
991
1319
                        st= BKE_spacetype_from_id(spacetype);
992
 
                        for(ar= sa1->regionbase.first; ar; ar= ar->next)
 
1320
                        for (ar= sa1->regionbase.first; ar; ar= ar->next)
993
1321
                                BKE_area_region_free(st, ar);
994
1322
                        BLI_freelistN(&sa1->regionbase);
995
1323
                }
996
1324
                
997
1325
                st= BKE_spacetype_from_id(sa2->spacetype);
998
 
                for(ar= sa2->regionbase.first; ar; ar= ar->next) {
 
1326
                for (ar= sa2->regionbase.first; ar; ar= ar->next) {
999
1327
                        ARegion *newar= BKE_area_region_copy(st, ar);
1000
1328
                        BLI_addtail(&sa1->regionbase, newar);
1001
1329
                }
1031
1359
 
1032
1360
void ED_area_newspace(bContext *C, ScrArea *sa, int type)
1033
1361
{
1034
 
        if(sa->spacetype != type) {
 
1362
        if (sa->spacetype != type) {
1035
1363
                SpaceType *st;
1036
1364
                SpaceLink *slold;
1037
1365
                SpaceLink *sl;
1047
1375
                
1048
1376
                /* check previously stored space */
1049
1377
                for (sl= sa->spacedata.first; sl; sl= sl->next)
1050
 
                        if(sl->spacetype==type)
 
1378
                        if (sl->spacetype==type)
1051
1379
                                break;
1052
1380
                
1053
1381
                /* old spacedata... happened during work on 2.50, remove */
1054
 
                if(sl && sl->regionbase.first==NULL) {
 
1382
                if (sl && sl->regionbase.first==NULL) {
1055
1383
                        st->free(sl);
1056
1384
                        BLI_freelinkN(&sa->spacedata, sl);
 
1385
                        if (slold == sl) {
 
1386
                                slold= NULL;
 
1387
                        }
1057
1388
                        sl= NULL;
1058
1389
                }
1059
1390
                
1070
1401
                } 
1071
1402
                else {
1072
1403
                        /* new space */
1073
 
                        if(st) {
 
1404
                        if (st) {
1074
1405
                                sl= st->new(C);
1075
1406
                                BLI_addhead(&sa->spacedata, sl);
1076
1407
                                
1077
1408
                                /* swap regions */
1078
 
                                if(slold)
 
1409
                                if (slold)
1079
1410
                                        slold->regionbase= sa->regionbase;
1080
1411
                                sa->regionbase= sl->regionbase;
1081
1412
                                sl->regionbase.first= sl->regionbase.last= NULL;
1087
1418
                /* tell WM to refresh, cursor types etc */
1088
1419
                WM_event_add_mousemove(C);
1089
1420
                                
1090
 
                /*send space change notifyer*/
 
1421
                /*send space change notifier*/
1091
1422
                WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
1092
 
 
1093
 
                ED_area_tag_redraw(sa);
 
1423
                
1094
1424
                ED_area_tag_refresh(sa);
1095
1425
        }
 
1426
        
 
1427
        /* also redraw when re-used */
 
1428
        ED_area_tag_redraw(sa);
1096
1429
}
1097
1430
 
1098
1431
void ED_area_prevspace(bContext *C, ScrArea *sa)
1099
1432
{
1100
1433
        SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
1101
1434
 
1102
 
        /* Special handling of filebrowser to stop background thread for
1103
 
           thumbnail creation - don't want to waste cpu resources if not showing
1104
 
           the filebrowser */
1105
 
        if (sl->spacetype == SPACE_FILE) {
1106
 
                ED_fileselect_exit(C, (SpaceFile*)sl);
1107
 
        }
1108
 
 
1109
 
        if(sl->next) {
 
1435
        if (sl->next) {
1110
1436
                /* workaround for case of double prevspace, render window
1111
 
                   with a file browser on top of it */
1112
 
                if(sl->next->spacetype == SPACE_FILE && sl->next->next)
 
1437
                 * with a file browser on top of it */
 
1438
                if (sl->next->spacetype == SPACE_FILE && sl->next->next)
1113
1439
                        ED_area_newspace(C, sa, sl->next->next->spacetype);
1114
1440
                else
1115
1441
                        ED_area_newspace(C, sa, sl->next->spacetype);
1119
1445
        }
1120
1446
        ED_area_tag_redraw(sa);
1121
1447
 
1122
 
        /*send space change notifyer*/
 
1448
        /*send space change notifier*/
1123
1449
        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
1124
1450
}
1125
1451
 
1126
 
static char *editortype_pup(void)
 
1452
static const char *editortype_pup(void)
1127
1453
{
1128
 
        return(
 
1454
        const char *types= N_(
1129
1455
                   "Editor type:%t"
1130
1456
                   "|3D View %x1"
1131
1457
 
1141
1467
                   "|UV/Image Editor %x6"
1142
1468
                   
1143
1469
                   "|Video Sequence Editor %x8"
 
1470
                   "|Movie Clip Editor %x20"
1144
1471
                   "|Text Editor %x9" 
1145
1472
                   "|Node Editor %x16"
1146
1473
                   "|Logic Editor %x17"
1151
1478
                   "|Outliner %x3"
1152
1479
                   "|User Preferences %x19"
1153
1480
                   "|Info%x7"
1154
 
                                   
 
1481
 
1155
1482
                   "|%l"
1156
 
                   
 
1483
 
1157
1484
                   "|File Browser %x5"
1158
1485
                   
1159
1486
                   "|%l"
1160
1487
                   
1161
 
                   "|Console %x18"
 
1488
                   "|Python Console %x18"
1162
1489
                   );
 
1490
 
 
1491
        return IFACE_(types);
1163
1492
}
1164
1493
 
1165
 
static void spacefunc(struct bContext *C, void *arg1, void *arg2)
 
1494
static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
1166
1495
{
1167
1496
        ED_area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype);
1168
1497
        ED_area_tag_redraw(CTX_wm_area(C));
1169
1498
 
1170
 
        /*send space change notifyer*/
 
1499
        /*send space change notifier*/
1171
1500
        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, CTX_wm_area(C));
1172
1501
}
1173
1502
 
1178
1507
        uiBut *but;
1179
1508
        int xco= 8;
1180
1509
        
1181
 
        but= uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, 
1182
 
                                                   editortype_pup(), xco, yco, XIC+10, YIC, 
 
1510
        but = uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, 
 
1511
                                                   editortype_pup(), xco, yco, UI_UNIT_X+10, UI_UNIT_Y, 
1183
1512
                                                   &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, 
1184
 
                                                   "Displays current editor type. "
1185
 
                                                   "Click for menu of available types");
 
1513
                                                   TIP_("Displays current editor type. Click for menu of available types"));
1186
1514
        uiButSetFunc(but, spacefunc, NULL, NULL);
 
1515
        uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
1187
1516
        
1188
 
        return xco + XIC + 14;
 
1517
        return xco + UI_UNIT_X + 14;
1189
1518
}
1190
1519
 
1191
1520
int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
1192
1521
{
1193
1522
        ScrArea *sa= CTX_wm_area(C);
1194
1523
        int xco= 8;
 
1524
        uiBut *but;
1195
1525
        
1196
1526
        if (!sa->full)
1197
1527
                xco= ED_area_header_switchbutton(C, block, yco);
1199
1529
        uiBlockSetEmboss(block, UI_EMBOSSN);
1200
1530
 
1201
1531
        if (sa->flag & HEADER_NO_PULLDOWN) {
1202
 
                uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
 
1532
                but = uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
1203
1533
                                                 ICON_DISCLOSURE_TRI_RIGHT,
1204
 
                                                 xco,yco,XIC,YIC-2,
 
1534
                                                 xco,yco,UI_UNIT_X,UI_UNIT_Y-2,
1205
1535
                                                 &(sa->flag), 0, 0, 0, 0, 
1206
1536
                                                 "Show pulldown menus");
1207
1537
        }
1208
1538
        else {
1209
 
                uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, 
 
1539
                but = uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0,
1210
1540
                                                 ICON_DISCLOSURE_TRI_DOWN,
1211
 
                                                 xco,yco,XIC,YIC-2,
 
1541
                                                 xco,yco,UI_UNIT_X,UI_UNIT_Y-2,
1212
1542
                                                 &(sa->flag), 0, 0, 0, 0, 
1213
1543
                                                 "Hide pulldown menus");
1214
1544
        }
1215
1545
 
 
1546
        uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
 
1547
 
1216
1548
        uiBlockSetEmboss(block, UI_EMBOSS);
1217
1549
        
1218
 
        return xco + XIC;
 
1550
        return xco + UI_UNIT_X;
1219
1551
}
1220
1552
 
1221
1553
/************************ standard UI regions ************************/
1222
1554
 
1223
 
void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context, int contextnr)
 
1555
void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr)
1224
1556
{
1225
1557
        ScrArea *sa= CTX_wm_area(C);
1226
 
        uiStyle *style= U.uistyles.first;
 
1558
        uiStyle *style= UI_GetStyle();
1227
1559
        uiBlock *block;
1228
1560
        PanelType *pt;
1229
1561
        Panel *panel;
1230
1562
        View2D *v2d= &ar->v2d;
1231
1563
        View2DScrollers *scrollers;
1232
 
        int xco, yco, x, y, miny=0, w, em, header, triangle, open, newcontext= 0;
 
1564
        int x, y, xco, yco, w, em, triangle, open, newcontext= 0;
1233
1565
 
1234
 
        if(contextnr >= 0)
 
1566
        if (contextnr >= 0)
1235
1567
                newcontext= UI_view2d_tab_set(v2d, contextnr);
1236
1568
 
1237
 
        if(vertical) {
 
1569
        if (vertical) {
1238
1570
                w= v2d->cur.xmax - v2d->cur.xmin;
1239
 
                em= (ar->type->prefsizex)? 10: 20;
 
1571
                em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y;
1240
1572
        }
1241
1573
        else {
1242
1574
                w= UI_PANEL_WIDTH;
1243
 
                em= (ar->type->prefsizex)? 10: 20;
 
1575
                em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y;
1244
1576
        }
1245
1577
 
1246
 
        x= 0;
1247
 
        y= -style->panelouter;
1248
 
 
1249
1578
        /* create panels */
1250
1579
        uiBeginPanels(C, ar);
1251
1580
 
1252
1581
        /* set view2d view matrix for scrolling (without scrollers) */
1253
 
        UI_view2d_view_ortho(C, v2d);
 
1582
        UI_view2d_view_ortho(v2d);
1254
1583
 
1255
 
        for(pt= ar->type->paneltypes.first; pt; pt= pt->next) {
 
1584
        for (pt= ar->type->paneltypes.first; pt; pt= pt->next) {
1256
1585
                /* verify context */
1257
 
                if(context)
1258
 
                        if(pt->context[0] && strcmp(context, pt->context) != 0)
 
1586
                if (context)
 
1587
                        if (pt->context[0] && strcmp(context, pt->context) != 0)
1259
1588
                                continue;
1260
1589
 
1261
1590
                /* draw panel */
1262
 
                if(pt->draw && (!pt->poll || pt->poll(C, pt))) {
 
1591
                if (pt->draw && (!pt->poll || pt->poll(C, pt))) {
1263
1592
                        block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
1264
1593
                        panel= uiBeginPanel(sa, ar, block, pt, &open);
1265
1594
 
1266
1595
                        /* bad fixed values */
1267
 
                        header= (pt->flag & PNL_NO_HEADER)? 0: 20;
1268
 
                        triangle= 22;
1269
 
 
1270
 
                        if(vertical)
1271
 
                                y -= header;
1272
 
 
1273
 
                        if(pt->draw_header && header && (open || vertical)) {
 
1596
                        triangle= (int)(UI_UNIT_Y * 1.1f);
 
1597
 
 
1598
                        if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
1274
1599
                                /* for enabled buttons */
1275
1600
                                panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
1276
 
                                        triangle, header+style->panelspace, header, 1, style);
 
1601
                                        triangle, UI_UNIT_Y+style->panelspace+2, UI_UNIT_Y, 1, style);
1277
1602
 
1278
1603
                                pt->draw_header(C, panel);
1279
1604
 
1281
1606
                                panel->labelofs= xco - triangle;
1282
1607
                                panel->layout= NULL;
1283
1608
                        }
 
1609
                        else {
 
1610
                                panel->labelofs= 0;
 
1611
                        }
1284
1612
 
1285
 
                        if(open) {
 
1613
                        if (open) {
1286
1614
                                short panelContext;
1287
1615
                                
1288
1616
                                /* panel context can either be toolbar region or normal panels region */
1308
1636
                        }
1309
1637
 
1310
1638
                        uiEndBlock(C, block);
1311
 
 
1312
 
                        if(vertical) {
1313
 
                                if(pt->flag & PNL_NO_HEADER)
1314
 
                                        y += yco;
1315
 
                                else
1316
 
                                        y += yco-style->panelouter;
1317
 
                        }
1318
 
                        else {
1319
 
                                x += w;
1320
 
                                miny= MIN2(y, yco-style->panelouter-header);
1321
 
                        }
1322
1639
                }
1323
1640
        }
1324
1641
 
1325
 
        if(vertical)
1326
 
                x += w;
1327
 
        else
1328
 
                y= miny;
1329
 
        
1330
 
        /* in case there are no panels */
1331
 
        if(x == 0 || y == 0) {
1332
 
                x= UI_PANEL_WIDTH;
1333
 
                y= UI_PANEL_WIDTH;
1334
 
        }
 
1642
        /* align panels and return size */
 
1643
        uiEndPanels(C, ar, &x, &y);
1335
1644
 
1336
1645
        /* clear */
1337
1646
        UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW)?TH_PREVIEW_BACK:TH_BACK);
1338
1647
        glClear(GL_COLOR_BUFFER_BIT);
1339
1648
        
1340
1649
        /* before setting the view */
1341
 
        if(vertical) {
 
1650
        if (vertical) {
1342
1651
                /* only allow scrolling in vertical direction */
1343
1652
                v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y;
1344
1653
                v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X);
1346
1655
                v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE;
1347
1656
                
1348
1657
                // don't jump back when panels close or hide
1349
 
                if(!newcontext)
 
1658
                if (!newcontext)
1350
1659
                        y= MAX2(-y, -v2d->cur.ymin);
1351
1660
                else
1352
1661
                        y= -y;
1353
1662
        }
1354
1663
        else {
1355
 
                /* for now, allow scrolling in both directions (since layouts are optimised for vertical,
 
1664
                /* for now, allow scrolling in both directions (since layouts are optimized for vertical,
1356
1665
                 * they often don't fit in horizontal layout)
1357
1666
                 */
1358
1667
                v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_LOCKOFS_Y|V2D_KEEPOFS_X|V2D_KEEPOFS_Y);
1362
1671
                v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_HIDE;
1363
1672
                
1364
1673
                // don't jump back when panels close or hide
1365
 
                if(!newcontext)
 
1674
                if (!newcontext)
1366
1675
                        x= MAX2(x, v2d->cur.xmax);
1367
1676
                y= -y;
1368
1677
        }
1371
1680
        UI_view2d_totRect_set(v2d, x+V2D_SCROLL_WIDTH, y+V2D_SCROLL_HEIGHT);
1372
1681
 
1373
1682
        /* set the view */
1374
 
        UI_view2d_view_ortho(C, v2d);
1375
 
 
1376
 
        /* this does the actual drawing! */
1377
 
        uiEndPanels(C, ar);
1378
 
        
 
1683
        UI_view2d_view_ortho(v2d);
 
1684
 
 
1685
        /* draw panels */
 
1686
        uiDrawPanels(C, ar);
 
1687
 
1379
1688
        /* restore view matrix */
1380
1689
        UI_view2d_view_restore(C);
1381
1690
        
1396
1705
        ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE;
1397
1706
        ar->v2d.keepzoom |= V2D_KEEPZOOM;
1398
1707
 
1399
 
                // correctly initialised User-Prefs?
1400
 
        if(!(ar->v2d.align & V2D_ALIGN_NO_POS_Y))
 
1708
                // correctly initialized User-Prefs?
 
1709
        if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y))
1401
1710
                ar->v2d.flag &= ~V2D_IS_INITIALISED;
1402
1711
        
1403
1712
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
1404
1713
 
1405
 
        keymap= WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0);
 
1714
        keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0);
1406
1715
        WM_event_add_keymap_handler(&ar->handlers, keymap);
1407
1716
}
1408
1717
 
1409
1718
void ED_region_header(const bContext *C, ARegion *ar)
1410
1719
{
1411
 
        uiStyle *style= U.uistyles.first;
 
1720
        uiStyle *style= UI_GetStyle();
1412
1721
        uiBlock *block;
1413
1722
        uiLayout *layout;
1414
1723
        HeaderType *ht;
1415
 
        Header header = {0};
 
1724
        Header header = {NULL};
1416
1725
        int maxco, xco, yco;
 
1726
        int headery= ED_area_headersize();
1417
1727
 
1418
1728
        /* clear */     
1419
1729
        UI_ThemeClearColor((ED_screen_area_active(C))?TH_HEADER:TH_HEADERDESEL);
1420
1730
        glClear(GL_COLOR_BUFFER_BIT);
1421
1731
        
1422
1732
        /* set view2d view matrix for scrolling (without scrollers) */
1423
 
        UI_view2d_view_ortho(C, &ar->v2d);
 
1733
        UI_view2d_view_ortho(&ar->v2d);
1424
1734
 
1425
1735
        xco= maxco= 8;
1426
 
        yco= HEADERY-3;
 
1736
        yco= headery-4;
1427
1737
 
1428
1738
        /* draw all headers types */
1429
 
        for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
1430
 
                block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
1431
 
                layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, HEADERY-6, 1, style);
 
1739
        for (ht= ar->type->headertypes.first; ht; ht= ht->next) {
 
1740
                block= uiBeginBlock(C, ar, ht->idname, UI_EMBOSS);
 
1741
                layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style);
1432
1742
 
1433
 
                if(ht->draw) {
 
1743
                if (ht->draw) {
1434
1744
                        header.type= ht;
1435
1745
                        header.layout= layout;
1436
1746
                        ht->draw(C, &header);
1437
1747
                        
1438
1748
                        /* for view2d */
1439
1749
                        xco= uiLayoutGetWidth(layout);
1440
 
                        if(xco > maxco)
 
1750
                        if (xco > maxco)
1441
1751
                                maxco= xco;
1442
1752
                }
1443
1753
 
1444
1754
                uiBlockLayoutResolve(block, &xco, &yco);
1445
1755
                
1446
1756
                /* for view2d */
1447
 
                if(xco > maxco)
 
1757
                if (xco > maxco)
1448
1758
                        maxco= xco;
1449
1759
                
1450
1760
                uiEndBlock(C, block);
1452
1762
        }
1453
1763
 
1454
1764
        /* always as last  */
1455
 
        UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
 
1765
        UI_view2d_totRect_set(&ar->v2d, maxco+UI_UNIT_X+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin);
1456
1766
 
1457
1767
        /* restore view matrix? */
1458
1768
        UI_view2d_view_restore(C);
1463
1773
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
1464
1774
}
1465
1775
 
 
1776
/* UI_UNIT_Y is defined as U variable now, depending dpi */
 
1777
int ED_area_headersize(void)
 
1778
{
 
1779
        return UI_UNIT_Y+6;
 
1780
}
 
1781
 
 
1782
void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
 
1783
{
 
1784
        const int header_height = 18;
 
1785
        uiStyle *style= UI_GetStyle();
 
1786
        int fontid= style->widget.uifont_id;
 
1787
        rcti rect;
 
1788
 
 
1789
        BLF_size(fontid, 11.0f, 72);
 
1790
 
 
1791
        /* background box */
 
1792
        rect= ar->winrct;
 
1793
        rect.xmin = 0;
 
1794
        rect.ymin = ar->winrct.ymax - ar->winrct.ymin - header_height;
 
1795
 
 
1796
        if (block) {
 
1797
                rect.xmax = ar->winrct.xmax - ar->winrct.xmin;
 
1798
        }
 
1799
        else {
 
1800
                rect.xmax = rect.xmin + BLF_width(fontid, text) + 24;
 
1801
        }
 
1802
 
 
1803
        rect.ymax = ar->winrct.ymax - ar->winrct.ymin;
 
1804
 
 
1805
        glEnable(GL_BLEND);
 
1806
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
 
1807
        glColor4f(0.0f, 0.0f, 0.0f, alpha);
 
1808
        glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1);
 
1809
        glDisable(GL_BLEND);
 
1810
 
 
1811
        /* text */
 
1812
        UI_ThemeColor(TH_TEXT_HI);
 
1813
        BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
 
1814
        BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX);
 
1815
}