soc.2009.vulture: 7347d623: Fixes to node-aliasing UI problems cause...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Tue Aug 4 16:06:46 EDT 2009


-----------------------------------------------------------------
Revision: 7347d623351d45184e8b1f27b0e638509e1167d6
Ancestor: f58e7eddac05e1d15a5cde153ceee0aa395732e4
Author: gdick at soc.pidgin.im
Date: 2009-08-03T15:22:59
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/7347d623351d45184e8b1f27b0e638509e1167d6

Modified files:
        vulture/purpleblist.c vulture/vultureblist.c
        vulture/vultureblist.h

ChangeLog: 

Fixes to node-aliasing UI problems caused by custom draw.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	346020b1270353d12bc8e3b11f7c7be4fece456e
+++ vulture/purpleblist.c	358fceb92083a5be00be4c3ecd64f31e254f9be4
@@ -79,6 +79,7 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 		lpvbn->szStatusText = NULL;
 		lpvbn->iStatusIcon = 0;
 		lpvbn->ui.bIconCacheValid = FALSE;
+		lpvbn->ui.editnodestate = VENS_NOEDIT;
 		InitializeCriticalSection(&lpvbn->cs);
 	}
 
============================================================
--- vulture/vultureblist.c	2bbc69fe7564c2520d1185cfc889ba09a6ca09ef
+++ vulture/vultureblist.c	cd2c4f55c1ba2d92df1e12cb4ed7149b88dedcc8
@@ -697,20 +697,42 @@ static INT_PTR CALLBACK BuddyListDlgProc
 
 						VULTURE_ALIAS_NODE valiasnode;
 						LPNMTVDISPINFO lpnmtvdispinfo = (LPNMTVDISPINFO)lParam;
+						VULTURE_BLIST_NODE *lpvblistnode = (VULTURE_BLIST_NODE*)lpnmtvdispinfo->item.lParam;
 
 						/* Make sure editing wasn't
 						 * cancelled.
 						 */
 						if(lpnmtvdispinfo->item.pszText)
 						{
-							valiasnode.lpvblistnode = (VULTURE_BLIST_NODE*)lpnmtvdispinfo->item.lParam;
+							valiasnode.lpvblistnode = lpvblistnode;
 							valiasnode.szAlias = lpnmtvdispinfo->item.pszText;
 							VultureSingleSyncPurpleCall(PC_ALIASNODE, &valiasnode);
 						}
+
+						lpvblistnode->ui.editnodestate = VENS_NOEDIT;
 					}
 
 					return TRUE;
 
