Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Desktop] Native window virtual menu bar #2215

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
},
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@comfyorg/comfyui-electron-types": "^0.4.6",
"@comfyorg/comfyui-electron-types": "^0.4.7",
"@comfyorg/litegraph": "^0.8.60",
"@primevue/themes": "^4.0.5",
"@tiptap/core": "^2.10.4",
Expand Down
8 changes: 8 additions & 0 deletions src/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,11 @@ audio.comfy-audio.empty-audio-widget {
.p-tree-node-content {
padding: var(--comfy-tree-explorer-item-padding) !important;
}

.app-drag {
app-region: drag;
}

.no-drag {
app-region: no-drag;
}
30 changes: 25 additions & 5 deletions src/views/templates/BaseViewTemplate.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<template>
<div
class="font-sans w-screen h-screen flex items-center justify-center pointer-events-auto overflow-auto"
class="font-sans w-screen h-screen flex flex-col pointer-events-auto"
:class="[
props.dark
? 'text-neutral-300 bg-neutral-900 dark-theme'
: 'text-neutral-900 bg-neutral-300'
]"
>
<slot></slot>
<!-- Virtual top menu for native window (drag handle) -->
<div
v-show="isNativeWindow"
ref="topMenuRef"
class="app-drag w-full h-[var(--comfy-topbar-height)]"
/>
<div
class="flex-grow w-full flex items-center justify-center overflow-auto"
>
<slot></slot>
</div>
</div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import { nextTick, onMounted, ref } from 'vue'

import { electronAPI, isElectron } from '@/utils/envUtil'

Expand All @@ -35,9 +45,19 @@ const lightTheme = {
symbolColor: '#171717'
}

onMounted(() => {
const topMenuRef = ref<HTMLDivElement | null>(null)
const isNativeWindow = ref(false)
onMounted(async () => {
if (isElectron()) {
electronAPI().changeTheme(props.dark ? darkTheme : lightTheme)
const windowStyle = await electronAPI().Config.getWindowStyle()
isNativeWindow.value = windowStyle === 'custom'

await nextTick()

electronAPI().changeTheme({
...(props.dark ? darkTheme : lightTheme),
height: topMenuRef.value.getBoundingClientRect().height
})
}
})
</script>
Loading