mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 18:23:08 +02:00
Let SurfaceCollection::add make a copy of an existing surface
This allows the SurfaceCollection to claim ownership of the surface, while ownership was undefined before.
This commit is contained in:
parent
aff5f53f7d
commit
799ebb9a29
@ -325,8 +325,7 @@ void GMenu2X::initBG() {
|
|||||||
drawTopBar(*bg);
|
drawTopBar(*bg);
|
||||||
drawBottomBar(*bg);
|
drawBottomBar(*bg);
|
||||||
|
|
||||||
Surface *bgmain = new Surface(bg);
|
Surface *bgmain = sc.add(bg, "bgmain");
|
||||||
sc.add(bgmain,"bgmain");
|
|
||||||
|
|
||||||
Surface *sd = Surface::loadImage("imgs/sd.png", confStr["skin"]);
|
Surface *sd = Surface::loadImage("imgs/sd.png", confStr["skin"]);
|
||||||
if (sd) sd->blit(*bgmain, 3, bottomBarIconY);
|
if (sd) sd->blit(*bgmain, 3, bottomBarIconY);
|
||||||
|
@ -98,10 +98,11 @@ bool SurfaceCollection::exists(const string &path) {
|
|||||||
return surfaces.find(path) != surfaces.end();
|
return surfaces.find(path) != surfaces.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface *SurfaceCollection::add(Surface *s, const string &path) {
|
Surface *SurfaceCollection::add(Surface const& s, std::string const& path) {
|
||||||
if (exists(path)) del(path);
|
if (exists(path)) del(path);
|
||||||
surfaces[path] = s;
|
Surface *copy = new Surface(s);
|
||||||
return s;
|
surfaces[path] = copy;
|
||||||
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface *SurfaceCollection::add(const string &path) {
|
Surface *SurfaceCollection::add(const string &path) {
|
||||||
|
@ -45,7 +45,12 @@ public:
|
|||||||
bool defaultAlpha = true;
|
bool defaultAlpha = true;
|
||||||
void debug();
|
void debug();
|
||||||
|
|
||||||
Surface *add(Surface *s, const std::string &path);
|
/**
|
||||||
|
* Adds a copy of the given surface to this collection under the given
|
||||||
|
* path. Returns the copy.
|
||||||
|
*/
|
||||||
|
Surface *add(Surface const& s, std::string const& path);
|
||||||
|
|
||||||
Surface *add(const std::string &path);
|
Surface *add(const std::string &path);
|
||||||
Surface *addSkinRes(const std::string &path, bool useDefault = true);
|
Surface *addSkinRes(const std::string &path, bool useDefault = true);
|
||||||
void del(const std::string &path);
|
void del(const std::string &path);
|
||||||
|
Loading…
Reference in New Issue
Block a user