Browse Source

基本优化完收银

张洋 1 month ago
parent
commit
a33e78c1c5

+ 32 - 44
DuiLib/Control/UIList.cpp

@@ -1422,11 +1422,11 @@ namespace DuiLib {
 
 				cyFixed += sz.cy + pControl->GetPadding().top + pControl->GetPadding().bottom;
 
-				RECT rcPadding = pControl->GetPadding();
 				sz.cx = MAX(sz.cx, 0);
 				if (sz.cx < pControl->GetMinWidth()) sz.cx = pControl->GetMinWidth();
 				if (sz.cx > pControl->GetMaxWidth()) sz.cx = pControl->GetMaxWidth();
 				cxNeeded = MAX(cxNeeded, sz.cx);
+
 				nEstimateNum++;
 			}
 
@@ -1448,11 +1448,15 @@ namespace DuiLib {
 				}
 			}
 
-			int cyNeeded = 0;
 			int cyExpand = 0;
-			if (nAdjustables > 0) cyExpand = MAX(0, (szAvailable.cy - cyFixed) / nAdjustables);
+			if (nAdjustables > 0)
+			{
+				cyExpand = MAX(0, (szAvailable.cy - cyFixed) / nAdjustables);
+			}
 
 			SIZE szRemaining = szAvailable;
