-
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: 'Conditionalise existing feedbacks' feedback
- Loading branch information
Showing
11 changed files
with
219 additions
and
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { ButtonStyleProperties, UnparsedButtonStyle } from '@companion-app/shared/Model/StyleModel.js' | ||
|
||
/** | ||
* A simple class to help combine multiple styles into one that can be drawn | ||
*/ | ||
export class FeedbackStyleBuilder { | ||
#combinedStyle: UnparsedButtonStyle | ||
|
||
get style(): UnparsedButtonStyle { | ||
return this.#combinedStyle | ||
} | ||
|
||
constructor(baseStyle: ButtonStyleProperties) { | ||
this.#combinedStyle = { | ||
...baseStyle, | ||
imageBuffers: [], | ||
} | ||
} | ||
|
||
/** | ||
* Apply a simple layer of style | ||
*/ | ||
applySimpleStyle(style: Partial<ButtonStyleProperties> | undefined) { | ||
this.#combinedStyle = { | ||
...this.#combinedStyle, | ||
...style, | ||
} | ||
} | ||
|
||
applyComplexStyle(rawValue: any) { | ||
if (typeof rawValue === 'object' && rawValue !== undefined) { | ||
// Prune off some special properties | ||
const prunedValue = { ...rawValue } | ||
delete prunedValue.imageBuffer | ||
delete prunedValue.imageBufferPosition | ||
|
||
// Ensure `textExpression` is set at the same times as `text` | ||
delete prunedValue.textExpression | ||
if ('text' in prunedValue) { | ||
prunedValue.textExpression = rawValue.textExpression || false | ||
} | ||
|
||
this.#combinedStyle = { | ||
...this.#combinedStyle, | ||
...prunedValue, | ||
} | ||
|
||
// Push the imageBuffer into an array | ||
if (rawValue.imageBuffer) { | ||
this.#combinedStyle.imageBuffers.push({ | ||
...rawValue.imageBufferPosition, | ||
...rawValue.imageBufferEncoding, | ||
buffer: rawValue.imageBuffer, | ||
}) | ||
} | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.