diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 118 |
1 files changed, 96 insertions, 22 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 752f388c338..901ab67d6cd 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -63,6 +63,7 @@ #include "BLF_api.h" #include "UI_interface.h" +#include "UI_interface_icons.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -149,6 +150,45 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa) } /** + * \brief Corner widget use for quitting fullscreen. + */ +static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, float alpha) +{ + int x = x2 - ((float) x2 - x1) * 0.5f / UI_DPI_FAC; + int y = y2 - ((float) y2 - y1) * 0.5f / UI_DPI_FAC; + + /* adjust the icon distance from the corner */ + x += 36.0f / UI_DPI_FAC; + y += 36.0f / UI_DPI_FAC; + + /* draws from the left bottom corner of the icon */ + x -= UI_DPI_ICON_SIZE; + y -= UI_DPI_ICON_SIZE; + + alpha = min_ff(alpha, 0.75f); + + UI_icon_draw_aspect(x, y, ICON_FULLSCREEN_EXIT, 0.7f / UI_DPI_FAC, alpha); + + /* debug drawing : + * The click_rect is the same as defined in fullscreen_click_rcti_init + * Keep them both in sync */ + + if (G.debug_value == 1) { + rcti click_rect; + float icon_size = UI_DPI_ICON_SIZE + 7 * UI_DPI_FAC; + char alpha_debug = 255 * alpha; + + BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size); + + glColor4ub(255, 0, 0, alpha_debug); + fdrawbox(click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax); + glColor4ub(0, 255, 255, alpha_debug); + fdrawline(click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax); + fdrawline(click_rect.xmin, click_rect.ymax, click_rect.xmax, click_rect.ymin); + } +} + +/** * \brief Corner widgets use for dragging and splitting the view. */ static void area_draw_azone(short x1, short y1, short x2, short y2) @@ -365,6 +405,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) } } } + else if (az->type == AZONE_FULLSCREEN) { + area_draw_azone_fullscreen(az->x1, az->y1, az->x2, az->y2, az->alpha); + } } } @@ -567,10 +610,10 @@ static void area_azone_initialize(wmWindow *win, bScreen *screen, ScrArea *sa) { AZone *az; - /* reinitalize entirely, regions add azones too */ + /* reinitalize entirely, regions and fullscreen add azones too */ BLI_freelistN(&sa->actionzones); - if (screen->full != SCREENNORMAL) { + if (screen->state != SCREENNORMAL) { return; } @@ -602,6 +645,26 @@ static void area_azone_initialize(wmWindow *win, bScreen *screen, ScrArea *sa) BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } +static void fullscreen_azone_initialize(ScrArea *sa, ARegion *ar) +{ + AZone *az; + + if (ar->regiontype != RGN_TYPE_WINDOW) + return; + + az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone"); + BLI_addtail(&(sa->actionzones), az); + az->type = AZONE_FULLSCREEN; + az->ar = ar; + az->alpha = 0.0f; + + az->x1 = ar->winrct.xmax - (AZONEFADEOUT - 1); + az->y1 = ar->winrct.ymax - (AZONEFADEOUT - 1); + az->x2 = ar->winrct.xmax; + az->y2 = ar->winrct.ymax; + BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); +} + #define AZONEPAD_EDGE (0.1f * U.widget_unit) #define AZONEPAD_ICON (0.45f * U.widget_unit) static void region_azone_edge(AZone *az, ARegion *ar) @@ -830,25 +893,30 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) } -static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) +static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const bool is_fullscreen) { AZone *az; + const bool is_hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0; - az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); - BLI_addtail(&(sa->actionzones), az); - az->type = AZONE_REGION; - az->ar = ar; - az->edge = edge; + if (is_hidden || !is_fullscreen) { + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&(sa->actionzones), az); + az->type = AZONE_REGION; + az->ar = ar; + az->edge = edge; + } if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { - if (G.debug_value == 3) - region_azone_icon(sa, az, ar); - else if (G.debug_value == 2) - region_azone_tria(sa, az, ar); - else if (G.debug_value == 1) - region_azone_tab(sa, az, ar); - else - region_azone_tab_plus(sa, az, ar); + if (!is_fullscreen) { + if (G.debug_value == 3) + region_azone_icon(sa, az, ar); + else if (G.debug_value == 2) + region_azone_tria(sa, az, ar); + else if (G.debug_value == 1) + region_azone_tab(sa, az, ar); + else + region_azone_tab_plus(sa, az, ar); + } } else { region_azone_edge(az, ar); @@ -859,18 +927,18 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) /* *************************************************************** */ -static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) +static void region_azone_add(ScrArea *sa, ARegion *ar, const int alignment, const bool is_fullscreen) { /* edge code (t b l r) is along which area edge azone will be drawn */ if (alignment == RGN_ALIGN_TOP) - region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT); + region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); else if (alignment == RGN_ALIGN_BOTTOM) - region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT); + region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen); else if (alignment == RGN_ALIGN_RIGHT) - region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT); + region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT, is_fullscreen); else if (alignment == RGN_ALIGN_LEFT) - region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT); + region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT, is_fullscreen); } /* dir is direction to check, not the splitting edge direction! */ @@ -1188,7 +1256,13 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti * must be minimum '4' */ } else { - region_azone_add(sa, ar, alignment); + if (ELEM(win->screen->state, SCREENNORMAL, SCREENMAXIMIZED)) { + region_azone_add(sa, ar, alignment, false); + } + else { + region_azone_add(sa, ar, alignment, true); + fullscreen_azone_initialize(sa, ar); + } } region_rect_recursive(win, sa, ar->next, remainder, quad); |