* Taseditor: middle button pauses/unpauses emulation

* Taseditor: Right button + wheel = Playback rewind/forward
* Taseditor: Shift/Ctrl + wheel = jump via Markers with Playback/Selection cursor
This commit is contained in:
ansstuff 2012-02-20 17:05:59 +00:00
parent e267095bd1
commit ce49322a0b
12 changed files with 257 additions and 121 deletions

View File

@ -1410,6 +1410,15 @@ LRESULT APIENTRY BookmarksListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
bookmarks.MouseMove(-1, -1);
break;
}
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
return 0;
}
case WM_MOUSEWHEEL:
return SendMessage(list.hwndList, msg, wParam, lParam);
}
return CallWindowProc(hwndBookmarksList_oldWndProc, hWnd, msg, wParam, lParam);
}
@ -1443,6 +1452,15 @@ LRESULT APIENTRY BranchesBitmapWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARA
EndPaint(hWnd, &ps);
return 0;
}
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
return 0;
}
case WM_MOUSEWHEEL:
return SendMessage(list.hwndList, msg, wParam, lParam);
}
return CallWindowProc(hwndBranchesBitmap_oldWndProc, hWnd, msg, wParam, lParam);
}

View File

@ -381,7 +381,7 @@ void GREENZONE::InvalidateAndCheck(int after)
playback.lost_position_frame = currFrameCounter + 1;
// auto-restore position if needed
if (taseditor_config.restore_position)
playback.restorePosition();
playback.RestorePosition();
else
playback.jump(greenZoneCount-1);
}

View File

@ -744,6 +744,25 @@ LRESULT APIENTRY HistoryListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
case WM_KEYUP:
case WM_KILLFOCUS:
return 0;
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
return 0;
}
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
return 0;
case WM_MOUSEWHEEL:
{
// right button/Ctrl/Shift + wheel -> send the message to Piano Roll
// but if just wheel - use default scrolling here
if (GET_KEYSTATE_WPARAM(wParam) & (MK_RBUTTON|MK_SHIFT|MK_CONTROL))
return SendMessage(list.hwndList, msg, wParam, lParam);
}
}
return CallWindowProc(hwndHistoryList_oldWndProc, hWnd, msg, wParam, lParam);
}

View File

@ -121,7 +121,7 @@ void PLAYBACK::update()
list.RedrawRow(currFrameCounter);
bookmarks.RedrawChangedBookmarks(currFrameCounter);
lastCursor = currFrameCounter;
if (taseditor_config.follow_playback && !turbo)
if (!turbo)
// enforce redrawing now
UpdateWindow(list.hwndList);
// lazy update of "Playback's Marker text"
@ -232,6 +232,28 @@ void PLAYBACK::UnpauseEmulation()
FCEUI_SetEmulationPaused(0);
// make some additional stuff
}
void PLAYBACK::RestorePosition()
{
if (pause_frame)
jump(pause_frame-1);
else
jump(lost_position_frame-1);
}
void PLAYBACK::MiddleButtonClick()
{
if (emu_paused)
{
if (pause_frame)
jump(pause_frame-1);
else if (lost_position_frame)
jump(lost_position_frame-1);
else
UnpauseEmulation();
} else
{
PauseEmulation();
}
}
void PLAYBACK::SeekingStart(int finish_frame)
{
@ -266,29 +288,44 @@ void PLAYBACK::ForwardFrame()
if (!pause_frame) PauseEmulation();
turbo = false;
}
void PLAYBACK::RewindFull()
void PLAYBACK::RewindFull(int speed)
{
// jump to previous marker
int index = currFrameCounter - 1;
for (; index >= 0; index--)
if (markers_manager.GetMarker(index)) break;
if (index >= 0)
jump(index);
else
jump(0);
jump_was_used_this_frame = true;
if (!jump_was_used_this_frame)
{
int index = currFrameCounter - 1;
// jump trough "speed" amount of previous markers
while (speed > 0)
{
for (; index >= 0; index--)
if (markers_manager.GetMarker(index)) break;
speed--;
}
if (index >= 0)
jump(index);
else
jump(0);
jump_was_used_this_frame = true;
}
}
void PLAYBACK::ForwardFull()
void PLAYBACK::ForwardFull(int speed)
{
// jump to next marker
int last_frame = currMovieData.getNumRecords()-1;
int index = currFrameCounter + 1;
for (; index <= last_frame; ++index)
if (markers_manager.GetMarker(index)) break;
if (index <= last_frame)
jump(index);
else
jump(last_frame);
if (!jump_was_used_this_frame)
{
int last_frame = currMovieData.getNumRecords()-1;
int index = currFrameCounter + 1;
// jump trough "speed" amount of next markers
while (speed > 0)
{
for (; index <= last_frame; ++index)
if (markers_manager.GetMarker(index)) break;
speed--;
}
if (index <= last_frame)
jump(index);
else
jump(last_frame);
jump_was_used_this_frame = true;
}
}
void PLAYBACK::RedrawMarker()
@ -324,13 +361,6 @@ void PLAYBACK::jump(int frame)
list.FollowPlaybackIfNeeded();
}
}
void PLAYBACK::restorePosition()
{
if (pause_frame)
jump(pause_frame-1);
else
jump(lost_position_frame-1);
}
bool PLAYBACK::JumpToFrame(int index)
{

View File

@ -17,7 +17,6 @@ public:
void update();
void jump(int frame);
void restorePosition();
void updateProgressbar();
@ -26,11 +25,13 @@ public:
void ToggleEmulationPause();
void PauseEmulation();
void UnpauseEmulation();
void RestorePosition();
void MiddleButtonClick();
void RewindFrame();
void ForwardFrame();
void RewindFull();
void ForwardFull();
void RewindFull(int speed = 1);
void ForwardFull(int speed = 1);
void RedrawMarker();
@ -50,9 +51,6 @@ public:
HWND hwndProgressbar, hwndRewind, hwndForward, hwndRewindFull, hwndForwardFull;
HWND hwndPlaybackMarker, hwndPlaybackMarkerEdit;
// temps
bool jump_was_used_this_frame;
private:
int lastCursor; // but for currentCursor we use external variable currFrameCounter
@ -66,4 +64,7 @@ private:
int button_hold_time;
int seeking_start_frame;
// temps
bool jump_was_used_this_frame;
};

View File

@ -156,6 +156,9 @@ void TASEDITOR_LIST::init()
lvc.mask = LVCF_WIDTH;
lvc.cx = COLUMN_ICONS_WIDTH;
ListView_InsertColumn(hwndList, 0, &lvc);
hrmenu = LoadMenu(fceu_hInstance,"TASEDITORCONTEXTMENUS");
}
void TASEDITOR_LIST::free()
{
@ -970,6 +973,55 @@ bool TASEDITOR_LIST::InputColumnSet(int joy, int button)
} else
return false;
}
// ----------------------------------------------------
void TASEDITOR_LIST::RightClick(LVHITTESTINFO& info)
{
int index = info.iItem;
if(index == -1)
StrayClickMenu(info);
else
RightClickMenu(info);
}
void TASEDITOR_LIST::StrayClickMenu(LVHITTESTINFO& info)
{
POINT pt = info.pt;
ClientToScreen(hwndList, &pt);
HMENU sub = GetSubMenu(hrmenu, CONTEXTMENU_STRAY);
TrackPopupMenu(sub, 0, pt.x, pt.y, 0, taseditor_window.hwndTasEditor, 0);
}
void TASEDITOR_LIST::RightClickMenu(LVHITTESTINFO& info)
{
SelectionFrames* current_selection = selection.MakeStrobe();
if (current_selection->size() == 0)
{
StrayClickMenu(info);
return;
}
HMENU sub = GetSubMenu(hrmenu, CONTEXTMENU_SELECTED);
// inspect current selection and disable inappropriate menu items
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
bool set_found = false, unset_found = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if(markers_manager.GetMarker(*it))
set_found = true;
else
unset_found = true;
}
if (set_found)
EnableMenuItem(sub, ID_SELECTED_REMOVEMARKER, MF_BYCOMMAND | MF_ENABLED);
else
EnableMenuItem(sub, ID_SELECTED_REMOVEMARKER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
if (unset_found)
EnableMenuItem(sub, ID_SELECTED_SETMARKER, MF_BYCOMMAND | MF_ENABLED);
else
EnableMenuItem(sub, ID_SELECTED_SETMARKER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
POINT pt = info.pt;
ClientToScreen(hwndList, &pt);
TrackPopupMenu(sub, 0, pt.x, pt.y, 0, taseditor_window.hwndTasEditor, 0);
}
// -------------------------------------------------------------------------
LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@ -983,7 +1035,7 @@ LRESULT APIENTRY HeaderWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
{
if (selection.GetCurrentSelectionSize())
{
//perform hit test
// perform hit test
HD_HITTESTINFO info;
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
@ -1028,6 +1080,61 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0;
break;
}
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
return 0;
}
case WM_MOUSEWHEEL:
{
int fwKeys = GET_KEYSTATE_WPARAM(wParam);
int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
if (fwKeys & MK_SHIFT)
{
// Shift + scroll = Playback rewind full(speed)/forward full(speed)
if (zDelta < 0)
playback.ForwardFull(-zDelta / 120);
else if (zDelta > 0)
playback.RewindFull(zDelta / 120);
return 0;
} else if (fwKeys & MK_CONTROL)
{
// Ctrl + scroll = Selection rewind full(speed)/forward full(speed)
if (zDelta < 0)
selection.JumpNextMarker(-zDelta / 120);
else if (zDelta > 0)
selection.JumpPrevMarker(zDelta / 120);
return 0;
} else if (fwKeys & MK_RBUTTON)
{
// Right button + scroll = rewind/forward
int destination_frame = currFrameCounter - (zDelta / 120);
if (destination_frame < 0) destination_frame = 0;
playback.jump(destination_frame);
return 0;
}
break;
}
case WM_RBUTTONDOWN:
if (GetFocus() != list.hwndList)
SetFocus(list.hwndList);
return 0;
case WM_RBUTTONDBLCLK:
return 0;
case WM_RBUTTONUP:
{
// perform hit test
LVHITTESTINFO info;
info.pt.x = GET_X_LPARAM(lParam);
info.pt.y = GET_Y_LPARAM(lParam);
ListView_SubItemHitTest(hWnd, (LPARAM)&info);
// show context menu
if(info.iSubItem <= COLUMN_FRAMENUM || info.iSubItem >= COLUMN_FRAMENUM2)
list.RightClick(info);
return 0;
}
}
return CallWindowProc(hwndList_oldWndProc, hWnd, msg, wParam, lParam);
}

View File

@ -140,6 +140,10 @@ public:
void SingleClick(LPNMITEMACTIVATE info);
void DoubleClick(LPNMITEMACTIVATE info);
void RightClick(LVHITTESTINFO& info);
void StrayClickMenu(LVHITTESTINFO& info);
void RightClickMenu(LVHITTESTINFO& info);
void ToggleJoypadBit(int column_index, int row_index, UINT KeyFlags);
void ColumnSet(int column, bool alt_pressed);
@ -162,4 +166,5 @@ private:
int num_columns;
int next_header_update_time;
HMENU hrmenu;
};

View File

@ -140,27 +140,36 @@ void TASEDITOR_SELECTION::RedrawMarker()
SetWindowText(hwndSelectionMarkerEdit, new_text);
}
void TASEDITOR_SELECTION::JumpPrevMarker()
void TASEDITOR_SELECTION::JumpPrevMarker(int speed)
{
// jump to previous marker
// if nothing is selected, consider playback cursor as current selection
int index = GetCurrentSelectionBeginning();
if (index < 0) index = currFrameCounter; // if nothing is selected, consider playback cursor as current selection
for (index--; index >= 0; index--)
if (markers_manager.GetMarker(index)) break;
if (index < 0) index = currFrameCounter;
// jump trough "speed" amount of previous markers
while (speed > 0)
{
for (index--; index >= 0; index--)
if (markers_manager.GetMarker(index)) break;
speed--;
}
if (index >= 0)
JumpToFrame(index);
else
JumpToFrame(0);
}
void TASEDITOR_SELECTION::JumpNextMarker()
void TASEDITOR_SELECTION::JumpNextMarker(int speed)
{
// jump to next marker
// if nothing is selected, consider playback cursor as current selection
int index = GetCurrentSelectionBeginning();
if (index < 0) index = currFrameCounter; // if nothing is selected, consider playback cursor as current selection
if (index < 0) index = currFrameCounter;
int last_frame = currMovieData.getNumRecords()-1;
for (++index; index <= last_frame; ++index)
if (markers_manager.GetMarker(index)) break;
// jump trough "speed" amount of previous markers
while (speed > 0)
{
for (++index; index <= last_frame; ++index)
if (markers_manager.GetMarker(index)) break;
speed--;
}
if (index <= last_frame)
JumpToFrame(index);
else

View File

@ -41,8 +41,8 @@ public:
void SelectBetweenMarkers();
void ReselectClipboard();
void JumpPrevMarker();
void JumpNextMarker();
void JumpPrevMarker(int speed = 1);
void JumpNextMarker(int speed = 1);
void JumpToFrame(int frame);
// getters

View File

@ -70,11 +70,11 @@ static struct
IDC_LUA_BOX, -1, 0, 0, 0, "", "", false, 0, 0,
IDC_BOOKMARKS_BOX, -1, 0, 0, 0, "", "", false, 0, 0,
IDC_HISTORY_BOX, -1, 0, 0, -1, "", "", false, 0, 0,
TASEDITOR_REWIND_FULL, -1, 0, 0, 0, "Send Playback to previous Marker (hotkey: Shift+PageUp)", "", false, 0, 0,
TASEDITOR_REWIND, -1, 0, 0, 0, "Rewind one frame", "", false, EMUCMD_TASEDITOR_REWIND, 0,
TASEDITOR_PLAYSTOP, -1, 0, 0, 0, "Pause/Unpause Emulation", "", false, EMUCMD_PAUSE, 0,
TASEDITOR_FORWARD, -1, 0, 0, 0, "Advance one frame", "", false, EMUCMD_FRAME_ADVANCE, 0,
TASEDITOR_FORWARD_FULL, -1, 0, 0, 0, "Send Playback to next Marker (hotkey: Shift+PageDown)", "", false, 0, 0,
TASEDITOR_REWIND_FULL, -1, 0, 0, 0, "Send Playback to previous Marker (mouse: Shift+Wheel up) (hotkey: Shift+PageUp)", "", false, 0, 0,
TASEDITOR_REWIND, -1, 0, 0, 0, "Rewind one frame (mouse: Right button+Wheel up)", "", false, EMUCMD_TASEDITOR_REWIND, 0,
TASEDITOR_PLAYSTOP, -1, 0, 0, 0, "Pause/Unpause Emulation (mouse: Middle button)", "", false, EMUCMD_PAUSE, 0,
TASEDITOR_FORWARD, -1, 0, 0, 0, "Advance one frame (mouse: Right button+Wheel down)", "", false, EMUCMD_FRAME_ADVANCE, 0,
TASEDITOR_FORWARD_FULL, -1, 0, 0, 0, "Send Playback to next Marker (mouse: Shift+Wheel down) (hotkey: Shift+PageDown)", "", false, 0, 0,
IDC_PROGRESS1, -1, 0, 0, 0, "", "", false, 0, 0,
CHECK_FOLLOW_CURSOR, -1, 0, 0, 0, "The List will follow Playback cursor movements", "", false, 0, 0,
CHECK_AUTORESTORE_PLAYBACK, -1, 0, 0, 0, "If you change input above Playback, cursor will run where it was before change", "", false, 0, 0,
@ -87,10 +87,10 @@ static struct
IDC_RADIO_4P, -1, 0, 0, 0, "", "", false, 0, 0,
IDC_SUPERIMPOSE, -1, 0, 0, 0, "Allows to superimpose old input with new buttons, instead of overwriting", "", false, 0, 0,
IDC_USEPATTERN, -1, 0, 0, 0, "Applies current Autofire Pattern to input recording", "", false, 0, 0,
TASEDITOR_PREV_MARKER, -1, -1, 0, -1, "Send Selection to previous Marker (hotkey: Ctrl+PageUp)", "", false, 0, 0,
TASEDITOR_PREV_MARKER, -1, -1, 0, -1, "Send Selection to previous Marker (mouse: Ctrl+Wheel up) (hotkey: Ctrl+PageUp)", "", false, 0, 0,
TASEDITOR_FIND_BEST_SIMILAR_MARKER, -1, -1, 0, -1, "Auto-search for Marker Note", "", false, 0, 0,
TASEDITOR_FIND_NEXT_SIMILAR_MARKER, -1, -1, 0, -1, "Continue Auto-search", "", false, 0, 0,
TASEDITOR_NEXT_MARKER, -1, -1, 0, -1, "Send Selection to next Marker (hotkey: Ctrl+PageDown)", "", false, 0, 0,
TASEDITOR_NEXT_MARKER, -1, -1, 0, -1, "Send Selection to next Marker (mouse: Ctrl+Wheel up) (hotkey: Ctrl+PageDown)", "", false, 0, 0,
IDC_JUMP_PLAYBACK_BUTTON, 0, 0, 0, 0, "Click here to scroll the List to Playback cursor", "", false, 0, 0,
IDC_PLAYBACK_MARKER_EDIT, 0, 0, -1, 0, "Click to edit text", "", false, 0, 0,
IDC_PLAYBACK_MARKER, 0, 0, 0, 0, "", "", false, 0, 0,
@ -132,7 +132,6 @@ void TASEDITOR_WINDOW::init()
ShowWindow(hwndTasEditor, SW_SHOWMAXIMIZED);
// menus and checked items
hmenu = GetMenu(hwndTasEditor);
hrmenu = LoadMenu(fceu_hInstance,"TASEDITORCONTEXTMENUS");
patterns_menu = GetSubMenu(hmenu, PATTERNS_MENU_POS);
UpdateCheckedItems();
// tooltips
@ -402,56 +401,6 @@ void TASEDITOR_WINDOW::RedrawTaseditor()
InvalidateRect(hwndTasEditor, 0, FALSE);
}
void TASEDITOR_WINDOW::RightClick(LPNMITEMACTIVATE info)
{
int index = info->iItem;
if(index == -1)
StrayClickMenu(info);
else if (selection.CheckFrameSelected(index))
RightClickMenu(info);
}
void TASEDITOR_WINDOW::StrayClickMenu(LPNMITEMACTIVATE info)
{
POINT pt = info->ptAction;
ClientToScreen(list.hwndList, &pt);
HMENU sub = GetSubMenu(hrmenu, CONTEXTMENU_STRAY);
TrackPopupMenu(sub, 0, pt.x, pt.y, 0, hwndTasEditor, 0);
}
void TASEDITOR_WINDOW::RightClickMenu(LPNMITEMACTIVATE info)
{
POINT pt = info->ptAction;
ClientToScreen(list.hwndList, &pt);
SelectionFrames* current_selection = selection.MakeStrobe();
if (current_selection->size() == 0)
{
StrayClickMenu(info);
return;
}
HMENU sub = GetSubMenu(hrmenu, CONTEXTMENU_SELECTED);
// inspect current selection and disable inappropriate menu items
SelectionFrames::iterator current_selection_begin(current_selection->begin());
SelectionFrames::iterator current_selection_end(current_selection->end());
bool set_found = false, unset_found = false;
for(SelectionFrames::iterator it(current_selection_begin); it != current_selection_end; it++)
{
if(markers_manager.GetMarker(*it))
set_found = true;
else
unset_found = true;
}
if (set_found)
EnableMenuItem(sub, ID_SELECTED_REMOVEMARKER, MF_BYCOMMAND | MF_ENABLED);
else
EnableMenuItem(sub, ID_SELECTED_REMOVEMARKER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
if (unset_found)
EnableMenuItem(sub, ID_SELECTED_SETMARKER, MF_BYCOMMAND | MF_ENABLED);
else
EnableMenuItem(sub, ID_SELECTED_SETMARKER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
TrackPopupMenu(sub, 0, pt.x, pt.y, 0, hwndTasEditor, 0);
}
void TASEDITOR_WINDOW::UpdateCheckedItems()
{
// check option ticks
@ -730,9 +679,6 @@ BOOL CALLBACK WndprocTasEditor(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
case NM_DBLCLK:
list.DoubleClick((LPNMITEMACTIVATE)lParam);
break;
case NM_RCLICK:
taseditor_window.RightClick((LPNMITEMACTIVATE)lParam);
break;
case LVN_ITEMCHANGED:
selection.ItemChanged((LPNMLISTVIEW) lParam);
break;
@ -779,7 +725,6 @@ BOOL CALLBACK WndprocTasEditor(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
break;
case NM_CLICK:
case NM_DBLCLK:
case NM_RCLICK:
history.Click((LPNMITEMACTIVATE)lParam);
break;
}
@ -1382,12 +1327,10 @@ BOOL CALLBACK WndprocTasEditor(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
break;
}
case ACCEL_SHIFT_PGUP:
if (!playback.jump_was_used_this_frame)
playback.RewindFull();
playback.RewindFull();
break;
case ACCEL_SHIFT_PGDN:
if (!playback.jump_was_used_this_frame)
playback.ForwardFull();
playback.ForwardFull();
break;
case ACCEL_CTRL_PGUP:
selection.JumpPrevMarker();
@ -1451,6 +1394,14 @@ BOOL CALLBACK WndprocTasEditor(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
}
break;
}
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
{
playback.MiddleButtonClick();
break;
}
case WM_MOUSEWHEEL:
return SendMessage(list.hwndList, uMsg, wParam, lParam);
default:
break;

View File

@ -30,10 +30,6 @@ public:
void UpdateCaption();
void RedrawTaseditor();
void RightClick(LPNMITEMACTIVATE info);
void StrayClickMenu(LPNMITEMACTIVATE info);
void RightClickMenu(LPNMITEMACTIVATE info);
void UpdateCheckedItems();
void UpdateRecentProjectsMenu();
@ -58,7 +54,7 @@ private:
HWND hToolTipWnd;
HMENU hmenu, hrmenu, patterns_menu;
HMENU hmenu, patterns_menu;
HICON hTaseditorIcon;
};

View File

@ -1201,7 +1201,7 @@ static void TaseditorRewindOff(void)
static void TaseditorRestorePlayback(void)
{
#ifdef WIN32
playback.restorePosition();
playback.RestorePosition();
#endif
}