Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 95bfbde

Browse files
committed
[Feature] Distinguish Panel&EditorWindow use cases
1 parent fe58e9d commit 95bfbde

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Runtime/editor/editor_window.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public Window window {
7171
public class EditorWindowAdapter : WindowAdapter {
7272
public readonly EditorWindow editorWindow;
7373

74-
public EditorWindowAdapter(EditorWindow editorWindow) {
74+
public EditorWindowAdapter(EditorWindow editorWindow):base( true) {
7575
this.editorWindow = editorWindow;
7676
}
7777

@@ -126,6 +126,10 @@ public interface WindowHost {
126126
public abstract class WindowAdapter : Window {
127127
static readonly List<WindowAdapter> _windowAdapters = new List<WindowAdapter>();
128128

129+
public WindowAdapter(bool inEditor = false) {
130+
this.inEditor = inEditor;
131+
}
132+
129133
public static List<WindowAdapter> windowAdapters {
130134
get { return _windowAdapters; }
131135
}
@@ -214,12 +218,14 @@ public void OnDisable() {
214218
this._surface = null;
215219
}
216220

221+
readonly protected bool inEditor;
222+
217223
public override IDisposable getScope() {
218224
WindowAdapter oldInstance = (WindowAdapter) _instance;
219225
_instance = this;
220226

221227
if (this._binding == null) {
222-
this._binding = new WidgetsBinding();
228+
this._binding = new WidgetsBinding(this.inEditor);
223229
}
224230

225231
SchedulerBinding._instance = this._binding;

Runtime/rendering/binding.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class RendererBinding : PaintingBinding {
1111
set { PaintingBinding.instance = value; }
1212
}
1313

14-
public RendererBinding() {
14+
public RendererBinding(bool inEditor = false) {
1515
this._pipelineOwner = new PipelineOwner(
1616
onNeedVisualUpdate: this.ensureVisualUpdate
1717
);
@@ -21,6 +21,8 @@ public RendererBinding() {
2121
this.initRenderView();
2222
D.assert(this.renderView != null);
2323
this.addPersistentFrameCallback(this._handlePersistentFrameCallback);
24+
25+
this.inEditor = inEditor;
2426
this._mouseTracker = this._createMouseTracker();
2527
}
2628

@@ -33,6 +35,7 @@ public void initRenderView() {
3335
public MouseTracker mouseTracker {
3436
get { return this._mouseTracker; }
3537
}
38+
3639
MouseTracker _mouseTracker;
3740

3841
public PipelineOwner pipelineOwner {
@@ -69,12 +72,14 @@ void _handlePersistentFrameCallback(TimeSpan timeStamp) {
6972
this.drawFrame();
7073
}
7174

75+
readonly protected bool inEditor;
76+
7277
MouseTracker _createMouseTracker() {
7378
return new MouseTracker(this.pointerRouter, (Offset offset) => {
7479
return this.renderView.layer.find<MouseTrackerAnnotation>(
75-
offset
76-
);
77-
});
80+
offset
81+
);
82+
}, this.inEditor);
7883
}
7984

8085
protected virtual void drawFrame() {

Runtime/widgets/binding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class WidgetsBinding : RendererBinding {
2727
set { RendererBinding.instance = value; }
2828
}
2929

30-
public WidgetsBinding() {
30+
public WidgetsBinding(bool inEditor = false) : base(inEditor) {
3131
this.buildOwner.onBuildScheduled = this._handleBuildScheduled;
3232
Window.instance.onLocaleChanged += this.handleLocaleChanged;
3333
this.widgetInspectorService = new WidgetInspectorService(this);

0 commit comments

Comments
 (0)