1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-01 04:42:22 +03:00

Cache current icon surface. By doing so we safe a huge number of hash map

lookups.
This commit is contained in:
Lars-Peter Clausen 2010-05-01 18:55:11 +02:00
parent 667fb05a35
commit a794a1c01a
2 changed files with 15 additions and 1 deletions

View File

@ -33,12 +33,14 @@ Link::Link(GMenu2X *gmenu2x) : Button(gmenu2x, true) {
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
iconX = 0;
padding = 0;
updateSurfaces();
}
void Link::run() {}
void Link::paint() {
gmenu2x->sc[getIconPath()]->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, SFontHAlignCenter, SFontVAlignBottom );
}
@ -50,6 +52,11 @@ bool Link::paintHover() {
return true;
}
void Link::updateSurfaces()
{
iconSurface = gmenu2x->sc[getIconPath()];
}
string Link::getTitle() {
return title;
}
@ -89,6 +96,7 @@ void Link::setIcon(string icon) {
this->icon = icon;
edited = true;
updateSurfaces();
}
string Link::searchIcon() {
@ -106,6 +114,7 @@ void Link::setIconPath(string icon) {
iconPath = icon;
else
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
updateSurfaces();
}
void Link::setSize(int w, int h) {

View File

@ -24,6 +24,7 @@
#include <iostream>
#include "button.h"
#include "surface.h"
using std::string;
@ -42,7 +43,11 @@ protected:
bool edited;
string title, description, icon, iconPath;
Surface *iconSurface;
Surface *icon_hover;
void recalcCoordinates();
void updateSurfaces();
public:
Link(GMenu2X *gmenu2x);