+
+			// 可见布局坐标:受滚动条影响
 			int iPosY = rcWork.top;
 			if (m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible())
 			{
@@ -1468,10 +1472,15 @@ namespace DuiLib {
 			int iAdjustable = 0;
 			int cyFixedRemaining = cyFixed;
 
+			// 真实内容高度:不受滚动条影响
+			int iContentY = rcWork.top;
+			int nVisibleIndex = 0;
+
 			for (int it2 = 0; it2 < m_items.GetSize(); it2++)
 			{
 				CControlUI* pControl = static_cast<CControlUI*>(m_items[it2]);
 				if (!pControl->IsVisible()) continue;
+
 				if (pControl->IsFloat())
 				{
 					SetFloatPos(it2);
@@ -1480,6 +1489,7 @@ namespace DuiLib {
 
 				RECT rcPadding = pControl->GetPadding();
 				szRemaining.cy -= rcPadding.top;
+
 				SIZE sz = pControl->EstimateSize(szRemaining);
 
 				if (sz.cy == 0)
@@ -1510,14 +1520,22 @@ namespace DuiLib {
 					iPosX + rcPadding.left + sz.cx,
 					iPosY + sz.cy + rcPadding.top + rcPadding.bottom
 				};
+
 				pControl->SetPos(rcCtrl);
 
+				// 真实内容高度按未滚动坐标累计
+				iContentY += sz.cy + rcPadding.top + rcPadding.bottom;
+				nVisibleIndex++;
+				if (nVisibleIndex < nEstimateNum)
+				{
+					iContentY += iChildPadding;
+				}
+
 				iPosY += sz.cy + iChildPadding + rcPadding.top + rcPadding.bottom;
-				cyNeeded += sz.cy + rcPadding.top + rcPadding.bottom;
 				szRemaining.cy -= sz.cy + iChildPadding + rcPadding.bottom;
 			}
 
-			cyNeeded += (nEstimateNum - 1) * iChildPadding;
+			int cyNeeded = MAX(0, iContentY - rcWork.top);
 
 			if (m_pHorizontalScrollBar != NULL)
 			{
@@ -1545,24 +1563,6 @@ namespace DuiLib {
 				}
 			}
 
-			if (m_pOwner->GetListType() == LT_LIST)
-			{
-				int nItemCount = m_items.GetSize();
-				if (nItemCount > 0)
-				{
-					CControlUI* pControl = static_cast<CControlUI*>(m_items[0]);
-					int nFixedWidth = pControl->GetFixedWidth();
-					if (nFixedWidth > 0)
-					{
-						int nRank = (rcWork.right - rcWork.left) / nFixedWidth;
-						if (nRank > 0)
-						{
-							cyNeeded = ((nItemCount - 1) / nRank + 1) * pControl->GetFixedHeight();
-						}
-					}
-				}
-			}
-
 			ProcessScrollBar(rcWork, cxNeeded, cyNeeded);
 		}
 	}
@@ -3200,27 +3200,13 @@ namespace DuiLib {
 		if (m_pOwner == NULL) return;
 
 		UINT uListType = m_pOwner->GetListType();
-		if (uListType == LT_LIST) {
-			int nFixedWidth = GetFixedWidth();
-			if (nFixedWidth > 0)
-			{
-				int nRank = (rc.right - rc.left) / nFixedWidth;
-				if (nRank > 0)
-				{
-					int nIndex = GetIndex();
-					int nfloor = nIndex / nRank;
-					int nHeight = rc.bottom - rc.top;
-
-					rc.top = rc.top - nHeight * (nIndex - nfloor);
-					rc.left = rc.left + nFixedWidth * (nIndex % nRank);
-					rc.right = rc.left + nFixedWidth;
-					rc.bottom = nHeight + rc.top;
-				}
-			}
-		}
+
+		// 直接按普通纵向布局处理,不再对 LT_LIST 做网格重排
 		CHorizontalLayoutUI::SetPos(rc, bNeedInvalidate);
 
+		// 只有 LT_LIST / LT_TREE 需要做表头列宽同步
 		if (uListType != LT_LIST && uListType != LT_TREE) return;
+
 		CListUI* pList = static_cast<CListUI*>(m_pOwner);
 		if (uListType == LT_TREE)
 		{
@@ -3228,14 +3214,16 @@ namespace DuiLib {
 			if (pList == NULL) return;
 		}
 
-		CListHeaderUI *pHeader = pList->GetHeader();
+		CListHeaderUI* pHeader = pList->GetHeader();
 		if (pHeader == NULL || !pHeader->IsVisible()) return;
+
 		int nCount = m_items.GetSize();
 		for (int i = 0; i < nCount; i++)
 		{
-			CControlUI *pListItem = static_cast<CControlUI*>(m_items[i]);
-			CControlUI *pHeaderItem = pHeader->GetItemAt(i);
+			CControlUI* pListItem = static_cast<CControlUI*>(m_items[i]);
+			CControlUI* pHeaderItem = pHeader->GetItemAt(i);
 			if (pHeaderItem == NULL) return;
+
 			RECT rcHeaderItem = pHeaderItem->GetPos();
 			if (pListItem != NULL && !(rcHeaderItem.left == 0 && rcHeaderItem.right == 0))
 			{

BIN
bin/Win32/Debug/zhipuzi_pos_windows/DuiLib_d.dll


BIN
bin/Win32/Release/zhipuzi_pos_windows/DuiLib.dll


BIN
dll/debug/DuiLib_d.dll


BIN
dll/release/DuiLib.dll


BIN
temp/link/Win32/Debug/DuiLib/DuiLib_d.pdb


+ 10 - 3
zhipuzi_pos_windows/page/CDiandanPageUI.cpp

@@ -1081,6 +1081,11 @@ void CDiandanPageUI::HandleTextChangedMsg(TNotifyUI& msg)
 //处理扫码枪捕捉到的扫码信息
 void CDiandanPageUI::HandleTextCapture(std::string content)
 {
+	if (content == "")
+	{
+		return;
+	}
+	
 	if (m_is_show_modal_wnd == true)
 	{
 		m_curModalWnd->HandleTextCapture(content);
@@ -1219,6 +1224,7 @@ void CDiandanPageUI::UpdateShopcartShow(bool is_add_new)
 	pList->RemoveAll();
 
 	int nItemNum = m_cur_diandan_order.getItemNum();
+
 	for (int i = 0; i < nItemNum; i++)
 	{
 		CDiandanOrderItem item = m_cur_diandan_order.getDiandanOrderItem(i);
@@ -1273,9 +1279,6 @@ void CDiandanPageUI::UpdateShopcartShow(bool is_add_new)
 
 	if (is_add_new == true)
 	{
-		//增加新商品,取消选择
-		pList->SelectItem(-1, false);
-
 		//必须先刷新重绘,再获取range才准
 		pList->NeedUpdate();
 		pList->Invalidate();
@@ -1284,7 +1287,11 @@ void CDiandanPageUI::UpdateShopcartShow(bool is_add_new)
 		//这个是同步阻塞重绘
 		::UpdateWindow(m_pManager->GetPaintWindow());
 
+		//增加新商品,选中最后一个
+		pList->SelectItem(nItemNum - 1, false);
+
 		pList->EnsureVisible(nItemNum - 1);
+
 	}
 	else
 	{

+ 3 - 2
zhipuzi_pos_windows/page/CSaomashouyinPageUI.cpp

@@ -932,8 +932,6 @@ void CSaomashouyinPageUI::UpdateShopcartShow(bool is_add_new)
 
 	if (is_add_new == true)
 	{
-		//增加新商品,取消选择
-		pList->SelectItem(-1, false);
 
 		//必须先刷新重绘,再获取range才准
 		pList->NeedUpdate();
@@ -943,6 +941,9 @@ void CSaomashouyinPageUI::UpdateShopcartShow(bool is_add_new)
 		//这个是同步阻塞重绘
 		::UpdateWindow(m_pManager->GetPaintWindow());
 
+		//增加新商品,选中最后一个
+		pList->SelectItem(nItemNum - 1, false);
+
 		pList->EnsureVisible(nItemNum - 1);
 	}
 	else

+ 3 - 3
zhipuzi_pos_windows/page/CZhengcanDiandanPageUI.cpp

@@ -1470,9 +1470,6 @@ void CZhengcanDiandanPageUI::UpdateShopcartShow(bool is_add_new)
 
 	if (is_add_new == true)
 	{
-		//增加新商品,取消选择
-		pList->SelectItem(-1, false);
-
 		//必须先刷新重绘,再获取range才准
 		pList->NeedUpdate();
 		pList->Invalidate();
@@ -1481,6 +1478,9 @@ void CZhengcanDiandanPageUI::UpdateShopcartShow(bool is_add_new)
 		//这个是同步阻塞重绘
 		::UpdateWindow(m_pManager->GetPaintWindow());
 
+		//增加新商品,选中最后一个
+		pList->SelectItem(nItemNum - 1, false);
+
 		pList->EnsureVisible(nItemNum - 1);
 	}
 	else