Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加VirtualTileBox控件的项目,可替换VirtualListBox #68

Merged
merged 4 commits into from
Jul 8, 2019

Conversation

smallevilbeast
Copy link
Contributor

@smallevilbeast smallevilbeast commented Jul 6, 2019

比VirtualListbox增强的特性

  • 无需用户设置初始化子项数量,完全由控件自动计算
  • 当尺寸变化时,子项能够自适应
  • 数据可以在运行时初始化、更新、新增和删除操作
  • 数据层添加DataChanged和CountChanged接口,通知TileBox数据的变化

更新数据并通知

void Provider::ChangeTaskName(int nIndex, const wstring& sName)
{
	if (nIndex > 0 && nIndex < m_vTasks.size())
	{
		m_vTasks[nIndex].sName = sName;
	}

	// 发送数据变动通知
	EmitDataChanged(nIndex, nIndex);
}

TileBox处理数据更新

void VirtualTileBox::OnModelDataChanged(int nStartIndex, int nEndIndex)
{
	for (auto i = nStartIndex; i <= nEndIndex; i++)
	{
		if (IsElementDisplay(i))
		{
			int nTopItemHeight = 0;
			int nItemIndex = i - GetTopElementIndex(nTopItemHeight);
			ASSERT(nItemIndex > 0);
			FillElement(m_items[nItemIndex], i);
		}
	}
}

void VirtualTileBox::OnModelCountChanged()
{
	Refresh();
}

效果演示
2

@smallevilbeast smallevilbeast changed the title 添加virtualTileBox项目,可替换VirtualListBox 添加VirtualTileBox控件的项目,可替换VirtualListBox Jul 6, 2019
@nmgwddj nmgwddj merged commit ffdbca5 into netease-im:development Jul 8, 2019
QWarGod pushed a commit to QWarGod/NIM_Duilib_Framework that referenced this pull request Jun 18, 2021
添加VirtualTileBox控件的项目,可替换VirtualListBox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants