浏览代码

Merge branch 'master' into 'master'

Master

See merge request upm-packages/ui-widgets/com.unity.uiwidgets!86
/main
Shenhua Gu 6 年前
当前提交
5667400e
共有 6 个文件被更改,包括 65 次插入22 次删除
  1. 8
      Runtime/debugger/inspector_treeview.cs
  2. 4
      Runtime/debugger/inspector_window.cs
  3. 17
      Runtime/ui/txt/linebreaker.cs
  4. 14
      Runtime/ui/txt/word_separate.cs
  5. 29
      Runtime/ui/txt/wordbreaker.cs
  6. 15
      Samples/UIWidgetSample/TextInputCanvas.cs

8
Runtime/debugger/inspector_treeview.cs


public override string displayName {
get { return this.node.name + this.node.description; }
get {
if (this.node.showName && !string.IsNullOrEmpty(this.node.name)) {
return $"{this.node.name}{this.node.separator} {this.node.description}";
}
return this.node.description;
}
}
}

4
Runtime/debugger/inspector_window.cs


window.Show();
}
void OnEnable() {
this.titleContent = new GUIContent("UIWidgets Inspector");
}
void OnGUI() {
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
this.DoSelectDropDown();

17
Runtime/ui/txt/linebreaker.cs


int candIndex = this._candidates.Count;
this._candidates.Add(cand);
if (cand.postBreak - this._preBreak > this._lineWidth) {
if (this._bestBreak == this._lastBreak) {
this._bestBreak = candIndex;
}
this._pushGreedyBreak();
}
while (this._lastBreak != candIndex && cand.postBreak - this._preBreak > this._lineWidth) {
for (int i = this._lastBreak + 1; i < candIndex; i++) {
float penalty = this._candidates[i].penalty;
if (penalty <= this._bestScore) {
this._bestBreak = i;
this._bestScore = penalty;
}
}
if (this._bestBreak == this._lastBreak) {
this._bestBreak = candIndex;
}
this._pushGreedyBreak();
}

14
Runtime/ui/txt/word_separate.cs


Backward,
}
enum characterType {
internal enum characterType {
LetterLike,
Symbol,
WhiteSpace

return new Range<int>(0, 0);
}
var t = this.classifyChar(index);
var t = classifyChar(this._text, index);
if (this.classifyChar(i) != t) {
if (classifyChar(this._text, i) != t) {
break;
}

int end = index;
for (int i = index; i < this._text.Length; ++i) {
if (!char.IsLowSurrogate(this._text[i])) {
if (this.classifyChar(i) != t) {
if (classifyChar(this._text, i) != t) {
break;
}

}
characterType classifyChar(int index) {
if (char.IsWhiteSpace(this._text, index)) {
internal static characterType classifyChar(string text, int index) {
if (char.IsWhiteSpace(text, index)) {
if (char.IsLetterOrDigit(this._text, index) || this._text[index] == '\'') {
if (char.IsLetterOrDigit(text, index) || text[index] == '\'') {
return characterType.LetterLike;
}

29
Runtime/ui/txt/wordbreaker.cs


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

this._current = this._findNextBreakInEmailOrUrl();
}
else {
this._current = this._findNextBreakNormal();
this._current = this._findNextBoundaryNormal();
}
return this._current;

this._current = 0;
this._scanOffset = 0;
this._inEmailOrUrl = false;
this.nextUntilCodePoint();
}
public int current() {

return 0;
}
int _findNextBreakNormal() {
int _findNextBoundaryNormal() {
WordSeparate.characterType preType = WordSeparate.classifyChar(this._text, this._current + this._offset);
char c = this._text[this._current + this._offset];
if (LayoutUtils.isWordSpace(c) || c == '\t') {
return this._current;
this.nextUntilCodePoint();
if (this._current >= this._size) {
break;
}
var currentType = WordSeparate.classifyChar(this._text, this._current + this._offset);
if (currentType != preType) {
break;
preType = currentType;
void _detectEmailOrUrl() {
}

public static uint getSupplementary(uint lead, uint trail) {
return (char) (((uint) (lead) << 10) + (uint) (trail - U16_SURROGATE_OFFSET));
}
void nextUntilCodePoint() {
while (this._current < this._size
&& (char.IsLowSurrogate(this._text[this._current + this._offset])
|| char.IsHighSurrogate(this._text[this._current + this._offset]))) {
this._current++;
}
}
}
}

15
Samples/UIWidgetSample/TextInputCanvas.cs


List<Widget> widgets = new List<Widget>();
var style = new TextStyle();
var cursorColor = new Color(0xFF000000);
var selectionColor = new Color(0xFF6F6F6F);
new EditableText(controller, node, style, cursorColor, onSubmitted: this.textSubmitted)))));
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, onSubmitted: this.textSubmitted)))));
new EditableText(controller, node, style, cursorColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, maxLines: 4,
new EditableText(controller, node, style, cursorColor, obscureText: true,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, obscureText: true,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.number,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.phone,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.emailAddress,
new EditableText(controller, node, style, cursorColor, keyboardType: TextInputType.url,
new EditableText(controller, node, style, cursorColor, selectionColor: selectionColor, keyboardType: TextInputType.url,
onSubmitted: this.textSubmitted)))));
return new Column(

正在加载...
取消
保存