wayland rewrite complete
This commit is contained in:
parent
5ff43e240c
commit
721ff8f42f
8 changed files with 134 additions and 87 deletions
|
|
@ -26,7 +26,15 @@ import std;
|
|||
|
||||
using namespace Crafter;
|
||||
|
||||
UiElement::UiElement(std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), relativeWidth(relativeWidth), relativeHeight(relativeHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), ignoreScaling(ignoreScaling) {
|
||||
Transform::Transform(std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), relativeWidth(relativeWidth), relativeHeight(relativeHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), ignoreScaling(ignoreScaling) {
|
||||
|
||||
}
|
||||
|
||||
UiElement::UiElement(std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : transform(anchorX, anchorY, relativeWidth, relativeHeight, anchorOffsetX, anchorOffsetY, z, ignoreScaling) {
|
||||
|
||||
}
|
||||
|
||||
UiElementMouse::UiElementMouse(std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling) : transform(anchorX, anchorY, relativeWidth, relativeHeight, anchorOffsetX, anchorOffsetY, z, ignoreScaling) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -34,22 +42,16 @@ UiElementBuffer::UiElementBuffer(std::uint_fast32_t width, std::uint_fast32_t he
|
|||
|
||||
}
|
||||
|
||||
// void UiElement::UpdatePosition(Window& window) {
|
||||
// // scaled.width = relativeWidth;
|
||||
// // scaled.height = relativeHeight;
|
||||
// // scaled.x = anchorX - (anchorOffsetX * scaled.width);
|
||||
// // scaled.y = anchorY - (anchorOffsetY * scaled.height);
|
||||
// // for(UiElement* child : children) {
|
||||
// // UpdatePosition(*child);
|
||||
// // }
|
||||
// }
|
||||
void UiElement::UpdatePosition(WindowFramebuffer& window) {
|
||||
window.ScaleElement(transform);
|
||||
for(UiElement* child : children) {
|
||||
UpdatePosition(window, *child);
|
||||
}
|
||||
}
|
||||
|
||||
// void UiElement::UpdatePosition(UiElement& parent) {
|
||||
// // scaled.width = parent.scaled.width / relativeWidth;
|
||||
// // scaled.height = parent.scaled.height / relativeHeight;
|
||||
// // scaled.x = (parent.scaled.width / anchorX) - (anchorOffsetX * scaled.width);
|
||||
// // scaled.y = (parent.scaled.height / anchorY) - (anchorOffsetY * scaled.height);
|
||||
// // for(UiElement* child : children) {
|
||||
// // UpdatePosition(*child);
|
||||
// // }
|
||||
// }
|
||||
void UiElement::UpdatePosition(WindowFramebuffer& window, UiElement& parent) {
|
||||
window.ScaleElement(transform, parent.transform);
|
||||
for(UiElement* child : children) {
|
||||
UpdatePosition(window, *child);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue