1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import {Component, Input} from '@angular/core';
17import {PersistentStore} from 'common/persistent_store';
18import {TraceType} from 'trace/trace_type';
19import {CollapsibleSections} from 'viewers/common/collapsible_sections';
20import {CollapsibleSectionType} from 'viewers/common/collapsible_section_type';
21import {ShadingMode} from 'viewers/components/rects/types3d';
22import {viewerCardStyle} from 'viewers/components/styles/viewer_card.styles';
23import {UiData} from './ui_data';
24
25@Component({
26  selector: 'viewer-window-manager',
27  template: `
28    <div class="card-grid">
29      <collapsed-sections
30        [class.empty]="sections.areAllSectionsExpanded()"
31        [sections]="sections"
32        (sectionChange)="sections.onCollapseStateChange($event, false)">
33      </collapsed-sections>
34      <rects-view
35        class="rects-view"
36        [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.RECTS)"
37        [title]="rectsTitle"
38        [store]="store"
39        [rects]="inputData?.rectsToDraw ?? []"
40        [displays]="inputData?.displays ?? []"
41        [highlightedItem]="inputData?.highlightedItem ?? ''"
42        [shadingModes]="shadingModes"
43        [dependencies]="inputData?.dependencies ?? []"
44        [userOptions]="inputData?.rectsUserOptions ?? {}"
45        (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.RECTS, true)"></rects-view>
46      <hierarchy-view
47        class="hierarchy-view"
48        [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.HIERARCHY)"
49        [tree]="inputData?.hierarchyTrees[0]"
50        [dependencies]="inputData?.dependencies ?? []"
51        [highlightedItem]="inputData?.highlightedItem ?? ''"
52        [pinnedItems]="inputData?.pinnedItems ?? []"
53        [store]="store"
54        [userOptions]="inputData?.hierarchyUserOptions ?? {}"
55        [rectIdToShowState]="inputData?.rectIdToShowState"
56        (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.HIERARCHY, true)"></hierarchy-view>
57      <properties-view
58        class="properties-view"
59        [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.PROPERTIES)"
60        [userOptions]="inputData?.propertiesUserOptions ?? {}"
61        [propertiesTree]="inputData?.propertiesTree"
62        [traceType]="${TraceType.WINDOW_MANAGER}"
63        [highlightedProperty]="inputData?.highlightedProperty ?? ''"
64        [store]="store"
65        [isProtoDump]="false"
66        placeholderText="No selected item."
67        (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.PROPERTIES, true)"></properties-view>
68    </div>
69  `,
70  styles: [viewerCardStyle],
71})
72export class ViewerWindowManagerComponent {
73  @Input() inputData: UiData | undefined;
74  @Input() store: PersistentStore | undefined;
75  @Input() active = false;
76  TraceType = TraceType;
77  CollapsibleSectionType = CollapsibleSectionType;
78
79  rectsTitle = 'WINDOWS';
80  sections = new CollapsibleSections([
81    {
82      type: CollapsibleSectionType.RECTS,
83      label: this.rectsTitle,
84      isCollapsed: false,
85    },
86    {
87      type: CollapsibleSectionType.HIERARCHY,
88      label: CollapsibleSectionType.HIERARCHY,
89      isCollapsed: false,
90    },
91    {
92      type: CollapsibleSectionType.PROPERTIES,
93      label: CollapsibleSectionType.PROPERTIES,
94      isCollapsed: false,
95    },
96  ]);
97  shadingModes = [
98    ShadingMode.GRADIENT,
99    ShadingMode.OPACITY,
100    ShadingMode.WIRE_FRAME,
101  ];
102}
103