Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2014-10-25 20:35:20 +0400
committerKacper Michajłow <kasper93@gmail.com>2014-10-27 00:59:45 +0300
commitddd41ee36326550f35b3934ab270b7c4a2f8e6dd (patch)
tree504874df3f7d86669dd0764963a4e845c7db8242
parentc1a0d5ccaece39f2353046370ba2d18ff9736538 (diff)
Position context menus below selected item or in top left corner of the
window when they are triggered by App key. Fixes #4995
-rw-r--r--docs/Changelog.txt1
-rw-r--r--src/mpc-hc/PPageInternalFilters.cpp12
-rw-r--r--src/mpc-hc/PlayerNavigationDialog.cpp21
-rw-r--r--src/mpc-hc/PlayerPlaylistBar.cpp37
4 files changed, 55 insertions, 16 deletions
diff --git a/docs/Changelog.txt b/docs/Changelog.txt
index 03879f2e5..3a5b95745 100644
--- a/docs/Changelog.txt
+++ b/docs/Changelog.txt
@@ -45,6 +45,7 @@ next version - not released yet
would reduce the size of the main window when hiding the panel from the "View" menu
! Ticket #4993, DVB: The content of the "Information" panel was lost when changing the UI language
! Ticket #4994, The "Channels" sub-menu was not translated
+! Ticket #4995, Some context menus weren't properly positioned when opened by App key
1.7.7 - 05 October 2014
diff --git a/src/mpc-hc/PPageInternalFilters.cpp b/src/mpc-hc/PPageInternalFilters.cpp
index 0232e556f..49cd2ae25 100644
--- a/src/mpc-hc/PPageInternalFilters.cpp
+++ b/src/mpc-hc/PPageInternalFilters.cpp
@@ -116,21 +116,25 @@ void CPPageInternalFiltersListBox::UpdateCheckState()
void CPPageInternalFiltersListBox::OnContextMenu(CWnd* pWnd, CPoint point)
{
+ BOOL bOutside;
+
if (point.x == -1 && point.y == -1) {
// The context menu was triggered using the keyboard,
// get the coordinates of the currently selected item.
int iSel = GetCurSel();
CRect r;
- if (iSel != LB_ERR && GetItemRect(iSel, &r) != LB_ERR) {
- point = r.TopLeft();
+ if (GetItemRect(iSel, &r) != LB_ERR) {
+ point.SetPoint(r.left, r.bottom);
+ } else {
+ point.SetPoint(0, 0);
}
+ bOutside = iSel == LB_ERR;
} else {
ScreenToClient(&point);
+ ItemFromPoint(point, bOutside);
}
// Check that we really inside the list
- BOOL bOutside = TRUE;
- ItemFromPoint(point, bOutside);
if (bOutside) {
// Trigger the default behavior
ClientToScreen(&point);
diff --git a/src/mpc-hc/PlayerNavigationDialog.cpp b/src/mpc-hc/PlayerNavigationDialog.cpp
index c4998013f..a7b2f42ba 100644
--- a/src/mpc-hc/PlayerNavigationDialog.cpp
+++ b/src/mpc-hc/PlayerNavigationDialog.cpp
@@ -178,12 +178,27 @@ void CPlayerNavigationDialog::OnTvRadioStations()
void CPlayerNavigationDialog::OnContextMenu(CWnd* pWnd, CPoint point)
{
auto& s = AfxGetAppSettings();
- CPoint clientPoint = point;
- m_channelList.ScreenToClient(&clientPoint);
BOOL bOutside;
- const int nItem = (int)m_channelList.ItemFromPoint(clientPoint, bOutside);
+ int nItem;
const int curSel = m_channelList.GetCurSel();
const int channelCount = m_channelList.GetCount();
+
+ if (point.x == -1 && point.y == -1) {
+ CRect r;
+ if (m_channelList.GetItemRect(curSel, r) != LB_ERR) {
+ point.SetPoint(r.left, r.bottom);
+ } else {
+ point.SetPoint(0, 0);
+ }
+ m_channelList.ClientToScreen(&point);
+ nItem = curSel;
+ bOutside = nItem == LB_ERR;
+ } else {
+ CPoint clientPoint = point;
+ m_channelList.ScreenToClient(&clientPoint);
+ nItem = (int)m_channelList.ItemFromPoint(clientPoint, bOutside);
+ }
+
CMenu m;
m.CreatePopupMenu();
diff --git a/src/mpc-hc/PlayerPlaylistBar.cpp b/src/mpc-hc/PlayerPlaylistBar.cpp
index 734e59c35..ef1a76a07 100644
--- a/src/mpc-hc/PlayerPlaylistBar.cpp
+++ b/src/mpc-hc/PlayerPlaylistBar.cpp
@@ -1356,17 +1356,36 @@ BOOL CPlayerPlaylistBar::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResul
void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
{
LVHITTESTINFO lvhti;
- lvhti.pt = p;
- m_list.ScreenToClient(&lvhti.pt);
- m_list.SubItemHitTest(&lvhti);
- POSITION pos = FindPos(lvhti.iItem);
- bool bOnItem = !!(lvhti.flags & LVHT_ONITEM);
- if (!bOnItem && m_pl.GetSize() == 1) {
- bOnItem = true;
- pos = m_pl.GetHeadPosition();
- lvhti.iItem = 0;
+ bool bOnItem;
+ if (p.x == -1 && p.y == -1) {
+ lvhti.iItem = m_list.GetSelectionMark();
+
+ if (lvhti.iItem == -1 && m_pl.GetSize() == 1) {
+ lvhti.iItem = 0;
+ }
+
+ CRect r;
+ if (!!m_list.GetItemRect(lvhti.iItem, r, LVIR_BOUNDS)) {
+ p.SetPoint(r.left, r.bottom);
+ bOnItem = true;
+ } else {
+ p.SetPoint(0, 0);
+ }
+ m_list.ClientToScreen(&p);
+ bOnItem = lvhti.iItem != -1;
+ } else {
+ lvhti.pt = p;
+ m_list.ScreenToClient(&lvhti.pt);
+ m_list.SubItemHitTest(&lvhti);
+ bOnItem = !!(lvhti.flags & LVHT_ONITEM);
+ if (!bOnItem && m_pl.GetSize() == 1) {
+ bOnItem = true;
+ lvhti.iItem = 0;
+ }
}
+
+ POSITION pos = FindPos(lvhti.iItem);
bool bIsLocalFile = bOnItem ? FileExists(m_pl.GetAt(pos).m_fns.GetHead()) : false;
CMenu m;