Skip to content

Commit bd37138

Browse files
committed
Move default window positioning to Utility
1 parent a54b9aa commit bd37138

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

Assets/MicroEngineer/Code/UI/MainGuiController.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,7 @@ public void OnEnable()
3636
MainGuiWindow = (MainGuiWindow)Manager.Instance.Windows.Find(w => w is MainGuiWindow);
3737

3838
// Handle initial window positioning. Set the position OnGeometryChangedEvent.
39-
EventCallback<GeometryChangedEvent> _positionCallBack = null;
40-
_positionCallBack = evt =>
41-
{
42-
if (evt.newRect.width == 0 || evt.newRect.height == 0)
43-
return;
44-
45-
Root[0].style.left = MainGuiWindow.FlightRect.position.x;
46-
Root[0].style.top = MainGuiWindow.FlightRect.position.y;
47-
48-
Root[0].UnregisterCallback(_positionCallBack);
49-
};
50-
Root[0].RegisterCallback<GeometryChangedEvent>(_positionCallBack);
39+
Utility.SetDefaultWindowPosition(Root[0], MainGuiWindow.FlightRect.position.x, MainGuiWindow.FlightRect.position.y);
5140
}
5241

5342
private void UpdateWindowPosition(PointerUpEvent evt)

Assets/MicroEngineer/Code/UI/StageInfoOABController.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,7 @@ public void OnEnable()
5050
Root[0].RegisterCallback<PointerUpEvent>(UpdateWindowPosition);
5151

5252
// Handle initial window positioning. Set the position OnGeometryChangedEvent.
53-
EventCallback<GeometryChangedEvent> _positionCallBack = null;
54-
_positionCallBack = evt =>
55-
{
56-
if (evt.newRect.width == 0 || evt.newRect.height == 0)
57-
return;
58-
59-
Root[0].style.left = StageInfoOABWindow.EditorRect.position.x;
60-
Root[0].style.top = StageInfoOABWindow.EditorRect.position.y;
61-
62-
Root[0].UnregisterCallback(_positionCallBack);
63-
};
64-
Root[0].RegisterCallback<GeometryChangedEvent>(_positionCallBack);
53+
Utility.SetDefaultWindowPosition(Root[0], StageInfoOABWindow.EditorRect.position.x, StageInfoOABWindow.EditorRect.position.y);
6554
}
6655

6756
private void UpdateWindowPosition(PointerUpEvent evt)

0 commit comments

Comments
 (0)