-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.cpp
More file actions
36 lines (25 loc) · 773 Bytes
/
button.cpp
File metadata and controls
36 lines (25 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "button.hpp"
#include "textureManager.hpp"
#include <memory>
Button::Button(const char* fontFileName,const char* caption,int x,int y, int width, int height,SDL_Renderer *ren)
: texture(std::unique_ptr<SDL_Texture,TextureDeleter>(TextureManager::LoadTextureFromFont(fontFileName, 100, caption, ren) ))
{
r.w = width;
r.h = height;
r.x = x;
r.y = y;
renderer = ren;
std::cout << "button created\n";
}
void Button::Render(){
texture.render(renderer, NULL, &r);
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
SDL_RenderDrawRect(renderer, &r);
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
}
Button::~Button(){
std::cout << "Button destroyed" << "\n";
}
SDL_Rect Button::getRect(){
return r;
}