Browse Source

AI学习优化完

张洋 1 month ago
parent
commit
71a67e6f07

+ 41 - 23
bin/Win32/Debug/zhipuzi_pos_windows/skin/aixuexi_page.xml

@@ -13,46 +13,64 @@
 				<Control width="1" bkcolor="#FFD1D1D1"></Control>
 				
 				<VerticalLayout name="aixuexi_page_paishe_layout" width="420" padding="0,0,0,0" bordercorner="10,10" bkcolor="#FFFFFFFF" autocalcwidth="true">
-					<Label name="aixuexi_page_xuanzhong_food_name" text="当前选中商品:无" height="26" padding="10,10,10,10" textcolor="#FFFF0000" font="22"></Label>
+					<!-- 选中商品结果条:浅绿底 + 绿描边(hs_amtbar_r10 九宫格),文字改品牌绿 -->
+					<Label name="aixuexi_page_xuanzhong_food_name" text="当前选中商品:无" height="40" padding="10,10,10,0" endellipsis="true" bkimage="file='hs_amtbar_r10.png' corner='10,10,10,10'" textcolor="#FF2E9B5C" font="15" textpadding="12,0,12,0"></Label>
 
-					<Label name="aixuexi_page_xuanzhong_food_name" wordbreak="true" height="40" padding="10,0,10,10" font="14" text="智铺子AI识别无需学习默认就能识别几百种常见的水果蔬菜,只需要对未正常识别的冷门商品或非水果蔬菜类商品进行学习。"></Label>
+					<!-- 说明文字:独立命名(原来与结果条复用同一个 name,FindSubControl 只能拿到第一个)+次级灰 -->
+					<Label name="aixuexi_page_food_tip" wordbreak="true" height="40" padding="10,8,10,0" font="13" textcolor="#FF5F6368" text="智铺子AI识别无需学习默认就能识别几百种常见的蔬菜水果,只需要对未正常识别的冷门商品或非水果蔬菜类商品进行学习。"></Label>
 
-					<Control name="image" width="400" height="300" padding="10,0,10,0"></Control>
+					<!-- 摄像头预览:直角、无圆角、无描边 —— 视频本身由 StretchBlt 直写窗口 DC、本来就是直角,
+					     之前为了视觉圆角加的 float 遮罩层与 bordercorner 已按需求撤掉 -->
+					<Container name="aixuexi_page_preview" width="400" height="300" padding="10,12,10,0" bkcolor="#FFF0F1F3">
+						<Control name="image" width="400" height="300" float="true" pos="0,0,400,300" mouse="false"/>
+					</Container>
 
