mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 12:09:41 +02:00
Cache current icon surface. By doing so we safe a huge number of hash map
lookups.
This commit is contained in:
parent
667fb05a35
commit
a794a1c01a
11
src/link.cpp
11
src/link.cpp
@ -33,12 +33,14 @@ Link::Link(GMenu2X *gmenu2x) : Button(gmenu2x, true) {
|
|||||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||||
iconX = 0;
|
iconX = 0;
|
||||||
padding = 0;
|
padding = 0;
|
||||||
|
|
||||||
|
updateSurfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Link::run() {}
|
void Link::run() {}
|
||||||
|
|
||||||
void Link::paint() {
|
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 );
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Link::updateSurfaces()
|
||||||
|
{
|
||||||
|
iconSurface = gmenu2x->sc[getIconPath()];
|
||||||
|
}
|
||||||
|
|
||||||
string Link::getTitle() {
|
string Link::getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
@ -89,6 +96,7 @@ void Link::setIcon(string icon) {
|
|||||||
|
|
||||||
this->icon = icon;
|
this->icon = icon;
|
||||||
edited = true;
|
edited = true;
|
||||||
|
updateSurfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
string Link::searchIcon() {
|
string Link::searchIcon() {
|
||||||
@ -106,6 +114,7 @@ void Link::setIconPath(string icon) {
|
|||||||
iconPath = icon;
|
iconPath = icon;
|
||||||
else
|
else
|
||||||
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png");
|
||||||
|
updateSurfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Link::setSize(int w, int h) {
|
void Link::setSize(int w, int h) {
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
|
#include "surface.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
@ -42,7 +43,11 @@ protected:
|
|||||||
bool edited;
|
bool edited;
|
||||||
string title, description, icon, iconPath;
|
string title, description, icon, iconPath;
|
||||||
|
|
||||||
|
Surface *iconSurface;
|
||||||
|
Surface *icon_hover;
|
||||||
|
|
||||||
void recalcCoordinates();
|
void recalcCoordinates();
|
||||||
|
void updateSurfaces();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Link(GMenu2X *gmenu2x);
|
Link(GMenu2X *gmenu2x);
|
||||||
|
Loading…
Reference in New Issue
Block a user