Skip to content

Commit

Permalink
Change 'Remove track' to 'Hide track' (#104)
Browse files Browse the repository at this point in the history
With the upcoming introduction of user-defined tracks (e.g.,
the user combines one or more counter tracks into a single one),
we need to adjust the existing removal track button. This button
doesn't technically remove the track; it hides it. The track
definition ends up in a filtered list, so that it can be
reintroduced into the timeline by the user via the Track
Filtering timeline toolbar button.

We also need to allow for a track removal that is a "true" removal.
Such an action will do more than just hide the track. It will
delete the track altogether. The user won't be able to un-hide it.
This type of action will be available only to user defined tracks.
The user can of course re-define the track from scratch
to effectively re-introduce it into the timeline.

The existing button is being given a new tooltip and icon to
better reflect the hiding nature. Additionally, the RemoveTrack
action now supports a purge option for use in a true removal.
In that case, we simply don't add the track definition to the
filtered list. We'll use the garbage can icon for that action,
and the tooltip will say "Delete user-defined track". Only
user-defined tracks will have this action, and it will be added
to the track by Sokatoa, as support for these user-defined tracks
is entirely done within Sokatoa using perfetto plugins.
  • Loading branch information
jcortell68 authored Apr 10, 2024
1 parent e080d86 commit 18197c0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
40 changes: 24 additions & 16 deletions ui/src/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ export type AddTrackLikeArgs = AddTrackArgs | AddTrackGroupArgs;
export interface RemoveTrackArgs {
// The ID of the track to remove
id: string;

// Whether to keep the ID so that it may be reused when the
// track is subsequently added again (required for group
// summary tracks only).
keepId?: boolean;

// Set to true if the track is user-defined and the user wishes
// to outright delete the track definition rather than just hide
// it. I.e., don't add the track to the filtered list.
purge? : boolean;
}

export interface RemoveTrackGroupArgs {
Expand Down Expand Up @@ -501,11 +507,11 @@ export const StateActions = {

removeTracks(state: StateDraft, args: {tracks: RemoveTrackArgs[]}): void {
args.tracks.forEach((track) => this.removeTrack(
state, {trackId: track.id, keepId: track.keepId}));
state, {trackId: track.id, keepId: track.keepId, purge: track.purge}));
},

removeTrack(state: StateDraft,
args: {trackId: string, keepId?: boolean}): void {
args: {trackId: string, keepId?: boolean, purge?: boolean}): void {
const track = state.tracks[args.trackId];
if (!track) {
return;
Expand All @@ -514,20 +520,22 @@ export const StateActions = {

this.cleanUiTrackIdByTraceTrackId(state, track as TrackState, args.trackId);

// Don't attempt to reuse track IDs unless requested (usually only
// for group summary tracks)
const id = args.keepId ? {id: args.trackId} : {};
state.filteredTracks.push({
...id,
kind: track.kind,
engineId: track.engineId,
name: track.name,
title: track.title,
trackSortKey: track.trackSortKey,
trackGroup: track.trackGroup,
labels: track.labels,
config: current(track.config),
});
if (!args.purge) {
// Don't attempt to reuse track IDs unless requested (usually only
// for group summary tracks)
const id = args.keepId ? {id: args.trackId} : {};
state.filteredTracks.push({
...id,
kind: track.kind,
engineId: track.engineId,
name: track.name,
title: track.title,
trackSortKey: track.trackSortKey,
trackGroup: track.trackGroup,
labels: track.labels,
config: current(track.config),
});
}

dropTables(track.engineId, track.id);
},
Expand Down
4 changes: 2 additions & 2 deletions ui/src/frontend/track_group_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ export class TrackGroupPanel extends Panel<Attrs> {
]);
e.stopPropagation();
},
i: 'delete',
i: 'hide',
disabled,
tooltip: 'Remove track group',
tooltip: 'Hide track group',
showButton: false, // Only show on roll-over
fullHeight: true,
}));
Expand Down
4 changes: 2 additions & 2 deletions ui/src/frontend/track_panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ class TrackShell implements m.ClassComponent<TrackShellAttrs> {
result.push(m(TrackButton, {
action: () => globals.dispatch(
Actions.removeTrack({trackId: attrs.trackState.id})),
i: 'delete',
tooltip: 'Remove track',
i: 'hide',
tooltip: 'Hide track',
showButton: false, // Only show on roll-over
fullHeight: true,
disabled: !this.canDeleteTrack(attrs.trackState),
Expand Down

0 comments on commit 18197c0

Please sign in to comment.