79 lines
1.4 KiB
C++
79 lines
1.4 KiB
C++
#include "libs.h"
|
|
#include "gui.h"
|
|
|
|
#define BUTTON_SIZE 16
|
|
|
|
namespace Gui {
|
|
|
|
RadioButton::RadioButton(Gui::RadioGroup* g) {
|
|
m_pressed = false;
|
|
SetSize(BUTTON_SIZE, BUTTON_SIZE);
|
|
g->Add(this);
|
|
}
|
|
|
|
RadioButton::~RadioButton(void) {
|
|
|
|
}
|
|
|
|
void RadioButton::OnMouseDown(MouseButtonEvent* e) {
|
|
onPress.emit();
|
|
OnActivate();
|
|
}
|
|
|
|
void RadioButton::OnActivate(void) {
|
|
if(!m_pressed) onSelect.emit(this);
|
|
m_pressed = true;
|
|
}
|
|
|
|
void RadioButton::GetSizeRequested(float& w, float& h) {
|
|
w = BUTTON_SIZE;
|
|
h = BUTTON_SIZE;
|
|
}
|
|
|
|
void RadioButton::Draw(void) {
|
|
if(m_pressed) {
|
|
glBegin(GL_QUADS);
|
|
glColor3fv(Color::bgShadow);
|
|
glVertex2f(0, 0);
|
|
glVertex2f(15, 0);
|
|
glVertex2f(15, 15);
|
|
glVertex2f(0, 15);
|
|
|
|
glColor3f(.6, .6, .6);
|
|
glVertex2f(2, 0);
|
|
glVertex2f(15, 0);
|
|
glVertex2f(15, 13);
|
|
glVertex2f(2, 13);
|
|
|
|
glColor3fv(Color::bg);
|
|
glVertex2f(2, 2);
|
|
glVertex2f(13, 2);
|
|
glVertex2f(13, 13);
|
|
glVertex2f(2, 13);
|
|
glEnd();
|
|
} else {
|
|
glBegin(GL_QUADS);
|
|
glColor3f(.6, .6, .6);
|
|
glVertex2f(0, 0);
|
|
glVertex2f(15, 0);
|
|
glVertex2f(15, 15);
|
|
glVertex2f(0, 15);
|
|
|
|
glColor3fv(Color::bgShadow);
|
|
glVertex2f(2, 0);
|
|
glVertex2f(15, 0);
|
|
glVertex2f(15, 13);
|
|
glVertex2f(2, 13);
|
|
|
|
glColor3fv(Color::bg);
|
|
glVertex2f(2, 2);
|
|
glVertex2f(13, 2);
|
|
glVertex2f(13, 13);
|
|
glVertex2f(2, 13);
|
|
glEnd();
|
|
}
|
|
}
|
|
|
|
}
|
|
|