WIP: Add CLipRects to UI7 Layouts
- Added Scissor Support to Font Rendering
This commit is contained in:
@@ -40,5 +40,18 @@ PD_API void Container::HandleScrolling(fvec2 scrolling, fvec4 viewport) {
|
||||
PD_API void Container::HandleInternalInput() {
|
||||
/** Requires Handle Scrolling First */
|
||||
}
|
||||
|
||||
/** Internal function */
|
||||
PD_API void Container::PreDraw() {
|
||||
if (pCLipRectUsed) {
|
||||
list->PushClipRect(pClipRect);
|
||||
}
|
||||
}
|
||||
/** Internal function */
|
||||
PD_API void Container::PostDraw() {
|
||||
if (pCLipRectUsed) {
|
||||
list->PopClipRect();
|
||||
}
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
@@ -28,14 +28,8 @@ namespace UI7 {
|
||||
PD_API void Label::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
if (pCLipRectUsed) {
|
||||
list->PushClipRect(pClipRect);
|
||||
}
|
||||
list->DrawTextEx(FinalPos(), label, io->Theme->Get(UI7Color_Text),
|
||||
LiTextFlags_NoOOS, PD::fvec2(0, io->CurrentViewPort.w));
|
||||
if (pCLipRectUsed) {
|
||||
list->PopClipRect();
|
||||
}
|
||||
}
|
||||
|
||||
PD_API void Label::Update() {
|
||||
|
||||
@@ -125,7 +125,12 @@ PD_API void Layout::Update() {
|
||||
it->SetPos(it->GetPos() + Pos);
|
||||
it->HandleInput();
|
||||
it->UnlockInput();
|
||||
if (Flags & UI7LayoutFlags_UseClipRect) {
|
||||
it->SetClipRect(fvec4(Pos, Size));
|
||||
}
|
||||
it->PreDraw();
|
||||
it->Draw();
|
||||
it->PostDraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,13 @@ Menu::Menu(const ID& id, IO::Ref io) : pIO(io), pID(id) {
|
||||
pLayout = Layout::New(id, io);
|
||||
TitleBarHeight = pIO->FontScale * pIO->Font->PixelHeight + pIO->MenuPadding.y;
|
||||
pLayout->WorkRect.y += TitleBarHeight;
|
||||
pLayout->Flags |= UI7LayoutFlags_UseClipRect;
|
||||
pLayout->CursorInit();
|
||||
}
|
||||
|
||||
PD_API void Menu::Label(const std::string& label) {
|
||||
// Layout API
|
||||
auto r = Label::New(label, pIO);
|
||||
r->SetClipRect(fvec4(pLayout->GetPosition(),
|
||||
pLayout->GetPosition() + pLayout->GetSize()));
|
||||
pLayout->AddObject(r);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user