+				case TVN_BEGINLABELEDIT:
+					{
+						VULTURE_BLIST_NODE *lpvblistnode = (VULTURE_BLIST_NODE*)((LPNMTVDISPINFO)lParam)->item.lParam;
+
+						if(lpvblistnode->ui.editnodestate == VENS_PREEDIT)
+						{
+							SetWindowText(TreeView_GetEditControl(lpnmhdr->hwndFrom), lpvblistnode->szNodeText);
+							lpvblistnode->ui.editnodestate = VENS_EDIT;
+							SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, FALSE);
+						}
+						else
+						{
+							/* No secret handshake, no label edit! */
+							SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+						}
+					}
+
+					return TRUE;
+
 				case NM_CUSTOMDRAW:
 					{
 						LPNMTVCUSTOMDRAW lpnmtvcdraw = (LPNMTVCUSTOMDRAW)lParam;
@@ -1055,6 +1077,7 @@ static BOOL RunCommonMenuCmd(HWND hwndBu
 		return TRUE;
 
 	case IDM_BLIST_CONTEXT_ALIAS:
+		lpvblistnode->ui.editnodestate = VENS_PREEDIT;
 		SendMessage(hwndBuddies, TVM_EDITLABEL, 0, (LPARAM)lpvblistnode->hti);
 		return TRUE;
 
@@ -1270,7 +1293,7 @@ static void DrawBListNodeExtra(LPNMTVCUS
 	EnterCriticalSection(&lpvblistnode->cs);
 	{
 		/* Draw status icon. */
-		if(lpvblistnode->nodetype != PURPLE_BLIST_GROUP_NODE)
+		if(lpvblistnode->nodetype != PURPLE_BLIST_GROUP_NODE && lpvblistnode->ui.editnodestate != VENS_EDIT)
 		{
 			int xIcon = rcText.left;
 			int yIcon = (rcText.bottom + rcText.top - CY_STATUSICON) / 2;
@@ -1349,30 +1372,33 @@ static void DrawBListNodeExtra(LPNMTVCUS
 			DeleteDC(hdcMem);
 		}
 
-		if(lpvblistnode->szStatusText &&
-			((lpvblistnode->nodetype == PURPLE_BLIST_CONTACT_NODE && !lpvblistnode->bExpanded) ||
-			lpvblistnode->nodetype == PURPLE_BLIST_BUDDY_NODE))
+		if(lpvblistnode->ui.editnodestate != VENS_EDIT)
 		{
-			HTREEITEM htiSel, htiDrop;
+			if(lpvblistnode->szStatusText &&
+				((lpvblistnode->nodetype == PURPLE_BLIST_CONTACT_NODE && !lpvblistnode->bExpanded) ||
+				lpvblistnode->nodetype == PURPLE_BLIST_BUDDY_NODE))
+			{
+				HTREEITEM htiSel, htiDrop;
 
-			/* Render main text. */
-			if(lpvblistnode->szNodeText)
-				DrawText(lpnmtvcdraw->nmcd.hdc, lpvblistnode->szNodeText, -1, &rcText, DT_END_ELLIPSIS | DT_SINGLELINE);
+				/* Render main text. */
+				if(lpvblistnode->szNodeText)
+					DrawText(lpnmtvcdraw->nmcd.hdc, lpvblistnode->szNodeText, -1, &rcText, DT_END_ELLIPSIS | DT_SINGLELINE);
 
-			/* Render secondary text. */
-			htiSel = TreeView_GetSelection(lpnmtvcdraw->nmcd.hdr.hwndFrom);
-			htiDrop = TreeView_GetDropHilight(lpnmtvcdraw->nmcd.hdr.hwndFrom);
-			if(htiDrop != (HTREEITEM)lpnmtvcdraw->nmcd.dwItemSpec &&
-				 (htiSel != (HTREEITEM)lpnmtvcdraw->nmcd.dwItemSpec || htiDrop != NULL))
-				SetTextColor(lpnmtvcdraw->nmcd.hdc, 0x808080);
-			DrawText(lpnmtvcdraw->nmcd.hdc, lpvblistnode->szStatusText, -1, &rcText, DT_BOTTOM | DT_END_ELLIPSIS | DT_SINGLELINE);
+				/* Render secondary text. */
+				htiSel = TreeView_GetSelection(lpnmtvcdraw->nmcd.hdr.hwndFrom);
+				htiDrop = TreeView_GetDropHilight(lpnmtvcdraw->nmcd.hdr.hwndFrom);
+				if(htiDrop != (HTREEITEM)lpnmtvcdraw->nmcd.dwItemSpec &&
+					 (htiSel != (HTREEITEM)lpnmtvcdraw->nmcd.dwItemSpec || htiDrop != NULL))
+					SetTextColor(lpnmtvcdraw->nmcd.hdc, 0x808080);
+				DrawText(lpnmtvcdraw->nmcd.hdc, lpvblistnode->szStatusText, -1, &rcText, DT_BOTTOM | DT_END_ELLIPSIS | DT_SINGLELINE);
+			}
+			else
+			{
+				/* No secondary text; render main text only. */
+				if(lpvblistnode->szNodeText)
+					DrawText(lpnmtvcdraw->nmcd.hdc, lpvblistnode->szNodeText, -1, &rcText, DT_VCENTER | DT_END_ELLIPSIS | DT_SINGLELINE);
+			}
 		}
-		else
-		{
-			/* No secondary text; render main text only. */
-			if(lpvblistnode->szNodeText)
-				DrawText(lpnmtvcdraw->nmcd.hdc, lpvblistnode->szNodeText, -1, &rcText, DT_VCENTER | DT_END_ELLIPSIS | DT_SINGLELINE);
-		}
 	}
 	LeaveCriticalSection(&lpvblistnode->cs);
 
============================================================
--- vulture/vultureblist.h	3efbb54c59c0255137701386c423d0a0aa23cc68
+++ vulture/vultureblist.h	9113d855c390713869a4274f32a4607866c67171
@@ -30,6 +30,13 @@
 #include "purple.h"
 
 
+typedef enum _VULTURE_EDIT_NODE_STATE
+{
+	VENS_NOEDIT,
+	VENS_PREEDIT,
+	VENS_EDIT
+} VULTURE_EDIT_NODE_STATE;
+
 typedef struct _VULTURE_BLIST_NODE
 {
 	PurpleBlistNode			*lpblistnode;
@@ -46,6 +53,8 @@ typedef struct _VULTURE_BLIST_NODE
 	{
 		HBITMAP			hbmIconCache;
 		BOOL			bIconCacheValid;
+		VULTURE_EDIT_NODE_STATE	editnodestate;
+		POINT			ptText;
 	} ui;
 
 	/* For contacts and buddies. */


More information about the Commits mailing list