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

🚩 PR: Multiple fixes and small features #781

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed layer naming in a context aware way
  • Loading branch information
elsoazemelet committed Jul 21, 2024
commit 49baab097479dc2b543f66835c07382b5e27df51
68 changes: 42 additions & 26 deletions src/renderer/config-blocks/LedColor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ A -> B : AB-First step
import AtomicSuggestions from "../main/user-interface/AtomicSuggestions.svelte";
import { configManager } from "../main/panels/configuration/Configuration.store";
import Toggle from "../main/user-interface/Toggle.svelte";

import { get } from "svelte/store";
import { ConfigTarget } from "./../main/panels/configuration/Configuration.store.js";
import { ElementType } from "@intechstudio/grid-protocol";
import SendFeedback from "../main/user-interface/SendFeedback.svelte";

import { Validator } from "./_validators";

import { Script } from "./_script_parsers.js";
import { LocalDefinitions } from "../runtime/runtime.store";
import { LocalDefinitions, user_input } from "../runtime/runtime.store";

export let config;
export let inputSet;
Expand Down Expand Up @@ -141,45 +141,61 @@ A -> B : AB-First step
dispatch("output", { short: config.short, script: script });
}

const _suggestions = [
[
//{value: 'this.ind()', info: 'this led'},
],
[
{ value: "1", info: "layer 1" },
{ value: "2", info: "layer 2" },
],
[
//{value: '255', info: '255'}
],
[
//{value: '255', info: '255'}
],
[
//{value: '255', info: '255'}
],
const defaultLayerSuggestion = [
{ value: "1", info: "layer 1" },
{ value: "2", info: "layer 2" },
];

const _suggestions = [[], defaultLayerSuggestion, [], [], []];

let suggestions = [];

$: if ($configManager) {
updateSuggestions();
}

function updateSuggestions() {
const index = $configManager.findIndex((e) => e.id === config.id);
const localDefinitions = LocalDefinitions.getFrom({
configs: $configManager,
index: index,
});
suggestions = _suggestions.map((s, i) => {
// SKIP LAYER
if (i != 1) {
return [...localDefinitions, ...s];
if (i === 1) {
const ui = get(user_input);
const target = ConfigTarget.createFrom({ userInput: ui });
switch (target.elementType) {
case ElementType.BUTTON:
return [
{ value: "1", info: "Button layer" },
{ value: "2", info: "Unused layer" },
];
case ElementType.ENCODER:
return [
{ value: "1", info: "Button layer" },
{ value: "2", info: "Rotation layer" },
];
case ElementType.FADER:
return [
{ value: "1", info: "Fader layer" },
{ value: "2", info: "Unused layer" },
];
case ElementType.POTMETER:
return [
{ value: "1", info: "Potmeter layer" },
{ value: "2", info: "Unused layer" },
];
default:
return defaultLayerSuggestion;
}
} else {
return [...s, ...localDefinitions];
return [...localDefinitions, ...s];
}
});
}

onMount(() => {
suggestions = _suggestions;
updateSuggestions();
initColorPicker();

updatePicker();
Expand Down
63 changes: 46 additions & 17 deletions src/renderer/config-blocks/LedPhase.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@
};
</script>

<script>
<script lang="ts">
import { onMount, createEventDispatcher, onDestroy } from "svelte";
import AtomicInput from "../main/user-interface/AtomicInput.svelte";
import { Script } from "./_script_parsers.js";
import { LocalDefinitions } from "../runtime/runtime.store";
import { LocalDefinitions, user_input } from "../runtime/runtime.store";

import { Validator } from "./_validators";
import AtomicSuggestions from "../main/user-interface/AtomicSuggestions.svelte";
import { configManager } from "../main/panels/configuration/Configuration.store";
import { get } from "svelte/store";
import { ConfigTarget } from "./../main/panels/configuration/Configuration.store.js";
import { ElementType } from "@intechstudio/grid-protocol";

export let config;
export let humanScript;
Expand Down Expand Up @@ -107,42 +110,68 @@
dispatch("output", { short: config.short, script: script });
}

const defaultLayerSuggestion = [
{ value: "1", info: "layer 1" },
{ value: "2", info: "layer 2" },
];

const _suggestions = [
// led number
[
//{value: 'this.ind()', info: 'this led'},
],
[],
// layer
[
{ value: "1", info: "layer 1" },
{ value: "2", info: "layer 2" },
],
defaultLayerSuggestion,
// intensity or value
[
//{value: 'to do...', info: 'to do...'}
],
[],
];

let suggestions = [];

$: if ($configManager) {
updateSuggestions();
}

function updateSuggestions() {
const index = $configManager.findIndex((e) => e.id === config.id);
const localDefinitions = LocalDefinitions.getFrom({
configs: $configManager,
index: index,
});
suggestions = _suggestions.map((s, i) => {
// SKIP LAYER
if (i != 1) {
return [...localDefinitions, ...s];
if (i === 1) {
const ui = get(user_input);
const target = ConfigTarget.createFrom({ userInput: ui });
switch (target.elementType) {
case ElementType.BUTTON:
return [
{ value: "1", info: "Button layer" },
{ value: "2", info: "Unused layer" },
];
case ElementType.ENCODER:
return [
{ value: "1", info: "Button layer" },
{ value: "2", info: "Rotation layer" },
];
case ElementType.FADER:
return [
{ value: "1", info: "Fader layer" },
{ value: "2", info: "Unused layer" },
];
case ElementType.POTMETER:
return [
{ value: "1", info: "Potmeter layer" },
{ value: "2", info: "Unused layer" },
];
default:
return defaultLayerSuggestion;
}
} else {
return [...s, ...localDefinitions];
return [...localDefinitions, ...s];
}
});
}

onMount(() => {
suggestions = _suggestions;
updateSuggestions();
});

let suggestionElement = undefined;
Expand Down
Loading