[commit] r2770 - trunk/GME/ObjectInspector

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Dec 28 14:27:16 CST 2018


Author: ksmyth
Date: Fri Dec 28 14:27:16 2018
New Revision: 2770

Log:
ObjectInspector: render booleans as checkbox. Toggle focused boolean with enter or space. Steal focus back after Ctrl-D or Del. Keep showing help text after Mga transaction commit.

Modified:
   trunk/GME/ObjectInspector/InPlaceManager.cpp
   trunk/GME/ObjectInspector/InspectorDefs.h
   trunk/GME/ObjectInspector/InspectorList.cpp

Modified: trunk/GME/ObjectInspector/InPlaceManager.cpp
==============================================================================
--- trunk/GME/ObjectInspector/InPlaceManager.cpp	Fri Dec 28 14:27:12 2018	(r2769)
+++ trunk/GME/ObjectInspector/InPlaceManager.cpp	Fri Dec 28 14:27:16 2018	(r2770)
@@ -120,9 +120,6 @@
 		}break;
 	case ITEMDATA_BOOLEAN:
 		{
-			if(!ListItem.bIsReadOnly) {
-				DisplayArrowButton(rectInPlace);
-			}
 		}break;
 
 	case ITEMDATA_COLOR	:
@@ -553,15 +550,10 @@
 			DisplayCompassOpt(rectWnd);
 		}break;
 
-	case ITEMDATA_BOOLEAN:
-		{
-			rectWnd.bottom += 2 * m_pInspectorList->m_ComboboxLineHeight + 2;
-			DisplayCombo(rectWnd);
-		}break;
 	case ITEMDATA_FIXED_LIST:
 		{
 			rectWnd.bottom += min((long)ListItem.Value.stringVal.GetSize(), 8) 
-				* m_pInspectorList->m_ComboboxLineHeight + 2;
+				* m_pInspectorList->m_ComboboxLineHeight + 2; // FIXME this magic number is wrong on high-DPI displays (e.g GetDeviceCaps(LOGPIXELSY) == 144)
 			DisplayCombo(rectWnd);
 		}break;
 

Modified: trunk/GME/ObjectInspector/InspectorDefs.h
==============================================================================
--- trunk/GME/ObjectInspector/InspectorDefs.h	Fri Dec 28 14:27:12 2018	(r2769)
+++ trunk/GME/ObjectInspector/InspectorDefs.h	Fri Dec 28 14:27:16 2018	(r2770)
@@ -33,6 +33,8 @@
 
 #define INSP_COLORBOX_SIZE				13
 #define INSP_COLORBOX_MARGIN			 2
+// FIXME is this right
+#define INSP_CHECKBOX_SIZE				13
 
 #define AUTOROUTER_SOURCE		0x01
 #define AUTOROUTER_DESTINATION	0x02

Modified: trunk/GME/ObjectInspector/InspectorList.cpp
==============================================================================
--- trunk/GME/ObjectInspector/InspectorList.cpp	Fri Dec 28 14:27:12 2018	(r2769)
+++ trunk/GME/ObjectInspector/InspectorList.cpp	Fri Dec 28 14:27:16 2018	(r2770)
@@ -268,6 +268,21 @@
 								rectText.right,rectText.bottom),
 				DT_LEFT | DT_SINGLELINE);
 			}
+			else if (ListItem.Value.dataType == ITEMDATA_BOOLEAN) {
+				CRect rectColorBox(rectRight);
+				rectColorBox.left += INSP_COLORBOX_MARGIN;
+				rectColorBox.right = rectColorBox.left + INSP_CHECKBOX_SIZE;
+				rectColorBox.top = rectColorBox.top + (rectColorBox.Height() - INSP_CHECKBOX_SIZE) / 2 - 1;
+				rectColorBox.bottom = rectColorBox.top + INSP_CHECKBOX_SIZE;
+				dc.DrawFrameControl(rectColorBox, DFC_BUTTON, DFCS_BUTTONCHECK | (ListItem.Value.boolVal ? DFCS_CHECKED : 0));
+
+				CRect rectText(rectRight);
+				rectText.left = rectColorBox.right + 2 * INSP_COLORBOX_MARGIN;
+
+				dc.DrawText(strTxt, CRect(rectText.left, rectText.top,
+					rectText.right, rectText.bottom),
+					DT_LEFT | DT_SINGLELINE);
+			}
 			else if(ListItem.Value.dataType==ITEMDATA_STRING&&ListItem.Value.cLineNum>1)
 			{
 				// Multiline string
@@ -443,6 +458,38 @@
 		// Redraw listbox
 		Invalidate();
 	}
