mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +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)
|
void SliderComponent::setValue(float value)
|
||||||
{
|
{
|
||||||
mValue = value;
|
mValue = value;
|
||||||
if(value < mMin)
|
if(mValue < mMin)
|
||||||
value = mMin;
|
mValue = mMin;
|
||||||
else if(value > mMax)
|
else if(mValue > mMax)
|
||||||
value = mMax;
|
mValue = mMax;
|
||||||
|
|
||||||
onValueChanged();
|
onValueChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
#include "../nanosvg/nanosvg.h"
|
#include "../nanosvg/nanosvg.h"
|
||||||
#include "../nanosvg/nanosvgrast.h"
|
#include "../nanosvg/nanosvgrast.h"
|
||||||
#include "../Log.h"
|
#include "../Log.h"
|
||||||
|
#include "../Util.h"
|
||||||
|
|
||||||
#define DPI 96
|
#define DPI 96
|
||||||
|
|
||||||
SVGResource::SVGResource(const std::string& path, bool tile) : TextureResource(path, tile), mSVGImage(NULL)
|
SVGResource::SVGResource(const std::string& path, bool tile) : TextureResource(path, tile), mSVGImage(NULL)
|
||||||
{
|
{
|
||||||
assert(tile == false);
|
mLastWidth = 0;
|
||||||
|
mLastHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SVGResource::~SVGResource()
|
SVGResource::~SVGResource()
|
||||||
|
@ -40,11 +42,20 @@ void SVGResource::initFromMemory(const char* file, size_t length)
|
||||||
return;
|
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)
|
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)
|
if(!mSVGImage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,6 @@ protected:
|
||||||
void deinitSVG();
|
void deinitSVG();
|
||||||
|
|
||||||
NSVGimage* mSVGImage;
|
NSVGimage* mSVGImage;
|
||||||
|
size_t mLastWidth;
|
||||||
|
size_t mLastHeight;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue