refactor UI7 clipping
This commit is contained in:
@@ -87,6 +87,8 @@ enum UI7LytAdd_ {
|
||||
UI7LytAdd_NoCursorUpdate = 1 << 0, ///< Add without cursor alignment
|
||||
UI7LytAdd_NoScrollHandle = 1 << 1, ///< Skip HandleScrolling
|
||||
UI7LytAdd_Front = 1 << 2, ///< Add in front of the list
|
||||
UI7LytAdd_NoGlobalClipping = 1 << 3, ///< Dont use global Layout clip rect
|
||||
UI7LytAdd_NoClipTitlebar = 1 << 4, ///< Dont clip content behind the titlebar
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+13
-3
@@ -77,6 +77,10 @@ PD_API void Layout::AddObject(Container* obj) {
|
||||
obj->Update();
|
||||
CursorMove(obj->GetSize());
|
||||
obj->HandleScrolling(ScrollOffset, WorkRect);
|
||||
if (Flags & UI7LayoutFlags_UseClipRect) {
|
||||
obj->SetClipRect(
|
||||
fvec4(Pos.x, Pos.y + WorkRect.y, Size.x, Size.y - WorkRect.y));
|
||||
}
|
||||
Objects.push_back(obj);
|
||||
}
|
||||
|
||||
@@ -93,6 +97,15 @@ PD_API void Layout::AddObjectEx(Container* obj, u32 flags) {
|
||||
if (!(flags & UI7LytAdd_NoScrollHandle)) {
|
||||
obj->HandleScrolling(ScrollOffset, WorkRect);
|
||||
}
|
||||
if (Flags & UI7LayoutFlags_UseClipRect &&
|
||||
!(flags & UI7LytAdd_NoGlobalClipping)) {
|
||||
if (flags & UI7LytAdd_NoClipTitlebar) {
|
||||
obj->SetClipRect(fvec4(Pos.x, Pos.y, Size.x, Size.y));
|
||||
} else {
|
||||
obj->SetClipRect(
|
||||
fvec4(Pos.x, Pos.y + WorkRect.y, Size.x, Size.y - WorkRect.y));
|
||||
}
|
||||
}
|
||||
if (flags & UI7LytAdd_Front) {
|
||||
Objects.push_front(obj);
|
||||
} else {
|
||||
@@ -171,9 +184,6 @@ PD_API void Layout::Update() {
|
||||
it->SetPos(it->GetPos() + Pos);
|
||||
it->HandleInput();
|
||||
it->UnlockInput();
|
||||
if (Flags & UI7LayoutFlags_UseClipRect) {
|
||||
it->SetClipRect(fvec4(Pos.x, Pos.y, Size.x, Size.y));
|
||||
}
|
||||
it->PreDraw();
|
||||
it->Draw();
|
||||
it->PostDraw();
|
||||
|
||||
+6
-4
@@ -248,7 +248,7 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
fvec2(pLayout.GetSize().x, pLayout.GetSize().y - TitleBarHeight));
|
||||
r->SetPos(fvec2(0, TitleBarHeight));
|
||||
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle |
|
||||
UI7LytAdd_Front);
|
||||
UI7LytAdd_Front | UI7LytAdd_NoClipTitlebar);
|
||||
}
|
||||
if (!(Flags & UI7MenuFlags_NoTitlebar)) {
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
@@ -273,7 +273,8 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
});
|
||||
r->SetSize(fvec2(pLayout.GetSize().x, TitleBarHeight));
|
||||
r->SetPos(0);
|
||||
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle);
|
||||
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle |
|
||||
UI7LytAdd_NoClipTitlebar);
|
||||
|
||||
/** Collapse Sym */
|
||||
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
||||
@@ -296,8 +297,9 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
});
|
||||
r->SetSize(TitleBarHeight - pIO.FramePadding.y * 2);
|
||||
r->SetPos(pIO.FramePadding);
|
||||
pLayout.AddObjectEx(r,
|
||||
UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle);
|
||||
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate |
|
||||
UI7LytAdd_NoScrollHandle |
|
||||
UI7LytAdd_NoClipTitlebar);
|
||||
}
|
||||
/** Close Sym (only shown if pIsShown is not nullptr) */
|
||||
if (!(Flags & UI7MenuFlags_NoClose) && pIsShown) {
|
||||
|
||||
Reference in New Issue
Block a user