(root)/wip/src/box_selector.cc - Rev 1085
Rev 1009 |
Rev 1098 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include "box_selector.h"
#include "random.h"
#include "container.h"
int box_selector::handle_input () {
if (exists() && is_menu_visible ()) {
abort ();
return 1;
}
if (is_lmb (this)) {
if (lmb_clicked == 0) {
if (op == NONE) {
op = EXISTS;
is_lmb.tie = this;
if (lis) lis->region_begin ();
} else if (op == EXISTS) {
op = FINISH;
}
lmb_clicked = 1;
}
} else {
lmb_clicked = 0;
if (op == EXISTS) {
if (lis) lis->region_update ();
} else if (op == FINISH) {
is_lmb.clear (this);
if (lis) lis->region_end ();
op = NONE;
}
}
return 1;
}
void box_selector::draw (const box<int>& region) {
if (op == EXISTS) {
glColor3f (1, 1, 1);
boxp[0]=region.left;boxp[1]=region.bottom;
boxp[2]=region.right;boxp[3]=region.bottom;
boxp[4]=region.right;boxp[5]=region.top;
boxp[6]=region.left;boxp[7]=region.top;
glVertexPointer (2, GL_INT, 0, boxp);
glDrawArrays (GL_LINE_LOOP, 0, 4);
}
}
int box_selector::abort () {
if (op != NONE) {
op = NONE;
is_lmb.clear (this);
if (lis) lis->region_abort ();
return 1;
}
return 0;
}