GlistEngine
Loading...
Searching...
No Matches
gGUIResources Class Reference

#include <gGUIResources.h>

Inheritance diagram for gGUIResources:
Collaboration diagram for gGUIResources:

Public Types

enum  {
  ICON_FILE , ICON_FOLDER , ICON_FOLDEROPENED , ICON_SAVE ,
  ICON_PLUS , ICON_BRUSH , ICON_DELETE , ICON_DOWNLOAD ,
  ICON_UPLOAD , ICON_FONT , ICON_HOME , ICON_PENLOGO ,
  ICON_PICTURE , ICON_PRINTER , ICON_REPAIR , ICON_RETURN ,
  ICON_FORWARD , ICON_SETTINGS , ICON_SPLIT , ICON_TEXT ,
  ICON_ZOOMIN , ICON_ZOOMOUT , ICON_SEARCH , ICON_PLAY ,
  ICON_PAUSE , ICON_STOP , ICON_FAV , ICON_INFO ,
  ICON_HELP , ICON_COPY , ICON_WARNING , ICON_ERROR ,
  ICON_CALENDAR , ICON_CLOCK , ICON_DOWN , ICON_UP ,
  ICON_MINIMIZEBLACK , ICON_MAXIMIZEBLACK , ICON_RESTOREBLACK , ICON_EXITBLACK ,
  ICON_MINIMIZEWHITE , ICON_MAXIMIZEWHITE , ICON_RESTOREWHITE , ICON_EXITWHITE ,
  ICON_STORE , COLORPICKER
}
 
enum  { ICONBIG_ERROR , ICONBIG_INFO , ICONBIG_WARNING , ICONBIG_LOADING }
 

Public Member Functions

 gGUIResources ()
 
virtual ~gGUIResources ()
 
void cleanup ()
 
void initialize ()
 
bool isInitialized ()
 
int getIconWidth ()
 
int getIconHeight ()
 
int getIconComponentsNum ()
 
int getIconNum ()
 
gTexturegetIconImage (int iconId, bool isIconBig=false)
 
- Public Member Functions inherited from gObject
 gObject ()
 
void logi (std::string message)
 
void logd (std::string message)
 
void logw (std::string message)
 
void loge (std::string message)
 
void logi (std::string tag, std::string message)
 
void logd (std::string tag, std::string message)
 
void logw (std::string tag, std::string message)
 
void loge (std::string tag, std::string message)
 

Static Public Attributes

static const int ICON_NONE
 
- Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
 
static const int LOGLEVEL_DEBUG
 
static const int LOGLEVEL_INFO
 
static const int LOGLEVEL_WARNING
 
static const int LOGLEVEL_ERROR
 

Additional Inherited Members

- Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
 
static std::string gGetAssetsDir ()
 
static void gSetAssetsDir (std::string assetsDir)
 
static std::string gGetFilesDir ()
 
static std::string gGetImagesDir ()
 
static std::string gGetFontsDir ()
 
static std::string gGetModelsDir ()
 
static std::string gGetTexturesDir ()
 
static std::string gGetShadersDir ()
 
static std::string gGetSoundsDir ()
 
static std::string gGetDatabasesDir ()
 
static std::string gGetVideosDir ()
 
static void setCurrentResolution (int scalingNo, int currentResolutionNo)
 
- Static Protected Attributes inherited from gObject
static int renderpassnum
 
static int renderpassno
 
static int releasescaling
 
static int releaseresolution
 

Detailed Description

gGUIResources keeps all images in base64 format that the programmer can use in their software thanks to their getter functions. We keep this data as base64 because asset images may be lost or corrupted in the file.This results in loss of image and bad experience for a developer. All the images have their own getter function and this getter functions return base64 string value of the image.

There are 2 types of getter functions in this class. The first of them is getBase64Icon... function. This function provides us to get base64 string of an image. Also every image has their own getBase64Icon... function. We use these functions inside the initialize function as parameters of the decode function. gDecodeBase64 is a function that converts the base64 string sent into the decode function to image data. Thanks to initialize function, we can add image that we decoded to gImage array that we created.Thus, we will be able to use any image we want in other classes.

