优化tableView控件横向拖动滑块的显示

This commit is contained in:
睿 安
2026-01-29 10:43:25 +08:00
parent bcb56200c1
commit dcdbf051d0
14 changed files with 22 additions and 4 deletions

5
.gitignore vendored
View File

@@ -1,9 +1,8 @@
build/* build/
build64/* demo/
_temp/ _temp/
_bin/ _bin/
temp/ temp/
bin/ bin/
.vs/ .vs/
demo/
*.lib *.lib

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
#include "TableView.h" #include "TableView.h"
namespace ezui { namespace ezui {
@@ -240,6 +240,11 @@ namespace ezui {
g.DrawRectangle(RectF(firstColRect)); g.DrawRectangle(RectF(firstColRect));
} }
int headerClipWidth = Width() - m_firstColumnWidth;
if (headerClipWidth > 0) {
g.PushAxisAlignedClip(RectF((float)m_firstColumnWidth, 0.0f, (float)headerClipWidth, (float)m_headerHeight));
}
// 绘制数据列表头 // 绘制数据列表头
int x = m_firstColumnWidth - m_scrollOffsetX; int x = m_firstColumnWidth - m_scrollOffsetX;
for (int i = 0; i < (int)m_columns.size(); ++i) { for (int i = 0; i < (int)m_columns.size(); ++i) {
@@ -277,9 +282,14 @@ namespace ezui {
x += col.Width; x += col.Width;
} }
if (headerClipWidth > 0) {
g.PopAxisAlignedClip();
}
} }
void TableView::DrawCells(PaintEventArgs& args) { void TableView::DrawCells(PaintEventArgs& args) {
auto& g = args.Graphics;
int startY = m_headerHeight; int startY = m_headerHeight;
for (int row = 0; row < (int)m_data.size(); ++row) { for (int row = 0; row < (int)m_data.size(); ++row) {
@@ -295,6 +305,11 @@ namespace ezui {
Rect firstColRect(0, rowY, m_firstColumnWidth, rowHeight); Rect firstColRect(0, rowY, m_firstColumnWidth, rowHeight);
DrawFirstColumn(args, row, firstColRect); DrawFirstColumn(args, row, firstColRect);
int rowClipWidth = Width() - m_firstColumnWidth;
if (rowClipWidth > 0) {
g.PushAxisAlignedClip(RectF((float)m_firstColumnWidth, (float)rowY, (float)rowClipWidth, (float)rowHeight));
}
// 绘制数据列 // 绘制数据列
int x = m_firstColumnWidth - m_scrollOffsetX; int x = m_firstColumnWidth - m_scrollOffsetX;
for (int col = 0; col < (int)m_columns.size(); ++col) { for (int col = 0; col < (int)m_columns.size(); ++col) {
@@ -310,6 +325,10 @@ namespace ezui {
DrawCell(args, row, col, cellRect); DrawCell(args, row, col, cellRect);
x += colWidth; x += colWidth;
} }
if (rowClipWidth > 0) {
g.PopAxisAlignedClip();
}
} }
} }