-
Notifications
You must be signed in to change notification settings - Fork 153
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] Add native win32 / linux custom window #2228
base: main
Are you sure you want to change the base?
Changes from all commits
ad87080
738de3b
582ca96
4559605
104c0a5
eb01fa6
504c661
9d108b8
002b7df
5f90dd9
6df7a45
56e18ae
9b28372
aa08f3d
c5314e4
a9e4f5e
c41db49
546993f
2e8e9e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
<div | ||
ref="topMenuRef" | ||
class="comfyui-menu flex items-center" | ||
v-show="showTopMenu" | ||
v-show="betaMenuEnabled && !workspaceState.focusMode" | ||
:class="{ dropzone: isDropZone, 'dropzone-active': isDroppable }" | ||
> | ||
<h1 class="comfyui-logo mx-2 app-drag">ComfyUI</h1> | ||
<h1 class="comfyui-logo mx-2">ComfyUI</h1> | ||
<CommandMenubar /> | ||
<Divider layout="vertical" class="mx-2" /> | ||
<div class="flex-grow min-w-0 app-drag h-full"> | ||
<div class="flex-grow min-w-0"> | ||
<WorkflowTabs v-if="workflowTabsPosition === 'Topbar'" /> | ||
</div> | ||
<div class="comfyui-menu-right" ref="menuRight"></div> | ||
|
@@ -25,22 +25,12 @@ | |
@click="workspaceState.focusMode = true" | ||
@contextmenu="showNativeMenu" | ||
/> | ||
<div | ||
v-show="menuSetting !== 'Bottom'" | ||
class="window-actions-spacer flex-shrink-0" | ||
/> | ||
</div> | ||
</teleport> | ||
|
||
<!-- Virtual top menu for native window (drag handle) --> | ||
<div | ||
v-show="isNativeWindow && !showTopMenu" | ||
class="fixed top-0 left-0 app-drag w-full h-[var(--comfy-topbar-height)]" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useEventBus } from '@vueuse/core' | ||
import { useEventBus, useResizeObserver } from '@vueuse/core' | ||
import Button from 'primevue/button' | ||
import Divider from 'primevue/divider' | ||
import { computed, onMounted, provide, ref } from 'vue' | ||
|
@@ -59,20 +49,14 @@ const settingStore = useSettingStore() | |
const workflowTabsPosition = computed(() => | ||
settingStore.get('Comfy.Workflow.WorkflowTabsPosition') | ||
) | ||
const menuSetting = computed(() => settingStore.get('Comfy.UseNewMenu')) | ||
const betaMenuEnabled = computed(() => menuSetting.value !== 'Disabled') | ||
const betaMenuEnabled = computed( | ||
() => settingStore.get('Comfy.UseNewMenu') !== 'Disabled' | ||
) | ||
const teleportTarget = computed(() => | ||
settingStore.get('Comfy.UseNewMenu') === 'Top' | ||
? '.comfyui-body-top' | ||
: '.comfyui-body-bottom' | ||
) | ||
const isNativeWindow = computed( | ||
() => | ||
isElectron() && settingStore.get('Comfy-Desktop.WindowStyle') === 'custom' | ||
) | ||
const showTopMenu = computed( | ||
() => betaMenuEnabled.value && !workspaceState.focusMode | ||
) | ||
|
||
const menuRight = ref<HTMLDivElement | null>(null) | ||
// Menu-right holds legacy topbar elements attached by custom scripts | ||
|
@@ -94,13 +78,20 @@ eventBus.on((event: string, payload: any) => { | |
} | ||
}) | ||
|
||
onMounted(() => { | ||
if (isElectron()) { | ||
electronAPI().changeTheme({ | ||
height: topMenuRef.value.getBoundingClientRect().height | ||
}) | ||
} | ||
}) | ||
/** Height of titlebar on desktop. */ | ||
if (isElectron()) { | ||
let desktopHeight = 0 | ||
|
||
useResizeObserver(topMenuRef, (entries) => { | ||
if (settingStore.get('Comfy.UseNewMenu') !== 'Top') return | ||
|
||
const { height } = entries[0].contentRect | ||
if (desktopHeight === height) return | ||
|
||
electronAPI().changeTheme({ height }) | ||
desktopHeight = height | ||
}) | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
|
@@ -136,3 +127,30 @@ onMounted(() => { | |
cursor: default; | ||
} | ||
</style> | ||
|
||
<style lang="postcss"> | ||
/* Desktop: Custom window styling */ | ||
:root[data-platform='electron'] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we restoring the logo change? I don't think that is something we want to ship:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a summary of points elsewhere: |
||
.comfyui-logo { | ||
@apply flex items-center gap-2 my-1 mx-1.5; | ||
|
||
&::before { | ||
@apply w-7 h-7 bg-[url('/assets/images/Comfy_Logo_x256.png')] bg-no-repeat bg-contain content-['']; | ||
} | ||
} | ||
|
||
.comfyui-body-top { | ||
.comfyui-menu { | ||
app-region: drag; | ||
padding-right: calc(100% - env(titlebar-area-width, 0)); | ||
} | ||
} | ||
|
||
button, | ||
.p-menubar, | ||
.comfyui-menu-right > *, | ||
.actionbar { | ||
app-region: no-drag; | ||
} | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don' think the resize observer is necessary after #2209 as the topbar menu height is now fixed.