summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugingui/eventhandler.cc4
-rw-r--r--plugingui/knob.cc35
-rw-r--r--plugingui/knob.h2
3 files changed, 31 insertions, 10 deletions
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc
index 57718c2..b971b15 100644
--- a/plugingui/eventhandler.cc
+++ b/plugingui/eventhandler.cc
@@ -498,9 +498,9 @@ void GUI::EventHandler::processEvents(Window *window)
if(be->direction == 1) {
if(w->catchMouse()) window->setButtonDownFocus(w);
- } else {
- if(w->isFocusable()) window->setKeyboardFocus(w);
}
+
+ if(w->isFocusable()) window->setKeyboardFocus(w);
}
}
break;
diff --git a/plugingui/knob.cc b/plugingui/knob.cc
index d60ecc4..43bc3e8 100644
--- a/plugingui/knob.cc
+++ b/plugingui/knob.cc
@@ -78,10 +78,6 @@ void GUI::Knob::scrollEvent(ScrollEvent *e)
void GUI::Knob::mouseMoveEvent(MouseMoveEvent *e)
{
if(state == down) {
- /*
- DEBUG(slider, "Knob::mouseMoveEvent(mouse_offset_x: %d, e->x: %d)\n",
- mouse_offset_x, e->x);
- */
if(mouse_offset_x == (e->x + -1*e->y)) return;
float dval = mouse_offset_x - (e->x + -1*e->y);
@@ -97,19 +93,44 @@ void GUI::Knob::mouseMoveEvent(MouseMoveEvent *e)
}
}
+void GUI::Knob::keyEvent(KeyEvent *e)
+{
+ if(e->direction != -1) return;
+
+ switch(e->keycode) {
+ case GUI::KeyEvent::KEY_UP:
+ val += 0.01;
+ break;
+ case GUI::KeyEvent::KEY_DOWN:
+ val -= 0.01;
+ break;
+ case GUI::KeyEvent::KEY_HOME:
+ val = 0;
+ break;
+ case GUI::KeyEvent::KEY_END:
+ val = 1;
+ break;
+ default:
+ break;
+ }
+
+ if(val < 0) val = 0;
+ if(val > 1) val = 1;
+
+ repaintEvent(NULL);
+}
+
void GUI::Knob::buttonEvent(ButtonEvent *e)
{
if(e->direction == 1) {
state = down;
mouse_offset_x = e->x + -1*e->y;
- //val = maximum / (float)width() * (float)e->x;
if(handler) handler(ptr);
repaintEvent(NULL);
}
if(e->direction == -1) {
state = up;
mouse_offset_x = e->x + -1*e->y;
- //val = maximum / (float)width() * (float)e->x;
repaintEvent(NULL);
clicked();
if(handler) handler(ptr);
@@ -118,8 +139,6 @@ void GUI::Knob::buttonEvent(ButtonEvent *e)
void GUI::Knob::repaintEvent(GUI::RepaintEvent *e)
{
- // DEBUG(slider, "Knob::repaintEvent (%f)\n", val);
-
Painter p(this);
float alpha = 0.8;
diff --git a/plugingui/knob.h b/plugingui/knob.h
index a78361b..515d872 100644
--- a/plugingui/knob.h
+++ b/plugingui/knob.h
@@ -36,6 +36,7 @@ public:
Knob(Widget *parent);
bool catchMouse() { return true; }
+ bool isFocusable() { return true; }
void setValue(float value);
float value();
@@ -49,6 +50,7 @@ public:
virtual void buttonEvent(ButtonEvent *e);
virtual void mouseMoveEvent(MouseMoveEvent *e);
virtual void scrollEvent(ScrollEvent *e);
+ virtual void keyEvent(KeyEvent *e);
private:
typedef enum {