Browse Source

Added option to center the window under the curor or caret instead of to the right (#753)

sabrogden 11 months ago
parent
commit
d4587da419
4 changed files with 37 additions and 1 deletions
  1. 9 0
      AdvGeneral.cpp
  2. 14 1
      Options.cpp
  3. 5 0
      Options.h
  4. 9 0
      QuickPaste.cpp

+ 9 - 0
AdvGeneral.cpp

@@ -145,6 +145,7 @@ END_MESSAGE_MAP()
 #define SETTING_IGNORE_ANNOYING_CF_DIB 94
 #define SETTING_REGEX_CASE_INSENSITIVE 95
 #define SETTING_DRAW_COPIED_COLOR_CODE 96
+#define SETTING_CENTER_WINDOW_BELOW_CURSOR_CARET 97
 
 BOOL CAdvGeneral::OnInitDialog()
 {
@@ -183,6 +184,7 @@ BOOL CAdvGeneral::OnInitDialog()
 
 	AddTrueFalse(pGroupTest, _T("Always show scroll bar"), CGetSetOptions::GetShowScrollBar(), SETTING_ALWAYS_SHOW_SCROLL_BAR);
 	pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Amount of text to save for description"), g_Opt.m_bDescTextSize, _T(""), SETTING_DESC_SIZE));
+	AddTrueFalse(pGroupTest, _T("Center window below cursor or caret"), CGetSetOptions::GetCenterWindowBelowCursorOrCaret(), SETTING_CENTER_WINDOW_BELOW_CURSOR_CARET);
 	pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Copy and save clipboard delay (ms)"), (long)CGetSetOptions::GetCopyAndSveDelay(), _T(""), SETTING_COPY_SAVE_DELAY));
 	pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Clipboard restore delay after copy buffer sent paste (ms, default: 750)"), (long)(CGetSetOptions::GetDittoRestoreClipboardDelay()), _T(""), SETTING_CLIPBOARD_RESTORE_AFTER_COPY_BUFFER_DELAY));
 
@@ -849,6 +851,13 @@ void CAdvGeneral::OnBnClickedOk()
 					CGetSetOptions::SetDrawCopiedColorCode(val);
 				}
 				break;
+			case SETTING_CENTER_WINDOW_BELOW_CURSOR_CARET:
+				if (wcscmp(pNewValue->bstrVal, pOrigValue->bstrVal) != 0)
+				{
+					BOOL val = wcscmp(pNewValue->bstrVal, L"True") == 0;
+					CGetSetOptions::SetCenterWindowBelowCursorOrCaret(val);
+				}
+				break;
 			}
 		}
 	}

+ 14 - 1
Options.cpp

@@ -45,6 +45,7 @@ BOOL CGetSetOptions::m_HideDittoOnHotKeyIfAlreadyShown;
 long CGetSetOptions::m_lPort;
 BOOL CGetSetOptions::m_bDrawThumbnail;
 BOOL CGetSetOptions::m_bDrawCopiedColorCode;
+BOOL CGetSetOptions::m_centerWindowBelowCursorOrCaret;
 BOOL CGetSetOptions::m_bFastThumbnailMode;
 CStringA CGetSetOptions::m_csPassword;
 BOOL CGetSetOptions::m_bDrawRTF;
@@ -265,6 +266,7 @@ void CGetSetOptions::LoadSettings()
 	m_lPort = GetPort();
 	m_bDrawThumbnail = GetDrawThumbnail();
 	m_bDrawCopiedColorCode = GetDrawCopiedColorCode();
+	m_centerWindowBelowCursorOrCaret = GetCenterWindowBelowCursorOrCaret();
 	m_bFastThumbnailMode = GetFastThumbnailMode();
 	m_csPassword = GetNetworkPassword();
 	m_bDrawRTF = GetDrawRTF();
@@ -3110,6 +3112,17 @@ void CGetSetOptions::SetDrawCopiedColorCode(long bDraw)
 BOOL CGetSetOptions::GetDrawCopiedColorCode()
 {
 	BOOL drawCopiedColorCode = TRUE;
-
 	return GetProfileLong("DrawCopiedColorCode", drawCopiedColorCode);
+}
+
+void CGetSetOptions::SetCenterWindowBelowCursorOrCaret(BOOL center)
+{
+	SetProfileLong("CenterWindowBelowCursorOrCaret", center);
+	m_centerWindowBelowCursorOrCaret = center;
+}
+
+BOOL CGetSetOptions::GetCenterWindowBelowCursorOrCaret()
+{
+	BOOL centerWindowBelowCursorOrCaret = FALSE;
+	return GetProfileLong("CenterWindowBelowCursorOrCaret", centerWindowBelowCursorOrCaret);
 }

+ 5 - 0
Options.h

@@ -689,6 +689,11 @@ public:
 	static BOOL		m_bDrawCopiedColorCode;
 	static void		SetDrawCopiedColorCode(long bDraw);
 	static BOOL		GetDrawCopiedColorCode();
+
+
+	static BOOL m_centerWindowBelowCursorOrCaret;
+	static void SetCenterWindowBelowCursorOrCaret(BOOL center);
+	static BOOL GetCenterWindowBelowCursorOrCaret();
 };
 
 // global for easy access and for initialization of fast access variables

+ 9 - 0
QuickPaste.cpp

@@ -179,6 +179,10 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 	else if (nPosition == POS_AT_CARET)
 	{
 		point = ptCaret;
+		if (CGetSetOptions::m_centerWindowBelowCursorOrCaret)
+		{
+			point.x -= csSize.cx / 2;
+		}
 	}
 	else if (nPosition == POS_AT_CURSOR)
 	{
@@ -186,6 +190,11 @@ void CQuickPaste::ShowQPasteWnd(CWnd *pParent, bool bAtPrevPos, bool bFromKeyboa
 		//keep the mouse from showing the tooltip because if overlaps with the top corner
 		point.x += 2;
 		point.y += 2;
+
+		if (CGetSetOptions::m_centerWindowBelowCursorOrCaret)
+		{
+			point.x -= csSize.cx / 2;
+		}
 	}
 	else if(nPosition == POS_AT_PREVIOUS)
 		CGetSetOptions::GetQuickPastePoint(point);