Skip to content

Commit

Permalink
Get Windows working... I think...
Browse files Browse the repository at this point in the history
  • Loading branch information
grantjbutler committed Jan 31, 2022
1 parent 150eb4e commit fa0e93f
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 112 deletions.
8 changes: 6 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="flex flex-col h-screen text-system-text text-sm">
<nav-bar v-if="isMacOS" class="flex-none"></nav-bar>
<command-bar v-if="isWindows" class="flex-none"></command-bar>
<div class="flex-1 flex flex-row items-stretch">
<sidebar class="flex-none border-r border-system-divider"></sidebar>
<preview></preview>
Expand All @@ -15,7 +16,8 @@ import Preview from './components/Preview.vue';
import Sidebar from './components/Sidebar.vue';
import Controls from './components/Controls.vue';
import NavBar from './components/NavBar.vue';
import { useIsMacOS } from './integration/platform';
import CommandBar from './components/CommandBar.vue';
import { useIsMacOS, useIsWindows } from './integration/platform';
export default defineComponent({
name: 'App',
Expand All @@ -24,10 +26,12 @@ export default defineComponent({
Sidebar,
Controls,
NavBar,
CommandBar,
},
setup() {
return {
isMacOS: useIsMacOS()
isMacOS: useIsMacOS(),
isWindows: useIsWindows()
}
}
});
Expand Down
14 changes: 12 additions & 2 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer'
import { basename } from 'path';

import { installContextMenuHandling, configureApplicationMenu } from './electron/menus';
import { installContextMenuHandling, configureApplicationMenu, showsApplicationMenu } from './electron/menus';
import emitter from './electron/events';
import { openPreferences } from './electron/preferences-window';
import { injectSystemColors } from './electron/colors';
Expand Down Expand Up @@ -51,7 +51,8 @@ async function createWindow() {
minWidth: 1050,
show: false,
vibrancy: 'sidebar',
titleBarStyle: process.platform === 'darwin' ? 'hiddenInset' : 'default',
titleBarStyle: process.platform === 'darwin' ? 'hiddenInset' : 'hidden',
titleBarOverlay: process.platform === 'win32',
webPreferences: {

// Use pluginOptions.nodeIntegration, leave this alone
Expand All @@ -70,6 +71,15 @@ async function createWindow() {
win.show();
});

if (!showsApplicationMenu() && isDevelopment) {
win.webContents.on('before-input-event', (event, input) => {
if (input.control && input.shift && input.key.toLocaleLowerCase() == 'i') {
win.webContents.openDevTools({ mode: 'undocked' });
event.preventDefault();
}
})
}

if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL as string)
Expand Down
59 changes: 59 additions & 0 deletions src/components/CommandBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div>
<div class="app-region-drag bg-system-background-nav-bar p-2 flex items-baseline space-x-2" style="height: env(titlebar-area-height, 40px); width: env(titlebar-area-width, 0px);">
<ConnectionState size="small"></ConnectionState>

<span>obs-layout</span>
</div>
<div class="bg-system-background-nav-bar flex items-center justify-end">
<Popover class="relative">
<PopoverButton class="flex items-center hover:bg-gray-300 p-3 space-x-1">
<CloudUploadIcon class="w-6 h-6 text-gray-600" />

<span>Sync</span>
</PopoverButton>

<PopoverPanel class="absolute z-10 right-0">
<sync-popover></sync-popover>
</PopoverPanel>
</Popover>

<button class="flex space-x-1 hover:bg-gray-300 p-3" @click="openSettings">
<CogIcon class="w-6 h-6 text-gray-600" />

<span>Settings</span>
</button>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { CloudUploadIcon, CogIcon } from '@heroicons/vue/outline';
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
import ConnectionState from './ConnectionState.vue';
import { ipcRenderer } from 'electron';
import SyncPopover from './SyncPopover.vue';
export default defineComponent({
components: {
CloudUploadIcon,
CogIcon,
ConnectionState,
SyncPopover,
Popover,
PopoverButton,
PopoverPanel
},
setup() {
const openSettings = () => {
ipcRenderer.send('open-settings');
}
return {
openSettings
}
},
})
</script>
72 changes: 72 additions & 0 deletions src/components/ConnectionState.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div :class="`${backgroundColor} ${sizeClasses} rounded-full`" :title="title"></div>
</template>

<script lang="ts">
import { defineComponent, computed, PropType, toRefs } from 'vue'
import { useStore } from '@/store/app'
import { OBSConnectionState } from '@/obs/connection-state';
enum Size {
Small = 'small',
Medium = 'medium'
}
export default defineComponent({
props: {
size: {
type: String as PropType<Size>,
required: true
}
},
setup(props) {
const store = useStore()
const { size } = toRefs(props);
const sizeClasses = computed(() => {
switch (size.value) {
case Size.Small:
return 'w-2 h-2'
case Size.Medium:
return 'w-4 h-4'
default:
return ''
}
})
// eslint-disable-next-line vue/return-in-computed-property
const backgroundColor = computed(() => {
switch (store.state.connectionState) {
case OBSConnectionState.Connecting:
return 'bg-yellow-500'
case OBSConnectionState.Connected:
return 'bg-green-500'
case OBSConnectionState.Disconnected:
case OBSConnectionState.Error:
return 'bg-red-500'
}
})
// eslint-disable-next-line vue/return-in-computed-property
const title = computed(() => {
switch (store.state.connectionState) {
case OBSConnectionState.Disconnected:
return 'Disconnected'
case OBSConnectionState.Connecting:
return 'Connecting'
case OBSConnectionState.Connected:
return 'Connected'
case OBSConnectionState.Error:
return 'Error'
}
})
return {
backgroundColor,
title,
sizeClasses
}
},
})
</script>
74 changes: 9 additions & 65 deletions src/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,20 @@
</div>

<PopoverPanel class="absolute z-10">
<div class="w-64 p-2 space-y-2 shadow-lg bg-system-background-window">
<div>Sync current layout to scene:</div>

<div>
<select class="w-full text-system-text-control bg-system-background-control" v-model="scene">
<option v-for="scene in scenes" :key="scene" :value="scene" v-text="scene"></option>
</select>
</div>

<div class="flex justify-end">
<button class="px-3 py-1 bg-green-500" @click="sync">Sync</button>
</div>
</div>
<sync-popover></sync-popover>
</PopoverPanel>
</Popover>
<div class="w-4 h-4 rounded-full" :class="connectionStateBackgroundColor" :title="connectionStateText"></div>
<ConnectionState size="medium"></ConnectionState>
</div>
</div>
</template>

<script lang="ts">
import { OBSConnectionState } from '@/obs/connection-state'
import { useStore } from '@/store/app'
import { computed, defineComponent, ref } from 'vue'
import { defineComponent } from 'vue'
import { CloudUploadIcon, ChevronDownIcon } from '@heroicons/vue/outline';
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue';
import { syncLayout } from '@/integration/obs';
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'
import ConnectionState from './ConnectionState.vue';
import SyncPopover from './SyncPopover.vue';
export default defineComponent({
components: {
Expand All @@ -47,53 +34,10 @@ export default defineComponent({
Popover,
PopoverButton,
PopoverPanel
},
setup() {
const store = useStore()
// eslint-disable-next-line vue/return-in-computed-property
const connectionStateBackgroundColor = computed(() => {
switch (store.state.connectionState) {
case OBSConnectionState.Connecting:
return 'bg-yellow-500'
case OBSConnectionState.Connected:
return 'bg-green-500'
case OBSConnectionState.Disconnected:
case OBSConnectionState.Error:
return 'bg-red-500'
}
})
// eslint-disable-next-line vue/return-in-computed-property
const connectionStateText = computed(() => {
switch (store.state.connectionState) {
case OBSConnectionState.Disconnected:
return 'Disconnected'
case OBSConnectionState.Connecting:
return 'Connecting'
case OBSConnectionState.Connected:
return 'Connected'
case OBSConnectionState.Error:
return 'Error'
}
})
const scene = ref('');
const scenes = computed(() => store.state.scenes);
const sync = () => {
if (!store.state.rootNode) { return }
syncLayout(store.state.rootNode, scene.value);
}
PopoverPanel,
return {
connectionStateBackgroundColor,
connectionStateText,
scenes,
scene,
sync
}
ConnectionState,
SyncPopover
},
})
</script>
41 changes: 41 additions & 0 deletions src/components/SyncPopover.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div class="w-64 p-2 space-y-2 shadow-lg bg-system-background-window">
<div>Sync current layout to scene:</div>

<div>
<select class="w-full text-system-text-control bg-system-background-control" v-model="scene">
<option v-for="scene in scenes" :key="scene" :value="scene" v-text="scene"></option>
</select>
</div>

<div class="flex justify-end">
<button class="px-3 py-1 bg-green-500" @click="sync">Sync</button>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent, ref, computed } from 'vue'
import { useStore } from '@/store/app'
import { syncLayout } from '@/integration/obs'
export default defineComponent({
setup() {
const store = useStore();
const scene = ref('');
const scenes = computed(() => store.state.scenes);
const sync = () => {
if (!store.state.rootNode) { return }
syncLayout(store.state.rootNode, scene.value);
}
return {
scene,
scenes,
sync
}
},
})
</script>
Loading

0 comments on commit fa0e93f

Please sign in to comment.