浏览代码

Merge branch 'text_edit' into 'master'

fix custom painter hit test default

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!50
/main
Shenhua Gu 6 年前
当前提交
bf557bf3
共有 4 个文件被更改,包括 22 次插入19 次删除
  1. 20
      Runtime/painting/image_resolution.cs
  2. 10
      Runtime/rendering/custom_paint.cs
  3. 9
      Runtime/widgets/editable_text.cs
  4. 2
      Runtime/widgets/scrollbar.cs

20
Runtime/painting/image_resolution.cs


}
}
public class AssetImageConfiguration: IEquatable<AssetImageConfiguration> {
public class AssetImageConfiguration : IEquatable<AssetImageConfiguration> {
public readonly ImageConfiguration configuration;
public readonly string assetName;

}
public bool Equals(AssetImageConfiguration other) {
if (ReferenceEquals(null, other)) {
return false;

public override int GetHashCode() {
unchecked {
return ((this.configuration != null ? this.configuration.GetHashCode() : 0) * 397) ^ (this.assetName != null ? this.assetName.GetHashCode() : 0);
return ((this.configuration != null ? this.configuration.GetHashCode() : 0) * 397) ^
(this.assetName != null ? this.assetName.GetHashCode() : 0);
}
}

return !Equals(left, right);
}
}
public static AssetBundleCache instance => _instance;
readonly Dictionary<int, Dictionary<AssetImageConfiguration, AssetBundleImageKey>> _bundleCaches =
public static AssetBundleCache instance {
get { return _instance; }
}
readonly Dictionary<int, Dictionary<AssetImageConfiguration, AssetBundleImageKey>> _bundleCaches =
public Dictionary<AssetImageConfiguration, AssetBundleImageKey> get(AssetBundle bundle) {
Dictionary<AssetImageConfiguration, AssetBundleImageKey> result;
int id = bundle == null ? 0 : bundle.GetInstanceID();

result = new Dictionary<AssetImageConfiguration, AssetBundleImageKey>();
this._bundleCaches[id] = result;
return result;

10
Runtime/rendering/custom_paint.cs


bool shouldRepaint(CustomPainter oldDelegate);
bool hitTest(Offset position);
bool? hitTest(Offset position);
}
public abstract class AbstractCustomPainter : CustomPainter {

public abstract bool shouldRepaint(CustomPainter oldDelegate);
public virtual bool hitTest(Offset position) {
return true;
public virtual bool? hitTest(Offset position) {
return null;
}
public override string ToString() {

}
protected override bool hitTestChildren(HitTestResult result, Offset position) {
if (this._foregroundPainter != null && (this._foregroundPainter.hitTest(position))) {
if (this._foregroundPainter != null && ((this._foregroundPainter.hitTest(position)) ?? false)) {
return true;
}

protected override bool hitTestSelf(Offset position) {
return this._painter != null && this._painter.hitTest(position);
return this._painter != null && (this._painter.hitTest(position) ?? true);
}
protected override void performResize() {

9
Runtime/widgets/editable_text.cs


public readonly TextDirection? textDirection;
public readonly double textScaleFactor;
public readonly double? textScaleFactor;
public readonly Color cursorColor;

public EditableText(TextEditingController controller, FocusNode focusNode, TextStyle style,
Color cursorColor, bool obscureText = false, bool autocorrect = false,
TextAlign textAlign = TextAlign.left, TextDirection? textDirection = null,
double textScaleFactor = 1.0, int maxLines = 1,
double? textScaleFactor = null, int maxLines = 1,
bool autofocus = false, Color selectionColor = null, TextSelectionControls selectionControls = null,
ValueChanged<string> onChanged = null, VoidCallback onEditingComplete = null,
ValueChanged<string> onSubmitted = null, SelectionChangedCallback onSelectionChanged = null,

defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new EnumProperty<TextDirection?>("textDirection", this.textDirection,
defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new DiagnosticsProperty<double>("textScaleFactor", this.textScaleFactor,
properties.add(new DiagnosticsProperty<double?>("textScaleFactor", this.textScaleFactor,
defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new DiagnosticsProperty<int>("maxLines", this.maxLines, defaultValue: 1));
properties.add(new DiagnosticsProperty<bool>("autofocus", this.autofocus, defaultValue: false));

hasFocus: this._hasFocus,
maxLines: this.widget.maxLines,
selectionColor: this.widget.selectionColor,
textScaleFactor: Window.instance
.devicePixelRatio, // todo widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
textScaleFactor: this.widget.textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
textAlign: this.widget.textAlign,
textDirection: this._textDirection,
obscureText: this.widget.obscureText,

2
Runtime/widgets/scrollbar.cs


}
}
public bool hitTest(Offset position) {
public bool? hitTest(Offset position) {
return false;
}

正在加载...
取消
保存