云信duilib 小知识总结 (对齐、半透明、右键菜单)

 duilib 快速入门

duilib入门基础一 容器之 BOX、VBOX、HBOX布局及其子控件align排列方式

duilib入门基础二 HBOX容器内 子控件margin定位规则

​​​​​​duilib入门基础三 VBOX容器内 子控件margin定位规则

duilib入门基础四 BOX容器内 子控件margin定位规则

duilib入门基础五 简单示例之 文件选择框使用

duilib入门基础 六 见见世面,duilib 基本控件 Button 能实现的界面一览

duilib入门基础 七 见见世面,duilib 基本控件 复选框 单选框

duilib入门基础 八 见见世面,duilib 基本控件 滑动条

duilib入门基础 九 见见世面,duilib 基本控件 组合框

duilib入门基础 十 见见世面,duilib 基本控件 选项框 OptionBox

云信duilib基本控件示例下载

1 对齐属性

	<Attribute name="halign" default="left" type="STRING" comment="控件的横向位置,如(center),支持left、center、right三种位置"/>
	<Attribute name="valign" default="top" type="STRING" comment="控件的纵向位置,如(center),支持top、center、bottom三种位置"/>

  但是值得注意的是:

 1)valign 不起作用的情况

VBOX 布局是从上而下依次排列的,因此,Vbox下的子控件,如果设置valign属性时,便不起作用。

比如,VBOX 下,设置子控件的valign=center时,是不起作用的

//不起作用
            <VBox width="stretch" height="stretch"  bkcolor="red">
   
                <HBox width="100" height="100"  halign="center"  valign="center"     bkcolor="blue">
                   
                </HBox>

            </VBox>

如果想让VBOX布局下,子控件也居中,需要辅助控件Control

            <VBox width="stretch" height="stretch"  bkcolor="red">
                <Control />
                 <HBox width="100" height="100"  halign="center"     bkcolor="blue">                  
                 </HBox>
                <Control />
            </VBox>

2)halign不起作用的原因

同理,HBOX 中,子控件按水平方向,依次排列,因此,在HBOX中,设置子控件的halign也是不起作用的。

2 半透明窗口

   想实现窗口半透明,控件不透明的效果,使用云信duilib也很方便实现

1)shadowattached=“false”   置为假

<Attribute name="shadowattached" default="true" type="BOOL" comment="窗口是否附加阴影效果,如(true)"/>

 窗口的一个属性

 如果为true时,默认给窗口加上阴影背景

 如果为false, 则不加额外背景

 因为,我们想让窗口半透明,所以需要将此属性设置为false, 不加额外阴影背景

2)duilib中的颜色

<TextColor name="xnw_lightcolor2_trans_50" value="#7f363E4B" />

  颜色值为 ARGB A是透明度

  也就是,dulib本身是支持透明的

  也就是,如果将背景设置为透明色的话,窗口背景就是透明的了。

  所以,

  窗口背景设置为透明色,控件颜色,设置为非透明色,便实现了 窗口透明,控件不透明的效果

示例:

<?xml version="1.0" encoding="UTF-8"?>
<Window caption="0,0,0,0" mininfo="500,500" size="500,500" sizebox="4,4,6,6" shadowattached="false"  roundcorner="10,10" >


    <VBox bkcolor="xnw_lightcolor2_trans_50" height="stretch" width="stretch">
        <!-- 客户端名称设置 -->
        

            <Control />
            <VBox width="stretch" height="stretch">
    
                <Control />
                <HBox   halign="center" width="auto" halign="center">
                    <Button class="btn_global_green_80x30" name="myClosebtn"  text="我知道了"/>
                    
                </HBox>
                <Control />
            </VBox>
            <Control />
          
    </VBox>

</Window>

效果:

   

3 右键菜单

1) 右键消息

	if (uMsg==WM_RBUTTONDOWN)
	{

		int xPos = LOWORD(lParam);
		INT yPos = HIWORD(lParam);
	
		CPoint pt;
		pt.x = xPos;
		pt.y = yPos;
		ClientToScreen(m_hWnd, &pt);

		PopupUserMenu(pt);

		return 1;


	}
