Skip to content

Commit 7330dda

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored andcommitted
Dim-out not hovered-over annotations and add border
Make the labels more readable by adding a border to the labels and dimming out the rest of the labels why one is hovered in the flamechart of in the sidebar. Video: http://screencast/cast/NTg2NDE3NDgwOTc3NjEyOHw4ZTExOWExZS1mYQ Bug: 433643462 Change-Id: I3a42b50a001d91d418bbb41d362669d0ec78e665 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6779639 Reviewed-by: Jack Franklin <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Auto-Submit: Alina Varkki <[email protected]>
1 parent 1b91382 commit 7330dda

File tree

8 files changed

+89
-1
lines changed

8 files changed

+89
-1
lines changed

front_end/panels/timeline/ModificationsManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ export class ModificationsManager extends EventTarget {
288288
return null;
289289
}
290290

291+
getOverlaybyAnnotation(annotation: Trace.Types.File.Annotation): Trace.Types.Overlays.Overlay|null {
292+
return this.#overlayForAnnotation.get(annotation) || null;
293+
}
294+
291295
getAnnotations(): Trace.Types.File.Annotation[] {
292296
return [...this.#overlayForAnnotation.keys()];
293297
}

front_end/panels/timeline/TimelineFlameChartView.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,17 @@ export class TimelineFlameChartView extends Common.ObjectWrapper.eventMixin<Even
770770
}
771771
}
772772

773+
hoverAnnotationInSidebar(annotation: Trace.Types.File.Annotation): void {
774+
const overlay = ModificationsManager.activeManager()?.getOverlaybyAnnotation(annotation);
775+
if (overlay && overlay.type === 'ENTRY_LABEL') {
776+
this.#overlays.highlightOverlay(overlay);
777+
}
778+
}
779+
780+
sidebarAnnotationHoverOut(): void {
781+
this.#overlays.undimAllEntryLabels();
782+
}
783+
773784
revealAnnotation(annotation: Trace.Types.File.Annotation): void {
774785
const traceBounds = TraceBounds.TraceBounds.BoundsManager.instance().state()?.micro.entireTraceBounds;
775786
if (!traceBounds) {

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,14 @@ export class TimelinePanel extends Common.ObjectWrapper.eventMixin<EventTypes, t
616616
this.flameChart.revealAnnotation(event.annotation);
617617
});
618618

619+
this.#sideBar.element.addEventListener(TimelineComponents.Sidebar.HoverAnnotation.eventName, event => {
620+
this.flameChart.hoverAnnotationInSidebar(event.annotation);
621+
});
622+
623+
this.#sideBar.element.addEventListener(TimelineComponents.Sidebar.AnnotationHoverOut.eventName, () => {
624+
this.flameChart.sidebarAnnotationHoverOut();
625+
});
626+
619627
this.#sideBar.element.addEventListener(TimelineInsights.SidebarInsight.InsightSetHovered.eventName, event => {
620628
if (event.bounds) {
621629
this.#minimapComponent.highlightBounds(event.bounds, /* withBracket */ true);

front_end/panels/timeline/components/Sidebar.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,27 @@ export class RevealAnnotation extends Event {
3131
super(RevealAnnotation.eventName, {bubbles: true, composed: true});
3232
}
3333
}
34+
export class HoverAnnotation extends Event {
35+
static readonly eventName = 'hoverannotation';
36+
37+
constructor(public annotation: Trace.Types.File.Annotation) {
38+
super(HoverAnnotation.eventName, {bubbles: true, composed: true});
39+
}
40+
}
41+
42+
export class AnnotationHoverOut extends Event {
43+
static readonly eventName = 'annotationhoverout';
44+
45+
constructor() {
46+
super(AnnotationHoverOut.eventName, {bubbles: true, composed: true});
47+
}
48+
}
3449

3550
declare global {
3651
interface GlobalEventHandlersEventMap {
3752
[RevealAnnotation.eventName]: RevealAnnotation;
53+
[HoverAnnotation.eventName]: HoverAnnotation;
54+
[AnnotationHoverOut.eventName]: AnnotationHoverOut;
3855
}
3956
}
4057

front_end/panels/timeline/components/SidebarAnnotationsTab.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as Lit from '../../../ui/lit/lit.js';
1414
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1515
import * as Utils from '../utils/utils.js';
1616

17-
import {RemoveAnnotation, RevealAnnotation} from './Sidebar.js';
17+
import {AnnotationHoverOut, HoverAnnotation, RemoveAnnotation, RevealAnnotation} from './Sidebar.js';
1818
import sidebarAnnotationsTabStyles from './sidebarAnnotationsTab.css.js';
1919

2020
const {html, render} = Lit;
@@ -97,6 +97,8 @@ export interface SidebarAnnotationsTabViewInput {
9797
annotationsHiddenSetting: Common.Settings.Setting<boolean>;
9898
annotationEntryToColorMap: ReadonlyMap<Trace.Types.Events.Event|Trace.Types.Events.LegacyTimelineFrame, string>;
9999
onAnnotationClick: (annotation: Trace.Types.File.Annotation) => void;
100+
onAnnotationHover: (annotation: Trace.Types.File.Annotation) => void;
101+
onAnnotationHoverOut: () => void;
100102
onAnnotationDelete: (annotation: Trace.Types.File.Annotation) => void;
101103
}
102104

