Add Input functionality to Ultra
- Add point InSpace check to PD::Li::Math - Add Universal AlignmentCenter flag for Horizontal and and Vertical Alignment - Add Fallbackfont to Layout (if you dont want to set font per object) - Add Button Object WIP - Rename OnHover to OnFocus and add OnUnfocus - Move font and FontScale to ElementBase (for fallback logic etc) - Add UpdateInput func to ElementBase - Corectly Set fontScale in Text Rendering - Update ecample
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
#include <pd/ultra/container.hpp>
|
||||
#include <pd/ultra/elems/element.hpp>
|
||||
|
||||
@@ -12,11 +13,35 @@ PD_API bool ElementBase::RevisionUpdate(PD::u32 req) {
|
||||
}
|
||||
}
|
||||
PD_API void ElementBase::Update() {
|
||||
if (!pParent) pRenderspace = PD::fvec4(pPos, pPos + pSize);
|
||||
pRenderspace = pParent->GetCanvas().VTranslateObject(
|
||||
pParent->GetTopLeft() + pPos, pSize, pAlignment);
|
||||
if (!pParent)
|
||||
pRenderspace = PD::fvec4(pPos, pPos + pSize);
|
||||
else
|
||||
pRenderspace = pParent->GetCanvas().VTranslateObject(
|
||||
pParent->GetTopLeft() + pPos, pSize, pAlignment);
|
||||
UpdateInput();
|
||||
/*pRenderspace = PD::fvec4(pParent->GetTopLeft() + pPos,
|
||||
pParent->GetTopLeft() + pPos + pSize);*/
|
||||
}
|
||||
|
||||
PD_API void ElementBase::UpdateInput() {
|
||||
if (PD::Li::Math::InSpace(
|
||||
PD::Hid::MousePos(),
|
||||
PD::fvec4(pRenderspace.TopLeft(), pRenderspace.BotRight()))) {
|
||||
if (pHover && !pFocued) {
|
||||
pHover();
|
||||
pFocued = true;
|
||||
}
|
||||
if (PD::Hid::IsEvent(PD::Hid::Event::Up, PD::Hid::Gamepad::Touch)) {
|
||||
if (pPress) {
|
||||
pPress();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pUnHover && pFocued) {
|
||||
pUnHover();
|
||||
pFocued = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user