浏览代码

change some classes in ui namspace to internal

/main
fzhangtj 6 年前
当前提交
bb7f0f99
共有 12 个文件被更改,包括 86 次插入82 次删除
  1. 36
      Runtime/painting/text_style.cs
  2. 23
      Runtime/ui/painting/txt/text_blob.cs
  3. 39
      Runtime/ui/text.cs
  4. 3
      Runtime/ui/txt/layout.cs
  5. 6
      Runtime/ui/txt/linebreaker.cs
  6. 2
      Runtime/ui/txt/paint_record.cs
  7. 26
      Runtime/ui/txt/paragraph.cs
  8. 12
      Runtime/ui/txt/paragraph_builder.cs
  9. 6
      Runtime/ui/txt/styled_runs.cs
  10. 2
      Runtime/ui/txt/word_separate.cs
  11. 2
      Runtime/ui/txt/wordbreaker.cs
  12. 11
      Tests/Editor/CanvasAndLayers.cs

36
Runtime/painting/text_style.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.painting {
public class TextStyle : Diagnosticable, IEquatable<TextStyle>, ParagraphBuilder.ITextStyleProvider {
public class TextStyle : Diagnosticable, IEquatable<TextStyle> {
public static readonly float _defaultFontSize = 14.0f;
public readonly bool inherit;
public readonly Color color;

this.fontFamily = fontFamily;
this.debugLabel = debugLabel;
this.background = background;
}
public ui.TextStyle getTextStyle(ui.TextStyle currentStyle = null, float textScaleFactor = 1.0f) {
if (currentStyle != null) {
return new ui.TextStyle(
color: this.color ?? currentStyle.color,
fontSize: this.fontSize != null ? this.fontSize * textScaleFactor : currentStyle.fontSize,
fontWeight: this.fontWeight ?? currentStyle.fontWeight,
fontStyle: this.fontStyle ?? currentStyle.fontStyle,
letterSpacing: this.letterSpacing ?? currentStyle.letterSpacing,
wordSpacing: this.wordSpacing ?? currentStyle.wordSpacing,
textBaseline: this.textBaseline ?? currentStyle.textBaseline,
height: this.height ?? currentStyle.height,
decoration: this.decoration ?? currentStyle.decoration,
decorationColor: this.decorationColor ?? currentStyle.decorationColor,
fontFamily: this.fontFamily ?? currentStyle.fontFamily,
background: this.background ?? currentStyle.background
);
}
return new ui.TextStyle(
color: this.color,
fontSize: this.fontSize * textScaleFactor,
fontWeight: this.fontWeight,
fontStyle: this.fontStyle,
letterSpacing: this.letterSpacing,
wordSpacing: this.wordSpacing,
textBaseline: this.textBaseline,
height: this.height,
decoration: this.decoration,
decorationColor: this.decorationColor,
fontFamily: this.fontFamily,
background: this.background
);
}
public RenderComparison compareTo(TextStyle other) {

23
Runtime/ui/painting/txt/text_blob.cs


namespace Unity.UIWidgets.ui {
public class TextBlob {
public TextBlob(string text, int textOffset, int textSize, Vector2d[] positions, Rect bounds, TextStyle style) {
internal TextBlob(string text, int textOffset, int textSize, Vector2d[] positions, Rect bounds, TextStyle style) {
this.instanceId = ++_nextInstanceId;
this.positions = positions;
this.text = text;

}
static long _nextInstanceId = 0;
public readonly long instanceId;
public readonly string text;
public readonly int textOffset;
public readonly int textSize;
public readonly Vector2d[] positions;
public readonly TextStyle style;
public readonly Rect bounds; // bounds with positions[start] as origin
internal readonly long instanceId;
internal readonly string text;
internal readonly int textOffset;
internal readonly int textSize;
internal readonly Vector2d[] positions;
internal readonly TextStyle style;
internal readonly Rect bounds; // bounds with positions[start] as origin
}
public class TextBlobBuilder {

int _size;
Rect _bounds;
public void allocRunPos(TextStyle style, string text, int offset, int size) {
public void allocRunPos(painting.TextStyle style, string text, int offset, int size, float textScaleFactor = 1.0f) {
this.allocRunPos(TextStyle.applyStyle(null, style, textScaleFactor), text, offset, size);
}
internal void allocRunPos(TextStyle style, string text, int offset, int size) {
this._style = style;
this._text = text;
this._textOffset = offset;

39
Runtime/ui/text.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.ui {
public enum FontStyle {

}
}
public class TextStyle : IEquatable<TextStyle> {
internal class TextStyle : IEquatable<TextStyle> {
public readonly Color color = Color.fromARGB(255, 0, 0, 0);
public readonly float fontSize = 14.0f;
public readonly FontWeight fontWeight = FontWeight.w400;

internal int UnityFontSize {
get { return (int) this.fontSize; }
}
public static TextStyle applyStyle(TextStyle currentStyle, painting.TextStyle style, float textScaleFactor) {
if (currentStyle != null) {
return new ui.TextStyle(
color: style.color ?? currentStyle.color,
fontSize: style.fontSize != null ? style.fontSize * textScaleFactor : currentStyle.fontSize,
fontWeight: style.fontWeight ?? currentStyle.fontWeight,
fontStyle: style.fontStyle ?? currentStyle.fontStyle,
letterSpacing: style.letterSpacing ?? currentStyle.letterSpacing,
wordSpacing: style.wordSpacing ?? currentStyle.wordSpacing,
textBaseline: style.textBaseline ?? currentStyle.textBaseline,
height: style.height ?? currentStyle.height,
decoration: style.decoration ?? currentStyle.decoration,
decorationColor: style.decorationColor ?? currentStyle.decorationColor,
fontFamily: style.fontFamily ?? currentStyle.fontFamily,
background: style.background ?? currentStyle.background
);
}
return new ui.TextStyle(
color: style.color,
fontSize: style.fontSize * textScaleFactor,
fontWeight: style.fontWeight,
fontStyle: style.fontStyle,
letterSpacing: style.letterSpacing,
wordSpacing: style.wordSpacing,
textBaseline: style.textBaseline,
height: style.height,
decoration: style.decoration,
decorationColor: style.decorationColor,
fontFamily: style.fontFamily,
background: style.background
);
}
public bool Equals(TextStyle other) {

}
}
public TextStyle getTextStyle() {
internal TextStyle getTextStyle() {
return new TextStyle(
fontWeight: this.fontWeight,
fontStyle: this.fontStyle,

3
Runtime/ui/txt/layout.cs


using UnityEngine;
namespace Unity.UIWidgets.ui {
public class Layout {
class Layout {
int _start;
int _count;
List<float> _advances = new List<float>();

6
Runtime/ui/txt/linebreaker.cs


using UnityEngine;
namespace Unity.UIWidgets.ui {
public class TabStops {
class TabStops {
int _tabWidth = int.MaxValue;
Font _font;

}
}
public class Candidate {
class Candidate {
public int offset;
public int pre;
public float preBreak;

public int postSpaceCount;
}
public class LineBreaker {
class LineBreaker {
const float ScoreInfty = float.MaxValue;
const float ScoreDesperate = 1e10f;

2
Runtime/ui/txt/paint_record.cs


namespace Unity.UIWidgets.ui {
public class PaintRecord {
class PaintRecord {
public PaintRecord(TextStyle style, Offset offset, TextBlob _text,
FontMetrics metrics,
int line, float runWidth) {

26
Runtime/ui/txt/paragraph.cs


}
}
public class CodeUnitRun {
class CodeUnitRun {
public readonly int lineNumber;
public readonly TextDirection direction;
public readonly Range<int> codeUnits;

}
public class FontMetrics {
class FontMetrics {
public readonly float ascent;
public readonly float leading = 0.0f;
public readonly float descent;

}
}
public class LineStyleRun {
class LineStyleRun {
public readonly int start;
public readonly int end;
public readonly TextStyle style;

}
}
public class PositionWithAffinity {
class PositionWithAffinity {
public readonly int position;
public readonly TextAffinity affinity;

}
}
public class GlyphPosition {
class GlyphPosition {
public readonly Range<float> xPos;
public readonly Range<int> codeUnits;

}
}
public class Range<T> : IEquatable<Range<T>> {
class Range<T> : IEquatable<Range<T>> {
public Range(T start, T end) {
this.start = start;
this.end = end;

public readonly T start, end;
}
public static class RangeUtils {
static class RangeUtils {
public static Range<float> shift(Range<float> value, float shift) {
return new Range<float>(value.start + shift, value.end + shift);
}

public class GlyphLine {
class GlyphLine {
public readonly List<GlyphPosition> positions;
public readonly int totalCountUnits;

}
public void setText(string text, StyledRuns runs) {
internal void setText(string text, StyledRuns runs) {
this._text = text;
this._runs = runs;
this._needsLayout = true;

return TextBox.fromLTBD(0, top, 0, bottom, TextDirection.ltr);
}
public PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {
internal PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {
if (this._lineHeights.Count == 0) {
return new PositionWithAffinity(0, TextAffinity.downstream);
}

return Mathf.Max(lineCount - 1, 0);
}
public LineRange getLineRange(int lineIndex) {
internal LineRange getLineRange(int lineIndex) {
public Range<int> getWordBoundary(int offset) {
internal Range<int> getWordBoundary(int offset) {
WordSeparate s = new WordSeparate(this._text);
return s.findWordRange(offset);
}

}
}
public class SplayTree<TKey, TValue> : IDictionary<TKey, TValue> where TKey : IComparable<TKey> {
class SplayTree<TKey, TValue> : IDictionary<TKey, TValue> where TKey : IComparable<TKey> {
SplayTreeNode root;
int count;
int version = 0;

12
Runtime/ui/txt/paragraph_builder.cs


List<int> _styleStack = new List<int>();
int _paragraph_style_index;
public interface ITextStyleProvider {
TextStyle getTextStyle(TextStyle current = null, float textScaleFactor = 1.0f);
}
public ParagraphBuilder(ParagraphStyle style) {
this.setParagraphStyle(style);
}

return paragraph;
}
public void pushStyle(ITextStyleProvider style, float textScaleFactor) {
var newStyle = style.getTextStyle(this.peekStyle(), textScaleFactor: textScaleFactor);
public void pushStyle(painting.TextStyle style, float textScaleFactor) {
var newStyle = TextStyle.applyStyle(this.peekStyle(), style, textScaleFactor: textScaleFactor);
public void pushStyle(TextStyle style) {
internal void pushStyle(TextStyle style) {
var styleIndex = this._runs.addStyle(style);
this._styleStack.Add(styleIndex);
this._runs.startRun(styleIndex, this._text.Length);

this._text.Append(text);
}
public TextStyle peekStyle() {
internal TextStyle peekStyle() {
return this._runs.getStyle(this.peekStyleIndex());
}

6
Runtime/ui/txt/styled_runs.cs


using System.Collections.Generic;
namespace Unity.UIWidgets.ui {
public class StyledRuns {
class StyledRuns {
readonly List<TextStyle> styles = new List<TextStyle>();
readonly List<IndexedRun> runs = new List<IndexedRun>();

}
}
public class Run {
internal class Run {
public readonly TextStyle style;
public readonly int start;
public readonly int end;

}
}
public class IndexedRun {
internal class IndexedRun {
public readonly int styleIndex = 0;
public readonly int start;
public int end;

2
Runtime/ui/txt/word_separate.cs


namespace Unity.UIWidgets.ui {
public class WordSeparate {
class WordSeparate {
enum Direction {
Forward,
Backward,

2
Runtime/ui/txt/wordbreaker.cs


namespace Unity.UIWidgets.ui {
public class WordBreaker {
class WordBreaker {
public const uint U16_SURROGATE_OFFSET = ((0xd800 << 10) + 0xdc00 - 0x10000);
string _text;
int _offset;

11
Tests/Editor/CanvasAndLayers.cs


using Gradient = Unity.UIWidgets.ui.Gradient;
using Material = UnityEngine.Material;
using Rect = UnityEngine.Rect;
using TextStyle = Unity.UIWidgets.ui.TextStyle;
namespace UIWidgets.Tests {
public class CanvasAndLayers : EditorWindow {

paint);
canvas.scale(3);
TextBlob textBlob = new TextBlob("This is a text blob", 0, 19, new Vector2d[] {
TextBlobBuilder builder = new TextBlobBuilder();
string text = "This is a text blob";
builder.allocRunPos(new TextStyle(), text, 0, text.Length);
builder.setBounds(Unity.UIWidgets.ui.Rect.fromLTWH(0, 0, 200, 50));
builder.positions = new Vector2d[] {
new Vector2d(10, 0),
new Vector2d(20, 0),
new Vector2d(30, 0),

new Vector2d(170, 0),
new Vector2d(180, 0),
new Vector2d(190, 0),
}, Unity.UIWidgets.ui.Rect.fromLTWH(0, 0, 200, 50), new TextStyle());
};
canvas.drawTextBlob(textBlob, new Offset(100, 100), paint);
canvas.drawTextBlob(builder.make(), new Offset(100, 100), paint);
canvas.drawLine(
new Offset(10, 30),

正在加载...
取消
保存