Some minor code cleanup.

This commit is contained in:
Leon Styhre 2022-09-12 19:03:45 +02:00
parent 4610e91bd7
commit 8d5dc46fc6
2 changed files with 12 additions and 14 deletions

View file

@ -366,15 +366,12 @@ void GamelistView::render(const glm::mat4& parentTrans)
{ {
glm::mat4 trans {parentTrans * getTransform()}; glm::mat4 trans {parentTrans * getTransform()};
float scaleX {trans[0].x}; // Make sure nothing renders outside our designated area.
float scaleY {trans[1].y}; mRenderer->pushClipRect(
glm::ivec2 {static_cast<int>(std::round(trans[3].x)),
static_cast<int>(std::round(trans[3].y))},
glm::ivec2 {static_cast<int>(std::round(mSize.x)), static_cast<int>(std::round(mSize.y))});
glm::ivec2 pos {static_cast<int>(std::round(trans[3].x)),
static_cast<int>(std::round(trans[3].y))};
glm::ivec2 size {static_cast<int>(std::round(mSize.x * scaleX)),
static_cast<int>(std::round(mSize.y * scaleY))};
mRenderer->pushClipRect(pos, size);
renderChildren(trans); renderChildren(trans);
mRenderer->popClipRect(); mRenderer->popClipRect();
} }

View file

@ -34,6 +34,8 @@ protected:
using List::mWindow; using List::mWindow;
using GuiComponent::mDefaultZIndex; using GuiComponent::mDefaultZIndex;
using GuiComponent::mOrigin;
using GuiComponent::mPosition;
using GuiComponent::mZIndex; using GuiComponent::mZIndex;
public: public:
@ -501,12 +503,11 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
return; return;
glm::mat4 carouselTrans {parentTrans}; glm::mat4 carouselTrans {parentTrans};
carouselTrans =
glm::translate(carouselTrans, glm::round(glm::vec3 {mPosition.x, mPosition.y, 0.0f}));
carouselTrans = glm::translate( carouselTrans = glm::translate(
carouselTrans, carouselTrans,
glm::round(glm::vec3 {GuiComponent::mPosition.x, GuiComponent::mPosition.y, 0.0f})); glm::round(glm::vec3 {mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 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}));
mRenderer->pushClipRect( mRenderer->pushClipRect(
glm::ivec2 {static_cast<int>(glm::clamp(std::round(carouselTrans[3].x), 0.0f, glm::ivec2 {static_cast<int>(glm::clamp(std::round(carouselTrans[3].x), 0.0f,
@ -746,8 +747,8 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
mSize.x = Renderer::getScreenWidth(); mSize.x = Renderer::getScreenWidth();
mSize.y = Renderer::getScreenHeight() * 0.23240f; mSize.y = Renderer::getScreenHeight() * 0.23240f;
GuiComponent::mPosition.x = 0.0f; mPosition.x = 0.0f;
GuiComponent::mPosition.y = Renderer::getScreenHeight() * 0.38378f; mPosition.y = Renderer::getScreenHeight() * 0.38378f;
mCarouselColor = 0xFFFFFFD8; mCarouselColor = 0xFFFFFFD8;
mCarouselColorEnd = 0xFFFFFFD8; mCarouselColorEnd = 0xFFFFFFD8;
mZIndex = mDefaultZIndex; mZIndex = mDefaultZIndex;