mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 04:50:38 +02:00
Declare Surface methods that don't change the surface as "const"
This allows source surfaces (such as icons) to be passed around as const references.
This commit is contained in:
parent
46626030b2
commit
b0d1d9e55f
@ -112,7 +112,7 @@ void Surface::flip() {
|
||||
SDL_Flip(raw);
|
||||
}
|
||||
|
||||
bool Surface::blit(SDL_Surface *destination, int x, int y, int w, int h, int a) {
|
||||
bool Surface::blit(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
|
||||
if (destination == NULL || a==0) return false;
|
||||
|
||||
SDL_Rect src = { 0, 0, static_cast<Uint16>(w), static_cast<Uint16>(h) };
|
||||
@ -123,25 +123,25 @@ bool Surface::blit(SDL_Surface *destination, int x, int y, int w, int h, int a)
|
||||
SDL_SetAlpha(raw, SDL_SRCALPHA|SDL_RLEACCEL, a);
|
||||
return SDL_BlitSurface(raw, (w==0 || h==0) ? NULL : &src, destination, &dest);
|
||||
}
|
||||
bool Surface::blit(Surface *destination, int x, int y, int w, int h, int a) {
|
||||
bool Surface::blit(Surface *destination, int x, int y, int w, int h, int a) const {
|
||||
return blit(destination->raw,x,y,w,h,a);
|
||||
}
|
||||
|
||||
bool Surface::blitCenter(SDL_Surface *destination, int x, int y, int w, int h, int a) {
|
||||
bool Surface::blitCenter(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
|
||||
int oh, ow;
|
||||
if (w==0) ow = halfW; else ow = min(halfW,w/2);
|
||||
if (h==0) oh = halfH; else oh = min(halfH,h/2);
|
||||
return blit(destination,x-ow,y-oh,w,h,a);
|
||||
}
|
||||
bool Surface::blitCenter(Surface *destination, int x, int y, int w, int h, int a) {
|
||||
bool Surface::blitCenter(Surface *destination, int x, int y, int w, int h, int a) const {
|
||||
return blitCenter(destination->raw,x,y,w,h,a);
|
||||
}
|
||||
|
||||
bool Surface::blitRight(SDL_Surface *destination, int x, int y, int w, int h, int a) {
|
||||
bool Surface::blitRight(SDL_Surface *destination, int x, int y, int w, int h, int a) const {
|
||||
if (!w) w = raw->w;
|
||||
return blit(destination,x-min(raw->w,w),y,w,h,a);
|
||||
}
|
||||
bool Surface::blitRight(Surface *destination, int x, int y, int w, int h, int a) {
|
||||
bool Surface::blitRight(Surface *destination, int x, int y, int w, int h, int a) const {
|
||||
if (!w) w = raw->w;
|
||||
return blitRight(destination->raw,x,y,w,h,a);
|
||||
}
|
||||
@ -192,7 +192,7 @@ void Surface::setClipRect(SDL_Rect rect) {
|
||||
SDL_SetClipRect(raw,&rect);
|
||||
}
|
||||
|
||||
bool Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) {
|
||||
bool Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) const {
|
||||
switch (halign) {
|
||||
case Font::HAlignLeft:
|
||||
break;
|
||||
|
@ -52,8 +52,8 @@ public:
|
||||
*/
|
||||
void convertToDisplayFormat();
|
||||
|
||||
int width() { return raw->w; }
|
||||
int height() { return raw->h; }
|
||||
int width() const { return raw->w; }
|
||||
int height() const { return raw->h; }
|
||||
|
||||
void flip();
|
||||
|
||||
@ -61,10 +61,10 @@ public:
|
||||
void setClipRect(int x, int y, int w, int h);
|
||||
void setClipRect(SDL_Rect rect);
|
||||
|
||||
bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop);
|
||||
bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
bool blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop) const;
|
||||
bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
|
||||
void write(Font *font, const std::string &text, int x, int y,
|
||||
Font::HAlign halign = Font::HAlignLeft,
|
||||
@ -83,9 +83,9 @@ public:
|
||||
|
||||
private:
|
||||
Surface(SDL_Surface *raw, bool freeWhenDone);
|
||||
bool blit(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
|
||||
bool blit(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
bool blitCenter(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
bool blitRight(SDL_Surface *destination, int x, int y, int w=0, int h=0, int a=-1) const;
|
||||
|
||||
SDL_Surface *raw;
|
||||
bool freeWhenDone;
|
||||
|
Loading…
Reference in New Issue
Block a user