2012-08-02 01:43:55 +00:00
|
|
|
#ifndef _GUIIMAGE_H_
|
|
|
|
#define _GUIIMAGE_H_
|
|
|
|
|
|
|
|
#include "../GuiComponent.h"
|
|
|
|
#include <SDL/SDL.h>
|
2012-08-09 21:19:07 +00:00
|
|
|
#include <SDL/SDL_thread.h>
|
2012-08-02 01:43:55 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class GuiImage : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-09 21:19:07 +00:00
|
|
|
GuiImage(int offsetX = 0, int offsetY = 0, std::string path = "", unsigned int maxWidth = 0, unsigned int maxHeight = 0);
|
2012-08-02 01:43:55 +00:00
|
|
|
~GuiImage();
|
|
|
|
|
|
|
|
void setImage(std::string path);
|
|
|
|
|
2012-08-09 21:19:07 +00:00
|
|
|
int getWidth();
|
|
|
|
int getHeight();
|
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
void onRender();
|
2012-08-09 21:19:07 +00:00
|
|
|
|
|
|
|
//this should really never be called by anything except setImage
|
|
|
|
//but it was either make this function public or make mSurface public
|
|
|
|
//so just don't use this, okay?
|
|
|
|
int runImageLoadThread();
|
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
private:
|
2012-08-09 21:19:07 +00:00
|
|
|
int mMaxWidth, mMaxHeight;
|
|
|
|
|
|
|
|
std::string mPath, mLoadedPath;
|
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
SDL_Surface* mSurface;
|
2012-08-09 21:19:07 +00:00
|
|
|
int mOffsetX, mOffsetY;
|
2012-08-02 01:43:55 +00:00
|
|
|
SDL_Rect mRect;
|
2012-08-09 21:19:07 +00:00
|
|
|
|
|
|
|
SDL_Thread* mLoadThread;
|
|
|
|
void setPathThreadSafe(std::string path);
|
|
|
|
std::string getPathThreadSafe();
|
|
|
|
SDL_mutex* mPathMutex;
|
|
|
|
SDL_mutex* mSurfaceMutex;
|
|
|
|
bool mDeleting;
|
2012-08-02 01:43:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|