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()};
float scaleX {trans[0].x};
float scaleY {trans[1].y};
// Make sure nothing renders outside our designated area.
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);
mRenderer->popClipRect();
}

View file

@ -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 <typename T> void CarouselComponent<T>::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<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.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;