浏览代码

Merge branch 'gallery' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into gallery

/main
Yuncong Zhang 6 年前
当前提交
e4624390
共有 14 个文件被更改,包括 92 次插入54 次删除
  1. 24
      Runtime/gestures/monodrag.cs
  2. 9
      Runtime/gestures/recognizer.cs
  3. 6
      Runtime/rendering/paragraph.cs
  4. 2
      Runtime/rendering/proxy_box.cs
  5. 15
      Runtime/service/keyboard.cs
  6. 8
      Runtime/service/text_input.cs
  7. 27
      Runtime/ui/painting/txt/font_manager.cs
  8. 4
      Runtime/ui/painting/txt/mesh_generator.cs
  9. 3
      Runtime/ui/txt/layout.cs
  10. 6
      Runtime/ui/txt/linebreaker.cs
  11. 24
      Runtime/widgets/binding.cs
  12. 6
      Runtime/widgets/framework.cs
  13. 2
      Runtime/widgets/media_query.cs
  14. 10
      Runtime/widgets/scroll_physics.cs

24
Runtime/gestures/monodrag.cs


});
}
this.invokeCallback<object>("onEnd", () => {
this.onEnd(new DragEndDetails(
velocity: Velocity.zero,
primaryVelocity: 0.0f
));
return null;
}, debugReport: () => { return "Pointer scroll end"; }
);
this._state = _DragState.ready;
this.stopTrackingScrollerPointer(evt.pointer);
return;
}

public override void rejectGesture(int pointer) {
this.stopTrackingPointer(pointer);
}
protected override void didStopTrackingLastScrollerPointer(int pointer) {
this._state = _DragState.ready;
this.invokeCallback<object>("onEnd", () => {
this.onEnd(new DragEndDetails(
velocity: Velocity.zero,
primaryVelocity: 0.0f
));
return null;
}, debugReport: () => { return "Pointer scroll end"; }
);
}
protected override void didStopTrackingLastPointer(int pointer) {

9
Runtime/gestures/recognizer.cs


protected abstract void didStopTrackingLastPointer(int pointer);
protected virtual void didStopTrackingLastScrollerPointer(int pointer) {
}
protected virtual void resolve(GestureDisposition disposition) {
var localEntries = new List<GestureArenaEntry>(this._entries.Values);
this._entries.Clear();

protected void startTrackingScrollerPointer(int pointer) {
GestureBinding.instance.pointerRouter.addRoute(pointer, this.handleEvent);
}
protected void stopTrackingScrollerPointer(int pointer) {
if (this._trackedPointers.isEmpty()) {
this.didStopTrackingLastScrollerPointer(pointer);
}
}
protected void startTrackingPointer(int pointer) {

6
Runtime/rendering/paragraph.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public enum TextOverflow {

this._textPainter.textDirection = this.textDirection;
this.markNeedsLayout();
}
}
protected Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) {
D.assert(this._textPainter != null);
return this._textPainter.getOffsetForCaret(position, caretPrototype);
}
public bool softWrap {

2
Runtime/rendering/proxy_box.cs


}
void _paintChildWithTransform(PaintingContext context, Offset offset) {
Offset childOffset = MatrixUtils.getAsTranslation(this._transform);
Offset childOffset = this._transform.getAsTranslation();
if (childOffset == null) {
context.pushTransform(this.needsCompositing, offset, this._transform, base.paint);
}

15
Runtime/service/keyboard.cs


}
var currentEvent = Event.current;
if (currentEvent != null && currentEvent.type == EventType.KeyDown) {
var action = TextInputUtils.getInputAction(currentEvent);
if (action != null) {

if (action == null || action == TextInputAction.newline) {
if (currentEvent.keyCode == KeyCode.None) {
this._value = this._value.clearCompose().insert(new string(currentEvent.character, 1));
char ch = currentEvent.character;
if (ch == '\r' || ch == 3) {
ch = '\n';
}
this._value = this._value.clearCompose();
if (_validateCharacter(ch)) {
this._value = this._value.insert(new string(ch, 1));
}
Window.instance.run(() => { TextInput._updateEditingState(this._client, this._value); });
}
}

}
public void Dispose() {
}
static bool _validateCharacter(char ch) {
return ch >= ' ' || ch == '\t' || ch == '\r' || ch == 10 || ch == '\n';
}
}

8
Runtime/service/text_input.cs


return this;
}
newText = this.selection.textBefore(this.text) + text + this.selection.textAfter(this.text);
newSelection = TextSelection.collapsed(this.selection.start + text.Length);
var selection = this.selection;
if (selection.start < 0) {
selection = TextSelection.collapsed(0, this.selection.affinity);
}
newText = selection.textBefore(this.text) + text + selection.textAfter(this.text);
newSelection = TextSelection.collapsed(selection.start + text.Length);
return new TextEditingValue(
text: newText, selection: newSelection, composing: TextRange.empty
);

27
Runtime/ui/painting/txt/font_manager.cs