PopupUserMenu(POINT point){



	CMenuWnd* pMenu = new CMenuWnd(NULL);
	STRINGorID xml(L"liveStream_rbt_menu.xml");
	pMenu->Init(xml, _T("xml"), point);

	CMenuElementUI *pFreshNlss = (CMenuElementUI*)pMenu->FindControl(L"fresh");
	if (pFreshNlss)
		pFreshNlss->AttachSelect(nbase::Bind(&NLSLiveForm::ReFreshNlss, this, std::placeholders::_1));


	CMenuElementUI* pVideoImage = (CMenuElementUI*)pMenu->FindControl(L"videoImage");
	if (pVideoImage)
	{
		pVideoImage->AttachSelect(nbase::Bind(&NLSLiveForm::ChangeImage, this, std::placeholders::_1));
		CheckBox* check_image = (CheckBox*)pVideoImage->FindSubControl(L"imageCheckBox");
		check_image->Selected(m_bVideoImage);
	}
	


	CMenuElementUI *pPull = (CMenuElementUI*)pMenu->FindControl(L"pullAdd");
	if (pPull)
	{
		pPull->AttachSelect(nbase::Bind(&NLSLiveForm::CopyPullAdd, this, std::placeholders::_1));
	}


	CMenuElementUI *pPush = (CMenuElementUI*)pMenu->FindControl(L"pushAdd");
	if (pPush)
	{
		pPush->AttachSelect(nbase::Bind(&NLSLiveForm::CopyPushAdd, this, std::placeholders::_1));
	}



/
	CMenuElementUI *pStopCapture = (CMenuElementUI*)pMenu->FindControl(L"stopCapture");
	if (pStopCapture)
	{
		pStopCapture->AttachSelect(nbase::Bind(&NLSLiveForm::StopCapture, this, std::placeholders::_1));
	}

	CMenuElementUI *pStartCapture = (CMenuElementUI*)pMenu->FindControl(L"startCapture");
	if (pStartCapture)
	{
		pStartCapture->AttachSelect(nbase::Bind(&NLSLiveForm::StartCapture, this, std::placeholders::_1));
	}


	CMenuElementUI *pStartInteractLive = (CMenuElementUI*)pMenu->FindControl(L"intLive");
	if (pStartInteractLive)
	{
		pStartInteractLive->AttachSelect(nbase::Bind(&NLSLiveForm::StartIntLive, this, std::placeholders::_1));
	}

	CMenuElementUI *pSwitchToInt = (CMenuElementUI*)pMenu->FindControl(L"switchMode");
	if (pSwitchToInt)
	{
		if (!g_bSwitchChangeable||!m_bLiving&&!m_bPaused)
		{
			pSwitchToInt->SetVisible(false);
		}

		pSwitchToInt->AttachSelect(nbase::Bind(&NLSLiveForm::SwtichToIntMode, this, std::placeholders::_1));
	}

	
	pMenu->Show();
	pMenu->SetFocus(NULL);
}

菜单响应函数格式

bool SwtichToIntMode(ui::EventArgs* param);

菜单XML 放在themes\default\menu下

类似

<?xml version="1.0" encoding="utf-8"?>
<Window shadowattached="true" alphafixcorner="10,20,10,10">
    <VListBox class="menu" name="user_menu">
        <MenuElement bkcolor="blue" width="140" height="10" alpha="10">
            <Control bkimage="up.png" width="auto" height="auto" halign="center" valign="bottom" />
        </MenuElement>



        <MenuElement class="MenuElement" name="switchMode" width="140" height="50">
            <Button class="menu_text" text="切换成互动模式" halign="center" valign="center" />
        </MenuElement>

        <MenuElement class="MenuElement" name="startCapture" width="140" height="50">
            <Button class="menu_text" text="恢复摄像头" halign="center" valign="center" />
        </MenuElement>


    </VListBox>
</Window>

duilib云信table是基于duilib框架和云信SDK而创建的一个表格控件,用于在应用程序中展示和编辑表格数据。 duilib是一个开源的C++图形界面库,它提供了丰富的UI控件和界面布局管理功能,使开发者可以快速、灵活地构建界面。而云信SDK是网易公司开发的一套实时音视频通信解决方案,它提供了丰富的音视频通信功能,包括语音通话、视频通话、实时消息等。 duilib云信table结合了duilib的UI控件和云信的实时消息功能,使得开发者可以在应用程序中展示表格数据,并且可以通过实时消息功能实现对表格数据的实时更新和同步。 duilib云信table具有以下特点和优势: 1. 界面美观:duilib框架提供了丰富的UI控件和界面布局管理功能,开发者可以自由设计和定制表格的外观和样式,使得表格界面更加美观和符合用户需求。 2. 功能丰富:duilib云信table支持表格的显示、编辑、排序、过滤等常用功能,方便开发者对表格数据进行操作和管理。同时,云信SDK提供的实时消息功能可以实现对表格数据的实时更新和同步,方便多人协作和实时数据交互。 3. 扩展性强:duilib云信table是基于duilib框架和云信SDK的开发,开发者可以自由扩展和定制该控件的功能和行为,满足不同应用场景的需求。 总之,duilib云信table是一个功能强大、界面美观的表格控件,可以方便地展示和编辑表格数据,并通过云信SDK实现实时数据的更新和同步。它的出现为表格数据展示和管理提供了一种简单、高效的解决方案。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清水迎朝阳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值