@@ -207,6 +209,12 @@ export class SidebarAnnotationsTab extends UI.Widget.Widget {
207209
onAnnotationClick: (annotation: Trace.Types.File.Annotation) => {
208210
this.contentElement.dispatchEvent(new RevealAnnotation(annotation));
209211
},
212+
onAnnotationHover: (annotation: Trace.Types.File.Annotation) => {
213+
this.contentElement.dispatchEvent(new HoverAnnotation(annotation));
214+
},
215+
onAnnotationHoverOut: () => {
216+
this.contentElement.dispatchEvent(new AnnotationHoverOut());
217+
},
210218
onAnnotationDelete: (annotation: Trace.Types.File.Annotation) => {
211219
this.contentElement.dispatchEvent(new RemoveAnnotation(annotation));
212220
},
@@ -417,6 +425,8 @@ export const DEFAULT_VIEW: (input: SidebarAnnotationsTabViewInput, output: objec
417425
return html`
418426
<div class="annotation-container"
419427
@click=${() => input.onAnnotationClick(annotation)}
428+
@mouseover=${() => (annotation.type === 'ENTRY_LABEL') ? input.onAnnotationHover(annotation): null}
429+
@mouseout=${() => (annotation.type === 'ENTRY_LABEL') ? input.onAnnotationHoverOut() : null}
420430
aria-label=${label}
421431
tabindex="0"
422432
jslog=${VisualLogging.item(`timeline.annotation-sidebar.annotation-${jslogForAnnotation(annotation)}`).track({click: true})}

front_end/panels/timeline/overlays/OverlaysImpl.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,36 @@ export class Overlays extends EventTarget {
13631363
};
13641364
}
13651365

1366+
// Dimms all label annotations except the one that is hovered over in the timeline or sidebar.
1367+
// The highlighter annotation is brought forward.
1368+
highlightOverlay(overlay: Trace.Types.Overlays.EntryLabel): void {
1369+
const allLabelOverlays = this.overlaysOfType('ENTRY_LABEL');
1370+
for (const otherOverlay of allLabelOverlays) {
1371+
const element = this.elementForOverlay(otherOverlay);
1372+
const component = element?.querySelector('devtools-entry-label-overlay');
1373+
if (element && !component?.hasAttribute('data-user-editing-label')) {
1374+
if (otherOverlay === overlay) {
1375+
element.style.opacity = '1';
1376+
element.style.zIndex = '3';
1377+
} else {
1378+
element.style.opacity = '0.5';
1379+
element.style.zIndex = '2';
1380+
}
1381+
}
1382+
}
1383+
}
1384+
1385+
undimAllEntryLabels(): void {
1386+
const allLabelOverlays = this.overlaysOfType('ENTRY_LABEL');
1387+
for (const otherOverlay of allLabelOverlays) {
1388+
const element = this.elementForOverlay(otherOverlay);
1389+
if (element) {
1390+
element.style.opacity = '1';
1391+
element.style.zIndex = '2';
1392+
}
1393+
}
1394+
}
1395+
13661396
#createElementForNewOverlay(overlay: Trace.Types.Overlays.Overlay): HTMLElement {
13671397
const overlayElement = document.createElement('div');
13681398
overlayElement.classList.add('overlay-item', `overlay-type-${overlay.type}`);
@@ -1394,6 +1424,12 @@ export class Overlays extends EventTarget {
13941424
overlay.label = newLabel;
13951425
this.dispatchEvent(new AnnotationOverlayActionEvent(overlay, 'Update'));
13961426
});
1427+
overlayElement.addEventListener('mouseover', () => {
1428+
this.highlightOverlay(overlay);
1429+
});
1430+
overlayElement.addEventListener('mouseout', () => {
1431+
this.undimAllEntryLabels();
1432+
});
13971433
overlayElement.appendChild(component);
13981434
overlayElement.addEventListener('click', event => {
13991435
event.preventDefault();

front_end/panels/timeline/overlays/components/entryLabelOverlay.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
font-family: var(--default-font-family);
118118
font-size: var(--sys-typescale-body2-size);
119119
font-weight: var(--ref-typeface-weight-medium);
120+
outline: 2px solid var(--color-background);
120121
}
121122

122123

front_end/panels/timeline/timelineFlameChartView.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
.overlay-type-ENTRY_LABEL {
2323
/* keep these above the selected entry overline, else they can become hard to read */
2424
z-index: 2;
25+
transition: opacity 0.2s;
2526

2627
/* if an overlay is being edited, keep it above the rest so the user is not obstructed */
2728
/* also bump the z-index if the label is being hovered, to ensure it appears above any other labels that might obstruct it */

0 commit comments

Comments
 (0)