public void addFont(Font font) {
D.assert(font != null);
D.assert(font.dynamic, $"adding font which is not dynamic is not allowed {font.name}");
FontInfo current;
this._fonts.TryGetValue(font.name, out current);
D.assert(current == null || current.font == font, $"font with name {font.name} already exists");
foreach (var fontName in font.fontNames) {
this._fonts[fontName] = fontInfo;
}
this._fonts[font.name] = fontInfo;
}
internal FontInfo getOrCreate(string name) {

osFont.material.mainTexture.hideFlags = HideFlags.DontSave;
var newFont = new FontInfo(osFont);
foreach (var fontName in osFont.fontNames) {
this._fonts[fontName] = newFont;
}
this._fonts[osFont.name] = newFont;
return newFont;
}

if (entry != null) {
entry.onTextureRebuilt();
}
}
}
public static class FontExtension
{
public static CharacterInfo getCharacterInfo(this Font font, char ch, int fontSize, UnityEngine.FontStyle fontStyle)
{
CharacterInfo info;
bool success = font.GetCharacterInfo(ch, out info, fontSize, fontStyle);
if (!success) {
Debug.LogWarning($"character info not found from the given font: character '{ch}' (code{(int)ch}) font: ${font.name}");
}
return info;
}
}
}

4
Runtime/ui/painting/txt/mesh_generator.cs


continue;
}
CharacterInfo charInfo;
font.GetCharacterInfo(ch, out charInfo, fontSizeToLoad, style.UnityFontStyle);
CharacterInfo charInfo = font.getCharacterInfo(ch, fontSizeToLoad, style.UnityFontStyle);
var minX = charInfo.minX / this._scale;
var maxX = charInfo.maxX / this._scale;
var minY = charInfo.minY / this._scale;

3
Runtime/ui/txt/layout.cs


for (int i = 0; i < count; i++) {
int charIndex = start + i;
var ch = text[charIndex];
CharacterInfo characterInfo;
font.GetCharacterInfo(ch, out characterInfo, style.UnityFontSize, style.UnityFontStyle);
CharacterInfo characterInfo = font.getCharacterInfo(ch, style.UnityFontSize, style.UnityFontStyle);
var rect = Rect.fromLTRB(characterInfo.minX, -characterInfo.maxY, characterInfo.maxX,
-characterInfo.minY);

6
Runtime/ui/txt/linebreaker.cs


using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

if (this._tabWidth == int.MaxValue) {
this._font.RequestCharactersInTexture(" ", this._fontSize);
CharacterInfo characterInfo;
this._font.GetCharacterInfo(' ', out characterInfo, this._fontSize);
CharacterInfo characterInfo = this._font.getCharacterInfo(' ', this._fontSize, UnityEngine.FontStyle.Normal);
this._tabWidth = characterInfo.advance * kTabSpaceCount;
}

24
Runtime/widgets/binding.cs


RenderObjectToWidgetElement<RenderBox> _renderViewElement;
public void detachRootWidget() {
this.pipelineOwner.rootNode = null;
void unMountAll(Element element) {
element.visitChildren(unMountAll);
element.deactivate();
element.unmount();
}
if (this._renderViewElement != null) {
this._renderViewElement.visitChildren(unMountAll);
this._renderViewElement.deactivate();
this._renderViewElement.unmount();
this._renderViewElement = null;
if (this._renderViewElement == null) {
return;
this.attachRootWidget(null);
this.buildOwner.buildScope(this._renderViewElement);
this.buildOwner.finalizeTree();
this.pipelineOwner.rootNode = null;
this._renderViewElement.deactivate();
this._renderViewElement.unmount();
this._renderViewElement = null;
}
public void attachRootWidget(Widget rootWidget) {

6
Runtime/widgets/framework.cs


return true;
}
return ReferenceEquals(this.componentKey1, other.componentKey1) &&
ReferenceEquals(this.componentKey2, other.componentKey2);
return Equals(this.componentKey1, other.componentKey1) &&
Equals(this.componentKey2, other.componentKey2);
}
public override bool Equals(object obj) {

return true;
});
if (_registry.getOrDefault(compKey) == element) {
if (_registry[compKey] == element) {
_registry.Remove(compKey);
_removedKeys.Add(compKey);
}

2
Runtime/widgets/media_query.cs


return of(context, nullOk: true)?.textScaleFactor ?? 1.0f;
}
static bool boldTextOverride(BuildContext context) {
public static bool boldTextOverride(BuildContext context) {
return of(context, nullOk: true)?.boldText ?? false;
}

10
Runtime/widgets/scroll_physics.cs


}
}
public virtual float dragStartDistanceMotionThreshold {
public virtual float? dragStartDistanceMotionThreshold {
if (this.parent == null) {
return 0.0f;
}
return this.parent.dragStartDistanceMotionThreshold;
return this.parent?.dragStartDistanceMotionThreshold;
}
}

Mathf.Min(0.000816f * Mathf.Pow(existingVelocity.abs(), 1.967f), 40000.0f);
}
public override float dragStartDistanceMotionThreshold {
public override float? dragStartDistanceMotionThreshold {
get { return 3.5f; }
}
}

正在加载...
取消
保存