split ui view clamp rule into separate x/y flags

This commit is contained in:
Ryan Fleury
2024-01-30 08:02:25 -08:00
parent c9b22acd5a
commit c61ff1910c
3 changed files with 49 additions and 46 deletions
+2 -1
View File
@@ -4042,6 +4042,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
UI_BoxFlag_Clip|
UI_BoxFlag_AllowOverflowY|
UI_BoxFlag_ViewScroll|
UI_BoxFlag_ViewClamp|
UI_BoxFlag_Floating|
UI_BoxFlag_AnimatePos|
UI_BoxFlag_Clickable|
@@ -5562,7 +5563,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
// rjf: build
UI_CornerRadius(0)
{
UI_Rect(tab_bar_rect) tab_bar_box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_AllowOverflowY|UI_BoxFlag_ViewScroll|UI_BoxFlag_Clickable, "tab_bar_%p", panel);
UI_Rect(tab_bar_rect) tab_bar_box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_AllowOverflowY|UI_BoxFlag_ViewClampX|UI_BoxFlag_ViewScroll|UI_BoxFlag_Clickable, "tab_bar_%p", panel);
if(panel->tab_side == Side_Max)
{
tab_bar_box->view_off.y = tab_bar_box->view_off_target.y = (tab_bar_rheight - tab_bar_vheight);
+4 -4
View File
@@ -1213,8 +1213,8 @@ ui_end_build(void)
ClampBot(0, box->view_bounds.x - box->fixed_size.x),
ClampBot(0, box->view_bounds.y - box->fixed_size.y),
};
box->view_off_target.x = Clamp(0, box->view_off_target.x, max_view_off_target.x);
box->view_off_target.y = Clamp(0, box->view_off_target.y, max_view_off_target.y);
if(box->flags & UI_BoxFlag_ViewClampX) { box->view_off_target.x = Clamp(0, box->view_off_target.x, max_view_off_target.x); }
if(box->flags & UI_BoxFlag_ViewClampY) { box->view_off_target.y = Clamp(0, box->view_off_target.y, max_view_off_target.y); }
}
// rjf: animate view offset
@@ -2560,8 +2560,8 @@ ui_signal_from_box(UI_Box *box)
ClampBot(0, box->view_bounds.x - box->fixed_size.x),
ClampBot(0, box->view_bounds.y - box->fixed_size.y),
};
box->view_off_target.x = Clamp(0, box->view_off_target.x, max_view_off_target.x);
box->view_off_target.y = Clamp(0, box->view_off_target.y, max_view_off_target.y);
if(box->flags & UI_BoxFlag_ViewClampX) { box->view_off_target.x = Clamp(0, box->view_off_target.x, max_view_off_target.x); }
if(box->flags & UI_BoxFlag_ViewClampY) { box->view_off_target.y = Clamp(0, box->view_off_target.y, max_view_off_target.y); }
}
}
+43 -41
View File
@@ -189,51 +189,52 @@ typedef U64 UI_BoxFlags;
# define UI_BoxFlag_ClickToFocus (UI_BoxFlags)(1ull<<2)
# define UI_BoxFlag_Scroll (UI_BoxFlags)(1ull<<3)
# define UI_BoxFlag_ViewScroll (UI_BoxFlags)(1ull<<4)
# define UI_BoxFlag_ViewClamp (UI_BoxFlags)(1ull<<5)
# define UI_BoxFlag_FocusHot (UI_BoxFlags)(1ull<<6)
# define UI_BoxFlag_FocusActive (UI_BoxFlags)(1ull<<7)
# define UI_BoxFlag_FocusHotDisabled (UI_BoxFlags)(1ull<<8)
# define UI_BoxFlag_FocusActiveDisabled (UI_BoxFlags)(1ull<<9)
# define UI_BoxFlag_DefaultFocusNavX (UI_BoxFlags)(1ull<<10)
# define UI_BoxFlag_DefaultFocusNavY (UI_BoxFlags)(1ull<<11)
# define UI_BoxFlag_DefaultFocusEdit (UI_BoxFlags)(1ull<<12)
# define UI_BoxFlag_FocusNavSkip (UI_BoxFlags)(1ull<<13)
# define UI_BoxFlag_Disabled (UI_BoxFlags)(1ull<<14)
# define UI_BoxFlag_ViewClampX (UI_BoxFlags)(1ull<<5)
# define UI_BoxFlag_ViewClampY (UI_BoxFlags)(1ull<<6)
# define UI_BoxFlag_FocusHot (UI_BoxFlags)(1ull<<7)
# define UI_BoxFlag_FocusActive (UI_BoxFlags)(1ull<<8)
# define UI_BoxFlag_FocusHotDisabled (UI_BoxFlags)(1ull<<9)
# define UI_BoxFlag_FocusActiveDisabled (UI_BoxFlags)(1ull<<10)
# define UI_BoxFlag_DefaultFocusNavX (UI_BoxFlags)(1ull<<11)
# define UI_BoxFlag_DefaultFocusNavY (UI_BoxFlags)(1ull<<12)
# define UI_BoxFlag_DefaultFocusEdit (UI_BoxFlags)(1ull<<13)
# define UI_BoxFlag_FocusNavSkip (UI_BoxFlags)(1ull<<14)
# define UI_BoxFlag_Disabled (UI_BoxFlags)(1ull<<15)
//- rjf: layout
# define UI_BoxFlag_FloatingX (UI_BoxFlags)(1ull<<15)
# define UI_BoxFlag_FloatingY (UI_BoxFlags)(1ull<<16)
# define UI_BoxFlag_FixedWidth (UI_BoxFlags)(1ull<<17)
# define UI_BoxFlag_FixedHeight (UI_BoxFlags)(1ull<<18)
# define UI_BoxFlag_AllowOverflowX (UI_BoxFlags)(1ull<<19)
# define UI_BoxFlag_AllowOverflowY (UI_BoxFlags)(1ull<<20)
# define UI_BoxFlag_SkipViewOffX (UI_BoxFlags)(1ull<<21)
# define UI_BoxFlag_SkipViewOffY (UI_BoxFlags)(1ull<<22)
# define UI_BoxFlag_FloatingX (UI_BoxFlags)(1ull<<16)
# define UI_BoxFlag_FloatingY (UI_BoxFlags)(1ull<<17)
# define UI_BoxFlag_FixedWidth (UI_BoxFlags)(1ull<<18)
# define UI_BoxFlag_FixedHeight (UI_BoxFlags)(1ull<<19)
# define UI_BoxFlag_AllowOverflowX (UI_BoxFlags)(1ull<<20)
# define UI_BoxFlag_AllowOverflowY (UI_BoxFlags)(1ull<<21)
# define UI_BoxFlag_SkipViewOffX (UI_BoxFlags)(1ull<<22)
# define UI_BoxFlag_SkipViewOffY (UI_BoxFlags)(1ull<<23)
//- rjf: appearance / animation
# define UI_BoxFlag_DrawDropShadow (UI_BoxFlags)(1ull<<23)
# define UI_BoxFlag_DrawBackgroundBlur (UI_BoxFlags)(1ull<<24)
# define UI_BoxFlag_DrawBackground (UI_BoxFlags)(1ull<<25)
# define UI_BoxFlag_DrawBorder (UI_BoxFlags)(1ull<<26)
# define UI_BoxFlag_DrawSideTop (UI_BoxFlags)(1ull<<27)
# define UI_BoxFlag_DrawSideBottom (UI_BoxFlags)(1ull<<28)
# define UI_BoxFlag_DrawSideLeft (UI_BoxFlags)(1ull<<29)
# define UI_BoxFlag_DrawSideRight (UI_BoxFlags)(1ull<<30)
# define UI_BoxFlag_DrawText (UI_BoxFlags)(1ull<<31)
# define UI_BoxFlag_DrawTextFastpathCodepoint (UI_BoxFlags)(1ull<<32)
# define UI_BoxFlag_DrawHotEffects (UI_BoxFlags)(1ull<<33)
# define UI_BoxFlag_DrawActiveEffects (UI_BoxFlags)(1ull<<34)
# define UI_BoxFlag_DrawOverlay (UI_BoxFlags)(1ull<<35)
# define UI_BoxFlag_DrawBucket (UI_BoxFlags)(1ull<<36)
# define UI_BoxFlag_Clip (UI_BoxFlags)(1ull<<37)
# define UI_BoxFlag_AnimatePosX (UI_BoxFlags)(1ull<<38)
# define UI_BoxFlag_AnimatePosY (UI_BoxFlags)(1ull<<39)
# define UI_BoxFlag_DisableTextTrunc (UI_BoxFlags)(1ull<<40)
# define UI_BoxFlag_DisableIDString (UI_BoxFlags)(1ull<<41)
# define UI_BoxFlag_DisableFocusViz (UI_BoxFlags)(1ull<<42)
# define UI_BoxFlag_RequireFocusBackground (UI_BoxFlags)(1ull<<43)
# define UI_BoxFlag_HasDisplayString (UI_BoxFlags)(1ull<<44)
# define UI_BoxFlag_RoundChildrenByParent (UI_BoxFlags)(1ull<<45)
# define UI_BoxFlag_DrawDropShadow (UI_BoxFlags)(1ull<<24)
# define UI_BoxFlag_DrawBackgroundBlur (UI_BoxFlags)(1ull<<25)
# define UI_BoxFlag_DrawBackground (UI_BoxFlags)(1ull<<26)
# define UI_BoxFlag_DrawBorder (UI_BoxFlags)(1ull<<27)
# define UI_BoxFlag_DrawSideTop (UI_BoxFlags)(1ull<<28)
# define UI_BoxFlag_DrawSideBottom (UI_BoxFlags)(1ull<<29)
# define UI_BoxFlag_DrawSideLeft (UI_BoxFlags)(1ull<<30)
# define UI_BoxFlag_DrawSideRight (UI_BoxFlags)(1ull<<31)
# define UI_BoxFlag_DrawText (UI_BoxFlags)(1ull<<32)
# define UI_BoxFlag_DrawTextFastpathCodepoint (UI_BoxFlags)(1ull<<33)
# define UI_BoxFlag_DrawHotEffects (UI_BoxFlags)(1ull<<34)
# define UI_BoxFlag_DrawActiveEffects (UI_BoxFlags)(1ull<<35)
# define UI_BoxFlag_DrawOverlay (UI_BoxFlags)(1ull<<36)
# define UI_BoxFlag_DrawBucket (UI_BoxFlags)(1ull<<37)
# define UI_BoxFlag_Clip (UI_BoxFlags)(1ull<<38)
# define UI_BoxFlag_AnimatePosX (UI_BoxFlags)(1ull<<39)
# define UI_BoxFlag_AnimatePosY (UI_BoxFlags)(1ull<<40)
# define UI_BoxFlag_DisableTextTrunc (UI_BoxFlags)(1ull<<41)
# define UI_BoxFlag_DisableIDString (UI_BoxFlags)(1ull<<42)
# define UI_BoxFlag_DisableFocusViz (UI_BoxFlags)(1ull<<43)
# define UI_BoxFlag_RequireFocusBackground (UI_BoxFlags)(1ull<<44)
# define UI_BoxFlag_HasDisplayString (UI_BoxFlags)(1ull<<45)
# define UI_BoxFlag_RoundChildrenByParent (UI_BoxFlags)(1ull<<46)
//- rjf: bundles
# define UI_BoxFlag_Clickable (UI_BoxFlag_MouseClickable|UI_BoxFlag_KeyboardClickable)
@@ -242,6 +243,7 @@ typedef U64 UI_BoxFlags;
# define UI_BoxFlag_FixedSize (UI_BoxFlag_FixedWidth|UI_BoxFlag_FixedHeight)
# define UI_BoxFlag_AllowOverflow (UI_BoxFlag_AllowOverflowX|UI_BoxFlag_AllowOverflowY)
# define UI_BoxFlag_AnimatePos (UI_BoxFlag_AnimatePosX|UI_BoxFlag_AnimatePosY)
# define UI_BoxFlag_ViewClamp (UI_BoxFlag_ViewClampX|UI_BoxFlag_ViewClampY)
//}
typedef struct UI_Box UI_Box;