-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7444930
commit d6742ae
Showing
26 changed files
with
643 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<div class="flex" :class="{ 'flex-col': component.direction == 'vertical', 'flex-row': component.direction == 'horizontal' }"> | ||
<component v-for="child in component.children" :key="child.id" :is="child.viewComponent" :component="child"></component> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, PropType } from 'vue' | ||
import FlexComponent from '@/layout/FlexComponent' | ||
export default defineComponent({ | ||
props: { | ||
component: { | ||
type: Object as PropType<FlexComponent>, | ||
required: true | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<div class="bg-black aspect-w-16 aspect-h-9"> | ||
<span v-text="component.source"></span> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, PropType } from 'vue' | ||
import SourceComponent from '@/layout/SourceComponent' | ||
export default defineComponent({ | ||
props: { | ||
component: { | ||
type: Object as PropType<SourceComponent>, | ||
required: true | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
<template> | ||
<div class="w-64 bg-gray-200"> | ||
Controls | ||
<div class="w-72 bg-gray-200 p-2"> | ||
<div v-if="component"> | ||
<div> | ||
<p>Base Component Controls</p> | ||
</div> | ||
|
||
<component :is="component.controlsComponent" :component="component"></component> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
import Component from '@/layout/Component' | ||
import { defineComponent, PropType } from 'vue' | ||
import FlexComponentControls from './Controls/FlexComponentControls.vue' | ||
import SourceComponentControls from './Controls/SourceComponentControls.vue' | ||
export default defineComponent({ | ||
components: { | ||
FlexComponentControls, | ||
SourceComponentControls | ||
}, | ||
props: { | ||
component: { | ||
type: Object as PropType<Component> | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<template> | ||
<div> | ||
<p>Flex Component</p> | ||
<div> | ||
<label>Direction</label> | ||
<select :value="component.direction" @change="setDirection"> | ||
<option value="horizontal">Horizontal</option> | ||
<option value="vertical">Vertical</option> | ||
</select> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import FlexComponent from '@/layout/FlexComponent' | ||
import { defineComponent, PropType, toRefs } from 'vue' | ||
export default defineComponent({ | ||
props: { | ||
component: { | ||
type: Object as PropType<FlexComponent>, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const { component } = toRefs(props) | ||
const setDirection = (direction: 'horizontal' | 'vertical') => { | ||
component.value.direction = direction | ||
} | ||
return { | ||
setDirection | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<div> | ||
<p>Source Component</p> | ||
<div> | ||
<label>Source</label> | ||
<select :value="component.source" @change="setSource"> | ||
<option value="">None</option> | ||
<option value="MC Ninja">MC Ninja</option> | ||
<option value="Game capture">Game capture</option> | ||
<option value="facecam">facecam</option> | ||
</select> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import SourceComponent from '@/layout/SourceComponent' | ||
import { defineComponent, PropType, toRefs } from 'vue' | ||
export default defineComponent({ | ||
props: { | ||
component: { | ||
type: Object as PropType<SourceComponent>, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const { component } = toRefs(props) | ||
const setSource = (source: string) => { | ||
component.value.source = source | ||
} | ||
return { | ||
setSource | ||
} | ||
}, | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ipcRenderer } from 'electron' | ||
import { defineComponent, h } from 'vue' | ||
|
||
export default defineComponent({ | ||
setup(props, context) { | ||
return () => { | ||
const defaultSlot = context.slots.default?.() ?? [] | ||
const menuSlot = context.slots.menu?.() ?? [] | ||
|
||
return h( | ||
'div', | ||
{ | ||
onContextmenu: () => { | ||
const [node] = menuSlot | ||
if (!node) { | ||
return; | ||
} | ||
|
||
const component = node.component | ||
if (!component) { | ||
return; | ||
} | ||
|
||
const buildItem = component.exposed?.buildItem | ||
if (!buildItem) { | ||
throw new Error(); | ||
} | ||
|
||
const menu = buildItem(); | ||
ipcRenderer.send('show-context-menu', JSON.parse(JSON.stringify(menu))); | ||
} | ||
}, | ||
[...defaultSlot, ...menuSlot] | ||
) | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { defineComponent } from 'vue' | ||
import useMenuBuilding from './useMenuBuilding'; | ||
|
||
export default defineComponent({ | ||
setup(props, context) { | ||
const { buildItem, buildMenu } = useMenuBuilding() | ||
|
||
context.expose({ | ||
buildItem | ||
}) | ||
|
||
return () => { | ||
const children = context.slots.default?.() | ||
buildMenu(children ?? []) | ||
return children | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { defineComponent, Text, ref } from 'vue' | ||
import { v4 as uuidv4 } from 'uuid' | ||
import { ipcRenderer } from 'electron'; | ||
import MenuItemDefinition from './MenuItemDefinition' | ||
|
||
export default defineComponent({ | ||
emits: ['click'], | ||
setup(props, context) { | ||
const label = ref(''); | ||
const id = ref(uuidv4()) | ||
|
||
const buildItem = (): MenuItemDefinition => { | ||
return { | ||
id: id.value, | ||
label: label.value | ||
} | ||
} | ||
|
||
context.expose({ | ||
buildItem | ||
}) | ||
|
||
ipcRenderer.on(`context-menu:click:${id.value}`, () => { | ||
context.emit('click'); | ||
}) | ||
|
||
return () => { | ||
if (!context.slots.default) { | ||
throw new Error(); | ||
} | ||
|
||
const children = context.slots.default() | ||
const [firstChild, ...others] = children | ||
|
||
if (others.length > 0) { | ||
throw new Error(); | ||
} | ||
|
||
if (firstChild.type != Text) { | ||
throw new Error(); | ||
} | ||
|
||
label.value = firstChild.children as string | ||
|
||
return null | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
interface MenuItem { | ||
id: string | ||
label: string | ||
} | ||
|
||
interface MenuSubmenu { | ||
label: string | ||
submenu: MenuItemDefinition[] | ||
} | ||
|
||
type MenuItemDefinition = MenuItem | MenuSubmenu | { | ||
type: 'separator' | ||
} | ||
|
||
export default MenuItemDefinition; |
Oops, something went wrong.