-					<HorizontalLayout height="50" padding="0,20,0,0">
-						<Control></Control>
-							<Button name="aixuexi_page_paishe_btn" width="120" height="50" text="拍摄并学习" textcolor="#FFFFFFFF" normalimage="file='btn_green_zhengchang.png' corner='5,5,5,5'" hotimage="file='btn_green_xuanfu.png' corner='5,5,5,5'" pushedimage="file='btn_green_dianji.png' corner='5,5,5,5'" />
-							<Button name="aixuexi_page_test_btn" width="120" height="50" padding="15,0,0,0" text="AI识别测试" textcolor="#FFFFFFFF" normalimage="file='btn_green_zhengchang.png' corner='5,5,5,5'" hotimage="file='btn_green_xuanfu.png' corner='5,5,5,5'" pushedimage="file='btn_green_dianji.png' corner='5,5,5,5'" />
-							<Button name="aixuexi_page_caiji_btn" width="120" height="50" padding="15,0,0,0" text="采集图片" textcolor="#FFFFFFFF" normalimage="file='btn_green_zhengchang.png' corner='5,5,5,5'" hotimage="file='btn_green_xuanfu.png' corner='5,5,5,5'" pushedimage="file='btn_green_dianji.png' corner='5,5,5,5'" />
-						<Control></Control>
+					<!-- 按钮行:左右 inset 10,与上方摄像头视频(内容区 400 宽,11..411)左右边界对齐;
+					     三枚等宽 126 + childpadding 11 → 126*3 + 11*2 = 400 严丝合缝;
+					     主按钮 corner 由 5 提到 8,与次按钮 / 点单页支付按钮(pay_scan_* corner 8)统一 -->
+					<HorizontalLayout height="50" padding="10,20,10,0" childpadding="11">
+						<Button name="aixuexi_page_paishe_btn" width="126" height="50" text="拍摄并学习" font="14" textcolor="#FFFFFFFF" normalimage="file='btn_green_zhengchang.png' corner='8,8,8,8'" hotimage="file='btn_green_xuanfu.png' corner='8,8,8,8'" pushedimage="file='btn_green_dianji.png' corner='8,8,8,8'" />
+						<Button name="aixuexi_page_test_btn" width="126" height="50" text="AI识别测试" font="14" textcolor="#FF5F6368" normalimage="file='btn_border_gray.png' corner='8,8,8,8'" hotimage="file='btn_border_gray_Hover.png' corner='8,8,8,8'" pushedimage="file='btn_border_gray_Click.png' corner='8,8,8,8'" />
+						<Button name="aixuexi_page_caiji_btn" width="126" height="50" text="采集图片" font="14" textcolor="#FF5F6368" normalimage="file='btn_border_gray.png' corner='8,8,8,8'" hotimage="file='btn_border_gray_Hover.png' corner='8,8,8,8'" pushedimage="file='btn_border_gray_Click.png' corner='8,8,8,8'" />
 					</HorizontalLayout>
 
-					<TileLayout name="aixuexi_page_food_xuexi_image_layout" padding="0,0,0,0" inset="10,10,0,10" childpadding="10" vscrollbar="true" hscrollbar="false">
+					<!-- 图库:分隔线 + 标题行 + 计数胶囊(计数由 CAIxuexiPageUI::UpdateXuexiCount 更新) -->
+					<Control height="1" padding="0,14,0,0" bkcolor="#FFF0F1F3"></Control>
+					<!-- 标题行:childvalign=vcenter 让 20 高的计数胶囊在 24 高行里垂直居中(HL 默认顶对齐会偏上 4px) -->
+					<HorizontalLayout height="24" padding="10,10,10,0" childvalign="vcenter">
+						<Label text="已学习图片" font="113" textcolor="#FF1F2329" width="80" height="24"></Label>
+						<Label name="aixuexi_page_xuexi_count" text="0" font="12" textcolor="#FF2E9B5C" height="20" maxheight="20" autocalcwidth="true" bkimage="file='hs_pill_r9.png' corner='9,9,9,9'" textpadding="9,0,9,0" mouse="false"></Label>
+					</HorizontalLayout>
+
+					<TileLayout name="aixuexi_page_food_xuexi_image_layout" padding="0,0,0,0" inset="10,10,0,0" childpadding="10" vscrollbar="true" hscrollbar="false">
 						
 					</TileLayout>                
 				</VerticalLayout> 
 
 				<Control width="1" bkcolor="#FFEBE8E8"></Control>
 				
-				<VerticalLayout name="aixuexi_page_food_layout">
+				<VerticalLayout name="aixuexi_page_food_layout" bkcolor="#FFF5F7FA" inset="12,12,12,12" childpadding="12">
 					<VerticalLayout name="aixuexi_page_fenlei_layout_scrolllayout" vscrollbar="true">
-						<HorizontalLayout name="aixuexi_page_fenlei_layout" padding="0,0,0,0" bkcolor="#FFFFFFFF">
-
-						</HorizontalLayout>
+						<!-- 分类栏:与点单页 diandan_fenlei_layout 同构(Container;子项 float=true,由 C++ SetFixedXY 定位) -->
+						<Container name="aixuexi_page_fenlei_layout">
+						</Container>
 					</VerticalLayout>				
 					
-					<TileLayout name="aixuexi_page_foodlist" padding="0,0,0,0" inset="10,10,0,10" childpadding="10" vscrollbar="true" hscrollbar="false">
+					<TileLayout name="aixuexi_page_foodlist" bkcolor="#00000000" childpadding="10" vscrollbar="true" hscrollbar="false">
 					
 					</TileLayout>
 					
-					<HorizontalLayout height="70" padding="0,0,0,0" bkcolor="#FFFFFFFF">
-						<Edit name="aixuexi_page_food_search_edit" tooltip="请输入商品名字或条码搜索" width="400" height="50" padding="30,10,0,10" textpadding="50,0,50,0" borderround="45,45" bkcolor="#FFECEFED" nativebkcolor="#FFECEFED" />
-						
-						<Label name="aixuexi_page_food_search_tishi" text="请输入商品名字或条码搜索" width="120" height="35" font="16" float="true" pos="90,18,425,50" mouse="false"></Label>
-						
-						<Control bkimage="search_icon.png" width="25" height="26" pos="45,23,70,49" float="true"></Control>
-						
-						<Button name="aixuexi_page_food_search_clear" visible="false" normalimage="search_clear.png" hotimage="search_clear.png" pushedimage="search_clear.png" bkimage="search_clear.png" width="23" height="23" pos="385,23,408,46" float="true"></Button>
+					<!-- 搜索行:对齐点单页(dc_search 九宫格 40 高满宽;inset / childvalign 照抄 diandan_page.xml) -->
+					<HorizontalLayout height="40" padding="0,0,0,0">
+						<HorizontalLayout bkimage="file='dc_search.png' corner='20,20,20,20'" inset="16,0,12,0" childpadding="8" childvalign="vcenter">
+							<Control bkimage="dc_ico_search16.png" width="16" height="16" maxheight="16"/>
+							
+							<Edit name="aixuexi_page_food_search_edit" tooltip="请输入商品名字或条码搜索" font="12" textcolor="#FF1F2329" maxheight="24" bkcolor="#00000000" nativebkcolor="#FFEFF1F3"/>
+							
+							<Label name="aixuexi_page_food_search_tishi" text="请输入商品名字或条码搜索" width="150" height="20" font="12" float="true" pos="40,10,190,30" mouse="false" valign="center" textcolor="#FFA8ADB3"/>
+							
+							<Button name="aixuexi_page_food_search_clear" visible="false" width="23" height="23" maxheight="23" normalimage="search_clear.png" hotimage="search_clear.png" pushedimage="search_clear.png"/>
+						</HorizontalLayout>
 					</HorizontalLayout>
 				</VerticalLayout>
 			</HorizontalLayout>

+ 5 - 1
bin/Win32/Debug/zhipuzi_pos_windows/skin/aixuexi_page_food_xuexi_image.xml

@@ -2,7 +2,11 @@
 <Window>	
 	<FoodXuexiImageItem name="shangpin_fooditem" bkcolor="#FFFFFFFF" padding="0,0,0,0">
 		<Control name="image" width="120" height="90" bkimage="file='food_image_default.png'" padding="0,0,0,0"></Control>
+		<!-- 缩略图按需求走直角:原先那张 8px 圆角九宫格遮罩层已撤掉。
+		     CFoodXuexiImageItemUI::SetImagePath 用 SetBkImage 直接铺图,撤掉遮罩即恢复直角显示。 -->
 		
-        <Button name="aixuexi_page_food_image_delete" normalimage="close_icon.png" hotimage="close_icon.png" pushedimage="close_icon.png" bkimage="close_icon.png" width="24" height="24" pos="95,0,119,24" float="true"></Button>
+        <!-- 删除角标:设计稿 .gdel 是 22x22 深色半透明圆 + 白叉、右上内缩 4px;
+             用 thumb_del.png 而不是仓库里那张 24x24 RGB 的旧叉图(四角不透明浅灰,会带出一圈灰底) -->
+        <Button name="aixuexi_page_food_image_delete" normalimage="thumb_del.png" hotimage="thumb_del.png" pushedimage="thumb_del.png" bkimage="thumb_del.png" width="22" height="22" pos="94,4,116,26" float="true"></Button>
 	</FoodXuexiImageItem>
 </Window>

BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/aixuexi_viewfinder_fg.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/bt_cat_hot.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/bt_cat_n.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/bt_cat_sel.png


+ 6 - 2
bin/Win32/Debug/zhipuzi_pos_windows/skin/foodtype_option.xml

@@ -1,9 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Window>
 	<!-- 分类胶囊 130x38 圆角 19。
-	     ⚠️ 删掉了 align="center":Option 继承 Button,align 走的是 float 对齐而不是文字对齐,
+	     ⚠️ 1) 删掉了 align="center":Option 继承 Button,align 走的是 float 对齐而不是文字对齐,
 	        一旦设了 DT_CENTER,SetFloatPos 就把 X 居中、完全无视 C++ 的 SetFixedXY,
-	        所有分类会叠在容器正中。文字居中由 CButtonUI 构造函数的 DT_CENTER 默认保证。 -->
+	        所有分类会叠在容器正中。文字居中由 CButtonUI 构造函数的 DT_CENTER 默认保证。
+	     ⚠️ 2) 代码里不要对胶囊调 SetBkColor:CControlUI::PaintBkColor 是 DrawColor 纯矩形填充、
+	        不读 bordercorner,方底会从 19px 圆角缺口里露出(即「灰色 4 角」)。
+	        选中态交给本文件的 selectedimage(bt_cat_sel.png)+ Option 的 group 机制即可。
+	        参见 CShangpinPageUI.cpp:86 / :355。 -->
 	<FoodtypeOption endellipsis="true" width="130" height="38" float="true" font="13"
 		textcolor="#FF5F6368" selectedtextcolor="#FFFFFFFF" pushedtextcolor="#FFFFFFFF" pushedtextcolor="#FFFFFFFF"
 		bkcolor="#00000000" selectedbkcolor="#00000000"

BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/hs_pill_r9.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/mask_r10_white.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/mask_r8_white.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/thumb_del.png


+ 52 - 18
zhipuzi_pos_windows/page/CAIxuexiPageUI.cpp

@@ -64,6 +64,9 @@ void CAIxuexiPageUI::InitShow()
 	CTileLayoutUI* pXuexiScrollLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("aixuexi_page_food_xuexi_image_layout")));
 	pXuexiScrollLayout->RemoveAll();
 
+	//图片已清空,计数同步归零
+	this->UpdateXuexiCount();
+
 	//先初始化商品分类
 	this->InitFoodtypeShow();
 
@@ -102,6 +105,26 @@ void CAIxuexiPageUI::UpdatCurFoodXuexiShow()
 
 		pXuexiScrollLayout->Add(pItem);
 	}
+
+	this->UpdateXuexiCount();
+}
+
+void CAIxuexiPageUI::UpdateXuexiCount()
+{
+	//图库计数胶囊(aixuexi_page_xuexi_count):直接取 TileLayout 的子项数,不另开成员变量,
+	//避免 RemoveAll / Add / Remove 三条路径各写一遍导致计数漂移。
+	CLabelUI* pCount = static_cast<CLabelUI*>(this->FindSubControl(_T("aixuexi_page_xuexi_count")));
+	if (pCount == NULL)
+	{
+		return;
+	}
+
+	CTileLayoutUI* pXuexiScrollLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("aixuexi_page_food_xuexi_image_layout")));
+	int nCount = (pXuexiScrollLayout != NULL) ? pXuexiScrollLayout->GetCount() : 0;
+
+	TCHAR szBuf[16] = { 0 };
+	wsprintf(szBuf, _T("%d"), nCount);
+	pCount->SetText(szBuf);
 }
 
 void CAIxuexiPageUI::InitFoodtypeShow()
@@ -146,10 +169,10 @@ void CAIxuexiPageUI::InitFoodtypeShow()
 
 	m_foodtype_mutex.unlock();
 
-	if (m_curFoodtypeOption != NULL)
-	{
-		m_curFoodtypeOption->SetBkColor(0xFF60B177);
-	}
+	//选中当前分类:走 foodtype_option.xml 的 selectedimage(bt_cat_sel.png)+ Option 的 group 机制。
+	//⚠️ 不能用 SetBkColor 上色:CControlUI::PaintBkColor 走 CRenderEngine::DrawColor 纯矩形填充,
+	//   根本不读 bordercorner,方矩形会从胶囊的 19px 圆角缺口里露出来,形成「灰色 4 角」。
+	//   与 CShangpinPageUI(:86/:355)和 CDiandanPageUI(全程未用)的既有约定保持一致。
 
 	//如果不是一个分类都没有,选中第一个分类
 	if (m_cur_type_id != "")
@@ -174,13 +197,16 @@ void CAIxuexiPageUI::UpdateFoodtypePos()
 	}
 
 	//根据宽度计算每行显示的数量
-	int nMeihangNum = (nWidth - 422) / 140;
+	//右栏宽 = 页宽 - 左栏 420 - 两条 1px 竖线 = nWidth - 422;右栏容器 inset 12*2 →
+	//分类区可用宽 = nWidth - 446。每个胶囊占 138(胶囊 130 + 间距 8),
+	//几何完全对齐点单页 CDiandanPageUI::UpdateFoodtypePos(列距 138 / 行距 46 / 首行 +8)。
+	int nMeihangNum = (nWidth - 446) / 138;
 
 	int num = 0;
 
 	m_foodtype_mutex.lock();
 
-	CHorizontalLayoutUI* pFenleiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("aixuexi_page_fenlei_layout")));
+	CContainerUI* pFenleiLayout = static_cast<CContainerUI*>(this->FindSubControl(_T("aixuexi_page_fenlei_layout")));
 	for (int i = 0; i < nFoodtypeNum; i++)
 	{
 		CButtonUI* curItem = static_cast<CButtonUI*>(pFenleiLayout->GetItemAt(i));
@@ -189,10 +215,11 @@ void CAIxuexiPageUI::UpdateFoodtypePos()
 		int curCol = num % nMeihangNum + 1;
 
 		RECT rect;
-		rect.left = (curCol - 1) * 140 + 10;
+		//左栏已由右栏 inset=12 提供左边距,这里首列从 x=0 起,与下方商品网格左边对齐
+		rect.left = (curCol - 1) * 138;
 		rect.right = rect.left + 130;
-		rect.top = (curRow - 1) * 52 + 10;
-		rect.bottom = rect.top + 42;
+		rect.top = (curRow - 1) * 46 + 8;
+		rect.bottom = rect.top + 38;
 
 		// 强制设置固定大小和位置
 		SIZE size;
@@ -210,7 +237,7 @@ void CAIxuexiPageUI::UpdateFoodtypePos()
 
 	//调整区域高度
 	int lastRow = (num - 1) / nMeihangNum + 1;
-	pFenleiLayout->SetFixedHeight(lastRow * 52 + 10);
+	pFenleiLayout->SetFixedHeight(lastRow * 46 + 8);
 
 	//处理滚动条问题
 	CVerticalLayoutUI* pFenleiScrollLayout = static_cast<CVerticalLayoutUI*>(this->FindSubControl(_T("aixuexi_page_fenlei_layout_scrolllayout")));
@@ -219,7 +246,7 @@ void CAIxuexiPageUI::UpdateFoodtypePos()
 		lastRow = 2;
 	}
 
-	pFenleiScrollLayout->SetFixedHeight(lastRow * 52 + 10);
+	pFenleiScrollLayout->SetFixedHeight(lastRow * 46 + 8);
 
 	SIZE size;
 	size.cx = 0;
