diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 31 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 8 |
4 files changed, 37 insertions, 11 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b81fa4ae483..3089d980f06 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1640,7 +1640,12 @@ struct Panel *UI_panel_begin(struct ScrArea *sa, struct PanelType *pt, struct Panel *pa, bool *r_open); -void UI_panel_end(uiBlock *block, int width, int height, bool open); +void UI_panel_end(const struct ScrArea *sa, + const struct ARegion *ar, + uiBlock *block, + int width, + int height, + bool open); void UI_panels_scale(struct ARegion *ar, float new_width); void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y); int UI_panel_size_y(const struct Panel *pa); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 3b21b689ba0..cc1b7187e45 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -131,7 +131,7 @@ typedef enum eSpaceButtons_Align { BUT_AUTO = 2, } eSpaceButtons_Align; -static int panel_aligned(ScrArea *sa, ARegion *ar) +static int panel_aligned(const ScrArea *sa, const ARegion *ar) { if (sa->spacetype == SPACE_PROPERTIES && ar->regiontype == RGN_TYPE_WINDOW) { return BUT_VERTICAL; @@ -367,7 +367,19 @@ Panel *UI_panel_begin( return pa; } -void UI_panel_end(uiBlock *block, int width, int height, bool open) +static float panel_region_offset_x_get(const ARegion *ar, int align) +{ + if (UI_panel_category_is_visible(ar)) { + if (align == BUT_VERTICAL && (RGN_ALIGN_ENUM_FROM_MASK(ar->alignment) != RGN_ALIGN_RIGHT)) { + return UI_PANEL_CATEGORY_MARGIN_WIDTH; + } + } + + return 0; +} + +void UI_panel_end( + const ScrArea *sa, const ARegion *ar, uiBlock *block, int width, int height, bool open) { Panel *pa = block->panel; @@ -391,6 +403,7 @@ void UI_panel_end(uiBlock *block, int width, int height, bool open) } else { int old_sizex = pa->sizex, old_sizey = pa->sizey; + int old_region_ofsx = pa->runtime.region_ofsx; /* update width/height if non-zero */ if (width != 0) { @@ -405,6 +418,11 @@ void UI_panel_end(uiBlock *block, int width, int height, bool open) pa->runtime_flag |= PNL_ANIM_ALIGN; pa->ofsy += old_sizey - pa->sizey; } + + int align = panel_aligned(sa, ar); + if (old_region_ofsx != panel_region_offset_x_get(ar, align)) { + pa->runtime_flag |= PNL_ANIM_ALIGN; + } } } @@ -1004,7 +1022,6 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo int a, tot = 0; bool done; int align = panel_aligned(sa, ar); - bool has_category_tabs = UI_panel_category_is_visible(ar); /* count active, not tabbed panels */ for (pa = ar->panels.first; pa; pa = pa->next) { @@ -1061,14 +1078,10 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo /* no smart other default start loc! this keeps switching f5/f6/etc compatible */ ps = panelsort; + ps->pa->runtime.region_ofsx = panel_region_offset_x_get(ar, align); ps->pa->ofsx = 0; ps->pa->ofsy = -get_panel_size_y(ps->pa); - - if (has_category_tabs) { - if (align == BUT_VERTICAL && (RGN_ALIGN_ENUM_FROM_MASK(ar->alignment) != RGN_ALIGN_RIGHT)) { - ps->pa->ofsx += UI_PANEL_CATEGORY_MARGIN_WIDTH; - } - } + ps->pa->ofsx += ps->pa->runtime.region_ofsx; for (a = 0; a < tot - 1; a++, ps++) { psnext = ps + 1; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 39b2c060ba4..f8dd4f4612f 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2344,7 +2344,7 @@ static void ed_panel_draw(const bContext *C, } } - UI_panel_end(block, w, h, open); + UI_panel_end(sa, ar, block, w, h, open); } /** diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 60fb7b62dff..a52767834a4 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -129,6 +129,12 @@ typedef struct ScrAreaMap { ListBase areabase; } ScrAreaMap; +typedef struct Panel_Runtime { + /* Applied to Panel.ofsx, but saved separately so we can track changes between redraws. */ + int region_ofsx; + char _pad[4]; +} Panel_Runtime; + /** The part from uiBlock that needs saved in file. */ typedef struct Panel { struct Panel *next, *prev; @@ -159,6 +165,8 @@ typedef struct Panel { void *activedata; /** Sub panels. */ ListBase children; + + Panel_Runtime runtime; } Panel; /** |