-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLButton.h
101 lines (72 loc) · 1.53 KB
/
LButton.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <string>
#include "Rectangle.h"
#ifndef __LBUTTON_H__
#define __LBUTTON_H__
//The mouse button
class LButton
{
public:
enum ResizeState
{
NO_RESIZE = 0,
TOP_RESIZE = 1,
BOT_RESIZE = 2,
LEFT_RESIZE = 3,
RIGHT_RESIZE = 4,
TLC_RESIZE = 5,
TRC_RESIZE = 6,
BLC_RESIZE = 7,
BRC_RESIZE = 8
};
enum LButtonSprite
{
BUTTON_SPRITE_MOUSE_OUT = 0,
BUTTON_SPRITE_MOUSE_OVER_MOTION = 1,
BUTTON_SPRITE_MOUSE_DOWN = 2,
BUTTON_SPRITE_MOUSE_UP = 3,
BUTTON_SPRITE_DRAG = 4,
BUTTON_SPRITE_TOTAL = 5
};
//Initializes internal variables
LButton();
LButton(int x, int y);
LButton(SDL_Rect* rect);
//Sets top left position
void setPosition(int x, int y);
//Handles mouse event
void handleEvent(SDL_Event* e);
SDL_Point* getPos();
void setEdges();
int checkResize(int x, int y);
void HandleResize(SDL_Event* e, int ResizeState);
//void move();
public:
//Currently used global sprite
LButtonSprite mCurrentSprite;
SDL_Rect mRect;
SDL_Rect edgeBoxes[4];
SDL_Rect cornerBoxes[4];
//Button constants
int BUTTON_WIDTH = 300;
int BUTTON_HEIGHT = 200;
const int TOTAL_BUTTONS = 4;
bool toolHover = false;
bool mouseHover = false;
Rectangle glowRect;
private:
//Top left position
SDL_Point mPosition;
bool mouseDrag = false;
bool resizeDrag = false;
bool resizing = false;
long int relX=0, relY=0;
long int relDragX, relDragY = 0;
long int stableEdgeX = 0;
long int stableEdgeY = 0;
int ResizeState = 0;
};
#endif