Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #ifndef _TBUTTON_H_
  2. #define _TBUTTON_H_
  3. #include <SDL.h>
  4. #include <string>
  5. #include <vector>
  6. #include <initializer_list>
  7. extern "C"{
  8. #include "SDL_FontCache.h" 
  9. }
  10.  
  11. class TButton {
  12. private:
  13.     SDL_Rect mButtonRect;
  14.     SDL_Rect mTextRect;
  15.     std::string mLabel;
  16.     FC_Effect mStyle;
  17.     FC_Font* mFont;
  18.     SDL_Color mBgColor;
  19.     SDL_Color mHoverColor;
  20.     float mHoverTime = 0.f;
  21.  
  22.     bool mHovered = false;
  23.     bool mCalled = false;
  24.     void(*mCallback)() = nullptr;
  25.  
  26.     static constexpr SDL_Color M_STANDARD_TEXT_COLOR{ 0xFF, 0xFF,0xAA,0xFF };
  27.     static constexpr SDL_Color M_STANDARD_BACKGROUND_COLOR{ 0x30, 0x00, 0xAA, 0xFF };
  28.     static constexpr SDL_Color M_STANDARD_HOVER_COLOR{ 0xFF, 0x00, 0x00, 0xFF};
  29.  
  30.  
  31. public:
  32.     void QuerryButton(const SDL_Point & mPos, const bool & clicked);
  33.     void Draw(SDL_Renderer * rend, const float & dTime);
  34.     void Call();
  35.     TButton(const SDL_Rect & rect, const std::string & label, const SDL_Color & textColor, const  SDL_Color & bgColor, const SDL_Color & hoverColor, void(*callback)(), FC_Font* font);
  36.     ~TButton();
  37.  
  38.     static std::vector<TButton> GetStandardButtons(std::initializer_list<std::string> labels, std::initializer_list<void(*)()> callbacks ,SDL_Rect startRect, const int& yOffset, FC_Font* font);
  39. };
  40.  
  41. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement