浏览代码

Merge branch 'keyboard' into 'master'

fix text bounds & focus issue

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!117
/main
Shenhua Gu 6 年前
当前提交
bc5d1eca
共有 4 个文件被更改,包括 34 次插入15 次删除
  1. 8
      Runtime/editor/editor_window.cs
  2. 20
      Runtime/engine/UIWidgetsPanel.cs
  3. 2
      Runtime/ui/painting/canvas_impl.cs
  4. 19
      Runtime/widgets/focus_manager.cs

8
Runtime/editor/editor_window.cs


this.editorWindow.Repaint();
}
protected override bool hasFocus() {
return EditorWindow.focusedWindow == this.editorWindow;
}
public override GUIContent titleContent {
get { return this.editorWindow.titleContent; }
}

protected virtual void updateSafeArea() {
}
protected abstract bool hasFocus();
public void OnEnable() {
this._devicePixelRatio = this.queryDevicePixelRatio();

public void Update() {
Timer.update();
bool hasFocus = this.hasFocus();
WidgetsBinding.instance.focusManager.focusNone(!hasFocus);
this._updateScrollInput();
TextInput.Update();
this._timerProvider.update(this.flushMicrotasks);

20
Runtime/engine/UIWidgetsPanel.cs


Screen.height - Screen.safeArea.height);
}
protected override bool hasFocus() {
return EventSystem.current != null &&
EventSystem.current.currentSelectedGameObject == this._uiWidgetsPanel.gameObject;
}
public override void scheduleFrame(bool regenerateLayerTree = true) {
base.scheduleFrame(regenerateLayerTree);
this._needsPaint = true;

PerformanceUtils.instance.updateDeltaTime(Time.unscaledDeltaTime);
this._displayMetrics.Update();
UIWidgetsMessageManager.ensureUIWidgetsMessageManagerIfNeeded();
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != this.gameObject) {
this.unfocusIfNeeded();
}
if (this._mouseEntered) {
if (this._lastMouseMove.x != Input.mousePosition.x || this._lastMouseMove.y != Input.mousePosition.y) {
this.handleMouseMovement();

D.assert(this._windowAdapter != null);
this._windowAdapter.Update();
this._windowAdapter.OnGUI(_repaintEvent);
}
void OnGUI() {

physicalX: position.x,
physicalY: position.y
));
}
void unfocusIfNeeded() {
using (this._windowAdapter.getScope()) {
var focusNode = WidgetsBinding.instance.focusManager.currentFocus;
if (focusNode != null) {
focusNode.unfocus();
}
}
}
}
}

2
Runtime/ui/painting/canvas_impl.cs


var tex = font.material.mainTexture;
Action<Paint> drawMesh = (Paint p) => {
if (!this._applyClip(textBlob.bounds)) {
if (!this._applyClip(matrix.mapRect(textBlob.bounds))) {
return;
}

19
Runtime/widgets/focus_manager.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace Unity.UIWidgets.widgets {
public class FocusNode : ChangeNotifier {

}
public readonly FocusScopeNode rootScope = new FocusScopeNode();
internal readonly FocusScopeNode _noneScope = new FocusScopeNode();
internal FocusNode _currentFocus;
internal void _willDisposeFocusNode(FocusNode node) {

}
}
public void focusNone(bool focus) {
if (focus) {
if (this._noneScope._parent != null && this._noneScope.isFirstFocus) {
return;
}
this.rootScope.setFirstFocus(this._noneScope);
}
else {
if (this._noneScope._parent == null) {
return;
}
this._noneScope.detach();
}
}
public override string ToString() {
var status = this._haveScheduledUpdate ? " UPDATE SCHEDULED" : "";
var indent = " ";

正在加载...
取消
保存