+
+
+	BOOL bOutside;
+	int nIndex = ItemFromPoint(point, bOutside);
+
+	if (!bOutside)
+	{
+		CRect rectItem;
+		GetItemRect(nIndex, rectItem);
+
+		CRect rectRight(rectItem);
+		rectRight.left = m_Settings.m_nDivider;
+
+		if (rectRight.PtInRect(point))
+		{
+			int cxDrag = GetSystemMetrics(SM_CXDRAG);
+			int cyDrag = GetSystemMetrics(SM_CYDRAG);
+			int nIndexMouseDown = ItemFromPoint(point, bOutside);
+			if (!bOutside && nIndex == nIndexMouseDown && abs(m_ptOldTop.x - point.x) <= cxDrag && abs(m_ptOldTop.y - point.y) <= cyDrag)
+			{
+				CListItem& ListItem = m_ListItemArray[nIndex];
+				if (ListItem.Value.dataType == ITEMDATA_BOOLEAN) {
+					ListItem.Value.SetBoolValue(!ListItem.Value.boolVal);
+					ListItem.SetDirty();
+					NotifyParent(nIndex);
+					SetFocus();
+					return;
+				}
+			}
+		}
+	}
+
 	CListBox::OnLButtonUp(nFlags, point);
 }
 
@@ -855,6 +902,8 @@
 
 		if(rectRight.PtInRect(point))
 		{
+			m_ptOldTop.y = point.y;
+			m_ptOldTop.x = point.x;
 			return m_InPlaceManager.OnRightItemClick(nIndex, rectRight);
 		}
 	}
@@ -955,6 +1004,7 @@
 				{
 					SetDefault();
 					Invalidate();
+					SetFocus();
 
 				}
 			}
@@ -963,6 +1013,7 @@
 			{
 				SetDefault();
 				Invalidate();
+				SetFocus();
 			}
 			break;
 		case VK_TAB:	// JIRA GME-178
@@ -970,6 +1021,30 @@
 				SelectNextItem(::GetKeyState(VK_SHIFT) & 0x8000);
 			}
 			break;
+		case VK_SPACE:
+		case VK_RETURN:
+		{
+			int nSelCount = GetSelCount();
+
+			CArray<int, int> IndexArray;
+			if (nSelCount > 0)
+			{
+				IndexArray.SetSize(nSelCount);
+				CListBox::GetSelItems(nSelCount, IndexArray.GetData());
+			}
+			for (int i = 0; i < nSelCount; i++) {
+				int nIndex = IndexArray[i];
+				CListItem& ListItem = m_ListItemArray[nIndex];
+				if (ListItem.Value.dataType == ITEMDATA_BOOLEAN) {
+					ListItem.Value.SetBoolValue(!ListItem.Value.boolVal);
+					ListItem.SetDirty();
+					NotifyParent(nIndex);
+					SetFocus();
+				}
+				else if (ListItem.Value.dataType == ITEMDATA_FIXED_LIST) {
+				}
+			}
+		}
 	}
 
 	CListBox::OnKeyDown(nChar, nRepCnt, nFlags);
@@ -1145,7 +1220,18 @@
 
 void CInspectorList::RefreshState()
 {
-	SetHelp(-1);
+	int nSelCount = GetSelCount();
+
+	if (nSelCount<1)
+	{
+		SetHelp(-1);
+	}
+	else
+	{
+		int nSelected;
+		CListBox::GetSelItems(1, &nSelected);
+		SetHelp(nSelected);
+	}
 	// PETER: Removed beacuse of JIRA #GME-64
 	// OnSelChange();
 }


More information about the gme-commit mailing list