HOW TO USE

  • First of all, you have to create a getter function that containing its own name in gGUIResources.h file. (Ex :std::string getBase64IconFile16(); )
  • After that, you have to enumeration procces to determine id of image which you want to add. (Ex : ICON_FILE,(in the enum))
  • You have to define the body of your getter function in gGUIResources.cpp. And this function have to return base64 string of your image.(You can encode your image by using encode function of GlistEngine)
  • Examples of encoding procces in a canvas : img.loadImage("Copy.png"); gLogi("base") << "base64img:" << gEncodeBase64(img.getImageData(), img.getWidth() * img.getHeight() * img.getComponentNum());
  • After you define body, go to initialize function and set your image to array by using id of your image.Don't forget that you have to use decode function inside setImageData function. Also, gDecodeBase64 have to contain getter function of your image. (Examples avaible below)
  • After we add the image to array, we can use this image in every class we want. To be able to use it, we have to create an object from gGUIResources class (Ex: gGUIResources res;) and have to use getIconImage method of this object ( Ex : res.getIconImage(gGUIResources::The id which you enumeration)). Don't forget to add res.initialize(); function to the constructor of your class. This function makes the initialize function of gGUIResources class work.

To draw this use draw function (Ex : res.getIconImage(id)->draw(....). If you want the users to choose the images by using your class. You have to define imageid variable as a parameter of getIconImage in your class. Define a function that get id information from developer user to your class and defines it into the iconid variable in your class. Thus, users can use the icons which you add by using the function you define to get id from users in your class.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ICON_FILE 
ICON_FOLDER 
ICON_FOLDEROPENED 
ICON_SAVE 
ICON_PLUS 
ICON_BRUSH 
ICON_DELETE 
ICON_DOWNLOAD 
ICON_UPLOAD 
ICON_FONT 
ICON_HOME 
ICON_PENLOGO 
ICON_PICTURE 
ICON_PRINTER 
ICON_REPAIR 
ICON_RETURN 
ICON_FORWARD 
ICON_SETTINGS 
ICON_SPLIT 
ICON_TEXT 
ICON_ZOOMIN 
ICON_ZOOMOUT 
ICON_SEARCH 
ICON_PLAY 
ICON_PAUSE 
ICON_STOP 
ICON_FAV 
ICON_INFO 
ICON_HELP 
ICON_COPY 
ICON_WARNING 
ICON_ERROR 
ICON_CALENDAR 
ICON_CLOCK 
ICON_DOWN 
ICON_UP 
ICON_MINIMIZEBLACK 
ICON_MAXIMIZEBLACK 
ICON_RESTOREBLACK 
ICON_EXITBLACK 
ICON_MINIMIZEWHITE 
ICON_MAXIMIZEWHITE 
ICON_RESTOREWHITE 
ICON_EXITWHITE 
ICON_STORE 
COLORPICKER 

◆ anonymous enum

anonymous enum
Enumerator
ICONBIG_ERROR 
ICONBIG_INFO 
ICONBIG_WARNING 
ICONBIG_LOADING 

Constructor & Destructor Documentation

◆ gGUIResources()

gGUIResources::gGUIResources ( )

◆ ~gGUIResources()

virtual gGUIResources::~gGUIResources ( )
virtual

Member Function Documentation

◆ cleanup()

void gGUIResources::cleanup ( )

◆ getIconComponentsNum()

int gGUIResources::getIconComponentsNum ( )

◆ getIconHeight()

int gGUIResources::getIconHeight ( )

◆ getIconImage()

gTexture * gGUIResources::getIconImage ( int  iconId,
bool  isIconBig = false 
)

◆ getIconNum()

int gGUIResources::getIconNum ( )

◆ getIconWidth()

int gGUIResources::getIconWidth ( )

◆ initialize()

void gGUIResources::initialize ( )

◆ isInitialized()

bool gGUIResources::isInitialized ( )

Member Data Documentation

◆ ICON_NONE

const int gGUIResources::ICON_NONE
static

The documentation for this class was generated from the following file: