Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Isabelle Taylor | c538e24 | 2020-01-27 17:34:25 +0000 | [diff] [blame] | 15 | import {hex} from 'color-convert'; |
Steve Golton | 5038846 | 2023-04-05 16:14:38 +0100 | [diff] [blame] | 16 | import m from 'mithril'; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 17 | |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 18 | import {currentTargetOffset} from '../base/dom_utils'; |
Steve Golton | d4e5bbe | 2023-09-07 08:17:38 +0100 | [diff] [blame] | 19 | import {Icons} from '../base/semantic_icons'; |
Steve Golton | 278b7f0 | 2023-09-06 16:26:23 +0100 | [diff] [blame] | 20 | import {duration, Span, time} from '../base/time'; |
Isabelle Taylor | 6b871e9 | 2019-09-16 13:46:29 +0100 | [diff] [blame] | 21 | import {Actions} from '../common/actions'; |
Steve Golton | f095db1 | 2023-08-25 10:21:06 +0100 | [diff] [blame] | 22 | import {pluginManager} from '../common/plugins'; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 23 | import {TrackState} from '../common/state'; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 24 | import {raf} from '../core/raf_scheduler'; |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 25 | import {Migrate, SliceRect, Track, TrackContext, TrackTags} from '../public'; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 26 | |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 27 | import {checkerboard} from './checkerboard'; |
Kenzie Schmoll | 9dd9156 | 2022-06-16 14:40:42 -0700 | [diff] [blame] | 28 | import {SELECTION_FILL_COLOR, TRACK_SHELL_WIDTH} from './css_constants'; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 29 | import {globals} from './globals'; |
| 30 | import {drawGridLines} from './gridline_helper'; |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 31 | import {Panel, PanelSize} from './panel'; |
Isabelle Taylor | 15fef6e | 2019-10-16 13:26:37 +0100 | [diff] [blame] | 32 | import {verticalScrollToTrack} from './scroll_helper'; |
Lalit Maganti | 666e41e | 2023-06-27 19:02:32 +0100 | [diff] [blame] | 33 | import {PxSpan, TimeScale} from './time_scale'; |
Isabelle Taylor | 5a254b5 | 2019-05-16 14:57:30 +0100 | [diff] [blame] | 34 | import { |
| 35 | drawVerticalLineAtTime, |
Isabelle Taylor | 5a254b5 | 2019-05-16 14:57:30 +0100 | [diff] [blame] | 36 | } from './vertical_line_helper'; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 37 | |
Hector Dearman | eaad204 | 2023-04-27 19:33:02 +0100 | [diff] [blame] | 38 | function getTitleSize(title: string): string|undefined { |
| 39 | const length = title.length; |
| 40 | if (length > 55) { |
| 41 | return '9px'; |
| 42 | } |
| 43 | if (length > 50) { |
| 44 | return '10px'; |
| 45 | } |
| 46 | if (length > 45) { |
| 47 | return '11px'; |
| 48 | } |
| 49 | if (length > 40) { |
| 50 | return '12px'; |
| 51 | } |
| 52 | if (length > 35) { |
| 53 | return '13px'; |
| 54 | } |
| 55 | return undefined; |
| 56 | } |
| 57 | |
Hector Dearman | a926f4e | 2018-09-17 13:33:30 +0100 | [diff] [blame] | 58 | function isPinned(id: string) { |
| 59 | return globals.state.pinnedTracks.indexOf(id) !== -1; |
| 60 | } |
| 61 | |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 62 | function isSelected(id: string) { |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 63 | const selection = globals.state.currentSelection; |
| 64 | if (selection === null || selection.kind !== 'AREA') return false; |
| 65 | const selectedArea = globals.state.areas[selection.areaId]; |
| 66 | return selectedArea.tracks.includes(id); |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 69 | interface TrackChipAttrs { |
| 70 | text: string; |
Hector Dearman | 453110d | 2023-07-21 12:19:56 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 73 | class TrackChip implements m.ClassComponent<TrackChipAttrs> { |
| 74 | view({attrs}: m.CVnode<TrackChipAttrs>) { |
| 75 | return m('span.chip', attrs.text); |
Hector Dearman | 453110d | 2023-07-21 12:19:56 -0700 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 79 | export function renderChips(tags?: TrackTags) { |
| 80 | return [ |
| 81 | tags?.metric && m(TrackChip, {text: 'metric'}), |
| 82 | tags?.debuggable && m(TrackChip, {text: 'debuggable'}), |
| 83 | ]; |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 84 | } |
| 85 | |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 86 | interface TrackShellAttrs { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 87 | trackKey: string; |
| 88 | title: string; |
| 89 | buttons: m.Children; |
| 90 | tags?: TrackTags; |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 91 | } |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 92 | |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 93 | class TrackShell implements m.ClassComponent<TrackShellAttrs> { |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 94 | // Set to true when we click down and drag the |
| 95 | private dragging = false; |
| 96 | private dropping: 'before'|'after'|undefined = undefined; |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 97 | |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 98 | view({attrs}: m.CVnode<TrackShellAttrs>) { |
Isabelle Taylor | 613d38c | 2019-10-24 12:35:31 +0100 | [diff] [blame] | 99 | // The shell should be highlighted if the current search result is inside |
| 100 | // this track. |
| 101 | let highlightClass = ''; |
Hector Dearman | 301ce39 | 2021-07-16 13:51:33 +0100 | [diff] [blame] | 102 | const searchIndex = globals.state.searchIndex; |
Isabelle Taylor | 613d38c | 2019-10-24 12:35:31 +0100 | [diff] [blame] | 103 | if (searchIndex !== -1) { |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 104 | const trackKey = globals.currentSearchResults.trackKeys[searchIndex]; |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 105 | if (trackKey === attrs.trackKey) { |
Isabelle Taylor | 613d38c | 2019-10-24 12:35:31 +0100 | [diff] [blame] | 106 | highlightClass = 'flash'; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | const dragClass = this.dragging ? `drag` : ''; |
| 111 | const dropClass = this.dropping ? `drop-${this.dropping}` : ''; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 112 | return m( |
Isabelle Taylor | 613d38c | 2019-10-24 12:35:31 +0100 | [diff] [blame] | 113 | `.track-shell[draggable=true]`, |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 114 | { |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 115 | class: `${highlightClass} ${dragClass} ${dropClass}`, |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 116 | ondragstart: (e: DragEvent) => this.ondragstart(e, attrs.trackKey), |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 117 | ondragend: this.ondragend.bind(this), |
| 118 | ondragover: this.ondragover.bind(this), |
| 119 | ondragleave: this.ondragleave.bind(this), |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 120 | ondrop: (e: DragEvent) => this.ondrop(e, attrs.trackKey), |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 121 | }, |
Hector Dearman | 9cf9e63 | 2021-08-23 10:27:52 +0100 | [diff] [blame] | 122 | m( |
| 123 | 'h1', |
| 124 | { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 125 | title: attrs.title, |
Hector Dearman | eaad204 | 2023-04-27 19:33:02 +0100 | [diff] [blame] | 126 | style: { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 127 | 'font-size': getTitleSize(attrs.title), |
Hector Dearman | eaad204 | 2023-04-27 19:33:02 +0100 | [diff] [blame] | 128 | }, |
Hector Dearman | 9cf9e63 | 2021-08-23 10:27:52 +0100 | [diff] [blame] | 129 | }, |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 130 | attrs.title, |
| 131 | renderChips(attrs.tags), |
Hector Dearman | 9cf9e63 | 2021-08-23 10:27:52 +0100 | [diff] [blame] | 132 | ), |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 133 | m('.track-buttons', |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 134 | attrs.buttons, |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 135 | m(TrackButton, { |
| 136 | action: () => { |
| 137 | globals.dispatch( |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 138 | Actions.toggleTrackPinned({trackKey: attrs.trackKey})); |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 139 | }, |
Steve Golton | d4e5bbe | 2023-09-07 08:17:38 +0100 | [diff] [blame] | 140 | i: Icons.Pin, |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 141 | filledIcon: isPinned(attrs.trackKey), |
| 142 | tooltip: isPinned(attrs.trackKey) ? 'Unpin' : 'Pin to top', |
| 143 | showButton: isPinned(attrs.trackKey), |
Mingjing Zhang | 8502227 | 2022-07-06 20:00:12 +0000 | [diff] [blame] | 144 | fullHeight: true, |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 145 | }), |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 146 | globals.state.currentSelection !== null && |
| 147 | globals.state.currentSelection.kind === 'AREA' ? |
| 148 | m(TrackButton, { |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 149 | action: (e: MouseEvent) => { |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 150 | globals.dispatch(Actions.toggleTrackSelection( |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 151 | {id: attrs.trackKey, isTrackGroup: false})); |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 152 | e.stopPropagation(); |
| 153 | }, |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 154 | i: isSelected(attrs.trackKey) ? Icons.Checkbox : |
| 155 | Icons.BlankCheckbox, |
| 156 | tooltip: isSelected(attrs.trackKey) ? 'Remove track' : |
| 157 | 'Add track to selection', |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 158 | showButton: true, |
| 159 | }) : |
| 160 | '')); |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 161 | } |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 162 | |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 163 | ondragstart(e: DragEvent, trackKey: string) { |
Isabelle Taylor | 2f1b272 | 2019-02-15 14:37:07 +0000 | [diff] [blame] | 164 | const dataTransfer = e.dataTransfer; |
| 165 | if (dataTransfer === null) return; |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 166 | this.dragging = true; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 167 | raf.scheduleFullRedraw(); |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 168 | dataTransfer.setData('perfetto/track', `${trackKey}`); |
Isabelle Taylor | 2f1b272 | 2019-02-15 14:37:07 +0000 | [diff] [blame] | 169 | dataTransfer.setDragImage(new Image(), 0, 0); |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | ondragend() { |
| 173 | this.dragging = false; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 174 | raf.scheduleFullRedraw(); |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | ondragover(e: DragEvent) { |
| 178 | if (this.dragging) return; |
| 179 | if (!(e.target instanceof HTMLElement)) return; |
Isabelle Taylor | 2f1b272 | 2019-02-15 14:37:07 +0000 | [diff] [blame] | 180 | const dataTransfer = e.dataTransfer; |
| 181 | if (dataTransfer === null) return; |
| 182 | if (!dataTransfer.types.includes('perfetto/track')) return; |
| 183 | dataTransfer.dropEffect = 'move'; |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 184 | e.preventDefault(); |
| 185 | |
| 186 | // Apply some hysteresis to the drop logic so that the lightened border |
| 187 | // changes only when we get close enough to the border. |
| 188 | if (e.offsetY < e.target.scrollHeight / 3) { |
| 189 | this.dropping = 'before'; |
| 190 | } else if (e.offsetY > e.target.scrollHeight / 3 * 2) { |
| 191 | this.dropping = 'after'; |
| 192 | } |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 193 | raf.scheduleFullRedraw(); |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | ondragleave() { |
| 197 | this.dropping = undefined; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 198 | raf.scheduleFullRedraw(); |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 199 | } |
| 200 | |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 201 | ondrop(e: DragEvent, trackKey: string) { |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 202 | if (this.dropping === undefined) return; |
Isabelle Taylor | 2f1b272 | 2019-02-15 14:37:07 +0000 | [diff] [blame] | 203 | const dataTransfer = e.dataTransfer; |
| 204 | if (dataTransfer === null) return; |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 205 | raf.scheduleFullRedraw(); |
Isabelle Taylor | 2f1b272 | 2019-02-15 14:37:07 +0000 | [diff] [blame] | 206 | const srcId = dataTransfer.getData('perfetto/track'); |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 207 | const dstId = trackKey; |
Primiano Tucci | e7b32e5 | 2018-11-05 01:24:31 -0800 | [diff] [blame] | 208 | globals.dispatch(Actions.moveTrack({srcId, op: this.dropping, dstId})); |
| 209 | this.dropping = undefined; |
| 210 | } |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 211 | } |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 212 | |
Steve Golton | f095db1 | 2023-08-25 10:21:06 +0100 | [diff] [blame] | 213 | export interface TrackContentAttrs { |
Steve Golton | 211d6a3 | 2023-10-05 13:08:43 +0100 | [diff] [blame] | 214 | track: Track; |
Steve Golton | f095db1 | 2023-08-25 10:21:06 +0100 | [diff] [blame] | 215 | } |
Hector Dearman | c1a703e | 2019-02-06 11:35:30 +0000 | [diff] [blame] | 216 | export class TrackContent implements m.ClassComponent<TrackContentAttrs> { |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 217 | private mouseDownX?: number; |
| 218 | private mouseDownY?: number; |
| 219 | private selectionOccurred = false; |
| 220 | |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 221 | view(node: m.CVnode<TrackContentAttrs>) { |
| 222 | const attrs = node.attrs; |
| 223 | return m( |
| 224 | '.track-content', |
| 225 | { |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 226 | onmousemove: (e: MouseEvent) => { |
| 227 | attrs.track.onMouseMove(currentTargetOffset(e)); |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 228 | raf.scheduleRedraw(); |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 229 | }, |
| 230 | onmouseout: () => { |
| 231 | attrs.track.onMouseOut(); |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 232 | raf.scheduleRedraw(); |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 233 | }, |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 234 | onmousedown: (e: MouseEvent) => { |
| 235 | const {x, y} = currentTargetOffset(e); |
| 236 | this.mouseDownX = x; |
| 237 | this.mouseDownY = y; |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 238 | }, |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 239 | onmouseup: (e: MouseEvent) => { |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 240 | if (this.mouseDownX === undefined || |
| 241 | this.mouseDownY === undefined) { |
| 242 | return; |
| 243 | } |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 244 | const {x, y} = currentTargetOffset(e); |
| 245 | if (Math.abs(x - this.mouseDownX) > 1 || |
| 246 | Math.abs(y - this.mouseDownY) > 1) { |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 247 | this.selectionOccurred = true; |
| 248 | } |
| 249 | this.mouseDownX = undefined; |
| 250 | this.mouseDownY = undefined; |
| 251 | }, |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 252 | onclick: (e: MouseEvent) => { |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 253 | // This click event occurs after any selection mouse up/drag events |
| 254 | // so we have to look if the mouse moved during this click to know |
| 255 | // if a selection occurred. |
| 256 | if (this.selectionOccurred) { |
| 257 | this.selectionOccurred = false; |
| 258 | return; |
| 259 | } |
| 260 | // Returns true if something was selected, so stop propagation. |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 261 | if (attrs.track.onMouseClick(currentTargetOffset(e))) { |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 262 | e.stopPropagation(); |
| 263 | } |
Hector Dearman | ba396db | 2023-07-03 18:25:08 +0100 | [diff] [blame] | 264 | raf.scheduleRedraw(); |
Hector Dearman | 23c078b | 2022-06-05 12:00:25 +0100 | [diff] [blame] | 265 | }, |
Andrew Shulaev | ee2fbdf | 2021-11-15 09:02:40 +0000 | [diff] [blame] | 266 | }, |
| 267 | node.children); |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 268 | } |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 269 | } |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 270 | |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 271 | interface TrackComponentAttrs { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 272 | trackKey: string; |
| 273 | heightPx?: number; |
| 274 | title: string; |
| 275 | buttons?: m.Children; |
| 276 | tags?: TrackTags; |
| 277 | track?: Track; |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 278 | } |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 279 | |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 280 | class TrackComponent implements m.ClassComponent<TrackComponentAttrs> { |
| 281 | view({attrs}: m.CVnode<TrackComponentAttrs>) { |
Hector Dearman | 97510d5 | 2023-03-10 16:21:12 +0000 | [diff] [blame] | 282 | // TODO(hjd): The min height below must match the track_shell_title |
| 283 | // max height in common.scss so we should read it from CSS to avoid |
| 284 | // them going out of sync. |
Isabelle Taylor | bb1cc59 | 2019-07-25 15:15:27 +0100 | [diff] [blame] | 285 | return m( |
| 286 | '.track', |
| 287 | { |
| 288 | style: { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 289 | height: `${Math.max(18, attrs.heightPx ?? 0)}px`, |
Isabelle Taylor | 0fa95e8 | 2019-09-17 15:41:10 +0100 | [diff] [blame] | 290 | }, |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 291 | id: 'track_' + attrs.trackKey, |
Isabelle Taylor | bb1cc59 | 2019-07-25 15:15:27 +0100 | [diff] [blame] | 292 | }, |
| 293 | [ |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 294 | m(TrackShell, { |
| 295 | buttons: attrs.buttons, |
| 296 | title: attrs.title, |
| 297 | trackKey: attrs.trackKey, |
| 298 | tags: attrs.tags, |
| 299 | }), |
| 300 | attrs.track && m(TrackContent, {track: attrs.track}), |
Isabelle Taylor | bb1cc59 | 2019-07-25 15:15:27 +0100 | [diff] [blame] | 301 | ]); |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 302 | } |
Isabelle Taylor | 15fef6e | 2019-10-16 13:26:37 +0100 | [diff] [blame] | 303 | |
Isabelle Taylor | 77fe3f2 | 2019-10-25 11:43:20 +0100 | [diff] [blame] | 304 | oncreate({attrs}: m.CVnode<TrackComponentAttrs>) { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 305 | if (globals.scrollToTrackKey === attrs.trackKey) { |
| 306 | verticalScrollToTrack(attrs.trackKey); |
Steve Golton | 99b8832 | 2023-12-07 18:54:14 +0000 | [diff] [blame] | 307 | globals.scrollToTrackKey = undefined; |
Isabelle Taylor | 15fef6e | 2019-10-16 13:26:37 +0100 | [diff] [blame] | 308 | } |
| 309 | } |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 310 | } |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 311 | |
Isabelle Taylor | 6b871e9 | 2019-09-16 13:46:29 +0100 | [diff] [blame] | 312 | export interface TrackButtonAttrs { |
Steve Golton | feaec37 | 2023-09-22 12:57:29 +0100 | [diff] [blame] | 313 | action: (e: MouseEvent) => void; |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 314 | i: string; |
Isabelle Taylor | 6b871e9 | 2019-09-16 13:46:29 +0100 | [diff] [blame] | 315 | tooltip: string; |
Isabelle Taylor | f16d642 | 2020-01-31 11:36:34 +0000 | [diff] [blame] | 316 | showButton: boolean; |
Mingjing Zhang | 8502227 | 2022-07-06 20:00:12 +0000 | [diff] [blame] | 317 | fullHeight?: boolean; |
Hector Dearman | 42849e6 | 2023-03-06 08:43:47 +0000 | [diff] [blame] | 318 | filledIcon?: boolean; |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 319 | } |
Isabelle Taylor | 6b871e9 | 2019-09-16 13:46:29 +0100 | [diff] [blame] | 320 | export class TrackButton implements m.ClassComponent<TrackButtonAttrs> { |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 321 | view({attrs}: m.CVnode<TrackButtonAttrs>) { |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 322 | return m( |
Hector Dearman | 42849e6 | 2023-03-06 08:43:47 +0000 | [diff] [blame] | 323 | 'i.track-button', |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 324 | { |
Mingjing Zhang | 8502227 | 2022-07-06 20:00:12 +0000 | [diff] [blame] | 325 | class: [ |
| 326 | (attrs.showButton ? 'show' : ''), |
| 327 | (attrs.fullHeight ? 'full-height' : ''), |
Hector Dearman | 42849e6 | 2023-03-06 08:43:47 +0000 | [diff] [blame] | 328 | (attrs.filledIcon ? 'material-icons-filled' : 'material-icons'), |
Mingjing Zhang | 8502227 | 2022-07-06 20:00:12 +0000 | [diff] [blame] | 329 | ].filter(Boolean) |
| 330 | .join(' '), |
Isabelle Taylor | 6b871e9 | 2019-09-16 13:46:29 +0100 | [diff] [blame] | 331 | onclick: attrs.action, |
| 332 | title: attrs.tooltip, |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 333 | }, |
Hector Dearman | a926f4e | 2018-09-17 13:33:30 +0100 | [diff] [blame] | 334 | attrs.i); |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 335 | } |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 336 | } |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 337 | |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 338 | interface TrackPanelAttrs { |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 339 | trackKey: string; |
Isabelle Taylor | 9b4a81d | 2020-01-31 11:11:02 +0000 | [diff] [blame] | 340 | selectable: boolean; |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | export class TrackPanel extends Panel<TrackPanelAttrs> { |
Steve Golton | b752fbd | 2023-10-05 12:57:40 +0100 | [diff] [blame] | 344 | // TODO(hjd): It would be nicer if these could not be undefined here. |
| 345 | // We should implement a NullTrack which can be used if the trackState |
| 346 | // has disappeared. |
Steve Golton | 211d6a3 | 2023-10-05 13:08:43 +0100 | [diff] [blame] | 347 | private track: Track|undefined; |
Steve Golton | b752fbd | 2023-10-05 12:57:40 +0100 | [diff] [blame] | 348 | private trackState: TrackState|undefined; |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 349 | private tags: TrackTags|undefined; |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 350 | |
Steve Golton | b47576c | 2023-09-26 18:36:21 +0100 | [diff] [blame] | 351 | private tryLoadTrack(vnode: m.CVnode<TrackPanelAttrs>) { |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 352 | const trackKey = vnode.attrs.trackKey; |
| 353 | const trackState = globals.state.tracks[trackKey]; |
Steve Golton | f095db1 | 2023-08-25 10:21:06 +0100 | [diff] [blame] | 354 | |
| 355 | if (!trackState) return; |
| 356 | |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 357 | const {uri, params} = trackState; |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 358 | |
| 359 | const trackCtx: TrackContext = { |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 360 | trackKey, |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 361 | mountStore: <T>(migrate: Migrate<T>) => { |
| 362 | const {store, state} = globals; |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 363 | const migratedState = migrate(state.tracks[trackKey].state); |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 364 | globals.store.edit((draft) => { |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 365 | draft.tracks[trackKey].state = migratedState; |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 366 | }); |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 367 | return store.createProxy<T>(['tracks', trackKey, 'state']); |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 368 | }, |
Steve Golton | d29ef3c | 2023-10-26 12:36:54 +0100 | [diff] [blame] | 369 | params, |
Steve Golton | 11c0c98 | 2023-10-03 08:30:15 +0100 | [diff] [blame] | 370 | }; |
| 371 | |
Steve Golton | 2f93d47 | 2023-10-17 14:48:59 +0100 | [diff] [blame] | 372 | this.track = pluginManager.createTrack(uri, trackCtx); |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 373 | this.tags = pluginManager.resolveTrackInfo(uri)?.tags; |
Steve Golton | 700e41d | 2023-10-03 13:53:09 +0100 | [diff] [blame] | 374 | |
Steve Golton | d29ef3c | 2023-10-26 12:36:54 +0100 | [diff] [blame] | 375 | this.track?.onCreate(trackCtx); |
Steve Golton | b752fbd | 2023-10-05 12:57:40 +0100 | [diff] [blame] | 376 | this.trackState = trackState; |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 377 | } |
| 378 | |
Steve Golton | b47576c | 2023-09-26 18:36:21 +0100 | [diff] [blame] | 379 | view(vnode: m.CVnode<TrackPanelAttrs>) { |
| 380 | if (!this.track) { |
| 381 | this.tryLoadTrack(vnode); |
| 382 | } |
| 383 | |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 384 | if (this.track === undefined || this.trackState === undefined) { |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 385 | return m(TrackComponent, { |
| 386 | trackKey: vnode.attrs.trackKey, |
| 387 | title: this.trackState?.name ?? 'Loading...', |
| 388 | }); |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 389 | } |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 390 | return m(TrackComponent, { |
| 391 | tags: this.tags, |
| 392 | heightPx: this.track.getHeight(), |
| 393 | title: this.trackState.name, |
| 394 | trackKey: this.trackState.key, |
| 395 | buttons: this.track.getTrackShellButtons(), |
| 396 | track: this.track, |
| 397 | }); |
Primiano Tucci | 9b5f13e | 2018-08-10 00:36:19 +0100 | [diff] [blame] | 398 | } |
| 399 | |
Hector Dearman | fe60412 | 2021-11-25 13:19:18 +0000 | [diff] [blame] | 400 | oncreate() { |
| 401 | if (this.track !== undefined) { |
| 402 | this.track.onFullRedraw(); |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | onupdate() { |
| 407 | if (this.track !== undefined) { |
| 408 | this.track.onFullRedraw(); |
| 409 | } |
| 410 | } |
| 411 | |
Hector Dearman | 5368781 | 2022-03-31 12:26:41 +0100 | [diff] [blame] | 412 | onremove() { |
| 413 | if (this.track !== undefined) { |
Steve Golton | b752fbd | 2023-10-05 12:57:40 +0100 | [diff] [blame] | 414 | this.track.onDestroy(); |
Hector Dearman | 5368781 | 2022-03-31 12:26:41 +0100 | [diff] [blame] | 415 | this.track = undefined; |
| 416 | } |
| 417 | } |
| 418 | |
Isabelle Taylor | 01254f7 | 2020-01-27 15:29:14 +0000 | [diff] [blame] | 419 | highlightIfTrackSelected(ctx: CanvasRenderingContext2D, size: PanelSize) { |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 420 | const {visibleTimeScale} = globals.frontendLocalState; |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 421 | const selection = globals.state.currentSelection; |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 422 | const trackState = this.trackState; |
| 423 | if (!selection || selection.kind !== 'AREA' || trackState === undefined) { |
| 424 | return; |
| 425 | } |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 426 | const selectedArea = globals.state.areas[selection.areaId]; |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 427 | const selectedAreaDuration = selectedArea.end - selectedArea.start; |
Steve Golton | cfe3e3d | 2023-10-26 16:24:31 +0100 | [diff] [blame] | 428 | if (selectedArea.tracks.includes(trackState.key)) { |
Kenzie Schmoll | 9dd9156 | 2022-06-16 14:40:42 -0700 | [diff] [blame] | 429 | ctx.fillStyle = SELECTION_FILL_COLOR; |
Isabelle Taylor | 01254f7 | 2020-01-27 15:29:14 +0000 | [diff] [blame] | 430 | ctx.fillRect( |
Steve Golton | b3a389d | 2023-07-10 11:03:17 +0100 | [diff] [blame] | 431 | visibleTimeScale.timeToPx(selectedArea.start) + TRACK_SHELL_WIDTH, |
Isabelle Taylor | 01254f7 | 2020-01-27 15:29:14 +0000 | [diff] [blame] | 432 | 0, |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 433 | visibleTimeScale.durationToPx(selectedAreaDuration), |
Isabelle Taylor | 01254f7 | 2020-01-27 15:29:14 +0000 | [diff] [blame] | 434 | size.height); |
| 435 | } |
| 436 | } |
| 437 | |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 438 | renderCanvas(ctx: CanvasRenderingContext2D, size: PanelSize) { |
Deepanjan Roy | 9a906ed | 2018-09-20 11:06:00 -0400 | [diff] [blame] | 439 | ctx.save(); |
Isabelle Taylor | 01254f7 | 2020-01-27 15:29:14 +0000 | [diff] [blame] | 440 | |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 441 | drawGridLines( |
| 442 | ctx, |
Hector Dearman | ea002ea | 2019-01-21 11:43:45 +0000 | [diff] [blame] | 443 | size.width, |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 444 | size.height); |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 445 | |
Hector Dearman | ea002ea | 2019-01-21 11:43:45 +0000 | [diff] [blame] | 446 | ctx.translate(TRACK_SHELL_WIDTH, 0); |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 447 | if (this.track !== undefined) { |
| 448 | this.track.render(ctx); |
Steve Golton | 8c581fb | 2023-12-11 09:58:50 +0000 | [diff] [blame^] | 449 | } else { |
| 450 | checkerboard(ctx, size.height, 0, size.width - TRACK_SHELL_WIDTH); |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 451 | } |
Deepanjan Roy | 9a906ed | 2018-09-20 11:06:00 -0400 | [diff] [blame] | 452 | ctx.restore(); |
Isabelle Taylor | b1b818e | 2019-02-08 14:57:43 +0000 | [diff] [blame] | 453 | |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 454 | this.highlightIfTrackSelected(ctx, size); |
| 455 | |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 456 | const {visibleTimeScale} = globals.frontendLocalState; |
Hector Dearman | 2442d61 | 2019-06-04 18:05:23 +0100 | [diff] [blame] | 457 | // Draw vertical line when hovering on the notes panel. |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 458 | if (globals.state.hoveredNoteTimestamp !== -1n) { |
Isabelle Taylor | a16dec2 | 2019-12-03 16:34:13 +0000 | [diff] [blame] | 459 | drawVerticalLineAtTime( |
| 460 | ctx, |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 461 | visibleTimeScale, |
Hector Dearman | 301ce39 | 2021-07-16 13:51:33 +0100 | [diff] [blame] | 462 | globals.state.hoveredNoteTimestamp, |
Isabelle Taylor | a16dec2 | 2019-12-03 16:34:13 +0000 | [diff] [blame] | 463 | size.height, |
| 464 | `#aaa`); |
Isabelle Taylor | 1ae33bc | 2019-02-22 11:44:33 +0000 | [diff] [blame] | 465 | } |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 466 | if (globals.state.hoverCursorTimestamp !== -1n) { |
Isabelle Taylor | 3da305e | 2020-02-11 11:46:28 +0000 | [diff] [blame] | 467 | drawVerticalLineAtTime( |
| 468 | ctx, |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 469 | visibleTimeScale, |
Steve Golton | cef2653 | 2023-03-15 16:23:00 +0000 | [diff] [blame] | 470 | globals.state.hoverCursorTimestamp, |
Isabelle Taylor | 3da305e | 2020-02-11 11:46:28 +0000 | [diff] [blame] | 471 | size.height, |
Isabelle Taylor | 797f483 | 2020-09-08 17:52:59 +0100 | [diff] [blame] | 472 | `#344596`); |
Isabelle Taylor | b0c0c0c | 2019-09-23 14:57:37 +0100 | [diff] [blame] | 473 | } |
Isabelle Taylor | c538e24 | 2020-01-27 17:34:25 +0000 | [diff] [blame] | 474 | |
Steve Golton | 9f56c2f | 2023-03-30 16:13:52 +0100 | [diff] [blame] | 475 | if (globals.state.currentSelection !== null) { |
Isabelle Taylor | bbd0b1c | 2019-04-05 15:14:19 +0100 | [diff] [blame] | 476 | if (globals.state.currentSelection.kind === 'SLICE' && |
| 477 | globals.sliceDetails.wakeupTs !== undefined) { |
| 478 | drawVerticalLineAtTime( |
| 479 | ctx, |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 480 | visibleTimeScale, |
Isabelle Taylor | bbd0b1c | 2019-04-05 15:14:19 +0100 | [diff] [blame] | 481 | globals.sliceDetails.wakeupTs, |
| 482 | size.height, |
| 483 | `black`); |
| 484 | } |
Isabelle Taylor | b1b818e | 2019-02-08 14:57:43 +0000 | [diff] [blame] | 485 | } |
Isabelle Taylor | c538e24 | 2020-01-27 17:34:25 +0000 | [diff] [blame] | 486 | // All marked areas should have semi-transparent vertical lines |
| 487 | // marking the start and end. |
| 488 | for (const note of Object.values(globals.state.notes)) { |
| 489 | if (note.noteType === 'AREA') { |
| 490 | const transparentNoteColor = |
| 491 | 'rgba(' + hex.rgb(note.color.substr(1)).toString() + ', 0.65)'; |
| 492 | drawVerticalLineAtTime( |
| 493 | ctx, |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 494 | visibleTimeScale, |
| 495 | globals.state.areas[note.areaId].start, |
Isabelle Taylor | c538e24 | 2020-01-27 17:34:25 +0000 | [diff] [blame] | 496 | size.height, |
| 497 | transparentNoteColor, |
| 498 | 1); |
| 499 | drawVerticalLineAtTime( |
| 500 | ctx, |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 501 | visibleTimeScale, |
| 502 | globals.state.areas[note.areaId].end, |
Isabelle Taylor | c538e24 | 2020-01-27 17:34:25 +0000 | [diff] [blame] | 503 | size.height, |
| 504 | transparentNoteColor, |
| 505 | 1); |
Steve Golton | 9f56c2f | 2023-03-30 16:13:52 +0100 | [diff] [blame] | 506 | } else if (note.noteType === 'DEFAULT') { |
| 507 | drawVerticalLineAtTime( |
Steve Golton | f3897e2 | 2023-05-11 14:18:30 +0100 | [diff] [blame] | 508 | ctx, visibleTimeScale, note.timestamp, size.height, note.color); |
Isabelle Taylor | c538e24 | 2020-01-27 17:34:25 +0000 | [diff] [blame] | 509 | } |
| 510 | } |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 511 | } |
Andrii | 698d4f3 | 2020-09-11 13:09:06 +0300 | [diff] [blame] | 512 | |
Lalit Maganti | 666e41e | 2023-06-27 19:02:32 +0100 | [diff] [blame] | 513 | getSliceRect( |
Steve Golton | b3a389d | 2023-07-10 11:03:17 +0100 | [diff] [blame] | 514 | visibleTimeScale: TimeScale, visibleWindow: Span<time, duration>, |
| 515 | windowSpan: PxSpan, tStart: time, tDur: time, depth: number): SliceRect |
| 516 | |undefined { |
Hector Dearman | cb9bb18 | 2021-10-18 11:35:46 +0100 | [diff] [blame] | 517 | if (this.track === undefined) { |
| 518 | return undefined; |
| 519 | } |
Lalit Maganti | 666e41e | 2023-06-27 19:02:32 +0100 | [diff] [blame] | 520 | return this.track.getSliceRect( |
Steve Golton | ab88091 | 2023-06-28 15:47:23 +0100 | [diff] [blame] | 521 | visibleTimeScale, visibleWindow, windowSpan, tStart, tDur, depth); |
Andrii | 698d4f3 | 2020-09-11 13:09:06 +0300 | [diff] [blame] | 522 | } |
Deepanjan Roy | abd79aa | 2018-08-28 07:29:15 -0400 | [diff] [blame] | 523 | } |