mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Fixed an issue where resizing in SwitchComponent would not reposition the image.
This commit is contained in:
parent
114c91679e
commit
022f8c7e8b
|
@ -49,6 +49,16 @@ void SwitchComponent::render(const glm::mat4& parentTrans)
|
|||
renderChildren(trans);
|
||||
}
|
||||
|
||||
void SwitchComponent::setResize(float width, float height)
|
||||
{
|
||||
// Reposition the switch after resizing to make it centered.
|
||||
const glm::vec2 oldSize = mImage.getSize();
|
||||
mImage.setResize(width, height);
|
||||
const float xDiff = oldSize.x - mImage.getSize().x;
|
||||
const float yDiff = oldSize.y - mImage.getSize().y;
|
||||
mImage.setPosition(mImage.getPosition().x + xDiff, mImage.getPosition().y + yDiff / 2.0f);
|
||||
}
|
||||
|
||||
void SwitchComponent::setState(bool state)
|
||||
{
|
||||
mState = state;
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
void render(const glm::mat4& parentTrans) override;
|
||||
void onSizeChanged() override { mImage.setSize(mSize); }
|
||||
|
||||
void setResize(float width, float height) override { mImage.setResize(width, height); }
|
||||
void setResize(float width, float height) override;
|
||||
|
||||
bool getState() const { return mState; }
|
||||
void setState(bool state);
|
||||
|
|
Loading…
Reference in a new issue