Skip to content

Commit

Permalink
feat: Set widget min size when selected (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarab42 authored Feb 28, 2021
1 parent 4c23b01 commit 3808fda
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/static/locales/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"check-disable-source-not-visible": "Check: Shutdown source when not visible.",
"check-refresh-browser-on-activate": "Check: Refresh browser when scene becomes active.",
"overlay-not-found": "Overlay not found",
"no-source-selected": "obs.no-source-selected"
"no-source-selected": "No source selected"
},
"anime": {
"timeline": "Animation"
Expand Down
2 changes: 1 addition & 1 deletion app/static/locales/es/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"check-disable-source-not-visible": "Marque la casilla: Desactivar la fuente en la que no este visible.",
"check-refresh-browser-on-activate": "Marque la casilla: Recargar el navegador cuando la escena sea activa.",
"overlay-not-found": "Overlay no encontrado",
"no-source-selected": "obs.no-source-selected"
"no-source-selected": "No se seleccionó ninguna fuente"
},
"anime": {
"timeline": "Animación"
Expand Down
2 changes: 1 addition & 1 deletion app/static/locales/fr/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"check-disable-source-not-visible": "Coche la case: Désactiver la source quand elle n'est pas visible.",
"check-refresh-browser-on-activate": "Coche la case: Rafraîchir le navigateur lorsque la scène devient active.",
"overlay-not-found": "Overlay non trouvé",
"no-source-selected": "obs.no-source-selected"
"no-source-selected": "Aucune source sélectionnée"
},
"anime": {
"timeline": "Animation"
Expand Down
11 changes: 3 additions & 8 deletions front-src/client/components/Panels/Panel/Widget/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@

{#if $editMode}
{#if !component}
<div class="absolute inset-0">
<div class="flex w-full h-full opacity-50 pb-2">
<MdAdd />
</div>
<div class="absolute bottom-0 w-full text-center">
<span
class="text-xs opacity-50"
>{_('sentences.double-click-to-edit')}</span>
<div class="flex absolute inset-0">
<div class="m-auto p-2 text-xs opacity-50">
{_('sentences.right-click-to-show-menu')}
</div>
</div>
{/if}
Expand Down
16 changes: 16 additions & 0 deletions front-src/client/components/Panels/Panel/Widget/Edit/Action.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import ActionEvents from "./ActionEvents.svelte";
import Button from "@/components/UI/Button.svelte";
import Select from "@/components/UI/Select.svelte";
import { findSpaceForWidget } from "@/stores/panels";
import MdDelete from "svelte-icons/md/MdDeleteForever.svelte";
import ConfirmModal from "@/components/UI/ConfirmModal.svelte";
Expand Down Expand Up @@ -58,6 +59,21 @@
}
function onComponentChange({ detail: name }) {
const { minSize } = widgets[name].config;
if (minSize) {
let oldSpace = {};
panel.grid = panel.grid.filter((space) => {
if (space.id === widget.id) {
oldSpace = space;
return false;
}
return true;
});
const space = findSpaceForWidget(panel, minSize);
panel.grid = [...panel.grid, { ...oldSpace, ...space }];
}
change("component", cloneDeep(widgets[name].config));
}
Expand Down
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/Anime/Timeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ export default {
label: "anime.timeline",
hasTrigger: true,
hasEvent: true,
minSize: {
w: 2,
h: 4,
},
props: {},
};
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/OBS/GoToScene/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export default {
label: "obs.go-to-scene",
hasTrigger: true,
hasEvent: true,
minSize: {
w: 2,
h: 4,
},
props: {
scene: null,
},
Expand Down
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/OBS/SceneList/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ export default {
label: "obs.scene-list",
hasTrigger: true,
hasEvent: ["onCommand"],
minSize: {
w: 2,
h: 4,
},
};
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/OBS/ToggleAudio/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export default {
label: "obs.toggle-audio",
hasTrigger: true,
hasEvent: true,
minSize: {
w: 2,
h: 4,
},
props: {
source: null,
},
Expand Down
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/OBS/ToggleScene/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export default {
label: "obs.toggle-scene",
hasTrigger: true,
hasEvent: true,
minSize: {
w: 2,
h: 4,
},
props: {
scene1: null,
scene2: null,
Expand Down
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/Twitch/Chat/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export default {
label: "twitch.chat",
hasTrigger: false,
hasEvent: false,
minSize: {
w: 3,
h: 8,
},
props: {
channel: null,
theme: "dark",
Expand Down
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/Twitch/Commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ export default {
label: "twitch.commands",
hasTrigger: false,
hasEvent: false,
minSize: {
w: 3,
h: 4,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ export default {
label: "twitch.followers",
hasTrigger: false,
hasEvent: false,
minSize: {
w: 3,
h: 4,
},
};
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/Twitch/Rewards/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ export default {
label: "twitch.rewards",
hasTrigger: false,
hasEvent: false,
minSize: {
w: 3,
h: 4,
},
};
4 changes: 4 additions & 0 deletions front-src/client/components/Widgets/Twitch/Stream/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ export default {
label: "twitch.stream",
hasTrigger: false,
hasEvent: false,
minSize: {
w: 3,
h: 4,
},
props: {
channel: null,
autoplay: true,
Expand Down

0 comments on commit 3808fda

Please sign in to comment.