浏览代码

add keyboard, fix text_input

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
4ec6a0bf
共有 12 个文件被更改,包括 87 次插入12 次删除
  1. 2
      Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs
  2. 23
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_switch_demo.cs
  3. 2
      com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
  4. 4
      com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs
  5. 14
      com.unity.uiwidgets/Runtime/gestures/converter.cs
  6. 4
      com.unity.uiwidgets/Runtime/services/text_input.cs
  7. 9
      com.unity.uiwidgets/Runtime/ui2/pointer.cs
  8. 5
      engine/src/lib/ui/window/pointer_data.h
  9. 6
      engine/src/shell/platform/embedder/embedder.cc
  10. 5
      engine/src/shell/platform/embedder/embedder.h
  11. 23
      engine/src/shell/platform/unity/windows/uiwidgets_panel.cc
  12. 2
      engine/src/shell/platform/unity/windows/uiwidgets_panel.h

2
Samples/UIWidgetsSamples_2019_4/Assets/Script/TextTest.cs


public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new HomeScreen()//new DetailScreen1("ok")
home: new HomeScreen() //new DetailScreen1("ok")
//color: Color.white
);
}

23
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_switch_demo.cs


"Disabled - Off"
),
}
)
),
new MyPrefilledText()
}
)
)

}
}
public class MyPrefilledText : StatefulWidget
{
public override State createState() => new _MyPrefilledTextState();
}
class _MyPrefilledTextState : State<MyPrefilledText>
{
TextEditingController _textController;
public override void initState()
{
base.initState();
_textController = new TextEditingController(text: "initial text");
}
public override Widget build(BuildContext context)
{
return new CupertinoTextField(controller: _textController);
}
}
}

2
com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs


EditorGUILayout.PropertyField(serializedObject.FindProperty("fonts"), true);
EditorGUILayout.PropertyField(pixelRatioProperty);
// EditorGUILayout.PropertyField(pixelRatioProperty);
EditorGUILayout.PropertyField(antiAliasingProperty);
UIWidgetsPanel panel = (UIWidgetsPanel)target;

4
com.unity.uiwidgets/Runtime/engine2/UIWidgetsPanel.cs


return result;
}
public float devicePixelRatioOverride;
public float devicePixelRatioOverride {
get => Screen.dpi / 96.0f;
}
public float hardwareAntiAliasing;
// RectTransform rectTransform {

14
com.unity.uiwidgets/Runtime/gestures/converter.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.service;
using UnityEngine;
namespace Unity.UIWidgets.gestures {

radiusMin: radiusMin,
radiusMax: radiusMax
);
break;
default:
//TODO: PUT KEYBOARD TO A PROPRER POSITION
if (datum.kind == PointerDeviceKind.keyboard) {
var keyBoardEvent = new Event();
if (datum.change == PointerChange.kMouseDown) {
keyBoardEvent.type = EventType.KeyDown;
}else if (datum.change == PointerChange.kMouseUp) {
keyBoardEvent.type = EventType.KeyUp;
}
keyBoardEvent.keyCode = (KeyCode)datum.buttons;
RawKeyboard.instance._handleKeyEvent(keyBoardEvent);
}
break;
}
}

4
com.unity.uiwidgets/Runtime/services/text_input.cs


string text = "",
TextSelection selection = null,
TextRange composing = null) {
D.assert(text != null);
D.assert(selection != null);
this.selection = this.selection ?? TextSelection.collapsed(offset: -1);
this.text = text;
this.composing = composing ?? TextRange.empty;

9
com.unity.uiwidgets/Runtime/ui2/pointer.cs


down,
move,
up,
kMouseDown,
kMouseUp,
touch,
mouse,
touch = 0,
mouse = 1,
unknown
unknown,
keyboard = 4,
}
public enum PointerSignalKind {

5
engine/src/lib/ui/window/pointer_data.h


kDown,
kMove,
kUp,
kMouseDown,
kMouseUp,
};
enum class DeviceKind : int64_t {

kInvertedStylus,
kInvertedStylus,
kKeyboard,
};
enum class SignalKind : int64_t {

6
engine/src/shell/platform/embedder/embedder.cc


return PointerData::Change::kRemove;
case kHover:
return PointerData::Change::kHover;
case kMouseDown:
return PointerData::Change::kMouseDown;
case kMouseUp:
return PointerData::Change::kMouseUp;
}
return PointerData::Change::kCancel;
}

return PointerData::DeviceKind::kMouse;
case kUIWidgetsPointerDeviceKindTouch:
return PointerData::DeviceKind::kTouch;
case kUIWidgetsPointerDeviceKindKeyboard:
return PointerData::DeviceKind::kKeyboard;
}
return PointerData::DeviceKind::kMouse;
}

5
engine/src/shell/platform/embedder/embedder.h


kAdd,
kRemove,
kHover,
kMouseDown,
kMouseUp,
kUIWidgetsPointerDeviceKindTouch = 0,
kUIWidgetsPointerDeviceKindTouch,
kUIWidgetsPointerDeviceKindKeyboard = 7,
} UIWidgetsPointerDeviceKind;
typedef enum {

23
engine/src/shell/platform/unity/windows/uiwidgets_panel.cc


}
}
void UIWidgetsPanel::OnKeyDown(int keyCode, bool isKeyDown) {
if (process_events_) {
UIWidgetsPointerEvent event = {};
event.phase = isKeyDown ? UIWidgetsPointerPhase::kMouseDown : UIWidgetsPointerPhase::kMouseUp;
event.device_kind =
UIWidgetsPointerDeviceKind::kUIWidgetsPointerDeviceKindKeyboard;
event.buttons = keyCode;
event.struct_size = sizeof(event);
event.timestamp =
std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::high_resolution_clock::now().time_since_epoch())
.count();
UIWidgetsEngineSendPointerEvent(engine_, &event, 1);
}
}
void UIWidgetsPanel::OnMouseMove(float x, float y) {
if (process_events_) {
SendMouseMove(x, y);

UIWIDGETS_API(void)
UIWidgetsPanel_unregisterTexture(UIWidgetsPanel* panel, int texture_id) {
panel->UnregisterTexture(texture_id);
}
UIWIDGETS_API(void)
UIWidgetsPanel_onKey(UIWidgetsPanel* panel, int keyCode, bool isKeyDown) {
panel->OnKeyDown(keyCode, isKeyDown);
}
UIWIDGETS_API(void)

2
engine/src/shell/platform/unity/windows/uiwidgets_panel.h


void ProcessVSync();
void VSyncCallback(intptr_t baton);
void OnKeyDown(int keyCode, bool isKeyDown);
void OnMouseMove(float x, float y);

正在加载...
取消
保存