siyao
4 年前
当前提交
6a9c08b8
共有 4 个文件被更改,包括 343 次插入 和 37 次删除
-
86com.unity.uiwidgets/Runtime/material/button_theme.cs
-
14com.unity.uiwidgets/Runtime/material/material_button.cs
-
178com.unity.uiwidgets/Runtime/material/theme_data.cs
-
102com.unity.uiwidgets/Runtime/material/material_state.cs
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEditor.VersionControl; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public enum MaterialState { |
|||
hovered, |
|||
|
|||
focused, |
|||
|
|||
pressed, |
|||
|
|||
dragged, |
|||
|
|||
selected, |
|||
|
|||
disabled, |
|||
|
|||
error, |
|||
} |
|||
|
|||
public partial class material_ { |
|||
public delegate T MaterialPropertyResolver<T>(HashSet<MaterialState> states); |
|||
} |
|||
|
|||
abstract class MaterialStateColor : Color { |
|||
public MaterialStateColor(uint defaultValue) : base(defaultValue) { |
|||
} |
|||
|
|||
static MaterialStateColor resolveWith(material_.MaterialPropertyResolver<Color> callback) => |
|||
new material._MaterialStateColor(callback); |
|||
|
|||
public abstract Color resolve(HashSet<MaterialState> states); |
|||
|
|||
|
|||
public static Color resolveAs<Color>(Color value, HashSet<MaterialState> states) { |
|||
if (value is MaterialStateProperty<Color> materialStateProperty) { |
|||
MaterialStateProperty<Color> property = materialStateProperty; |
|||
return property.resolve(states); |
|||
} |
|||
|
|||
return value; |
|||
} |
|||
|
|||
public static MaterialStateProperty<Color> resolveWith<Color>( |
|||
material_.MaterialPropertyResolver<Color> callback) => new _MaterialStateProperty<Color>(callback); |
|||
} |
|||
|
|||
class _MaterialStateColor : MaterialStateColor { |
|||
internal _MaterialStateColor(material_.MaterialPropertyResolver<Color> _resolve) : base(_resolve(_defaultStates) |
|||
.value) { |
|||
this._resolve = _resolve; |
|||
} |
|||
|
|||
readonly material_.MaterialPropertyResolver<Color> _resolve; |
|||
|
|||
public static readonly HashSet<MaterialState> _defaultStates = new HashSet<MaterialState>(); |
|||
|
|||
public override Color resolve(HashSet<MaterialState> states) => _resolve(states); |
|||
} |
|||
|
|||
abstract class MaterialStateProperty<T> { |
|||
public abstract T resolve(HashSet<MaterialState> states); |
|||
|
|||
|
|||
public static T resolveAs<T>(T value, HashSet<MaterialState> states) { |
|||
if (value is MaterialStateProperty<T> materialStateProperty) { |
|||
MaterialStateProperty<T> property = materialStateProperty; |
|||
return property.resolve(states); |
|||
} |
|||
|
|||
return value; |
|||
} |
|||
|
|||
public static MaterialStateProperty<T> resolveWith<T>(material_.MaterialPropertyResolver<T> callback) => |
|||
new _MaterialStateProperty<T>(callback); |
|||
} |
|||
|
|||
|
|||
class _MaterialStateProperty<T> : MaterialStateProperty<T> { |
|||
internal _MaterialStateProperty(material_.MaterialPropertyResolver<T> _resolve) { |
|||
this._resolve = _resolve; |
|||
} |
|||
|
|||
readonly material_.MaterialPropertyResolver<T> _resolve; |
|||
|
|||
public override T resolve(HashSet<MaterialState> states) => _resolve(states); |
|||
|
|||
public static T resolveAs<T>(T value, HashSet<MaterialState> states) { |
|||
if (value is MaterialStateProperty<T> materialStateProperty) { |
|||
MaterialStateProperty<T> property = materialStateProperty; |
|||
return property.resolve(states); |
|||
} |
|||
|
|||
return value; |
|||
} |
|||
|
|||
public static MaterialStateProperty<T> resolveWith<T>(material_.MaterialPropertyResolver<T> callback) => |
|||
new _MaterialStateProperty<T>(callback); |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue