fix: updated UI to macosx conventions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { app, ipcMain, dialog, shell } from 'electron';
|
||||
import { app, BrowserWindow, ipcMain, dialog, shell } from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as fsPromises from 'fs/promises';
|
||||
import { eq } from 'drizzle-orm';
|
||||
@@ -697,6 +697,20 @@ export function registerIpcHandlers(): void {
|
||||
return projectEngine.getDefaultProjectBaseDir(projectId);
|
||||
});
|
||||
|
||||
safeHandle('app:getTitleBarMetrics', async (event) => {
|
||||
const ownerWindow = BrowserWindow.fromWebContents(event.sender);
|
||||
const buttonPosition = ownerWindow?.getWindowButtonPosition?.();
|
||||
if (!buttonPosition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const estimatedClusterWidth = Math.max(52, Math.round(buttonPosition.y * 4));
|
||||
const trailingPadding = Math.max(8, Math.round(buttonPosition.y * 0.6));
|
||||
const macosLeftInset = Math.max(0, Math.round(buttonPosition.x + estimatedClusterWidth + trailingPadding));
|
||||
|
||||
return { macosLeftInset };
|
||||
});
|
||||
|
||||
safeHandle('app:showItemInFolder', async (_, itemPath: string) => {
|
||||
return shell.showItemInFolder(itemPath);
|
||||
});
|
||||
|
||||
@@ -137,6 +137,7 @@ export const electronAPI: ElectronAPI = {
|
||||
// App
|
||||
app: {
|
||||
getDataPaths: () => ipcRenderer.invoke('app:getDataPaths'),
|
||||
getTitleBarMetrics: () => ipcRenderer.invoke('app:getTitleBarMetrics'),
|
||||
openFolder: (folderPath: string) => ipcRenderer.invoke('app:openFolder', folderPath),
|
||||
showItemInFolder: (itemPath: string) => ipcRenderer.invoke('app:showItemInFolder', itemPath),
|
||||
selectFolder: (title?: string) => ipcRenderer.invoke('app:selectFolder', title),
|
||||
|
||||
@@ -505,6 +505,7 @@ export interface ElectronAPI {
|
||||
};
|
||||
app: {
|
||||
getDataPaths: () => Promise<{ database: string; posts: string; media: string }>;
|
||||
getTitleBarMetrics: () => Promise<{ macosLeftInset: number } | null>;
|
||||
openFolder: (folderPath: string) => Promise<string>;
|
||||
showItemInFolder: (itemPath: string) => Promise<void>;
|
||||
selectFolder: (title?: string) => Promise<string | null>;
|
||||
|
||||
Reference in New Issue
Block a user