@@ -238,9 +265,11 @@ void CAIxuexiPageUI::InitFoodShow()
 
 	if (setting_xianshi_is_youtu == "1")
 	{
+		// 与点单页统一:diandan_fooditem_youtu.xml 是 148x172(图上文下)。
+		// SetItemSize 必须与商品卡 XML 的 width/height 一致,否则卡片错位。
 		SIZE itemsize;
-		itemsize.cx = 130;
-		itemsize.cy = 200;
+		itemsize.cx = 148;
+		itemsize.cy = 172;
 		m_foodLayout->SetItemSize(itemsize);
 
 		xml_name = _T("diandan_fooditem_youtu.xml");
@@ -389,6 +418,9 @@ void CAIxuexiPageUI::HandleClickMsg(TNotifyUI& msg)
 		CTileLayoutUI* pXuexiScrollLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("aixuexi_page_food_xuexi_image_layout")));
 		pXuexiScrollLayout->Remove(m_pImageItem);
 
+		//删掉一张图,计数同步
+		this->UpdateXuexiCount();
+
 		//然后从数据库中删除这个图片对应的向量
 		std::string imageName = m_pImageItem->GetImageName();
 
@@ -415,11 +447,8 @@ void CAIxuexiPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
 
 		if (m_cur_type_id != id)
 		{
-			//切换了商品分类
-			m_curFoodtypeOption->SetBkColor(0xFFECECEC);
-
-			msg.pSender->SetBkColor(0xFF60B177);
-
+			//切换了商品分类(选中态由 Option 的 group 机制 + selectedimage 处理,不要再 SetBkColor:
+			//  SetBkColor 是方矩形填充、会盖出「灰色 4 角」,且上个分类会残留 #ECECEC 方底)
 			m_curFoodtypeOption = static_cast<CControlUI*>(msg.pSender);
 
 			m_cur_type_id = id;
@@ -560,6 +589,9 @@ void CAIxuexiPageUI::UpdateVideoShow()
 
 	SelectObject(m_hMemDC, hOldBitmap);
 
+	//(原「StretchBlt 之后补画圆角遮罩」的代码已随摄像头去圆角一并移除:
+	//  摄像头区现在是直角,不再需要 float 遮罩层,也就没有会被视频盖掉的前景层了。)
+
 	return;
 }
 
@@ -688,6 +720,8 @@ void CAIxuexiPageUI::DoXuexi()
 	pItem->SetImagePath(imagePath);
 
 	pXuexiScrollLayout->Add(pItem);
+
+	this->UpdateXuexiCount();
 }
 
 std::wstring CAIxuexiPageUI::DoCaiji()

+ 3 - 0
zhipuzi_pos_windows/page/CAIxuexiPageUI.h

@@ -25,6 +25,9 @@ public:
 	//更新当前选中商品的已学习的显示
 	void UpdatCurFoodXuexiShow();
 
+	//更新图库标题行的计数胶囊(取 aixuexi_page_food_xuexi_image_layout 的子项数)
+	void UpdateXuexiCount();
+
 	//初始化商品分类的显示
 	void InitFoodtypeShow();
 

+ 13 - 1
zhipuzi_pos_windows/page/CZhengcanDiandanPageUI.cpp

@@ -941,7 +941,19 @@ void CZhengcanDiandanPageUI::RefreshCartItemSelectedColor()
 			continue;
 		}
 
-		pName->SetTextColor(pEle->IsSelected() ? 0xFF2E9B5C : 0xFF1F2329);
+		if (pEle->IsSelected())
+		{
+			pName->SetTextColor(0xFF2E9B5C);
+		}
+		else
+		{
+			if (pEle->IsEnabled())
+			{
+				pName->SetTextColor(0xFF1F2329);
+			}
+
+			//如果是禁用的,就不处理了,保持灰色
+		}
 	}
 }