Skip to content

Commit

Permalink
Add keyboard shortcut to zoom to enabled range (closes #255)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 6, 2024
1 parent e9da183 commit f559e62
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions docsSite/docs/getting-started/keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ AdvantageScope includes numerous keyboard shortcuts that allow for faster naviga
<tr><td>`Space`</td><td>Toggle playback</td></tr>
<tr><td>`Left` and `Right`</td><td>Step through log file</td></tr>
<tr><td>`L`</td><td>Toggle lock when viewing live data</td></tr>
<tr><td>`Ctrl+\`</td><td>Zoom timeline to enabled range</td></tr>
</table>

### Touch Bar
Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/3d-field.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Drag the desired field to the main view to get started. Each row represents an u
Click the color palette icon to toggle highlighting for warning and error messages. Messages are highlighted if they contain the text "warning" or "error".
:::

The controls are similar to the 🔢 [Table](../tab-reference/table.md) tab. The selected time is synchronized across all tabs. Click a row to select it, or hover over a row to preview it in any visible pop-up windows. Clicking the ↓ button jumps to the selected time (or the time entered in the box). Enter text in the "Filter" input to only display rows which contain the filter text. Press **Ctrl+F** to quickly select the "Filter" input.
The controls are similar to the 🔢 [Table](../tab-reference/table.md) tab. The selected time is synchronized across all tabs. Click a row to select it, or hover over a row to preview it in any visible pop-up windows. Clicking the ↓ button jumps to the selected time (or the time entered in the box). Enter text in the "Filter" input to only display rows which contain the filter text. Press `Ctrl+F` to quickly select the "Filter" input.

:::info
Add a "!" at the start of the filter text to _exclude_ matching messages from the main view.
Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/joysticks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/mechanism.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/odometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/points.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/swerve.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
2 changes: 1 addition & 1 deletion docsSite/docs/tab-reference/video.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The timeline is used to control playback and visualization. Clicking on the time

The green sections of the timeline indicate when the robot is autonomous, and the blue sections indicate when the robot is teleoperated.

To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again.
To zoom, place the cursor over the timeline and scroll up or down. A range can also be selecting by clicking and dragging while holding `Shift`. Move left and right by scrolling horizontally (on supported devices), or by clicking and dragging on the timeline. When connected live, scrolling to the left unlocks from the current time, and scrolling all the way to the right locks to the current time again. Press `Ctrl+\` to zoom to the period where the robot is enabled.

![Timeline](./img/timeline.png)

Expand Down
7 changes: 7 additions & 0 deletions src/hub/SelectionImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ export default class SelectionImpl implements Selection {
return this.timelineRange;
}

/** Set the visible range for the timeline. */
setTimelineRange(range: [number, number], lockMaxZoom: boolean) {
this.timelineRange = range;
this.timelineMaxZoom = lockMaxZoom;
this.applyTimelineScroll(0, 0, 0);
}

/** Updates the timeline range based on a scroll event. */
applyTimelineScroll(dx: number, dy: number, widthPixels: number) {
// Find available timestamp range
Expand Down
18 changes: 17 additions & 1 deletion src/hub/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Preferences from "../shared/Preferences";
import Selection from "../shared/Selection";
import { SourceListItemState, SourceListTypeMemory } from "../shared/SourceListConfig";
import Log from "../shared/log/Log";
import { AKIT_TIMESTAMP_KEYS, MERGE_PREFIX } from "../shared/log/LogUtil";
import { AKIT_TIMESTAMP_KEYS, getEnabledData, MERGE_PREFIX } from "../shared/log/LogUtil";
import { calcMockProgress, clampValue, htmlEncode, scaleValue } from "../shared/util";
import SelectionImpl from "./SelectionImpl";
import Sidebar from "./Sidebar";
Expand Down Expand Up @@ -644,6 +644,22 @@ async function handleMainMessage(message: NamedMessage) {
}
break;

case "zoom-enabled":
{
let enabledData = getEnabledData(window.log);
let range = window.log.getTimestampRange();
let firstEnableIndex = enabledData === null ? -1 : enabledData.values.findIndex((value) => value);
let lastDisableIndex = enabledData === null ? -1 : enabledData.values.findLastIndex((value) => !value);
if (firstEnableIndex !== -1) {
range[0] = enabledData!.timestamps[firstEnableIndex];
}
if (lastDisableIndex !== -1) {
range[1] = enabledData!.timestamps[lastDisableIndex];
}
window.selection.setTimelineRange(range, firstEnableIndex === -1 && lastDisableIndex === -1);
}
break;

case "show-update-button":
document.documentElement.style.setProperty("--show-update-button", message.data ? "1" : "0");
UPDATE_BUTTON.hidden = !message.data;
Expand Down
10 changes: 10 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,16 @@ function setupMenu() {
{ role: "zoomIn" },
{ role: "zoomOut" },
{ type: "separator" },
{
label: "Zoom to Enabled Range",
accelerator: "CmdOrCtrl+\\",
click(_, baseWindow) {
const window = baseWindow as BrowserWindow | undefined;
if (window === undefined || !hubWindows.includes(window)) return;
sendMessage(window, "zoom-enabled");
}
},
{ type: "separator" },
{
label: "Toggle Sidebar",
accelerator: "CmdOrCtrl+.",
Expand Down
4 changes: 4 additions & 0 deletions src/satellite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ class MockSelection implements Selection {
throw new Error("Method not implemented.");
}

setTimelineRange(range: [number, number], lockMaxZoom: boolean) {
throw new Error("Method not implemented.");
}

applyTimelineScroll(dx: number, dy: number, widthPixels: number): void {
window.sendMainMessage("call-selection-setter", { name: "applyTimelineScroll", args: [dx, dy, widthPixels] });
}
Expand Down
3 changes: 3 additions & 0 deletions src/shared/Selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export default interface Selection {
/** Returns the visible range for the timeline. */
getTimelineRange(): [number, number];

/** Set the visible range for the timeline. */
setTimelineRange(range: [number, number], lockMaxZoom: boolean): void;

/** Updates the timeline range based on a scroll event. */
applyTimelineScroll(dx: number, dy: number, widthPixels: number): void;
}
Expand Down

0 comments on commit f559e62

Please sign in to comment.