From 5209c9f2ae1c4a430abf7025669e9969e7bff589 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 2 Aug 2016 18:04:37 +0200 Subject: [PATCH] Unbreak RefBroweser context menu Fixes a regression of commit a647def6f3bf080841c59ac8c40574ae87d23e25. Signed-off-by: Sven Strickroth --- src/TortoiseGitBlame/stdafx.h | 1 + src/TortoiseProc/BrowseRefsDlg.cpp | 13 ++++--------- src/TortoiseProc/ResizableColumnsListCtrl.h | 11 +++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/TortoiseGitBlame/stdafx.h b/src/TortoiseGitBlame/stdafx.h index 1c051ac06..8a97d9d12 100644 --- a/src/TortoiseGitBlame/stdafx.h +++ b/src/TortoiseGitBlame/stdafx.h @@ -54,6 +54,7 @@ #include #include #include +#include #define USE_GDI_GRADIENT #define HISTORYCOMBO_WITH_SYSIMAGELIST diff --git a/src/TortoiseProc/BrowseRefsDlg.cpp b/src/TortoiseProc/BrowseRefsDlg.cpp index 7edb8f2e8..0687ad90e 100644 --- a/src/TortoiseProc/BrowseRefsDlg.cpp +++ b/src/TortoiseProc/BrowseRefsDlg.cpp @@ -291,6 +291,7 @@ BOOL CBrowseRefsDlg::OnInitDialog() (1 << eCol_LastAuthor) | (1 << eCol_Hash) | (1 << eCol_Description); m_ListRefLeafs.m_bAllowHiding = false; m_ListRefLeafs.Init(); + m_ListRefLeafs.SetListContextMenuHandler([&](CPoint point) {OnContextMenu_ListRefLeafs(point); }); m_ListRefLeafs.m_ColumnManager.SetNames(columnNames, _countof(columnNames)); m_ListRefLeafs.m_ColumnManager.ReadSettings(dwDefaultColumns, 0, _T("BrowseRefs"), _countof(columnNames), columnWidths); m_bPickedRefSet = false; @@ -806,14 +807,8 @@ CString CBrowseRefsDlg::GetFullRefName(CString partialRefName) void CBrowseRefsDlg::OnContextMenu(CWnd* pWndFrom, CPoint point) { - if(pWndFrom==&m_RefTreeCtrl) OnContextMenu_RefTreeCtrl(point); - else if (pWndFrom == &m_ListRefLeafs) - { - CRect headerPosition; - m_ListRefLeafs.GetHeaderCtrl()->GetWindowRect(headerPosition); - if (!headerPosition.PtInRect(point)) - OnContextMenu_ListRefLeafs(point); - } + if (pWndFrom == &m_RefTreeCtrl) + OnContextMenu_RefTreeCtrl(point); } void CBrowseRefsDlg::OnContextMenu_RefTreeCtrl(CPoint point) @@ -1218,7 +1213,7 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh break; case eCmd_UnifiedDiff: { - CAppUtils::StartShowUnifiedDiff(nullptr, CTGitPath(), selectedLeafs[0]->m_csRefHash, CTGitPath(), selectedLeafs[1]->m_csRefHash); + CAppUtils::StartShowUnifiedDiff(nullptr, CTGitPath(), selectedLeafs[0]->m_csRefHash, CTGitPath(), selectedLeafs[1]->m_csRefHash, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000)); } break; case eCmd_EditBranchDescription: diff --git a/src/TortoiseProc/ResizableColumnsListCtrl.h b/src/TortoiseProc/ResizableColumnsListCtrl.h index ace5ae708..5cf58328f 100644 --- a/src/TortoiseProc/ResizableColumnsListCtrl.h +++ b/src/TortoiseProc/ResizableColumnsListCtrl.h @@ -67,6 +67,8 @@ protected: { if (pWnd == GetHeaderCtrl() && m_bAllowHiding) OnContextMenuHeader(pWnd, point); + else if (pWnd == this && m_ContextMenuHandler) + m_ContextMenuHandler(point); } // prevent users from extending our hidden (size 0) columns @@ -82,6 +84,9 @@ protected: Default(); } + typedef std::function ContextMenuHandler; + ContextMenuHandler m_ContextMenuHandler; + public: void Init() { @@ -91,6 +96,12 @@ public: exStyle |= LVS_EX_FULLROWSELECT; SetExtendedStyle(GetExtendedStyle() | exStyle); } + + void SetListContextMenuHandler(ContextMenuHandler pContextMenuHandler) + { + m_ContextMenuHandler = pContextMenuHandler; + } + void AdjustColumnWidths() { int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount() - 1; -- 2.11.4.GIT