Make diff toggle responsive
Makes sure that when show diff is toggled the UI tree responds to that change
Test: Toggle the diff in different TreeViews and check if the diff appears and disapears
Change-Id: I260bed717f2998c6b1a2d71a011e756f64a19990
diff --git a/tools/winscope/src/TraceView.vue b/tools/winscope/src/TraceView.vue
index c49fa2a..043e1e9 100644
--- a/tools/winscope/src/TraceView.vue
+++ b/tools/winscope/src/TraceView.vue
@@ -164,6 +164,7 @@
lastSelectedStableId: null,
bounds: {},
rects: [],
+ item: null,
tree: null,
highlight: null,
showHierachyDiff: true,
@@ -200,28 +201,23 @@
this.itemSelected(item);
}
},
- setData(item) {
- this.tree = item;
-
- if (this.showHierachyDiff && this.diffVisualizationAvailable) {
- // Required pre-processing to match algo
- // TODO: Clean this up somehow
- if (this.file.type == DATA_TYPES.SURFACE_FLINGER) {
- item.obj.id = -1; // TODO: Make sure this ID can never be used by other objects
- item.children[0].obj.id = 0;
- }
-
- this.tree = new DiffGenerator(item)
- .compareWith(this.getDataWithOffset(-1))
- .withUniqueNodeId(node => {
- return node.stableId;
- })
- .withModifiedCheck(defaultModifiedCheck)
- .generateDiffTree();
- } else {
- this.tree = item;
+ generateTreeFromItem(item) {
+ if (!this.showHierachyDiff || !this.diffVisualizationAvailable) {
+ return item;
}
+ return new DiffGenerator(this.item)
+ .compareWith(this.getDataWithOffset(-1))
+ .withUniqueNodeId(node => {
+ return node.stableId;
+ })
+ .withModifiedCheck(defaultModifiedCheck)
+ .generateDiffTree();
+ },
+ setData(item) {
+ this.item = item;
+ this.tree = this.generateTreeFromItem(item);
+
this.rects = [...item.rects].reverse();
this.bounds = item.bounds;
@@ -298,11 +294,14 @@
selectedIndex() {
this.setData(this.file.data[this.file.selectedIndex]);
},
+ showHierachyDiff() {
+ this.tree = this.generateTreeFromItem(this.item);
+ },
showPropertiesDiff() {
if (this.hierarchySelected) {
this.selectedTree = this.getTransformedProperties(this.hierarchySelected);
}
- }
+ },
},
props: ['store', 'file'],
computed: {
diff --git a/tools/winscope/src/TreeView.vue b/tools/winscope/src/TreeView.vue
index e5ae4a1..f8c8cdb 100644
--- a/tools/winscope/src/TreeView.vue
+++ b/tools/winscope/src/TreeView.vue
@@ -142,6 +142,13 @@
// Update anything that is required to change when item changes.
this.updateCollapsedDiffClass();
},
+ hasDiff(hasDiff) {
+ if (!hasDiff) {
+ this.collapseDiffClass = null;
+ } else {
+ this.updateCollapsedDiffClass();
+ }
+ },
currentTimestamp() {
// Update anything that is required to change when time changes.
this.updateCollapsedDiffClass();
@@ -318,6 +325,9 @@
},
},
computed: {
+ hasDiff() {
+ return this.item?.diff !== undefined;
+ },
stableId() {
return this.item?.stableId;
},