Skip to content

Commit 7320e18

Browse files
committed
fixes for zoom (tab bar)
1 parent ffe3247 commit 7320e18

5 files changed

Lines changed: 44 additions & 8 deletions

File tree

emain/menu.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ async function getAppMenu(
215215
label: "Reset Zoom",
216216
accelerator: "CommandOrControl+0",
217217
click: (_, window) => {
218-
getWindowWebContents(window ?? ww)?.setZoomFactor(1);
218+
const wc = getWindowWebContents(window ?? ww);
219+
if (wc) {
220+
wc.setZoomFactor(1);
221+
wc.send("zoom-factor-change", 1);
222+
}
219223
},
220224
},
221225
{
@@ -226,7 +230,9 @@ async function getAppMenu(
226230
if (wc == null) {
227231
return;
228232
}
229-
wc.setZoomFactor(Math.min(5, wc.getZoomFactor() + 0.2));
233+
const newZoom = Math.min(5, wc.getZoomFactor() + 0.2);
234+
wc.setZoomFactor(newZoom);
235+
wc.send("zoom-factor-change", newZoom);
230236
},
231237
},
232238
{
@@ -237,7 +243,9 @@ async function getAppMenu(
237243
if (wc == null) {
238244
return;
239245
}
240-
wc.setZoomFactor(Math.min(5, wc.getZoomFactor() + 0.2));
246+
const newZoom = Math.min(5, wc.getZoomFactor() + 0.2);
247+
wc.setZoomFactor(newZoom);
248+
wc.send("zoom-factor-change", newZoom);
241249
},
242250
visible: false,
243251
acceleratorWorksWhenHidden: true,
@@ -250,7 +258,9 @@ async function getAppMenu(
250258
if (wc == null) {
251259
return;
252260
}
253-
wc.setZoomFactor(Math.max(0.2, wc.getZoomFactor() - 0.2));
261+
const newZoom = Math.max(0.2, wc.getZoomFactor() - 0.2);
262+
wc.setZoomFactor(newZoom);
263+
wc.send("zoom-factor-change", newZoom);
254264
},
255265
},
256266
{
@@ -261,7 +271,9 @@ async function getAppMenu(
261271
if (wc == null) {
262272
return;
263273
}
264-
wc.setZoomFactor(Math.max(0.2, wc.getZoomFactor() - 0.2));
274+
const newZoom = Math.max(0.2, wc.getZoomFactor() - 0.2);
275+
wc.setZoomFactor(newZoom);
276+
wc.send("zoom-factor-change", newZoom);
265277
},
266278
visible: false,
267279
acceleratorWorksWhenHidden: true,

frontend/app/tab/tabbar.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
.tab-bar-wrapper {
55
--default-indent: 10px;
6-
--darwin-not-fullscreen-indent: 74px;
6+
--darwin-not-fullscreen-indent: calc(74px * var(--zoomfactor-inv));
77
}
88

99
.darwin:not(.fullscreen) .tab-bar-wrapper {
@@ -29,8 +29,10 @@
2929
user-select: none;
3030
display: flex;
3131
flex-direction: row;
32+
align-items: end;
3233
width: 100vw;
3334
-webkit-app-region: drag;
35+
height: max(33px, calc(33px * var(--zoomfactor-inv)));
3436

3537
button {
3638
-webkit-app-region: no-drag;
@@ -97,6 +99,10 @@
9799

98100
.add-tab {
99101
padding: 0 10px;
102+
height: 27px;
103+
}
104+
105+
.workspace-switcher {
100106
}
101107

102108
.window-drag {

frontend/app/workspace/workspace-layout-model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ImperativePanelGroupHandle, ImperativePanelHandle } from "react-resizab
1717
const dlog = debug("wave:workspace");
1818

1919
const AIPANEL_DEFAULTWIDTH = 300;
20+
const AIPANEL_DEFAULTWIDTHRATIO = 0.33;
2021
const AIPANEL_MINWIDTH = 250;
2122
const AIPANEL_MAXWIDTHRATIO = 0.5;
2223

@@ -110,7 +111,8 @@ class WorkspaceLayoutModel {
110111
return;
111112
}
112113
const width = this.getAIPanelWidth();
113-
this.aiPanelWrapperRef.style.width = `${width}px`;
114+
const clampedWidth = this.getClampedAIPanelWidth(width, window.innerWidth);
115+
this.aiPanelWrapperRef.style.width = `${clampedWidth}px`;
114116
}
115117

116118
enableTransitions(duration: number): void {
@@ -149,6 +151,7 @@ class WorkspaceLayoutModel {
149151
const layout = [aiPanelPercentage, mainContentPercentage];
150152
this.panelGroupRef.setLayout(layout);
151153
this.inResize = false;
154+
this.updateWrapperWidth();
152155
}
153156

154157
handlePanelLayout(sizes: number[]): void {
@@ -248,7 +251,7 @@ class WorkspaceLayoutModel {
248251
getAIPanelWidth(): number {
249252
this.initializeFromTabMeta();
250253
if (this.aiPanelWidth == null) {
251-
this.aiPanelWidth = Math.max(AIPANEL_DEFAULTWIDTH, window.innerWidth / 3);
254+
this.aiPanelWidth = Math.max(AIPANEL_DEFAULTWIDTH, window.innerWidth * AIPANEL_DEFAULTWIDTHRATIO);
252255
}
253256
return this.aiPanelWidth;
254257
}

frontend/tailwindsetup.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
--container-tiny: 120px;
6969
}
7070

71+
:root {
72+
--zoomfactor: 1;
73+
--zoomfactor-inv: 1;
74+
}
75+
7176
/* Chart tooltip styling for sysinfo plots */
7277
svg [aria-label="tip"] g path {
7378
color: var(--border-color);

frontend/wave.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ let savedInitOpts: WaveInitOpts = null;
5050
(window as any).removeNotificationById = removeNotificationById;
5151
(window as any).modalsModel = modalsModel;
5252

53+
function updateZoomFactor(zoomFactor: number) {
54+
console.log("update zoomfactor", zoomFactor);
55+
document.documentElement.style.setProperty("--zoomfactor", String(zoomFactor));
56+
document.documentElement.style.setProperty("--zoomfactor-inv", String(1 / zoomFactor));
57+
}
58+
5359
async function initBare() {
5460
getApi().sendLog("Init Bare");
5561
document.body.style.visibility = "hidden";
@@ -58,6 +64,10 @@ async function initBare() {
5864
getApi().onWaveInit(initWaveWrap);
5965
setKeyUtilPlatform(platform);
6066
loadFonts();
67+
updateZoomFactor(getApi().getZoomFactor());
68+
getApi().onZoomFactorChange((zoomFactor) => {
69+
updateZoomFactor(zoomFactor);
70+
});
6171
document.fonts.ready.then(() => {
6272
console.log("Init Bare Done");
6373
getApi().setWindowInitStatus("ready");

0 commit comments

Comments
 (0)