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>2019-05-03 06:04:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-03 06:04:37 +0300
commit70682d11b8a8b3bca327a309f2e1e8383b920387 (patch)
tree3de183e21e545da5df17e6afe0edf2561db0319b
parenta01bcfa6366f893fbc8fdbf537d91ece4832ea03 (diff)
Cleanup: replace RGN_ALIGN_ENUM_MASK
This was only used once, other checks were masking out RGN_SPLIT_PREV which isn't future proof (if other flags are added). Add RGN_ALIGN_ENUM_FROM_MASK macro, use it everywhere we need to check the alignment enum.
-rw-r--r--source/blender/editors/screen/area.c8
-rw-r--r--source/blender/editors/screen/screen_ops.c2
-rw-r--r--source/blender/makesdna/DNA_screen_types.h42
-rw-r--r--source/blender/makesrna/intern/rna_screen.c2
4 files changed, 31 insertions, 23 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 38684afec39..9a74ffc38d9 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1110,7 +1110,7 @@ static int rct_fits(const rcti *rect, char dir, int size)
static void region_overlap_fix(ScrArea *sa, ARegion *ar)
{
ARegion *ar1;
- const int align = ar->alignment & ~RGN_SPLIT_PREV;
+ const int align = RGN_ALIGN_ENUM_FROM_MASK(ar->alignment);
int align1 = 0;
/* find overlapping previous region on same place */
@@ -1227,7 +1227,7 @@ static void region_rect_recursive(
}
}
- int alignment = ar->alignment & ~RGN_SPLIT_PREV;
+ int alignment = RGN_ALIGN_ENUM_FROM_MASK(ar->alignment);
/* set here, assuming userpref switching forces to call this again */
ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
@@ -1690,7 +1690,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
}
/* Some AZones use View2D data which is only updated in region init, so call that first! */
- region_azones_add(screen, area, ar, ar->alignment & ~RGN_SPLIT_PREV);
+ region_azones_add(screen, area, ar, RGN_ALIGN_ENUM_FROM_MASK(ar->alignment));
}
ED_area_azones_update(area, &win->eventstate->x);
@@ -1761,7 +1761,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
}
/* Some AZones use View2D data which is only updated in region init, so call that first! */
- region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV);
+ region_azones_add(screen, sa, ar, RGN_ALIGN_ENUM_FROM_MASK(ar->alignment));
}
/* Avoid re-initializing tools while resizing the window. */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 9f452dd79e0..a87660d2cb7 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2431,7 +2431,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
/* regions in regions. */
if (scalear->alignment & RGN_SPLIT_PREV) {
- const int align = scalear->alignment & RGN_ALIGN_ENUM_MASK;
+ const int align = RGN_ALIGN_ENUM_FROM_MASK(scalear->alignment);
if (ELEM(align, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
ARegion *ar = scalear->prev;
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 411777333a9..e014de183e3 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -599,31 +599,39 @@ enum {
/* Region supports panel tabs (categories). */
#define RGN_TYPE_HAS_CATEGORY_MASK (1 << RGN_TYPE_UI)
-/* region alignment */
-#define RGN_ALIGN_NONE 0
-#define RGN_ALIGN_TOP 1
-#define RGN_ALIGN_BOTTOM 2
-#define RGN_ALIGN_LEFT 3
-#define RGN_ALIGN_RIGHT 4
-#define RGN_ALIGN_HSPLIT 5
-#define RGN_ALIGN_VSPLIT 6
-#define RGN_ALIGN_FLOAT 7
-#define RGN_ALIGN_QSPLIT 8
-#define RGN_ALIGN_ENUM_MASK 0x0F
-
-#define RGN_SPLIT_PREV 32
+/** #ARegion.alignment */
+enum {
+ RGN_ALIGN_NONE = 0,
+ RGN_ALIGN_TOP = 1,
+ RGN_ALIGN_BOTTOM = 2,
+ RGN_ALIGN_LEFT = 3,
+ RGN_ALIGN_RIGHT = 4,
+ RGN_ALIGN_HSPLIT = 5,
+ RGN_ALIGN_VSPLIT = 6,
+ RGN_ALIGN_FLOAT = 7,
+ RGN_ALIGN_QSPLIT = 8,
+ /* Maximum 15. */
+
+ /* Flags start here. */
+ RGN_SPLIT_PREV = 32,
+};
+
+/** Mask out flags so we can check the alignment. */
+#define RGN_ALIGN_ENUM_FROM_MASK(align) ((align) & ((1 << 4) - 1))
/** #ARegion.flag */
enum {
RGN_FLAG_HIDDEN = (1 << 0),
RGN_FLAG_TOO_SMALL = (1 << 1),
- /* Force delayed reinit of region size data, so that region size is calculated
+ /**
+ * Force delayed reinit of region size data, so that region size is calculated
* just big enough to show all its content (if enough space is available).
- * Note that only ED_region_header supports this right now. */
+ * Note that only ED_region_header supports this right now.
+ */
RGN_FLAG_DYNAMIC_SIZE = (1 << 2),
- /* Region data is NULL'd on read, never written. */
+ /** Region data is NULL'd on read, never written. */
RGN_FLAG_TEMP_REGIONDATA = (1 << 3),
- /* The region must either use its prefsizex/y or be hidden. */
+ /** The region must either use its prefsizex/y or be hidden. */
RGN_FLAG_PREFSIZE_OR_HIDDEN = (1 << 4),
/** Size has been clamped (floating regions only). */
RGN_FLAG_SIZE_CLAMP_X = (1 << 5),
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 3de946c1c8f..9c349d64953 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -93,7 +93,7 @@ static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
static int rna_region_alignment_get(PointerRNA *ptr)
{
ARegion *region = ptr->data;
- return (region->alignment & ~RGN_SPLIT_PREV);
+ return RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
}
static bool rna_Screen_fullscreen_get(PointerRNA *ptr)