mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 09:09:43 +02:00
Made strtorgba into a factory method of RGBAColor
The method is RGBAColor::fromString.
This commit is contained in:
parent
950518f3a7
commit
5f454a8569
@ -830,7 +830,8 @@ void GMenu2X::setSkin(const string &skin, bool setWallpaper) {
|
|||||||
if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"')
|
if (value.length()>1 && value.at(0)=='"' && value.at(value.length()-1)=='"')
|
||||||
skinConfStr[name] = value.substr(1,value.length()-2);
|
skinConfStr[name] = value.substr(1,value.length()-2);
|
||||||
else if (value.at(0) == '#')
|
else if (value.at(0) == '#')
|
||||||
skinConfColors[stringToColor(name)] = strtorgba( value.substr(1,value.length()) );
|
skinConfColors[stringToColor(name)] =
|
||||||
|
RGBAColor::fromString(value.substr(1, value.length()));
|
||||||
else
|
else
|
||||||
skinConfInt[name] = atoi(value.c_str());
|
skinConfInt[name] = atoi(value.c_str());
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,17 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
RGBAColor strtorgba(const string &strColor) {
|
RGBAColor RGBAColor::fromString(const string &strColor) {
|
||||||
RGBAColor c = {0,0,0,255};
|
return {
|
||||||
c.r = constrain( strtol( strColor.substr(0,2).c_str(), NULL, 16 ), 0, 255 );
|
uint8_t(constrain(strtol(strColor.substr(0, 2).c_str(), nullptr, 16),
|
||||||
c.g = constrain( strtol( strColor.substr(2,2).c_str(), NULL, 16 ), 0, 255 );
|
0, 255)),
|
||||||
c.b = constrain( strtol( strColor.substr(4,2).c_str(), NULL, 16 ), 0, 255 );
|
uint8_t(constrain(strtol(strColor.substr(2, 2).c_str(), nullptr, 16),
|
||||||
c.a = constrain( strtol( strColor.substr(6,2).c_str(), NULL, 16 ), 0, 255 );
|
0, 255)),
|
||||||
return c;
|
uint8_t(constrain(strtol(strColor.substr(4, 2).c_str(), nullptr, 16),
|
||||||
|
0, 255)),
|
||||||
|
uint8_t(constrain(strtol(strColor.substr(6, 2).c_str(), nullptr, 16),
|
||||||
|
0, 255)),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface *Surface::openOutputSurface(int width, int height, int bitsperpixel) {
|
Surface *Surface::openOutputSurface(int width, int height, int bitsperpixel) {
|
||||||
|
@ -29,10 +29,9 @@
|
|||||||
|
|
||||||
struct RGBAColor {
|
struct RGBAColor {
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
|
static RGBAColor fromString(std::string const& strColor);
|
||||||
};
|
};
|
||||||
|
|
||||||
RGBAColor strtorgba(const std::string &strColor);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Wrapper around SDL_Surface
|
Wrapper around SDL_Surface
|
||||||
@author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
@author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
||||||
|
Loading…
Reference in New Issue
Block a user