rendering element rewrite
This commit is contained in:
parent
4c286e1fd8
commit
3d40256bde
22 changed files with 799 additions and 795 deletions
|
|
@ -29,35 +29,35 @@ Window::Window(std::int_fast32_t width, std::int_fast32_t height) : width(width)
|
|||
}
|
||||
|
||||
void Window::ScaleElement(Transform& element) {
|
||||
element.scaled.width = MappedToPixel(element.relativeWidth, width);
|
||||
element.scaled.height = MappedToPixel(element.relativeHeight, height);
|
||||
element.scaled.x = MappedToPixel(element.anchorX, width) - MappedToPixel(element.anchorOffsetX, element.scaled.width);
|
||||
element.scaled.y = MappedToPixel(element.anchorY, height) - MappedToPixel(element.anchorOffsetY, element.scaled.height);
|
||||
element.scaled.width = MappedToPixel(element.anchor.width, width);
|
||||
element.scaled.height = MappedToPixel(element.anchor.height, height);
|
||||
element.scaled.x = MappedToPixel(element.anchor.x, width) - MappedToPixel(element.anchor.offsetX, element.scaled.width);
|
||||
element.scaled.y = MappedToPixel(element.anchor.y, height) - MappedToPixel(element.anchor.offsetY, element.scaled.height);
|
||||
}
|
||||
|
||||
void Window::ScaleElement(Transform& element, Transform& parent) {
|
||||
element.scaled.width = MappedToPixel(element.relativeWidth, parent.scaled.width);
|
||||
element.scaled.height = MappedToPixel(element.relativeHeight, parent.scaled.height);
|
||||
element.scaled.x = MappedToPixel(element.anchorX, parent.scaled.width) - MappedToPixel(element.anchorOffsetX, element.scaled.width) + parent.scaled.x;
|
||||
element.scaled.y = MappedToPixel(element.anchorY, parent.scaled.height) - MappedToPixel(element.anchorOffsetY, element.scaled.height) + parent.scaled.y;
|
||||
element.scaled.width = MappedToPixel(element.anchor.width, parent.scaled.width);
|
||||
element.scaled.height = MappedToPixel(element.anchor.height, parent.scaled.height);
|
||||
element.scaled.x = MappedToPixel(element.anchor.x, parent.scaled.width) - MappedToPixel(element.anchor.offsetX, element.scaled.width) + parent.scaled.x;
|
||||
element.scaled.y = MappedToPixel(element.anchor.y, parent.scaled.height) - MappedToPixel(element.anchor.offsetY, element.scaled.height) + parent.scaled.y;
|
||||
}
|
||||
|
||||
void Window::ScaleMouse(Transform& element, Transform& parent) {
|
||||
std::int_fast32_t boundlessWidth = PixelToMappedBoundless(parent.scaled.width, width);
|
||||
std::int_fast32_t boundlessHeight = PixelToMappedBoundless(parent.scaled.height, height);
|
||||
element.scaled.width = BoundToBoundless(MappedToPixel(element.relativeWidth, PixelToMapped(parent.scaled.width, width)));
|
||||
element.scaled.height = BoundToBoundless(MappedToPixel(element.relativeHeight, PixelToMapped(parent.scaled.height, height)));
|
||||
element.scaled.x = MappedToPixelBoundless(element.anchorX, boundlessWidth) - MappedToPixelBoundless(element.anchorOffsetX, element.scaled.width) + PixelToMappedBoundless(parent.scaled.x, width);
|
||||
element.scaled.y = MappedToPixelBoundless(element.anchorY, boundlessHeight) - MappedToPixelBoundless(element.anchorOffsetY, element.scaled.height) + PixelToMappedBoundless(parent.scaled.y, height);
|
||||
element.scaled.width = BoundToBoundless(MappedToPixel(element.anchor.width, PixelToMapped(parent.scaled.width, width)));
|
||||
element.scaled.height = BoundToBoundless(MappedToPixel(element.anchor.height, PixelToMapped(parent.scaled.height, height)));
|
||||
element.scaled.x = MappedToPixelBoundless(element.anchor.x, boundlessWidth) - MappedToPixelBoundless(element.anchor.offsetX, element.scaled.width) + PixelToMappedBoundless(parent.scaled.x, width);
|
||||
element.scaled.y = MappedToPixelBoundless(element.anchor.y, boundlessHeight) - MappedToPixelBoundless(element.anchor.offsetY, element.scaled.height) + PixelToMappedBoundless(parent.scaled.y, height);
|
||||
}
|
||||
|
||||
void Window::ScaleMouse(Transform& element) {
|
||||
// std::int_fast32_t boundlessWidth = PixelToMappedBoundless(parent.scaled.width, width);
|
||||
// std::int_fast32_t boundlessHeight = PixelToMappedBoundless(parent.scaled.height, height);
|
||||
// element.scaled.width = BoundToBoundless(MappedToPixel(element.relativeWidth, width));
|
||||
// element.scaled.height = BoundToBoundless(MappedToPixel(element.relativeHeight, height));
|
||||
// element.scaled.x = MappedToPixelBoundless(element.anchorX, boundlessWidth) - MappedToPixelBoundless(element.anchorOffsetX, element.scaled.width) + PixelToMappedBoundless(parent.scaled.x, width);
|
||||
// element.scaled.y = MappedToPixelBoundless(element.anchorY, boundlessHeight) - MappedToPixelBoundless(element.anchorOffsetY, element.scaled.height) + PixelToMappedBoundless(parent.scaled.y, height);
|
||||
// element.scaled.width = BoundToBoundless(MappedToPixel(element.anchor.width, width));
|
||||
// element.scaled.height = BoundToBoundless(MappedToPixel(element.anchor.height, height));
|
||||
// element.scaled.x = MappedToPixelBoundless(element.anchor.x, boundlessWidth) - MappedToPixelBoundless(element.anchor.offsetX, element.scaled.width) + PixelToMappedBoundless(parent.scaled.x, width);
|
||||
// element.scaled.y = MappedToPixelBoundless(element.anchor.y, boundlessHeight) - MappedToPixelBoundless(element.anchor.offsetY, element.scaled.height) + PixelToMappedBoundless(parent.scaled.y, height);
|
||||
}
|
||||
|
||||
#ifdef CRAFTER_TIMING
|
||||
|
|
@ -107,30 +107,30 @@ void Window::AddDirtyRect(ScaleData scale) {
|
|||
.bottom = std::min(scale.y + scale.height, height),
|
||||
};
|
||||
|
||||
if (rect.left >= rect.right || rect.top >= rect.bottom) {
|
||||
return;
|
||||
}
|
||||
// if (rect.left >= rect.right || rect.top >= rect.bottom) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
for(ClipRect existing : dirtyRects) {
|
||||
//fully enclosed
|
||||
if(rect.left >= existing.left && rect.right <= existing.right && rect.top >= existing.top && rect.bottom <= existing.bottom) {
|
||||
return;
|
||||
}
|
||||
// for(ClipRect existing : dirtyRects) {
|
||||
// //fully enclosed
|
||||
// if(rect.left >= existing.left && rect.right <= existing.right && rect.top >= existing.top && rect.bottom <= existing.bottom) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//horizontal line
|
||||
if(rect.top == existing.top && rect.bottom == existing.bottom) {
|
||||
existing.left = std::min(rect.left, existing.left);
|
||||
existing.right = std::max(rect.right, existing.right);
|
||||
return;
|
||||
}
|
||||
// //horizontal line
|
||||
// if(rect.top == existing.top && rect.bottom == existing.bottom) {
|
||||
// existing.left = std::min(rect.left, existing.left);
|
||||
// existing.right = std::max(rect.right, existing.right);
|
||||
// return;
|
||||
// }
|
||||
|
||||
//vertical line
|
||||
if(rect.left == existing.left && rect.right == existing.right) {
|
||||
existing.top = std::min(rect.top, existing.top);
|
||||
existing.bottom = std::max(rect.bottom, existing.bottom);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// //vertical line
|
||||
// if(rect.left == existing.left && rect.right == existing.right) {
|
||||
// existing.top = std::min(rect.top, existing.top);
|
||||
// existing.bottom = std::max(rect.bottom, existing.bottom);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
//no overlap
|
||||
dirtyRects.push_back(rect);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue