Skip to content

Commit d9f658b

Browse files
committed
Updated Exchange Window Fullscreen layout
1 parent f504b6d commit d9f658b

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#exchange-inspector {
2+
flex-grow: 1;
3+
margin-bottom: -2px;
4+
}
5+
6+
.exchange-inspector-ancestor {
7+
flex-grow: 1;
8+
position: absolute;
9+
top: 0px;
10+
bottom: 0px;
11+
left: 0px;
12+
right: 0px;
13+
}

Packages/com.quickeye.http-debugger/Editor/UIAssets/ExchangeInspector.style.uss.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/com.quickeye.http-debugger/Editor/Windows/ExchangeInspectorWindow.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using UnityEditor;
2+
using UnityEngine;
23
using UnityEngine.UIElements;
34

45
namespace QuickEye.WebTools.Editor
@@ -13,44 +14,52 @@ public static void Select(RequestData request, bool readOnly)
1314
}
1415

1516
private ExchangeInspector _inspectorController;
16-
private VisualElement _fullWindowRoot;
1717

1818
public override VisualElement CreateInspectorGUI()
1919
{
2020
var root = GetRoot();
21-
InitViewController();
21+
InitViewController(root);
2222
return root;
2323
}
2424

25-
private void InitViewController()
25+
private void InitViewController(VisualElement root)
2626
{
2727
var uxml = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
2828
"Packages/com.quickeye.http-debugger/Editor/UIAssets/ExchangeInspector.uxml");
29-
uxml.CloneTree(_fullWindowRoot);
30-
_inspectorController = new ExchangeInspector(_fullWindowRoot);
31-
var readOnly = serializedObject.FindProperty("isReadOnly").boolValue;
29+
uxml.CloneTree(root);
30+
_inspectorController = new ExchangeInspector(root);
3231
_inspectorController.Setup(serializedObject);
3332
}
3433

3534
private VisualElement GetRoot()
3635
{
3736
var root = new VisualElement();
38-
_fullWindowRoot = new VisualElement();
39-
StretchVe(_fullWindowRoot);
37+
root.name = "exchange-inspector";
38+
39+
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>(
40+
"Packages/com.quickeye.http-debugger/Editor/UIAssets/ExchangeInspector.style.uss");
4041

4142
root.RegisterCallback<AttachToPanelEvent>(evt =>
4243
{
43-
var fullParent = evt.destinationPanel.visualTree.Q(null, "unity-inspector-main-container");
44-
fullParent.Add(_fullWindowRoot);
44+
EnableClassForAllParents(root, "exchange-inspector-ancestor", true);
45+
evt.destinationPanel.visualTree.styleSheets.Add(styleSheet);
46+
});
47+
root.RegisterCallback<DetachFromPanelEvent>(evt =>
48+
{
49+
//change to destination panel to cause an exception
50+
evt.originPanel?.visualTree?.styleSheets.Remove(styleSheet);
4551
});
46-
root.RegisterCallback<DetachFromPanelEvent>(evt => { _fullWindowRoot.RemoveFromHierarchy(); });
4752
return root;
4853
}
4954

50-
private static void StretchVe(VisualElement ve)
55+
private static void EnableClassForAllParents(VisualElement root, string className, bool enabled)
5156
{
52-
ve.style.position = Position.Absolute;
53-
ve.style.bottom = ve.style.top = ve.style.left = ve.style.right = 0;
57+
root = root.hierarchy.parent;
58+
while (root != null)
59+
{
60+
root.EnableInClassList(className, enabled);
61+
root = root.hierarchy.parent;
62+
}
5463
}
5564

5665
public override bool UseDefaultMargins() => false;

0 commit comments

Comments
 (0)