From 518e2272a0c6717a45469088d86747b78486f3fc Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 19 Feb 2006 01:16:15 +0000 Subject: [PATCH] More fixes and tweaks to new grid Originally committed to SVN as r68. --- core/base_grid.cpp | 18 +++++++++++++++--- core/frame_main.cpp | 23 +++++++---------------- core/frame_main.h | 3 +-- core/subs_grid.cpp | 28 ---------------------------- 4 files changed, 23 insertions(+), 49 deletions(-) diff --git a/core/base_grid.cpp b/core/base_grid.cpp index f4bb91dbb..bb58c128b 100644 --- a/core/base_grid.cpp +++ b/core/base_grid.cpp @@ -177,6 +177,18 @@ bool BaseGrid::IsInSelection(int row, int col) const { } +/////////////////////////// +// Number of selected rows +int BaseGrid::GetNumberSelection() { + int count = 0; + int rows = selMap.size(); + for (int i=0;iSetSelectionFlag(GetNumberSelection()); + parentFrame->UpdateToolbar(); return; } @@ -515,7 +527,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) { if (click && !shift && !ctrl && !alt) { editBox->SetToLine(row); SelectRow(row,false); - parentFrame->SetSelectionFlag(GetNumberSelection()); + parentFrame->UpdateToolbar(); lastRow = row; return; } @@ -538,7 +550,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) { SelectRow(i,notFirst,true); notFirst = true; } - parentFrame->SetSelectionFlag(GetNumberSelection()); + parentFrame->UpdateToolbar(); } return; } diff --git a/core/frame_main.cpp b/core/frame_main.cpp index a1b9538a0..469afe398 100644 --- a/core/frame_main.cpp +++ b/core/frame_main.cpp @@ -390,6 +390,7 @@ void FrameMain::UpdateToolbar() { // Collect flags bool isVideo = (curMode == 1) || (curMode == 2); HasSelection = true; + int selRows = SubsBox->GetNumberSelection(); // Update wxToolBar* toolbar = GetToolBar(); @@ -397,13 +398,13 @@ void FrameMain::UpdateToolbar() { toolbar->FindById(Menu_Video_Zoom_In)->Enable(isVideo); toolbar->FindById(Menu_Video_Zoom_Out)->Enable(isVideo); ZoomBox->Enable(isVideo); - toolbar->FindById(Menu_Subs_Snap_Start_To_Video)->Enable(isVideo && HasSelection); - toolbar->FindById(Menu_Subs_Snap_End_To_Video)->Enable(isVideo && HasSelection); - toolbar->FindById(Menu_Subs_Snap_Video_To_Start)->Enable(isVideo && HasSelection); - toolbar->FindById(Menu_Subs_Snap_Video_To_End)->Enable(isVideo && HasSelection); + toolbar->FindById(Menu_Subs_Snap_Start_To_Video)->Enable(isVideo && selRows > 0); + toolbar->FindById(Menu_Subs_Snap_End_To_Video)->Enable(isVideo && selRows > 0); + toolbar->FindById(Menu_Subs_Snap_Video_To_Start)->Enable(isVideo && selRows == 1); + toolbar->FindById(Menu_Subs_Snap_Video_To_End)->Enable(isVideo && selRows == 1); toolbar->FindById(Menu_Video_Select_Visible)->Enable(isVideo); - toolbar->FindById(Menu_Video_Snap_To_Scene)->Enable(isVideo && HasSelection); - toolbar->FindById(Menu_Video_Shift_To_Frame)->Enable(isVideo && HasSelection); + toolbar->FindById(Menu_Video_Snap_To_Scene)->Enable(isVideo && selRows > 0); + toolbar->FindById(Menu_Video_Shift_To_Frame)->Enable(isVideo && selRows > 0); toolbar->Realize(); } @@ -946,16 +947,6 @@ void FrameMain::OpenHelp(wxString page) { } -////////////////////// -// Set selection flag -void FrameMain::SetSelectionFlag(bool sel) { - if (HasSelection != sel) { - HasSelection = sel; - UpdateToolbar(); - } -} - - ///////////////// // Get encodings wxArrayString FrameMain::GetEncodings() { diff --git a/core/frame_main.h b/core/frame_main.h index 72c2d27e4..68f82a824 100644 --- a/core/frame_main.h +++ b/core/frame_main.h @@ -212,7 +212,6 @@ private: void AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp); wxMenuItem *RebuildMenuItem(wxMenu *menu,int id,wxBitmap bmp1,wxBitmap bmp2,bool state); void MenuItemEnable(int id,bool state,wxBitmap &bmp1,wxBitmap &bmp2); - void UpdateToolbar(); void SynchronizeProject(bool FromSubs=false); public: @@ -228,11 +227,11 @@ public: static void OpenHelp(wxString page=_T("")); static wxArrayString GetEncodings(); void UpdateTitle(); - void SetSelectionFlag (bool HasSelection); void StatusTimeout(wxString text,int ms=10000); void SetAccelerators(); void InitMenu(); + void UpdateToolbar(); DECLARE_EVENT_TABLE() }; diff --git a/core/subs_grid.cpp b/core/subs_grid.cpp index 0ea499007..ef51e148e 100644 --- a/core/subs_grid.cpp +++ b/core/subs_grid.cpp @@ -55,10 +55,7 @@ /////////////// // Event table BEGIN_EVENT_TABLE(SubtitlesGrid, BaseGrid) - EVT_GRID_CELL_LEFT_CLICK(SubtitlesGrid::OnCellLeftClick) - EVT_GRID_SELECT_CELL(SubtitlesGrid::OnSelectCell) EVT_KEY_DOWN(SubtitlesGrid::OnKeyDown) - EVT_MENU(MENU_SWAP,SubtitlesGrid::OnSwap) EVT_MENU(MENU_DUPLICATE,SubtitlesGrid::OnDuplicate) EVT_MENU(MENU_DUPLICATE_NEXT_FRAME,SubtitlesGrid::OnDuplicateNextFrame) @@ -800,31 +797,6 @@ void SubtitlesGrid::On112Recombine(wxCommandEvent &event) { } -/////////////////// -// Cell left click -void SubtitlesGrid::OnCellLeftClick (wxGridEvent &event) { - //SetGridCursor(GetGridCursorRow(),0); - event.Skip(); -} - - -///////////////////////// -// Cell change selection -void SubtitlesGrid::OnSelectCell(wxGridEvent &event) { - int row = event.GetRow(); - - // Update editbox - if (editBox && event.Selecting() && ready) { - editBox->SetToLine(row); - } - - // Update parent - parentFrame->SetSelectionFlag(row >= 0); - - event.Skip(); -} - - ////////////////////////////////////// // Clears grid and sets it to default void SubtitlesGrid::LoadDefault (AssFile *_ass) {