From 8d5dc46fc662e8debef9d9da4c762dcc983ad881 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 12 Sep 2022 19:03:45 +0200 Subject: [PATCH] Some minor code cleanup. --- es-app/src/views/GamelistView.cpp | 13 +++++-------- es-core/src/components/primary/CarouselComponent.h | 13 +++++++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index a886db174..18affb39f 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -366,15 +366,12 @@ void GamelistView::render(const glm::mat4& parentTrans) { glm::mat4 trans {parentTrans * getTransform()}; - float scaleX {trans[0].x}; - float scaleY {trans[1].y}; + // Make sure nothing renders outside our designated area. + mRenderer->pushClipRect( + glm::ivec2 {static_cast(std::round(trans[3].x)), + static_cast(std::round(trans[3].y))}, + glm::ivec2 {static_cast(std::round(mSize.x)), static_cast(std::round(mSize.y))}); - glm::ivec2 pos {static_cast(std::round(trans[3].x)), - static_cast(std::round(trans[3].y))}; - glm::ivec2 size {static_cast(std::round(mSize.x * scaleX)), - static_cast(std::round(mSize.y * scaleY))}; - - mRenderer->pushClipRect(pos, size); renderChildren(trans); mRenderer->popClipRect(); } diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index 00f382ecb..03d41d2e6 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -34,6 +34,8 @@ protected: using List::mWindow; using GuiComponent::mDefaultZIndex; + using GuiComponent::mOrigin; + using GuiComponent::mPosition; using GuiComponent::mZIndex; public: @@ -501,12 +503,11 @@ template void CarouselComponent::render(const glm::mat4& parentT return; glm::mat4 carouselTrans {parentTrans}; + carouselTrans = + glm::translate(carouselTrans, glm::round(glm::vec3 {mPosition.x, mPosition.y, 0.0f})); carouselTrans = glm::translate( carouselTrans, - glm::round(glm::vec3 {GuiComponent::mPosition.x, GuiComponent::mPosition.y, 0.0f})); - carouselTrans = glm::translate( - carouselTrans, glm::round(glm::vec3 {GuiComponent::mOrigin.x * mSize.x * -1.0f, - GuiComponent::mOrigin.y * mSize.y * -1.0f, 0.0f})); + glm::round(glm::vec3 {mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f})); mRenderer->pushClipRect( glm::ivec2 {static_cast(glm::clamp(std::round(carouselTrans[3].x), 0.0f, @@ -746,8 +747,8 @@ void CarouselComponent::applyTheme(const std::shared_ptr& theme, mSize.x = Renderer::getScreenWidth(); mSize.y = Renderer::getScreenHeight() * 0.23240f; - GuiComponent::mPosition.x = 0.0f; - GuiComponent::mPosition.y = Renderer::getScreenHeight() * 0.38378f; + mPosition.x = 0.0f; + mPosition.y = Renderer::getScreenHeight() * 0.38378f; mCarouselColor = 0xFFFFFFD8; mCarouselColorEnd = 0xFFFFFFD8; mZIndex = mDefaultZIndex;