c514e4faec
Track menu popup visibility and propagate zoom level to the popup. Add menu_popup_visible_ flag, SendMenuPopupZoom(), and call it when creating/showing the popup and when adjusting zoom. Make CreateNewTab accept an optional URL and route popup/new-tab flows to it. Prevent per-tab child closes from triggering app shutdown by tracking closing_tab_browsers_ and adding ForgetClosingTabBrowser(). Treat MenuPopup role specially when enabling frame hit-testing. Platform: remove usage of ApplyRoundedBrowserRegion and switch menu popup sizing to use resized client_size helpers (consolidate calculations across Win/Mac/Linux). UI: update menu-popup CSS/JS (new styling, font, zoom formatting API via NebulaMenuPopup.setZoomLevel), wire settings to use nebulaNative.postMessage for new-tab, and remove the static menu-popup.html. Misc: small chrome CSS/JS tweaks and ensure chrome state includes zoomLevel.
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
const zoomPercentEl = document.getElementById('zoom-percent');
|
|
|
|
function setCssVar(name, value, fallback) {
|
|
const val = value || fallback;
|
|
if (val) document.documentElement.style.setProperty(name, val);
|
|
}
|
|
|
|
function applyTheme(theme) {
|
|
const colors = theme?.colors || theme || {};
|
|
setCssVar('--bg', colors.bg, '#0b0d10');
|
|
setCssVar('--dark-blue', colors.darkBlue, '#0b1c2b');
|
|
setCssVar('--dark-purple', colors.darkPurple, '#1b1035');
|
|
setCssVar('--primary', colors.primary, '#7b2eff');
|
|
setCssVar('--accent', colors.accent, '#00c6ff');
|
|
setCssVar('--text', colors.text, '#e0e0e0');
|
|
setCssVar('--url-bar-bg', colors.urlBarBg, '#1c2030');
|
|
setCssVar('--url-bar-border', colors.urlBarBorder, '#3e4652');
|
|
}
|
|
|
|
function sendMenuCommand(cmd) {
|
|
if (window.nebulaNative?.postMessage) {
|
|
window.nebulaNative.postMessage(cmd);
|
|
}
|
|
}
|
|
|
|
function formatZoomPercent(zoomLevel) {
|
|
const level = Number.isFinite(zoomLevel) ? zoomLevel : 0;
|
|
return `${Math.round(Math.pow(1.2, level) * 100)}%`;
|
|
}
|
|
|
|
function setZoomLevel(zoomLevel) {
|
|
if (zoomPercentEl) {
|
|
zoomPercentEl.textContent = formatZoomPercent(zoomLevel);
|
|
}
|
|
}
|
|
|
|
window.NebulaMenuPopup = { applyTheme, setZoomLevel };
|
|
|
|
window.addEventListener('click', (e) => {
|
|
const btn = e.target.closest('button[data-cmd]');
|
|
if (!btn) return;
|
|
const cmd = btn.getAttribute('data-cmd');
|
|
sendMenuCommand(cmd);
|
|
});
|
|
|
|
window.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Escape') {
|
|
sendMenuCommand('close-menu-popup');
|
|
}
|
|
});
|
|
|
|
setZoomLevel(0);
|