表格面板:多选统一设置样式、选择即重绘、单元格配置换成覆盖层入口
- 新增 SetCellStyleRect / SetCellStyleNamespaceRect:按选区矩形逐格写命名空间+样式路径, 合并块按 ResolveStyleRect 展开,边框与脏标记各只写一次;面板改为作用于整个选区。 - Inspector 订阅 SelectionHandle.OnSelectionChanged / OnCellSelected / Undo.undoRedoPerformed, 事件驱动 Repaint——点选单元格不再需要把鼠标移进面板才刷新。 - 「单元格配置」的 infobox 换成按钮,直接打开 Table Editor Override Layer; 该开关状态收敛到 XTableEditorOverlay.Enabled(EditorPrefs + Menu.SetChecked), 删掉 SceneEditor 里重复注册的同路径 MenuItem。
This commit is contained in:
@@ -183,6 +183,53 @@ namespace XericUI.XTable.Rendering.Component
|
||||
MarkDirty(TableDirtyType.StyleChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按矩形区域设置命名空间 + 样式路径(Inspector 多选统一设置用)。
|
||||
/// 每格仍走合并块展开;边框只写一次,脏标记只打一次。
|
||||
/// </summary>
|
||||
public void SetCellStyleRect(int minRow, int minCol, int maxRow, int maxCol,
|
||||
string styleNamespace, string stylePath)
|
||||
{
|
||||
ClampCellRect(ref minRow, ref minCol, ref maxRow, ref maxCol);
|
||||
for (int r = minRow; r <= maxRow; r++)
|
||||
for (int c = minCol; c <= maxCol; c++)
|
||||
{
|
||||
var data = TableData.GetOrCreateCell(r, c);
|
||||
data.CellStyle ??= new XericLibrary.Runtime.SuperStyleSheet.StyleMember();
|
||||
data.CellStyle.CurrentNamespace = styleNamespace ?? "";
|
||||
data.CellStyle.StylePath = stylePath ?? "";
|
||||
data.StyleNamespace = styleNamespace ?? "";
|
||||
}
|
||||
TableData.SetBorderRect(minRow, maxRow + 1, minCol, maxCol + 1, styleNamespace);
|
||||
MarkDirty(TableDirtyType.StyleChanged);
|
||||
}
|
||||
|
||||
/// <summary>按矩形区域只设置命名空间(兼容旧版的批量版本)。</summary>
|
||||
public void SetCellStyleNamespaceRect(int minRow, int minCol, int maxRow, int maxCol, string styleNamespace)
|
||||
{
|
||||
ClampCellRect(ref minRow, ref minCol, ref maxRow, ref maxCol);
|
||||
for (int r = minRow; r <= maxRow; r++)
|
||||
for (int c = minCol; c <= maxCol; c++)
|
||||
TableData.GetOrCreateCell(r, c).StyleNamespace = styleNamespace ?? string.Empty;
|
||||
TableData.SetBorderRect(minRow, maxRow + 1, minCol, maxCol + 1, styleNamespace);
|
||||
MarkDirty(TableDirtyType.StyleChanged);
|
||||
}
|
||||
|
||||
private void ClampCellRect(ref int minRow, ref int minCol, ref int maxRow, ref int maxCol)
|
||||
{
|
||||
int rowCount = m_RowHeights?.Length ?? 0;
|
||||
int colCount = m_ColWidths?.Length ?? 0;
|
||||
if (rowCount <= 0 || colCount <= 0)
|
||||
{
|
||||
minRow = 0; maxRow = -1; minCol = 0; maxCol = -1;
|
||||
return;
|
||||
}
|
||||
minRow = Mathf.Clamp(minRow, 0, rowCount - 1);
|
||||
maxRow = Mathf.Clamp(maxRow, minRow, rowCount - 1);
|
||||
minCol = Mathf.Clamp(minCol, 0, colCount - 1);
|
||||
maxCol = Mathf.Clamp(maxCol, minCol, colCount - 1);
|
||||
}
|
||||
|
||||
private void ResolveStyleRect(int row, int col, out int rowStart, out int rowEnd, out int colStart, out int colEnd)
|
||||
{
|
||||
rowStart = row; colStart = col; rowEnd = row + 1; colEnd = col + 1;
|
||||
|
||||
Reference in New Issue
Block a user