Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

hotfixes #377

Merged
merged 7 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Runtime/editor/editor_window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,33 @@ namespace Unity.UIWidgets.editor {
#if UNITY_EDITOR
public abstract class UIWidgetsEditorWindow : EditorWindow, WindowHost {
WindowAdapter _windowAdapter;


static readonly List<UIWidgetsEditorWindow> _activeEditorWindows = new List<UIWidgetsEditorWindow>();

[InitializeOnLoadMethod]
static void _OnBaseEditorWindowLoaded()
{
EditorApplication.quitting += () =>
{
foreach (var editorWindow in _activeEditorWindows) {
editorWindow.OnDisable();
}

_activeEditorWindows.Clear();
};
}

public UIWidgetsEditorWindow() {
this.wantsMouseMove = true;
this.wantsMouseEnterLeaveWindow = true;

_activeEditorWindows.Add(this);
}

void OnDestroy() {
if (_activeEditorWindows.Contains(this)) {
_activeEditorWindows.Remove(this);
}
}

protected virtual void OnEnable() {
Expand Down Expand Up @@ -404,7 +427,7 @@ void _doOnGUI(Event evt) {
-evt.delta.y * this._devicePixelRatio,
evt.mousePosition.x * this._devicePixelRatio,
evt.mousePosition.y * this._devicePixelRatio,
InputUtils.getMouseButtonKey(evt.button)
InputUtils.getScrollButtonKey()
);
}
else if (evt.type == EventType.DragUpdated) {
Expand Down
3 changes: 3 additions & 0 deletions Runtime/gestures/binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ evt is PointerDragFromEditorReleaseEvent

void _handlePointerScrollEvent(PointerEvent evt) {
this.pointerRouter.clearScrollRoute(evt.pointer);
if (!this.pointerRouter.acceptScroll()) {
return;
}

HitTestResult result = new HitTestResult();
this.hitTest(result, evt.position);
Expand Down
4 changes: 4 additions & 0 deletions Runtime/gestures/pointer_router.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public void removeRoute(int pointer, PointerRoute route) {
this._routeMap.Remove(pointer);
}
}

public bool acceptScroll() {
return this._routeMap.Count == 0;
}

public void clearScrollRoute(int pointer) {
if (this._routeMap.ContainsKey(pointer)) {
Expand Down
3 changes: 3 additions & 0 deletions Runtime/service/text_input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ public TextEditingValue compose(string composeText) {
D.assert(!string.IsNullOrEmpty(composeText));
var composeStart = this.composing == TextRange.empty ? this.selection.start : this.composing.start;
var lastComposeEnd = this.composing == TextRange.empty ? this.selection.end : this.composing.end;

composeStart = Mathf.Clamp(composeStart, 0, this.text.Length);
lastComposeEnd = Mathf.Clamp(lastComposeEnd, 0, this.text.Length);
var newText = this.text.Substring(0, composeStart) + composeText + this.text.Substring(lastComposeEnd);
var componseEnd = composeStart + composeText.Length;
return new TextEditingValue(
Expand Down
2 changes: 1 addition & 1 deletion Runtime/ui/renderer/common/geometry/path/path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal uiPathCache flatten(float scale) {
return this._cache;
}

var _cache = uiPathCache.create(scale);
var _cache = uiPathCache.create(scale, this._shapeHint);

var i = 0;
while (i < this._commands.Count) {
Expand Down
13 changes: 11 additions & 2 deletions Runtime/ui/renderer/common/geometry/path/path_cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public uiMeshMesh strokeMesh {
float _miterLimit;
float _fringe;

public static uiPathCache create(float scale) {
uiPath.uiPathShapeHint _shapeHint;

public static uiPathCache create(float scale, uiPath.uiPathShapeHint shapeHint) {
uiPathCache newPathCache = ObjectPool<uiPathCache>.alloc();
newPathCache._distTol = 0.01f / scale;
newPathCache._tessTol = 0.25f / scale;
newPathCache._scale = scale;
newPathCache._shapeHint = shapeHint;
return newPathCache;
}

Expand All @@ -49,6 +52,10 @@ public bool canReuse(float scale) {
return true;
}

public bool canSkipAAHairline {
get { return this._shapeHint == uiPath.uiPathShapeHint.Rect; }
}

public override void clear() {
this._paths.Clear();
this._points.Clear();
Expand All @@ -57,6 +64,8 @@ public override void clear() {

ObjectPool<uiMeshMesh>.release(this._strokeMesh);
this._strokeMesh = null;

this._shapeHint = uiPath.uiPathShapeHint.Other;
}

public uiPathCache() {
Expand Down Expand Up @@ -460,7 +469,7 @@ uiVertexUV _expandFill(float fringe) {

uiList<Vector3> _strokeVertices = null;
uiList<Vector2> _strokeUV = null;
if (aa > 0.0f) {
if (aa > 0.0f && !this.canSkipAAHairline) {
_strokeVertices = ObjectPool<uiList<Vector3>>.alloc();
_strokeUV = ObjectPool<uiList<Vector2>>.alloc();
cvertices = 0;
Expand Down