Merge remote-tracking branch 'gitea/master' into thr_dev/dev2
This commit is contained in:
@@ -80,14 +80,13 @@ namespace XericUIEditor.XTable
|
|||||||
|
|
||||||
if (GUILayout.Button("重新生成表格", GUILayout.Height(26)))
|
if (GUILayout.Button("重新生成表格", GUILayout.Height(26)))
|
||||||
{
|
{
|
||||||
m_Table.FullRebuild();
|
m_Table.FullRebuildPreservingData();
|
||||||
m_Table.SetChildrenVisible(m_ShowChildren);
|
m_Table.SetChildrenVisible(m_ShowChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("强制刷新样式", GUILayout.Height(26)))
|
if (GUILayout.Button("强制刷新样式", GUILayout.Height(26)))
|
||||||
{
|
{
|
||||||
XericLibrary.Runtime.SuperStyleSheet.StyleManager.ForceRefresh();
|
m_Table.ForceStyleRefresh();
|
||||||
m_Table.FullRebuild();
|
|
||||||
m_Table.SetChildrenVisible(m_ShowChildren);
|
m_Table.SetChildrenVisible(m_ShowChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,25 @@ namespace XericUIEditor.XTable
|
|||||||
// ★ 状态机:必须最先执行,后续所有逻辑依赖 s_State
|
// ★ 状态机:必须最先执行,后续所有逻辑依赖 s_State
|
||||||
UpdateState();
|
UpdateState();
|
||||||
|
|
||||||
|
// Unity 2021 兼容:阻止鼠标事件穿透 overlay 到背后 UI 对象
|
||||||
|
// 原理:在 overlay 区域注册默认控件,Scene View 拣选系统检测到控件后
|
||||||
|
// 不再选中背后 GameObject(Canvas、ScrollRect 等)
|
||||||
|
if (s_State == EditorState.TableNavigation)
|
||||||
|
{
|
||||||
|
// 覆盖区域:行标签 + 列表头 + 表格主体 + 底部工具栏
|
||||||
|
Rect overlayArea = new Rect(
|
||||||
|
tableRect.x - COL_W - MARGIN, // 包含行标签
|
||||||
|
tableRect.y - ROW_H - MARGIN, // 包含列表头
|
||||||
|
tableRect.width + COL_W + MARGIN + 4, // 包含行标签
|
||||||
|
tableRect.height + ROW_H + MARGIN + 56); // 包含列表头+工具栏
|
||||||
|
|
||||||
|
if (overlayArea.Contains(Event.current.mousePosition))
|
||||||
|
{
|
||||||
|
int blockId = GUIUtility.GetControlID(FocusType.Passive);
|
||||||
|
HandleUtility.AddDefaultControl(blockId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DrawRowLabels(rh, tableRect, xScale, yScale, table);
|
DrawRowLabels(rh, tableRect, xScale, yScale, table);
|
||||||
DrawColumnLabels(cw, tableRect, xScale, yScale, table);
|
DrawColumnLabels(cw, tableRect, xScale, yScale, table);
|
||||||
DrawGridLines(rh, cw, tableRect, xScale, yScale);
|
DrawGridLines(rh, cw, tableRect, xScale, yScale);
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ using XericUI.XTable.Core;
|
|||||||
using XericUI.XTable.Mapping;
|
using XericUI.XTable.Mapping;
|
||||||
using XericUI.XTable.Rendering.Elements;
|
using XericUI.XTable.Rendering.Elements;
|
||||||
using XericLibrary.Runtime.SuperStyleSheet;
|
using XericLibrary.Runtime.SuperStyleSheet;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace XericUI.XTable.Rendering.Component
|
namespace XericUI.XTable.Rendering.Component
|
||||||
{
|
{
|
||||||
@@ -723,6 +726,48 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
SetChildrenVisible(m_ChildrenVisible);
|
SetChildrenVisible(m_ChildrenVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>重新生成表格但保留已有文本数据——先保存,重建后再回填</summary>
|
||||||
|
public void FullRebuildPreservingData()
|
||||||
|
{
|
||||||
|
// 保存当前单元格文本
|
||||||
|
var savedTexts = new Dictionary<(int, int), string>();
|
||||||
|
if (m_TableData != null)
|
||||||
|
{
|
||||||
|
int rows = m_RowHeights?.Length ?? 0;
|
||||||
|
int cols = m_ColWidths?.Length ?? 0;
|
||||||
|
for (int r = 0; r < rows; r++)
|
||||||
|
{
|
||||||
|
for (int c = 0; c < cols; c++)
|
||||||
|
{
|
||||||
|
var cell = m_TableData.GetCell(r, c);
|
||||||
|
if (cell != null && !string.IsNullOrEmpty(cell.Text))
|
||||||
|
savedTexts[(r, c)] = cell.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FullRebuild();
|
||||||
|
|
||||||
|
// 恢复文本数据
|
||||||
|
foreach (var kv in savedTexts)
|
||||||
|
{
|
||||||
|
int r = kv.Key.Item1, c = kv.Key.Item2;
|
||||||
|
if (r < (m_RowHeights?.Length ?? 0) && c < (m_ColWidths?.Length ?? 0))
|
||||||
|
m_TableData.GetOrCreateCell(r, c).Text = kv.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshView();
|
||||||
|
SetChildrenVisible(m_ChildrenVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>仅强制刷新样式,不重建数据结构</summary>
|
||||||
|
public void ForceStyleRefresh()
|
||||||
|
{
|
||||||
|
StyleManager.ForceRefresh();
|
||||||
|
MarkDirty(TableDirtyType.StyleChanged);
|
||||||
|
RefreshView();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 单元格渲染
|
#region 单元格渲染
|
||||||
@@ -808,6 +853,7 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
txt.Text.color = GetStyleColor(cellNS, "/cell/fg/color", fgFallback);
|
txt.Text.color = GetStyleColor(cellNS, "/cell/fg/color", fgFallback);
|
||||||
txt.Text.fontSize = GetStyleInt(cellNS, "/cell/font/size", 14);
|
txt.Text.fontSize = GetStyleInt(cellNS, "/cell/font/size", 14);
|
||||||
txt.Text.alignment = TextAlignmentOptions.Midline;
|
txt.Text.alignment = TextAlignmentOptions.Midline;
|
||||||
|
txt.Text.font = GetStyleFontAsset(cellNS, "/cell/font/fontAsset") ?? txt.Text.font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -886,6 +932,7 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
txt.Text.color = GetStyleColor(cellNS, "/cell/fg/color", fgFallback);
|
txt.Text.color = GetStyleColor(cellNS, "/cell/fg/color", fgFallback);
|
||||||
txt.Text.fontSize = GetStyleInt(cellNS, "/cell/font/size", 14);
|
txt.Text.fontSize = GetStyleInt(cellNS, "/cell/font/size", 14);
|
||||||
txt.Text.alignment = TextAlignmentOptions.Midline;
|
txt.Text.alignment = TextAlignmentOptions.Midline;
|
||||||
|
txt.Text.font = GetStyleFontAsset(cellNS, "/cell/font/fontAsset") ?? txt.Text.font;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1007,6 +1054,14 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
return val != null ? (float)val : fallback;
|
return val != null ? (float)val : fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TMP_FontAsset GetStyleFontAsset(string ns, string path, TMP_FontAsset fallback = null)
|
||||||
|
{
|
||||||
|
StyleValue val = StyleManager.GetValue(ns, path);
|
||||||
|
if (val == null) return fallback;
|
||||||
|
try { return val.GetValueAs<TMP_FontAsset>(); }
|
||||||
|
catch { return fallback; }
|
||||||
|
}
|
||||||
|
|
||||||
private void EnsureDefaultStyleNamespace()
|
private void EnsureDefaultStyleNamespace()
|
||||||
{
|
{
|
||||||
// 避免在样式表尚未加载时触发 HasStyle → GetValue 的命名空间不存在错误
|
// 避免在样式表尚未加载时触发 HasStyle → GetValue 的命名空间不存在错误
|
||||||
@@ -1037,6 +1092,13 @@ namespace XericUI.XTable.Rendering.Component
|
|||||||
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/size", 14);
|
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/size", 14);
|
||||||
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/alignment", "MiddleCenter");
|
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/alignment", "MiddleCenter");
|
||||||
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/richText", true);
|
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/richText", true);
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
// 编辑器下尝试加载默认字体资源
|
||||||
|
var defaultFont = UnityEditor.AssetDatabase.LoadAssetAtPath<TMP_FontAsset>(
|
||||||
|
"Packages/com.lrss3.xericuiactionvessel/Runtime/Font/SourceHanSansSC-Regular-2 SDF.asset");
|
||||||
|
if (defaultFont != null)
|
||||||
|
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/font/fontAsset", defaultFont);
|
||||||
|
#endif
|
||||||
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/default/height", 40f);
|
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/default/height", 40f);
|
||||||
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/default/width", 100f);
|
StyleManager.AddDynamicStyle(m_DefaultStyleNamespace, "/cell/default/width", 100f);
|
||||||
StyleManager.ForceRefresh();
|
StyleManager.ForceRefresh();
|
||||||
|
|||||||
@@ -1,183 +1,197 @@
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
using XericLibrary.Runtime.SuperStyleSheet;
|
using XericLibrary.Runtime.SuperStyleSheet;
|
||||||
|
|
||||||
namespace XericUI.XTable.Rendering.Elements
|
namespace XericUI.XTable.Rendering.Elements
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 样式绑定元素——将 Image 或 TMP_Text 挂勾到样式表路径。
|
/// 样式绑定元素——将 Image 或 TMP_Text 挂勾到样式表路径。
|
||||||
/// 自动从 StyleManager 拉取值并应用,样式变更时自动刷新。
|
/// 自动从 StyleManager 拉取值并应用,样式变更时自动刷新。
|
||||||
/// 通过对象池复用时调用 Bind/Unbind 切换绑定目标。
|
/// 通过对象池复用时调用 Bind/Unbind 切换绑定目标。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StyleBoundElement
|
public class StyleBoundElement
|
||||||
{
|
{
|
||||||
#region 字段
|
#region 字段
|
||||||
|
|
||||||
/// <summary>绑定的 Image 组件(可能为 null)</summary>
|
/// <summary>绑定的 Image 组件(可能为 null)</summary>
|
||||||
public Image ImageComponent;
|
public Image ImageComponent;
|
||||||
|
|
||||||
/// <summary>绑定的 TMP_Text 组件(可能为 null)</summary>
|
/// <summary>绑定的 TMP_Text 组件(可能为 null)</summary>
|
||||||
public TMP_Text TextComponent;
|
public TMP_Text TextComponent;
|
||||||
|
|
||||||
/// <summary>样式命名空间</summary>
|
/// <summary>样式命名空间</summary>
|
||||||
private string m_StyleNamespace;
|
private string m_StyleNamespace;
|
||||||
|
|
||||||
/// <summary>各路径的 StyleField 缓存</summary>
|
/// <summary>各路径的 StyleField 缓存</summary>
|
||||||
private System.Collections.Generic.Dictionary<string, StyleField> m_Fields
|
private System.Collections.Generic.Dictionary<string, StyleField> m_Fields
|
||||||
= new System.Collections.Generic.Dictionary<string, StyleField>();
|
= new System.Collections.Generic.Dictionary<string, StyleField>();
|
||||||
|
|
||||||
/// <summary>是否已绑定</summary>
|
/// <summary>是否已绑定</summary>
|
||||||
private bool m_IsBound;
|
private bool m_IsBound;
|
||||||
|
|
||||||
/// <summary>样式变更时触发(通知表格重绘)</summary>
|
/// <summary>样式变更时触发(通知表格重绘)</summary>
|
||||||
public event System.Action OnStyleChangedCallback;
|
public event System.Action OnStyleChangedCallback;
|
||||||
|
|
||||||
/// <summary>当前绑定的命名空间(空字符串表示未绑定)</summary>
|
/// <summary>当前绑定的命名空间(空字符串表示未绑定)</summary>
|
||||||
public string BoundNamespace => m_IsBound ? (m_StyleNamespace ?? "") : "";
|
public string BoundNamespace => m_IsBound ? (m_StyleNamespace ?? "") : "";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 公开方法
|
#region 公开方法
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绑定到指定命名空间并开始监听样式。
|
/// 绑定到指定命名空间并开始监听样式。
|
||||||
/// 运行时注册 StyleField 实现被动更新(push);编辑器下在渲染时直接 pull。
|
/// 运行时注册 StyleField 实现被动更新(push);编辑器下在渲染时直接 pull。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Bind(string styleNamespace)
|
public void Bind(string styleNamespace)
|
||||||
{
|
{
|
||||||
if (m_IsBound) Unbind();
|
if (m_IsBound) Unbind();
|
||||||
m_StyleNamespace = styleNamespace;
|
m_StyleNamespace = styleNamespace;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(styleNamespace)) return;
|
if (string.IsNullOrEmpty(styleNamespace)) return;
|
||||||
|
|
||||||
// 检查命名空间是否存在,避免 Register → GetValue 报错
|
// 检查命名空间是否存在,避免 Register → GetValue 报错
|
||||||
var namespaces = StyleManager.GetAvailableNamespaces();
|
var namespaces = StyleManager.GetAvailableNamespaces();
|
||||||
if (namespaces == null || !namespaces.Contains(styleNamespace))
|
if (namespaces == null || !namespaces.Contains(styleNamespace))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 预注册常用路径
|
// 预注册常用路径
|
||||||
RegisterField("/cell/bg/color", OnStyleChanged);
|
RegisterField("/cell/bg/color", OnStyleChanged);
|
||||||
RegisterField("/cell/fg/color", OnStyleChanged);
|
RegisterField("/cell/fg/color", OnStyleChanged);
|
||||||
RegisterField("/cell/border/top/color", OnStyleChanged);
|
RegisterField("/cell/border/top/color", OnStyleChanged);
|
||||||
RegisterField("/cell/border/bottom/color", OnStyleChanged);
|
RegisterField("/cell/border/bottom/color", OnStyleChanged);
|
||||||
RegisterField("/cell/border/left/color", OnStyleChanged);
|
RegisterField("/cell/border/left/color", OnStyleChanged);
|
||||||
RegisterField("/cell/border/right/color", OnStyleChanged);
|
RegisterField("/cell/border/right/color", OnStyleChanged);
|
||||||
RegisterField("/cell/font/size", OnStyleChanged);
|
RegisterField("/cell/font/size", OnStyleChanged);
|
||||||
RegisterField("/cell/font/alignment", OnStyleChanged);
|
RegisterField("/cell/font/alignment", OnStyleChanged);
|
||||||
RegisterField("/cell/font/richText", OnStyleChanged);
|
RegisterField("/cell/font/richText", OnStyleChanged);
|
||||||
|
RegisterField("/cell/font/fontAsset", OnStyleChanged);
|
||||||
|
|
||||||
m_IsBound = true;
|
m_IsBound = true;
|
||||||
RefreshAll();
|
RefreshAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解绑并停止监听样式。
|
/// 解绑并停止监听样式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Unbind()
|
public void Unbind()
|
||||||
{
|
{
|
||||||
if (!m_IsBound) return;
|
if (!m_IsBound) return;
|
||||||
|
|
||||||
foreach (var kvp in m_Fields)
|
foreach (var kvp in m_Fields)
|
||||||
{
|
{
|
||||||
if (kvp.Value != null)
|
if (kvp.Value != null)
|
||||||
{
|
{
|
||||||
kvp.Value.Member.OnValueChanged -= OnStyleChanged;
|
kvp.Value.Member.OnValueChanged -= OnStyleChanged;
|
||||||
kvp.Value.Unregister();
|
kvp.Value.Unregister();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Fields.Clear();
|
|
||||||
m_IsBound = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
m_Fields.Clear();
|
||||||
/// 刷新全部样式值到组件。
|
m_IsBound = false;
|
||||||
/// </summary>
|
}
|
||||||
public void RefreshAll()
|
|
||||||
{
|
|
||||||
if (!m_IsBound || string.IsNullOrEmpty(m_StyleNamespace)) return;
|
|
||||||
|
|
||||||
// 背景颜色 → Image.color
|
/// <summary>
|
||||||
StyleValue bgVal = GetStyleValue("/cell/bg/color");
|
/// 刷新全部样式值到组件。
|
||||||
if (bgVal != null && ImageComponent != null)
|
/// </summary>
|
||||||
ImageComponent.color = bgVal;
|
public void RefreshAll()
|
||||||
|
{
|
||||||
|
if (!m_IsBound || string.IsNullOrEmpty(m_StyleNamespace)) return;
|
||||||
|
|
||||||
// 前景颜色 → Text.color
|
// 背景颜色 → Image.color
|
||||||
StyleValue fgVal = GetStyleValue("/cell/fg/color");
|
StyleValue bgVal = GetStyleValue("/cell/bg/color");
|
||||||
if (fgVal != null && TextComponent != null)
|
if (bgVal != null && ImageComponent != null)
|
||||||
TextComponent.color = fgVal;
|
ImageComponent.color = bgVal;
|
||||||
|
|
||||||
// 字体大小
|
// 前景颜色 → Text.color
|
||||||
StyleValue sizeVal = GetStyleValue("/cell/font/size");
|
StyleValue fgVal = GetStyleValue("/cell/fg/color");
|
||||||
if (sizeVal != null && TextComponent != null)
|
if (fgVal != null && TextComponent != null)
|
||||||
TextComponent.fontSize = (int)sizeVal;
|
TextComponent.color = fgVal;
|
||||||
|
|
||||||
// 对齐
|
// 字体大小
|
||||||
StyleValue alignVal = GetStyleValue("/cell/font/alignment");
|
StyleValue sizeVal = GetStyleValue("/cell/font/size");
|
||||||
if (alignVal != null && TextComponent != null)
|
if (sizeVal != null && TextComponent != null)
|
||||||
TextComponent.alignment = alignVal.Convert<TextAlignmentOptions>();
|
TextComponent.fontSize = (int)sizeVal;
|
||||||
|
|
||||||
// 富文本
|
// 对齐
|
||||||
StyleValue richVal = GetStyleValue("/cell/font/richText");
|
StyleValue alignVal = GetStyleValue("/cell/font/alignment");
|
||||||
if (richVal != null && TextComponent != null)
|
if (alignVal != null && TextComponent != null)
|
||||||
TextComponent.richText = (bool)richVal;
|
TextComponent.alignment = alignVal.Convert<TextAlignmentOptions>();
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
// 富文本
|
||||||
|
StyleValue richVal = GetStyleValue("/cell/font/richText");
|
||||||
|
if (richVal != null && TextComponent != null)
|
||||||
|
TextComponent.richText = (bool)richVal;
|
||||||
|
|
||||||
#region 私有方法
|
// 字体资源
|
||||||
|
StyleValue fontVal = GetStyleValue("/cell/font/fontAsset");
|
||||||
|
if (fontVal != null && TextComponent != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TextComponent.font = fontVal.GetValueAs<TMP_FontAsset>();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
/* 类型不匹配时忽略 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void RegisterField(string path, System.Action<StyleValue> callback)
|
#endregion
|
||||||
{
|
|
||||||
var field = new StyleField
|
|
||||||
{
|
|
||||||
Namespace = m_StyleNamespace,
|
|
||||||
StylePath = path
|
|
||||||
};
|
|
||||||
field.Register();
|
|
||||||
field.Member.OnValueChanged += callback;
|
|
||||||
m_Fields[path] = field;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StyleValue GetStyleValue(string path)
|
#region 私有方法
|
||||||
{
|
|
||||||
return StyleManager.GetValue(m_StyleNamespace, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnStyleChanged(StyleValue val)
|
private void RegisterField(string path, System.Action<StyleValue> callback)
|
||||||
{
|
{
|
||||||
RefreshAll();
|
var field = new StyleField
|
||||||
OnStyleChangedCallback?.Invoke();
|
{
|
||||||
}
|
Namespace = m_StyleNamespace,
|
||||||
|
StylePath = path
|
||||||
|
};
|
||||||
|
field.Register();
|
||||||
|
field.Member.OnValueChanged += callback;
|
||||||
|
m_Fields[path] = field;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
private StyleValue GetStyleValue(string path)
|
||||||
}
|
{
|
||||||
|
return StyleManager.GetValue(m_StyleNamespace, path);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void OnStyleChanged(StyleValue val)
|
||||||
/// 用于 TextAnchor → TextAlignmentOptions 的转换扩展。
|
{
|
||||||
/// </summary>
|
RefreshAll();
|
||||||
internal static class StyleBoundElementExtensions
|
OnStyleChangedCallback?.Invoke();
|
||||||
{
|
}
|
||||||
public static TextAlignmentOptions Convert<T>(this StyleValue val)
|
|
||||||
{
|
|
||||||
string s = val?.GetValueAs<string>();
|
|
||||||
if (string.IsNullOrEmpty(s)) return TextAlignmentOptions.Midline;
|
|
||||||
|
|
||||||
switch (s)
|
#endregion
|
||||||
{
|
}
|
||||||
case "UpperLeft": return TextAlignmentOptions.TopLeft;
|
|
||||||
case "UpperCenter": return TextAlignmentOptions.Top;
|
/// <summary>
|
||||||
case "UpperRight": return TextAlignmentOptions.TopRight;
|
/// 用于 TextAnchor → TextAlignmentOptions 的转换扩展。
|
||||||
case "MiddleLeft": return TextAlignmentOptions.MidlineLeft;
|
/// </summary>
|
||||||
case "MiddleCenter": return TextAlignmentOptions.Midline;
|
internal static class StyleBoundElementExtensions
|
||||||
case "MiddleRight": return TextAlignmentOptions.MidlineRight;
|
{
|
||||||
case "LowerLeft": return TextAlignmentOptions.BottomLeft;
|
public static TextAlignmentOptions Convert<T>(this StyleValue val)
|
||||||
case "LowerCenter": return TextAlignmentOptions.Bottom;
|
{
|
||||||
case "LowerRight": return TextAlignmentOptions.BottomRight;
|
string s = val?.GetValueAs<string>();
|
||||||
default: return TextAlignmentOptions.Midline;
|
if (string.IsNullOrEmpty(s)) return TextAlignmentOptions.Midline;
|
||||||
}
|
|
||||||
}
|
switch (s)
|
||||||
}
|
{
|
||||||
|
case "UpperLeft": return TextAlignmentOptions.TopLeft;
|
||||||
|
case "UpperCenter": return TextAlignmentOptions.Top;
|
||||||
|
case "UpperRight": return TextAlignmentOptions.TopRight;
|
||||||
|
case "MiddleLeft": return TextAlignmentOptions.MidlineLeft;
|
||||||
|
case "MiddleCenter": return TextAlignmentOptions.Midline;
|
||||||
|
case "MiddleRight": return TextAlignmentOptions.MidlineRight;
|
||||||
|
case "LowerLeft": return TextAlignmentOptions.BottomLeft;
|
||||||
|
case "LowerCenter": return TextAlignmentOptions.Bottom;
|
||||||
|
case "LowerRight": return TextAlignmentOptions.BottomRight;
|
||||||
|
default: return TextAlignmentOptions.Midline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,36 +3,47 @@
|
|||||||
// 表格默认样式定义
|
// 表格默认样式定义
|
||||||
// ==========================================
|
// ==========================================
|
||||||
|
|
||||||
|
|
||||||
namespace: xeric_table_default
|
namespace: xeric_table_default
|
||||||
|
|
||||||
// ---- 单元格背景 ----
|
|
||||||
cell/bg/color = (1,1,1,1):UnityEngine.Color @Desc:单元格背景颜色
|
cell/bg/color = (1,1,1,1):UnityEngine.Color @Desc:单元格背景颜色
|
||||||
|
|
||||||
// ---- 单元格前景 ----
|
|
||||||
cell/fg/color = (0.1,0.1,0.1,1):UnityEngine.Color @Desc:单元格前景文字颜色
|
cell/fg/color = (0.1,0.1,0.1,1):UnityEngine.Color @Desc:单元格前景文字颜色
|
||||||
|
|
||||||
// ---- 边框 ----
|
cell/border/top/ {
|
||||||
cell/border/top/color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:上边框颜色
|
color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:上边框颜色
|
||||||
cell/border/top/width = 1:System.Single @Desc:上边框宽度
|
width = 1:System.Single @Desc:上边框宽度
|
||||||
cell/border/bottom/color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:下边框颜色
|
}
|
||||||
cell/border/bottom/width = 1:System.Single @Desc:下边框宽度
|
|
||||||
cell/border/left/color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:左边框颜色
|
cell/border/bottom/ {
|
||||||
cell/border/left/width = 1:System.Single @Desc:左边框宽度
|
color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:下边框颜色
|
||||||
cell/border/right/color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:右边框颜色
|
width = 1:System.Single @Desc:下边框宽度
|
||||||
cell/border/right/width = 1:System.Single @Desc:右边框宽度
|
}
|
||||||
|
|
||||||
|
cell/border/left/ {
|
||||||
|
color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:左边框颜色
|
||||||
|
width = 1:System.Single @Desc:左边框宽度
|
||||||
|
}
|
||||||
|
|
||||||
|
cell/border/right/ {
|
||||||
|
color = (0.8,0.8,0.8,1):UnityEngine.Color @Desc:右边框颜色
|
||||||
|
width = 1:System.Single @Desc:右边框宽度
|
||||||
|
}
|
||||||
|
|
||||||
// ---- 选中高亮 ----
|
|
||||||
cell/selection/bg/color = (0.2,0.5,1,0.3):UnityEngine.Color @Desc:选中单元格高亮颜色
|
cell/selection/bg/color = (0.2,0.5,1,0.3):UnityEngine.Color @Desc:选中单元格高亮颜色
|
||||||
|
|
||||||
// ---- 表头样式 ----
|
|
||||||
header/bg/color = (0.9,0.9,0.9,1):UnityEngine.Color @Desc:表头背景颜色
|
header/bg/color = (0.9,0.9,0.9,1):UnityEngine.Color @Desc:表头背景颜色
|
||||||
|
|
||||||
header/fg/color = (0,0,0,1):UnityEngine.Color @Desc:表头文字颜色
|
header/fg/color = (0,0,0,1):UnityEngine.Color @Desc:表头文字颜色
|
||||||
|
|
||||||
// ---- 字体 ----
|
cell/font/ {
|
||||||
cell/font/size = 14:System.Int32 @Desc:默认字体大小
|
size = 14:System.Int32 @Desc:默认字体大小
|
||||||
cell/font/alignment = MiddleCenter:UnityEngine.TextAnchor @Desc:默认文本对齐
|
alignment = MiddleCenter:UnityEngine.TextAnchor @Desc:默认文本对齐
|
||||||
cell/font/richText = true:System.Boolean @Desc:是否启用富文本
|
richText = true:System.Boolean @Desc:是否启用富文本
|
||||||
|
fontAsset = guid:68dace674a028544187e7ffe55cdae8b:TMPro.TMP_FontAsset:TMPro.TMP_FontAsset @Desc:字体资源 @ResourceSoftReference:Packages/com.lrss3.xericuiactionvessel/Runtime/Font/SourceHanSansSC-Regular-2 SDF.asset
|
||||||
|
}
|
||||||
|
|
||||||
// ---- 行高 / 列宽(缺省值) ----
|
cell/default/ {
|
||||||
cell/default/height = 40:System.Single @Desc:默认行高
|
height = 40:System.Single @Desc:默认行高
|
||||||
cell/default/width = 100:System.Single @Desc:默认列宽
|
width = 100:System.Single @Desc:默认列宽
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user