update UIElements
This commit is contained in:
@@ -127,15 +127,37 @@ namespace YooAsset.Editor
|
||||
toolbarBtn.name = column.ElementName;
|
||||
toolbarBtn.text = column.HeaderTitle;
|
||||
toolbarBtn.style.unityTextAlign = column.ColumnStyle.TxtAnchor;
|
||||
toolbarBtn.style.flexGrow = column.ColumnStyle.Stretchable ? 1f : 0f;
|
||||
toolbarBtn.style.flexGrow = 0;
|
||||
toolbarBtn.style.width = column.ColumnStyle.Width;
|
||||
toolbarBtn.style.minWidth = column.ColumnStyle.MinWidth;
|
||||
toolbarBtn.style.maxWidth = column.ColumnStyle.MaxWidth;
|
||||
toolbarBtn.style.minWidth = column.ColumnStyle.Width;
|
||||
toolbarBtn.style.maxWidth = column.ColumnStyle.Width;
|
||||
toolbarBtn.clickable.clickedWithEventInfo += OnClickTableHead;
|
||||
SetCellElementStyle(toolbarBtn);
|
||||
_toolbar.Add(toolbarBtn);
|
||||
_columns.Add(column);
|
||||
|
||||
// 可伸缩控制柄
|
||||
if (column.ColumnStyle.Stretchable)
|
||||
{
|
||||
int handleWidth = 3;
|
||||
int minWidth = (int)column.ColumnStyle.MinWidth.value;
|
||||
int maxWidth = (int)column.ColumnStyle.MaxWidth.value;
|
||||
var resizeHandle = new ResizeHandle(handleWidth, toolbarBtn, minWidth, maxWidth);
|
||||
resizeHandle.ResizeChanged += (float value) =>
|
||||
{
|
||||
float width = Mathf.Clamp(value, column.ColumnStyle.MinWidth.value, column.ColumnStyle.MaxWidth.value);
|
||||
column.ColumnStyle.Width = width;
|
||||
|
||||
foreach (var element in column.CellElements)
|
||||
{
|
||||
element.style.width = width;
|
||||
element.style.minWidth = width;
|
||||
element.style.maxWidth = width;
|
||||
}
|
||||
};
|
||||
_toolbar.Add(resizeHandle);
|
||||
}
|
||||
|
||||
// 计算索引值
|
||||
column.ColumnIndex = _columns.Count - 1;
|
||||
|
||||
@@ -293,8 +315,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var cellElement = colum.MakeCell.Invoke();
|
||||
cellElement.name = colum.ElementName;
|
||||
cellElement.style.flexGrow = 0f;
|
||||
SetCellElementStyle(cellElement);
|
||||
listViewElement.Add(cellElement);
|
||||
colum.CellElements.Add(cellElement);
|
||||
}
|
||||
return listViewElement;
|
||||
}
|
||||
@@ -314,12 +338,13 @@ namespace YooAsset.Editor
|
||||
StyleLength defaultStyle = new StyleLength(1f);
|
||||
element.style.paddingTop = defaultStyle;
|
||||
element.style.paddingBottom = defaultStyle;
|
||||
element.style.paddingLeft = defaultStyle;
|
||||
element.style.paddingRight = defaultStyle;
|
||||
element.style.marginTop = defaultStyle;
|
||||
element.style.marginBottom = defaultStyle;
|
||||
element.style.marginLeft = defaultStyle;
|
||||
element.style.marginRight = defaultStyle;
|
||||
|
||||
element.style.paddingLeft = 1;
|
||||
element.style.paddingRight = 1;
|
||||
element.style.marginLeft = 0;
|
||||
element.style.marginRight = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user