1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-10-02 15:43:16 +03:00

SurfaceCollection: Removed alpha flag.

In the existing code the alpha flag is always true, so there is no point
in passing it around.
This commit is contained in:
Maarten ter Huurne 2011-06-02 05:52:47 +02:00
parent af3ed78496
commit 44ca4e3460
2 changed files with 16 additions and 17 deletions

View File

@ -28,9 +28,9 @@
using std::endl; using std::endl;
using std::string; using std::string;
SurfaceCollection::SurfaceCollection(bool defaultAlpha, const string &skin) { SurfaceCollection::SurfaceCollection()
this->defaultAlpha = defaultAlpha; : skin("default")
setSkin(skin); {
} }
SurfaceCollection::~SurfaceCollection() {} SurfaceCollection::~SurfaceCollection() {}
@ -68,7 +68,7 @@ Surface *SurfaceCollection::add(Surface *s, const string &path) {
return s; return s;
} }
Surface *SurfaceCollection::add(const string &path, bool alpha) { Surface *SurfaceCollection::add(const string &path) {
DEBUG("Adding surface: '%s'\n", path.c_str()); DEBUG("Adding surface: '%s'\n", path.c_str());
if (exists(path)) del(path); if (exists(path)) del(path);
@ -80,12 +80,12 @@ Surface *SurfaceCollection::add(const string &path, bool alpha) {
return NULL; return NULL;
} else if (!fileExists(filePath)) return NULL; } else if (!fileExists(filePath)) return NULL;
Surface *s = new Surface(filePath, "", alpha); Surface *s = new Surface(filePath, "");
surfaces[path] = s; surfaces[path] = s;
return s; return s;
} }
Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) { Surface *SurfaceCollection::addSkinRes(const string &path) {
DEBUG("Adding skin surface: '%s'\n", path.c_str()); DEBUG("Adding skin surface: '%s'\n", path.c_str());
if (path.empty()) return NULL; if (path.empty()) return NULL;
@ -94,7 +94,7 @@ Surface *SurfaceCollection::addSkinRes(const string &path, bool alpha) {
string skinpath = getSkinFilePath(path); string skinpath = getSkinFilePath(path);
if (skinpath.empty()) if (skinpath.empty())
return NULL; return NULL;
Surface *s = new Surface(skinpath, "", alpha); Surface *s = new Surface(skinpath, "", true);
if (s != NULL) if (s != NULL)
surfaces[path] = s; surfaces[path] = s;
return s; return s;
@ -125,7 +125,7 @@ void SurfaceCollection::move(const string &from, const string &to) {
Surface *SurfaceCollection::operator[](const string &key) { Surface *SurfaceCollection::operator[](const string &key) {
SurfaceHash::iterator i = surfaces.find(key); SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end()) if (i == surfaces.end())
return add(key, defaultAlpha); return add(key);
else else
return i->second; return i->second;
} }
@ -135,7 +135,7 @@ Surface *SurfaceCollection::skinRes(const string &key) {
SurfaceHash::iterator i = surfaces.find(key); SurfaceHash::iterator i = surfaces.find(key);
if (i == surfaces.end()) if (i == surfaces.end())
return addSkinRes(key, defaultAlpha); return addSkinRes(key);
else else
return i->second; return i->second;
} }

View File

@ -33,13 +33,8 @@ Hash Map of surfaces that loads surfaces not already loaded and reuses already l
@author Massimiliano Torromeo <massimiliano.torromeo@gmail.com> @author Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
*/ */
class SurfaceCollection { class SurfaceCollection {
private:
SurfaceHash surfaces;
std::string skin;
public: public:
SurfaceCollection( SurfaceCollection();
bool defaultAlpha = true, const std::string &skin = "default");
~SurfaceCollection(); ~SurfaceCollection();
void setSkin(const std::string &skin); void setSkin(const std::string &skin);
@ -49,8 +44,8 @@ public:
void debug(); void debug();
Surface *add(Surface *s, const std::string &path); Surface *add(Surface *s, const std::string &path);
Surface *add(const std::string &path, bool alpha=true); Surface *add(const std::string &path);
Surface *addSkinRes(const std::string &path, bool alpha=true); Surface *addSkinRes(const std::string &path);
void del(const std::string &path); void del(const std::string &path);
void clear(); void clear();
void move(const std::string &from, const std::string &to); void move(const std::string &from, const std::string &to);
@ -58,6 +53,10 @@ public:
Surface *operator[](const std::string &); Surface *operator[](const std::string &);
Surface *skinRes(const std::string &); Surface *skinRes(const std::string &);
private:
SurfaceHash surfaces;
std::string skin;
}; };
#endif #endif