您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
57 行
1.5 KiB
57 行
1.5 KiB
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UIWidgets.foundation;
|
|
using UIWidgets.ui;
|
|
|
|
namespace UIWidgets.gestures {
|
|
public interface HitTestable {
|
|
void hitTest(HitTestResult result, Offset position);
|
|
}
|
|
|
|
public interface HitTestDispatcher {
|
|
void dispatchEvent(PointerEvent evt, HitTestResult result);
|
|
}
|
|
|
|
public interface HitTestTarget {
|
|
void handleEvent(PointerEvent evt, HitTestEntry entry);
|
|
}
|
|
|
|
public class HitTestEntry {
|
|
public HitTestEntry(HitTestTarget target) {
|
|
this._target = target;
|
|
}
|
|
|
|
public virtual HitTestTarget target {
|
|
get { return this._target; }
|
|
}
|
|
|
|
readonly HitTestTarget _target;
|
|
|
|
public override string ToString() {
|
|
return this._target.ToString();
|
|
}
|
|
}
|
|
|
|
public class HitTestResult {
|
|
public HitTestResult(List<HitTestEntry> path = null) {
|
|
this._path = path ?? new List<HitTestEntry>();
|
|
}
|
|
|
|
public IList<HitTestEntry> path {
|
|
get { return this._path.AsReadOnly(); }
|
|
}
|
|
|
|
readonly List<HitTestEntry> _path;
|
|
|
|
public void add(HitTestEntry entry) {
|
|
this._path.Add(entry);
|
|
}
|
|
|
|
public override string ToString() {
|
|
return string.Format("HitTestResult({0})",
|
|
this._path.isEmpty()
|
|
? "<empty path>"
|
|
: string.Join(", ", this._path.Select(x => x.ToString()).ToArray()));
|
|
}
|
|
}
|
|
}
|