mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fixed SliderComponent going beyond its min/max values.
Defensive measures against a possible SVG reinitialization bug.
This commit is contained in:
parent
d18140536a
commit
cf836c0f8a
|
@ -85,10 +85,10 @@ void SliderComponent::render(const Eigen::Affine3f& parentTrans)
|
|||
void SliderComponent::setValue(float value)
|
||||
{
|
||||
mValue = value;
|
||||
if(value < mMin)
|
||||
value = mMin;
|
||||
else if(value > mMax)
|
||||
value = mMax;
|
||||
if(mValue < mMin)
|
||||
mValue = mMin;
|
||||
else if(mValue > mMax)
|
||||
mValue = mMax;
|
||||
|
||||
onValueChanged();
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
#include "../nanosvg/nanosvg.h"
|
||||
#include "../nanosvg/nanosvgrast.h"
|
||||
#include "../Log.h"
|
||||
#include "../Util.h"
|
||||
|
||||
#define DPI 96
|
||||
|
||||
SVGResource::SVGResource(const std::string& path, bool tile) : TextureResource(path, tile), mSVGImage(NULL)
|
||||
{
|
||||
assert(tile == false);
|
||||
mLastWidth = 0;
|
||||
mLastHeight = 0;
|
||||
}
|
||||
|
||||
SVGResource::~SVGResource()
|
||||
|
@ -40,11 +42,20 @@ void SVGResource::initFromMemory(const char* file, size_t length)
|
|||
return;
|
||||
}
|
||||
|
||||
rasterizeAt((int)mSVGImage->width, (int)mSVGImage->height);
|
||||
if(mLastWidth && mLastHeight)
|
||||
rasterizeAt(mLastWidth, mLastHeight);
|
||||
else
|
||||
rasterizeAt((int)round(mSVGImage->width), (int)round(mSVGImage->height));
|
||||
}
|
||||
|
||||
void SVGResource::rasterizeAt(size_t width, size_t height)
|
||||
{
|
||||
if(width != (int)round(mSVGImage->width) && height != (int)round(mSVGImage->height))
|
||||
{
|
||||
mLastWidth = width;
|
||||
mLastHeight = height;
|
||||
}
|
||||
|
||||
if(!mSVGImage)
|
||||
return;
|
||||
|
||||
|
|
|
@ -22,4 +22,6 @@ protected:
|
|||
void deinitSVG();
|
||||
|
||||
NSVGimage* mSVGImage;
|
||||
size_t mLastWidth;
|
||||
size_t mLastHeight;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue