From d188a2def217183b54dedac357e2a49ec0ea2c69 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Sun, 15 Apr 2012 15:05:37 +0000 Subject: [PATCH] Taseditor: minor fixes --- src/drivers/win/res.rc | 2 +- src/drivers/win/taseditor/bookmarks.cpp | 11 ++- src/drivers/win/taseditor/branches.cpp | 61 +++++++----- src/drivers/win/taseditor/branches.h | 7 +- src/drivers/win/taseditor/piano_roll.cpp | 10 +- .../win/taseditor/taseditor_window.cpp | 98 ++++++++++++------- 6 files changed, 112 insertions(+), 77 deletions(-) diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 665967f9..fc7314ab 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -384,7 +384,7 @@ TASEDITORCONTEXTMENUS MENU BEGIN POPUP "Selected" BEGIN - MENUITEM "Set Markers\tDbl-Clk", ID_SELECTED_SETMARKERS + MENUITEM "Set Markers\tDbl-Clk", ID_SELECTED_SETMARKERS MENUITEM "Remove Markers", ID_SELECTED_REMOVEMARKERS MENUITEM SEPARATOR MENUITEM "Deselect", ID_SELECTED_DESELECT diff --git a/src/drivers/win/taseditor/bookmarks.cpp b/src/drivers/win/taseditor/bookmarks.cpp index 5b0f9b9f..13a61d3d 100644 --- a/src/drivers/win/taseditor/bookmarks.cpp +++ b/src/drivers/win/taseditor/bookmarks.cpp @@ -652,13 +652,14 @@ void BOOKMARKS::RightClick() int BOOKMARKS::FindBookmarkAtFrame(int frame) { - int current_branch = branches.GetCurrentBranch(); - if (current_branch >= 0 && bookmarks_array[current_branch].snapshot.jump_frame == frame) - return current_branch + TOTAL_BOOKMARKS; // blue digit has highest priority when drawing + int cur_bookmark = branches.GetCurrentBranch(); + if (cur_bookmark >= 0 && bookmarks_array[cur_bookmark].snapshot.jump_frame == frame) + return cur_bookmark + TOTAL_BOOKMARKS; // blue digit has highest priority when drawing for (int i = 0; i < TOTAL_BOOKMARKS; ++i) { - if (bookmarks_array[i].not_empty && bookmarks_array[i].snapshot.jump_frame == frame) - return i; // green digit + cur_bookmark = (i + 1) % TOTAL_BOOKMARKS; + if (bookmarks_array[cur_bookmark].not_empty && bookmarks_array[cur_bookmark].snapshot.jump_frame == frame) + return cur_bookmark; // green digit } return -1; // no Bookmarks at the frame } diff --git a/src/drivers/win/taseditor/branches.cpp b/src/drivers/win/taseditor/branches.cpp index 85414490..c1924d7e 100644 --- a/src/drivers/win/taseditor/branches.cpp +++ b/src/drivers/win/taseditor/branches.cpp @@ -70,12 +70,32 @@ void BRANCHES::init() // init GDI stuff HDC win_hdc = GetWindowDC(bookmarks.hwndBranchesBitmap); hBitmapDC = CreateCompatibleDC(win_hdc); - branches_hbitmap = CreateCompatibleBitmap(win_hdc, BRANCHES_BITMAP_WIDTH, BRANCHES_BITMAP_WIDTH); + branches_hbitmap = CreateCompatibleBitmap(win_hdc, BRANCHES_BITMAP_WIDTH, BRANCHES_BITMAP_HEIGHT); hOldBitmap = (HBITMAP)SelectObject(hBitmapDC, branches_hbitmap); hBufferDC = CreateCompatibleDC(win_hdc); - buffer_hbitmap = CreateCompatibleBitmap(win_hdc, BRANCHES_BITMAP_WIDTH, BRANCHES_BITMAP_WIDTH); + buffer_hbitmap = CreateCompatibleBitmap(win_hdc, BRANCHES_BITMAP_WIDTH, BRANCHES_BITMAP_HEIGHT); hOldBitmap1 = (HBITMAP)SelectObject(hBufferDC, buffer_hbitmap); normal_brush = CreateSolidBrush(0x000000); + border_brush = CreateSolidBrush(0xb99d7f); + // prepare bg gradient + vertex[0].x = 0; + vertex[0].y = 0; + vertex[0].Red = 0xBF00; + vertex[0].Green = 0xE200; + vertex[0].Blue = 0xEF00; + vertex[0].Alpha = 0x0000; + vertex[1].x = BRANCHES_BITMAP_WIDTH; + vertex[1].y = BRANCHES_BITMAP_HEIGHT; + vertex[1].Red = 0xE500; + vertex[1].Green = 0xFB00; + vertex[1].Blue = 0xFF00; + vertex[1].Alpha = 0x0000; + gRect.UpperLeft = 0; + gRect.LowerRight = 1; + branches_bitmap_rect.left = 0; + branches_bitmap_rect.top = 0; + branches_bitmap_rect.right = BRANCHES_BITMAP_WIDTH; + branches_bitmap_rect.bottom = BRANCHES_BITMAP_HEIGHT; // prepare branches spritesheet branchesSpritesheet = LoadBitmap(fceu_hInstance, MAKEINTRESOURCE(IDB_BRANCH_SPRITESHEET)); hSpritesheetDC = CreateCompatibleDC(win_hdc); @@ -142,6 +162,16 @@ void BRANCHES::free() DeleteObject(branchesSpritesheet); branchesSpritesheet = NULL; } + if (normal_brush) + { + DeleteObject(normal_brush); + normal_brush = 0; + } + if (border_brush) + { + DeleteObject(border_brush); + border_brush = 0; + } if (normal_pen) { DeleteObject(normal_pen); @@ -417,25 +447,8 @@ error: // ---------------------------------------------------------- void BRANCHES::RedrawBranchesTree() { - // draw background gradient - TRIVERTEX vertex[2] ; - vertex[0].x = 0; - vertex[0].y = 0; - vertex[0].Red = 0xC700; - vertex[0].Green = 0xE700; - vertex[0].Blue = 0xF300; - vertex[0].Alpha = 0x0000; - vertex[1].x = BRANCHES_BITMAP_WIDTH; - vertex[1].y = BRANCHES_BITMAP_HEIGHT; - vertex[1].Red = 0xEB00; - vertex[1].Green = 0xFA00; - vertex[1].Blue = 0xF800; - vertex[1].Alpha = 0x0000; - GRADIENT_RECT gRect; - gRect.UpperLeft = 0; - gRect.LowerRight = 1; + // draw background GradientFill(hBitmapDC, vertex, 2, &gRect, 1, GRADIENT_FILL_RECT_H); - // lines int branch, branch_x, branch_y, parent_x, parent_y, child_id; SelectObject(hBitmapDC, normal_pen); @@ -535,10 +548,8 @@ void BRANCHES::RedrawBranchesTree() branch_y = BranchCurrY[TOTAL_BOOKMARKS]; LineTo(hBitmapDC, branch_x, branch_y); } - // cloud TransparentBlt(hBitmapDC, cloud_x - BRANCHES_CLOUD_HALFWIDTH, BRANCHES_CLOUD_Y - BRANCHES_CLOUD_HALFHEIGHT, BRANCHES_CLOUD_WIDTH, BRANCHES_CLOUD_HEIGHT, hSpritesheetDC, BRANCHES_CLOUD_SPRITESHEET_X, BRANCHES_CLOUD_SPRITESHEET_Y, BRANCHES_CLOUD_WIDTH, BRANCHES_CLOUD_HEIGHT, 0x00FF00); - // branches rectangles for (int i = 0; i < TOTAL_BOOKMARKS; ++i) { @@ -555,12 +566,12 @@ void BRANCHES::RedrawBranchesTree() { // draw colored rect HBRUSH color_brush = CreateSolidBrush(bookmark_flash_colors[bookmarks.bookmarks_array[i].flash_type][bookmarks.bookmarks_array[i].flash_phase]); - FillRect(hBitmapDC, &temp_rect, color_brush); + FrameRect(hBitmapDC, &temp_rect, color_brush); DeleteObject(color_brush); } else { // draw black rect - FillRect(hBitmapDC, &temp_rect, normal_brush); + FrameRect(hBitmapDC, &temp_rect, normal_brush); } } // digits @@ -625,6 +636,8 @@ void BRANCHES::RedrawBranchesTree() } } } + // draw border of canvas + FrameRect(hBitmapDC, &branches_bitmap_rect, border_brush); // finished must_redraw_branches_tree = false; InvalidateRect(bookmarks.hwndBranchesBitmap, 0, FALSE); diff --git a/src/drivers/win/taseditor/branches.h b/src/drivers/win/taseditor/branches.h index 4fd77774..bdc106a0 100644 --- a/src/drivers/win/taseditor/branches.h +++ b/src/drivers/win/taseditor/branches.h @@ -31,7 +31,7 @@ #define BASE_HORIZONTAL_SHIFT 10 #define BRANCHES_GRID_MIN_HALFHEIGHT 8 #define BRANCHES_GRID_MAX_HALFHEIGHT 12 -#define EMPTY_BRANCHES_X_BASE 3 +#define EMPTY_BRANCHES_X_BASE 4 #define EMPTY_BRANCHES_Y_BASE 9 #define EMPTY_BRANCHES_Y_FACTOR 14 #define MAX_NUM_CHILDREN_ON_CANVAS_HEIGHT 9 @@ -160,11 +160,14 @@ private: int latest_drawn_item_under_mouse; // GDI stuff - HBRUSH normal_brush; + HBRUSH normal_brush, border_brush; RECT temp_rect; HPEN normal_pen, timeline_pen, select_pen; HBITMAP branches_hbitmap, hOldBitmap, buffer_hbitmap, hOldBitmap1, branchesSpritesheet, hOldBitmap2; HDC hBitmapDC, hBufferDC, hSpritesheetDC; + TRIVERTEX vertex[2]; + GRADIENT_RECT gRect; + RECT branches_bitmap_rect; // temps std::vector GridX; // in grid units diff --git a/src/drivers/win/taseditor/piano_roll.cpp b/src/drivers/win/taseditor/piano_roll.cpp index ff53cf8d..73a2c171 100644 --- a/src/drivers/win/taseditor/piano_roll.cpp +++ b/src/drivers/win/taseditor/piano_roll.cpp @@ -1593,15 +1593,9 @@ LRESULT APIENTRY ListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // clicked without Shift/Alt - set "row_last_clicked" here piano_roll.row_last_clicked = row_index; - // and change Selection to this row - if (fwKeys & MK_CONTROL) - { - if (selection.GetRowSelection(row_index)) - selection.ClearRowSelection(row_index); - else - selection.SetRowSelection(row_index); - } else + if (!(fwKeys & MK_CONTROL)) { + // change Selection to this row selection.ClearSelection(); selection.SetRowSelection(row_index); } diff --git a/src/drivers/win/taseditor/taseditor_window.cpp b/src/drivers/win/taseditor/taseditor_window.cpp index bcab7ae3..72fc310f 100644 --- a/src/drivers/win/taseditor/taseditor_window.cpp +++ b/src/drivers/win/taseditor/taseditor_window.cpp @@ -92,29 +92,29 @@ LRESULT APIENTRY TASEDITOR_RUN_MANUAL_WndProc(HWND hWnd, UINT msg, WPARAM wParam LRESULT APIENTRY IDC_RUN_AUTO_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); // variables storing old wndprocs WNDPROC - IDC_PROGRESS_BUTTON_oldWndProc = 0, - IDC_BRANCHES_BUTTON_oldWndProc = 0, - TASEDITOR_REWIND_FULL_oldWndProc = 0, - TASEDITOR_REWIND_oldWndProc = 0, - TASEDITOR_PLAYSTOP_oldWndProc = 0, - TASEDITOR_FORWARD_oldWndProc = 0, - TASEDITOR_FORWARD_FULL_oldWndProc = 0, - CHECK_FOLLOW_CURSOR_oldWndProc = 0, - CHECK_AUTORESTORE_PLAYBACK_oldWndProc = 0, - IDC_RADIO_ALL_oldWndProc = 0, - IDC_RADIO_1P_oldWndProc = 0, - IDC_RADIO_2P_oldWndProc = 0, - IDC_RADIO_3P_oldWndProc = 0, - IDC_RADIO_4P_oldWndProc = 0, - IDC_SUPERIMPOSE_oldWndProc = 0, - IDC_USEPATTERN_oldWndProc = 0, - TASEDITOR_PREV_MARKER_oldWndProc = 0, - TASEDITOR_FIND_BEST_SIMILAR_MARKER_oldWndProc = 0, - TASEDITOR_FIND_NEXT_SIMILAR_MARKER_oldWndProc = 0, - TASEDITOR_NEXT_MARKER_oldWndProc = 0, - CHECK_TURBO_SEEK_oldWndProc = 0, - IDC_RECORDING_oldWndProc = 0, - TASEDITOR_RUN_MANUAL_oldWndProc = 0, + IDC_PROGRESS_BUTTON_oldWndProc = 0, + IDC_BRANCHES_BUTTON_oldWndProc = 0, + TASEDITOR_REWIND_FULL_oldWndProc = 0, + TASEDITOR_REWIND_oldWndProc = 0, + TASEDITOR_PLAYSTOP_oldWndProc = 0, + TASEDITOR_FORWARD_oldWndProc = 0, + TASEDITOR_FORWARD_FULL_oldWndProc = 0, + CHECK_FOLLOW_CURSOR_oldWndProc = 0, + CHECK_AUTORESTORE_PLAYBACK_oldWndProc = 0, + IDC_RADIO_ALL_oldWndProc = 0, + IDC_RADIO_1P_oldWndProc = 0, + IDC_RADIO_2P_oldWndProc = 0, + IDC_RADIO_3P_oldWndProc = 0, + IDC_RADIO_4P_oldWndProc = 0, + IDC_SUPERIMPOSE_oldWndProc = 0, + IDC_USEPATTERN_oldWndProc = 0, + TASEDITOR_PREV_MARKER_oldWndProc = 0, + TASEDITOR_FIND_BEST_SIMILAR_MARKER_oldWndProc = 0, + TASEDITOR_FIND_NEXT_SIMILAR_MARKER_oldWndProc = 0, + TASEDITOR_NEXT_MARKER_oldWndProc = 0, + CHECK_TURBO_SEEK_oldWndProc = 0, + IDC_RECORDING_oldWndProc = 0, + TASEDITOR_RUN_MANUAL_oldWndProc = 0, IDC_RUN_AUTO_oldWndProc = 0; // Recent Menu @@ -1003,8 +1003,6 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara splicer.InsertFrames(); break; case ACCEL_DEL: - case ID_EDIT_CLEAR: - case ID_CONTEXT_SELECTED_CLEARFRAMES: if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_UPPER) { DWORD sel_start, sel_end; @@ -1022,6 +1020,10 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara } else splicer.ClearFrames(); break; + case ID_EDIT_CLEAR: + case ID_CONTEXT_SELECTED_CLEARFRAMES: + splicer.ClearFrames(); + break; case CHECK_FOLLOW_CURSOR: taseditor_config.follow_playback ^= 1; taseditor_window.UpdateCheckedItems(); @@ -1180,14 +1182,6 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara taseditor_config.autopause_at_finish ^= 1; taseditor_window.UpdateCheckedItems(); break; - case IDC_PROGRESS_BUTTON: - playback.CancelSeeking(); - break; - case IDC_BRANCHES_BUTTON: - // click on "Bookmarks/Branches" - switch between Bookmarks List and Branches Tree - taseditor_config.view_branches_tree ^= 1; - bookmarks.RedrawBookmarksCaption(); - break; case IDC_RECORDING: FCEUI_MovieToggleReadOnly(); CheckDlgButton(taseditor_window.hwndTasEditor, IDC_RECORDING, movie_readonly?BST_UNCHECKED : BST_CHECKED); @@ -1340,13 +1334,33 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara DialogBox(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_ABOUT), taseditor_window.hwndTasEditor, AboutProc); break; case ACCEL_HOME: - // scroll Piano Roll to the beginning - ListView_Scroll(piano_roll.hwndList, 0, -piano_roll.list_row_height * ListView_GetTopIndex(piano_roll.hwndList)); + { + if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_UPPER) + SendMessage(playback.hwndPlaybackMarkerEdit, EM_SETSEL, 0, 0); + else if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_LOWER) + SendMessage(selection.hwndSelectionMarkerEdit, EM_SETSEL, 0, 0); + else + // scroll Piano Roll to the beginning + ListView_Scroll(piano_roll.hwndList, 0, -piano_roll.list_row_height * ListView_GetTopIndex(piano_roll.hwndList)); break; + } case ACCEL_END: - // scroll Piano Roll to the end - ListView_Scroll(piano_roll.hwndList, 0, piano_roll.list_row_height * currMovieData.getNumRecords()); + { + if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_UPPER) + { + SendMessage(playback.hwndPlaybackMarkerEdit, EM_SETSEL, 0, -1); + SendMessage(playback.hwndPlaybackMarkerEdit, EM_SETSEL, -1, -1); + } else if (markers_manager.marker_note_edit == MARKER_NOTE_EDIT_LOWER) + { + SendMessage(selection.hwndSelectionMarkerEdit, EM_SETSEL, 0, -1); + SendMessage(selection.hwndSelectionMarkerEdit, EM_SETSEL, -1, -1); + } else + { + // scroll Piano Roll to the end + ListView_Scroll(piano_roll.hwndList, 0, piano_roll.list_row_height * currMovieData.getNumRecords()); + } break; + } case ACCEL_PGUP: // scroll Piano Roll 1 page up ListView_Scroll(piano_roll.hwndList, 0, -piano_roll.list_row_height * ListView_GetCountPerPage(piano_roll.hwndList)); @@ -1531,6 +1545,10 @@ LRESULT APIENTRY IDC_PROGRESS_BUTTON_WndProc(HWND hWnd, UINT msg, WPARAM wParam, { switch(msg) { + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + playback.CancelSeeking(); + return 0; case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: playback.MiddleButtonClick(); @@ -1544,6 +1562,12 @@ LRESULT APIENTRY IDC_BRANCHES_BUTTON_WndProc(HWND hWnd, UINT msg, WPARAM wParam, { switch(msg) { + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + // click on "Bookmarks/Branches" - switch between Bookmarks List and Branches Tree + taseditor_config.view_branches_tree ^= 1; + bookmarks.RedrawBookmarksCaption(); + return 0; case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: playback.MiddleButtonClick();