Skip to content

Commit

Permalink
Fix issue 341: cannot scroll Timeline with space bar
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Feb 8, 2014
1 parent 61c5b0d commit aa9eec2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
39 changes: 18 additions & 21 deletions src/app/ui/timeline.cpp
Expand Up @@ -195,7 +195,6 @@ void Timeline::updateUsingEditor(Editor* editor)
m_state = STATE_STANDBY;
m_hot_part = A_PART_NOTHING;
m_clk_part = A_PART_NOTHING;
m_space_pressed = false;

setFocusStop(true);
regenerateLayers();
Expand Down Expand Up @@ -256,21 +255,13 @@ bool Timeline::onProcessMessage(Message* msg)
case kTimerMessage:
break;

case kMouseEnterMessage:
if (key[KEY_SPACE]) m_space_pressed = true;
break;

case kMouseLeaveMessage:
if (m_space_pressed) m_space_pressed = false;
break;

case kMouseDownMessage: {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);

if (!m_document)
break;

if (mouseMsg->middle() || m_space_pressed) {
if (mouseMsg->middle() || key[KEY_SPACE]) {
captureMouse();
m_state = STATE_SCROLLING;
return true;
Expand Down Expand Up @@ -798,6 +789,16 @@ bool Timeline::onProcessMessage(Message* msg)
}
break;

case kKeyDownMessage:
switch (static_cast<KeyMessage*>(msg)->scancode()) {

case kKeySpace: {
setCursor(jmouse_x(0), jmouse_y(0));
return true;
}
}
break;

case kKeyUpMessage:
switch (static_cast<KeyMessage*>(msg)->scancode()) {

Expand All @@ -806,16 +807,13 @@ bool Timeline::onProcessMessage(Message* msg)
invalidate();
break;

case kKeySpace:
if (m_space_pressed) {
// We have to clear all the KEY_SPACE in buffer.
clear_keybuf();
case kKeySpace: {
// We have to clear all the KEY_SPACE in buffer.
clear_keybuf();

m_space_pressed = false;
setCursor(jmouse_x(0), jmouse_y(0));
return true;
}
break;
setCursor(jmouse_x(0), jmouse_y(0));
return true;
}
}
break;

Expand Down Expand Up @@ -1035,8 +1033,7 @@ void Timeline::setCursor(int x, int y)
//int my = y - getBounds().y;

// Scrolling.
if (m_state == STATE_SCROLLING ||
m_space_pressed) {
if (m_state == STATE_SCROLLING || key[KEY_SPACE]) {
jmouse_set_cursor(kScrollCursor);
}
// Moving a frame.
Expand Down
2 changes: 0 additions & 2 deletions src/app/ui/timeline.h
Expand Up @@ -203,8 +203,6 @@ namespace app {
int m_clk_part;
int m_clk_layer;
FrameNumber m_clk_frame;
// Keys
bool m_space_pressed;
// Old mouse position (for scrolling).
gfx::Point m_oldPos;
};
Expand Down

0 comments on commit aa9eec2

Please sign in to comment.