Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _TBUTTON_H_
- #define _TBUTTON_H_
- #include <SDL.h>
- #include <string>
- #include <vector>
- #include <initializer_list>
- extern "C"{
- #include "SDL_FontCache.h"
- }
- class TButton {
- private:
- SDL_Rect mButtonRect;
- SDL_Rect mTextRect;
- std::string mLabel;
- FC_Effect mStyle;
- FC_Font* mFont;
- SDL_Color mBgColor;
- SDL_Color mHoverColor;
- float mHoverTime = 0.f;
- bool mHovered = false;
- bool mCalled = false;
- void(*mCallback)() = nullptr;
- static constexpr SDL_Color M_STANDARD_TEXT_COLOR{ 0xFF, 0xFF,0xAA,0xFF };
- static constexpr SDL_Color M_STANDARD_BACKGROUND_COLOR{ 0x30, 0x00, 0xAA, 0xFF };
- static constexpr SDL_Color M_STANDARD_HOVER_COLOR{ 0xFF, 0x00, 0x00, 0xFF};
- public:
- void QuerryButton(const SDL_Point & mPos, const bool & clicked);
- void Draw(SDL_Renderer * rend, const float & dTime);
- void Call();
- 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);
- ~TButton();
- 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);
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement