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:
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r--source/blender/editors/screen/area.c167
1 files changed, 80 insertions, 87 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index f30e0abb4f3..852ce02fa40 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -235,8 +235,8 @@ static void region_draw_azone_icon(AZone *az)
static void draw_azone_plus(float x1, float y1, float x2, float y2)
{
- float width = 2.0f;
- float pad = 4.0f;
+ float width = 0.05f * U.widget_unit;
+ float pad = 0.2f * U.widget_unit;
glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad);
glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f);
@@ -395,47 +395,14 @@ void ED_area_overdraw(bContext *C)
}
-/* get scissor rect, checking overlapping regions */
-void region_scissor_winrct(ARegion *ar, rcti *winrct)
-{
- *winrct = ar->winrct;
-
- if (ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT))
- return;
-
- while (ar->prev) {
- ar = ar->prev;
-
- if (BLI_rcti_isect(winrct, &ar->winrct, NULL)) {
- if (ar->flag & RGN_FLAG_HIDDEN) {
- /* pass */
- }
- else if (ar->alignment & RGN_SPLIT_PREV) {
- /* pass */
- }
- else if (ar->alignment == RGN_OVERLAP_LEFT) {
- winrct->xmin = ar->winrct.xmax + 1;
- }
- else if (ar->alignment == RGN_OVERLAP_RIGHT) {
- winrct->xmax = ar->winrct.xmin - 1;
- }
- else break;
- }
- }
-}
-
/* only exported for WM */
/* makes region ready for drawing, sets pixelspace */
void ED_region_set(const bContext *C, ARegion *ar)
{
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
- rcti winrct;
- /* checks other overlapping regions */
- region_scissor_winrct(ar, &winrct);
-
- ar->drawrct = winrct;
+ ar->drawrct = ar->winrct;
/* note; this sets state, so we can use wmOrtho and friends */
wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct);
@@ -452,24 +419,20 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
ARegionType *at = ar->type;
- rcti winrct;
/* see BKE_spacedata_draw_locks() */
if (at->do_lock)
return;
- /* checks other overlapping regions */
- region_scissor_winrct(ar, &winrct);
-
/* if no partial draw rect set, full rect */
if (ar->drawrct.xmin == ar->drawrct.xmax)
- ar->drawrct = winrct;
+ ar->drawrct = ar->winrct;
else {
/* extra clip for safety (intersect the rects, could use API func) */
- ar->drawrct.xmin = max_ii(winrct.xmin, ar->drawrct.xmin);
- ar->drawrct.ymin = max_ii(winrct.ymin, ar->drawrct.ymin);
- ar->drawrct.xmax = min_ii(winrct.xmax, ar->drawrct.xmax);
- ar->drawrct.ymax = min_ii(winrct.ymax, ar->drawrct.ymax);
+ ar->drawrct.xmin = max_ii(ar->winrct.xmin, ar->drawrct.xmin);
+ ar->drawrct.ymin = max_ii(ar->winrct.ymin, ar->drawrct.ymin);
+ ar->drawrct.xmax = min_ii(ar->winrct.xmax, ar->drawrct.xmax);
+ ar->drawrct.ymax = min_ii(ar->winrct.ymax, ar->drawrct.ymax);
}
/* note; this sets state, so we can use wmOrtho and friends */
@@ -500,7 +463,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
uiFreeInactiveBlocks(C, &ar->uiblocks);
if (sa)
- region_draw_emboss(ar, &winrct);
+ region_draw_emboss(ar, &ar->winrct);
}
/* **********************************
@@ -627,8 +590,8 @@ static void area_azone_initialize(bScreen *screen, ScrArea *sa)
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
-#define AZONEPAD_EDGE 4
-#define AZONEPAD_ICON 9
+#define AZONEPAD_EDGE (0.2f * U.widget_unit)
+#define AZONEPAD_ICON (0.45f * U.widget_unit)
static void region_azone_edge(AZone *az, ARegion *ar)
{
switch (az->edge) {
@@ -720,8 +683,8 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar)
}
}
-#define AZONEPAD_TAB_PLUSW 14
-#define AZONEPAD_TAB_PLUSH 14
+#define AZONEPAD_TAB_PLUSW (0.7f * U.widget_unit)
+#define AZONEPAD_TAB_PLUSH (0.7f * U.widget_unit)
/* region already made zero sized, in shape of edge */
static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
@@ -765,8 +728,8 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
}
-#define AZONEPAD_TABW 18
-#define AZONEPAD_TABH 7
+#define AZONEPAD_TABW (0.9f * U.widget_unit)
+#define AZONEPAD_TABH (0.35f * U.widget_unit)
/* region already made zero sized, in shape of edge */
static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
@@ -809,8 +772,8 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
}
-#define AZONEPAD_TRIAW 16
-#define AZONEPAD_TRIAH 9
+#define AZONEPAD_TRIAW (0.8f * U.widget_unit)
+#define AZONEPAD_TRIAH (0.45f * U.widget_unit)
/* region already made zero sized, in shape of edge */
@@ -892,9 +855,9 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT);
else if (alignment == RGN_ALIGN_BOTTOM)
region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT);
- else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
+ else if (alignment == RGN_ALIGN_RIGHT)
region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT);
- else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
+ else if (alignment == RGN_ALIGN_LEFT)
region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT);
}
@@ -909,7 +872,20 @@ static int rct_fits(rcti *rect, char dir, int size)
}
}
-static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
+/* *************************************************************** */
+
+/* overlapping regions only in the following restricted cases */
+static int region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar)
+{
+ if (U.uiflag2 & USER_REGION_OVERLAP)
+ if (WM_is_draw_triple(win))
+ if (ELEM5(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_SEQ, SPACE_CLIP, SPACE_NODE))
+ if (ELEM3(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
+ return 1;
+ return 0;
+}
+
+static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
{
rcti *remainder_prev = remainder;
int prefsizex, prefsizey;
@@ -928,6 +904,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
alignment = ar->alignment & ~RGN_SPLIT_PREV;
+ /* set here, assuming userpref switching forces to call this again */
+ ar->overlap = region_is_overlap(win, sa, ar);
+
/* clear state flags first */
ar->flag &= ~RGN_FLAG_TOO_SMALL;
/* user errors */
@@ -935,15 +914,15 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
alignment = RGN_ALIGN_NONE;
/* prefsize, for header we stick to exception */
- prefsizex = ar->sizex ? ar->sizex : ar->type->prefsizex;
+ prefsizex = ar->sizex ? ar->sizex : UI_DPI_FAC * ar->type->prefsizex;
if (ar->regiontype == RGN_TYPE_HEADER) {
- prefsizey = ar->type->prefsizey;
+ prefsizey = ED_area_headersize();
}
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
}
else {
- prefsizey = ar->sizey ? ar->sizey : ar->type->prefsizey;
+ prefsizey = ar->sizey ? ar->sizey : UI_DPI_FAC * ar->type->prefsizey;
}
@@ -985,7 +964,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
}
}
- else if (ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) {
+ else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
if (rct_fits(remainder, 'h', prefsizex) < 0) {
ar->flag |= RGN_FLAG_TOO_SMALL;
@@ -998,14 +977,14 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
ar->winrct = *remainder;
- if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) {
+ if (alignment == RGN_ALIGN_RIGHT) {
ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1;
- if (alignment == RGN_ALIGN_RIGHT)
+ if (ar->overlap == 0)
remainder->xmax = ar->winrct.xmin - 1;
}
else {
ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1;
- if (alignment == RGN_ALIGN_LEFT)
+ if (ar->overlap == 0)
remainder->xmin = ar->winrct.xmax + 1;
}
}
@@ -1090,9 +1069,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
ar->winrct.ymin = ar->winrct.ymax;
else if (alignment == RGN_ALIGN_BOTTOM)
ar->winrct.ymax = ar->winrct.ymin;
- else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT))
+ else if (alignment == RGN_ALIGN_RIGHT)
ar->winrct.xmin = ar->winrct.xmax;
- else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT))
+ else if (alignment == RGN_ALIGN_LEFT)
ar->winrct.xmax = ar->winrct.xmin;
else /* prevent winrct to be valid */
ar->winrct.xmax = ar->winrct.xmin;
@@ -1121,12 +1100,12 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
region_azone_add(sa, ar, alignment);
}
- region_rect_recursive(sa, ar->next, remainder, quad);
+ region_rect_recursive(win, sa, ar->next, remainder, quad);
}
static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
{
- short rt = 0; // CLAMPIS(G.debug_value, 0, 16);
+ short rt = U.pixelsize > 1 ? 1 : 0;
if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + 1 + rt;
else sa->totrct.xmin = sa->v1->vec.x;
@@ -1229,14 +1208,14 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
/* area sizes */
- area_calc_totrct(sa, win->sizex, win->sizey);
+ area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
/* clear all azones, add the area triange widgets */
area_azone_initialize(win->screen, sa);
/* region rect sizes */
rect = sa->totrct;
- region_rect_recursive(sa, sa->regionbase.first, &rect, 0);
+ region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
/* default area handlers */
ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
@@ -1284,11 +1263,17 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar)
ar->flag ^= RGN_FLAG_HIDDEN;
- if (ar->flag & RGN_FLAG_HIDDEN)
- WM_event_remove_handlers(C, &ar->handlers);
+ if (ar->overlap) {
+ /* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */
+ region_blend_start(C, sa, ar);
+ }
+ else {
+ if (ar->flag & RGN_FLAG_HIDDEN)
+ WM_event_remove_handlers(C, &ar->handlers);
- ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
- ED_area_tag_redraw(sa);
+ ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
+ ED_area_tag_redraw(sa);
+ }
}
/* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
@@ -1441,7 +1426,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
{
SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
- if (sl->next) {
+ if (sl && sl->next) {
/* workaround for case of double prevspace, render window
* with a file browser on top of it */
if (sl->next->spacetype == SPACE_FILE && sl->next->next)
@@ -1565,14 +1550,14 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr)
{
ScrArea *sa = CTX_wm_area(C);
- uiStyle *style = UI_GetStyle();
+ uiStyle *style = UI_GetStyleDraw();
uiBlock *block;
PanelType *pt;
Panel *panel;
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
int x, y, xco, yco, w, em, triangle, open, newcontext = 0;
-
+
if (contextnr >= 0)
newcontext = UI_view2d_tab_set(v2d, contextnr);
@@ -1653,8 +1638,18 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
uiEndPanels(C, ar, &x, &y);
/* clear */
- UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT);
+ if (ar->overlap) {
+ /* view should be in pixelspace */
+ UI_view2d_view_restore(C);
+ glEnable(GL_BLEND);
+ UI_ThemeColor4((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
+ glRecti(0, 0, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
+ glDisable(GL_BLEND);
+ }
+ else {
+ UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
/* before setting the view */
if (vertical) {
@@ -1725,7 +1720,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
void ED_region_header(const bContext *C, ARegion *ar)
{
- uiStyle *style = UI_GetStyle();
+ uiStyle *style = UI_GetStyleDraw();
uiBlock *block;
uiLayout *layout;
HeaderType *ht;
@@ -1740,8 +1735,8 @@ void ED_region_header(const bContext *C, ARegion *ar)
/* set view2d view matrix for scrolling (without scrollers) */
UI_view2d_view_ortho(&ar->v2d);
- xco = maxco = 8;
- yco = headery - 4;
+ xco = maxco = 0.4f * UI_UNIT_X;
+ yco = headery - floor(0.2f * UI_UNIT_Y);
/* draw all headers types */
for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
@@ -1784,18 +1779,16 @@ void ED_region_header_init(ARegion *ar)
/* UI_UNIT_Y is defined as U variable now, depending dpi */
int ED_area_headersize(void)
{
- return UI_UNIT_Y + 6;
+ return (int)(1.3f * UI_UNIT_Y);
}
void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
{
- const int header_height = 18;
- uiStyle *style = UI_GetStyle();
+ const int header_height = UI_UNIT_Y;
+ uiStyle *style = UI_GetStyleDraw();
int fontid = style->widget.uifont_id;
rcti rect;
- BLF_size(fontid, 11.0f, 72);
-
/* background box */
rect = ar->winrct;
rect.xmin = 0;