-
Notifications
You must be signed in to change notification settings - Fork 10
/
MGButton.h
75 lines (54 loc) · 2.43 KB
/
MGButton.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
// Copyright 2009 Isis Innovation Limited
#ifndef MGBUTTON_H
#define MGBUTTON_H
#include <iostream>
#include <vector>
#include "OpenGL.h"
#include <TooN/TooN.h>
#include "GLWindow2.h"
#include "ModelsGameData.h"
namespace PTAMM {
using namespace TooN;
class ModelControls;
/**
* A button for the model controls
*/
class MGButton {
public:
MGButton( std::string sName, bool bEnableRepeat = false, bool bToggle = false );
~MGButton() {}
// The form of the callback function
typedef void (*ActionCallback)( ModelsGameData & data );
void Init( CVD::ImageRef irPosition, CVD::ImageRef irSize, ActionCallback action,
std::string sIconFileName = "", std::string sActiveIconFileName = "" );
void Action( ModelsGameData & data );
bool IsMouseOver( Vector<2> v2VidCoords );
void Draw();
CVD::ImageRef GetSize() { return mirSize; } /// The size of the button
CVD::ImageRef GetPosition() { return mirPosition; } /// The position of the button
std::string GetName() { return msName; } /// The name of the button
bool IsToggle() { return mbToggle; } /// Is it a toggle button
bool IsRepeatEnabled() { return mbEnableRepeat; } /// Is repeat action enabled
public:
Vector<4> v4BorderColor; // Colours for the button
Vector<4> v4BackColor;
Vector<4> v4FontColor;
Vector<4> v4ActiveColor;
private:
void _DrawLineBox();
void _DrawFillBox();
private:
std::string msName; // Name of the button
CVD::ImageRef mirPosition; // The top left corner of the button
CVD::ImageRef mirSize; // The size of the button
bool mbActive; // Is the button activated
CVD::Image< CVD::Rgba<CVD::byte> > mimIcon; // The button's icon
CVD::Image< CVD::Rgba<CVD::byte> > mimIconActive; // Its active icon
bool mbIcons; // Use icons?
ActionCallback mpActionCallback; // The callback function
int mnActiveCounter; // Number of frames left to derw as active
const bool mbToggle; // Is it a toggle button?
const bool mbEnableRepeat; // enable repeat actions for press and hold
};
}
#endif