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:
authorCampbell Barton <ideasman42@gmail.com>2018-06-12 11:11:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-12 11:42:49 +0300
commit4bf331c0fcfebf211443bdd15181a334cdf1566b (patch)
tree5d2188bdb5799f8130212c6683930c60fb7cc379 /source/blender/editors/screen
parent3937e8fbc3bb6ec7bdd3caad26e4e8a504ee5100 (diff)
UI: Initial persistent floating redo panel
This is the first step to moving redo out of the top-bar, see: T55039 - Support for floating panels in the ScrArea has been added. - A new region type RGN_TYPE_HUD is used for floating settings input. - Only one HUD should be visible at a time. - Currently HUD regions are only visible for 3D view and image space types. - There are currently some remaining glitches with hide/show that need further investigation.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/area.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 4eef386dd04..316b8cbe55f 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -953,6 +953,9 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar)
}
if (ar1->overlap && ((ar1->alignment & RGN_SPLIT_PREV) == 0)) {
+ if (ELEM(ar1->alignment, RGN_ALIGN_FLOAT)) {
+ continue;
+ }
align1 = ar1->alignment;
if (BLI_rcti_isect(&ar1->winrct, &ar->winrct, NULL)) {
if (align1 != align) {
@@ -994,6 +997,9 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar)
if (ar1->flag & (RGN_FLAG_HIDDEN)) {
continue;
}
+ if (ELEM(ar1->alignment, RGN_ALIGN_FLOAT)) {
+ continue;
+ }
if (ar1->overlap && (ar1->alignment & RGN_SPLIT_PREV) == 0) {
if ((ar1->alignment != align) && BLI_rcti_isect(&ar1->winrct, &ar->winrct, NULL)) {
@@ -1009,6 +1015,9 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar)
bool ED_region_is_overlap(int spacetype, int regiontype)
{
if (U.uiflag2 & USER_REGION_OVERLAP) {
+ if (regiontype == RGN_TYPE_HUD) {
+ return 1;
+ }
if (ELEM(spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
if (ELEM(regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
return 1;
@@ -1052,8 +1061,9 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
/* clear state flags first */
ar->flag &= ~RGN_FLAG_TOO_SMALL;
/* user errors */
- if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT)
+ if ((ar->next == NULL) && !ELEM(alignment, RGN_ALIGN_QSPLIT, RGN_ALIGN_FLOAT)) {
alignment = RGN_ALIGN_NONE;
+ }
/* prefsize, taking into account DPI */
prefsizex = UI_DPI_FAC * ((ar->sizex > 1) ? ar->sizex + 0.5f : ar->type->prefsizex);
@@ -1076,7 +1086,28 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
/* hidden is user flag */
}
else if (alignment == RGN_ALIGN_FLOAT) {
- /* XXX floating area region, not handled yet here */
+ /**
+ * \note Currently this window type is only used for #RGN_TYPE_HUD,
+ * We expect the panel to resize it's self to be larger.
+ *
+ * This aligns to the lower left of the area.
+ */
+ rcti overlap_remainder_margin = *overlap_remainder;
+ BLI_rcti_resize(
+ &overlap_remainder_margin,
+ max_ii(0, BLI_rcti_size_x(overlap_remainder) - UI_UNIT_X / 2),
+ max_ii(0, BLI_rcti_size_y(overlap_remainder) - UI_UNIT_Y / 2));
+ ar->winrct.xmin = overlap_remainder_margin.xmin;
+ ar->winrct.ymin = overlap_remainder_margin.ymin;
+ ar->winrct.xmax = ar->winrct.xmin + ar->sizex;
+ ar->winrct.ymax = ar->winrct.ymin + ar->sizey;
+
+ BLI_rcti_isect(&ar->winrct, &overlap_remainder_margin, &ar->winrct);
+ if (BLI_rcti_size_x(&ar->winrct) < UI_UNIT_X ||
+ BLI_rcti_size_y(&ar->winrct) < UI_UNIT_Y)
+ {
+ ar->flag |= RGN_FLAG_TOO_SMALL;
+ }
}
else if (rct_fits(remainder, 'v', 1) < 0 || rct_fits(remainder, 'h', 1) < 0) {
/* remainder is too small for any usage */
@@ -1215,7 +1246,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
/* exception for multiple overlapping regions on same spot */
- if (ar->overlap) {
+ if (ar->overlap & (alignment != RGN_ALIGN_FLOAT)) {
region_overlap_fix(sa, ar);
}
@@ -1781,7 +1812,10 @@ static ThemeColorID region_background_color_id(const bContext *C, const ARegion
static void region_clear_color(const bContext *C, const ARegion *ar, ThemeColorID colorid)
{
- if (ar->overlap) {
+ if (ar->alignment == RGN_ALIGN_FLOAT) {
+ /* handle our own drawing. */
+ }
+ else if (ar->overlap) {
/* view should be in pixelspace */
UI_view2d_view_restore(C);
@@ -1911,6 +1945,7 @@ void ED_region_panels_layout_ex(
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
int margin_x = 0;
+ const bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *);
@@ -2021,7 +2056,25 @@ void ED_region_panels_layout_ex(
UI_panels_end(C, ar, &x, &y);
/* before setting the view */
- if (vertical) {
+ if (region_layout_based) {
+ /* XXX, only single panel support atm.
+ * Can't use x/y values calculated above because they're not using the real height of panels,
+ * instead they calculate offsets for the next panel to start drawing. */
+ Panel *panel = ar->panels.last;
+ int size_dyn[2] = {
+ UI_UNIT_X * 12,
+ UI_panel_size_y(panel),
+ };
+ /* region size is layout based and needs to be updated */
+ if ((ar->sizex != size_dyn[0]) ||
+ (ar->sizey != size_dyn[1]))
+ {
+ ar->sizex = size_dyn[0];
+ ar->sizey = size_dyn[1];
+ sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ }
+ }
+ else if (vertical) {
/* we always keep the scroll offset - so the total view gets increased with the scrolled away part */
if (v2d->cur.ymax < -FLT_EPSILON) {
/* Clamp to lower view boundary */
@@ -2071,7 +2124,9 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar)
{
View2D *v2d = &ar->v2d;
- region_clear_color(C, ar, (ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
+ if (ar->alignment != RGN_ALIGN_FLOAT) {
+ region_clear_color(C, ar, (ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
+ }
/* reset line width for drawing tabs */
glLineWidth(1.0f);
@@ -2717,6 +2772,9 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect)
rect->ymax = arn->winrct.ymin;
}
}
+ else if (arn->alignment == RGN_ALIGN_FLOAT) {
+ /* Skip floating. */
+ }
else {
BLI_assert(!"Region overlap with unknown alignment");
}