mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-19 09:38:38 +00:00
add label support to pianoroll
This commit is contained in:
parent
51cc69208f
commit
3ccbd35fad
@ -50,6 +50,7 @@ Pattern.prototype.pianoroll = function ({
|
|||||||
timeframe: timeframeProp,
|
timeframe: timeframeProp,
|
||||||
fold = 0,
|
fold = 0,
|
||||||
vertical = 0,
|
vertical = 0,
|
||||||
|
labels = 0,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const ctx = getDrawContext();
|
const ctx = getDrawContext();
|
||||||
const w = ctx.canvas.width;
|
const w = ctx.canvas.width;
|
||||||
@ -114,6 +115,14 @@ Pattern.prototype.pianoroll = function ({
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
isActive ? ctx.strokeRect(...coords) : ctx.fillRect(...coords);
|
isActive ? ctx.strokeRect(...coords) : ctx.fillRect(...coords);
|
||||||
|
if (labels) {
|
||||||
|
const label = event.value.note ?? event.value.s + (event.value.n ? `:${event.value.n}` : '');
|
||||||
|
ctx.font = `${barThickness * 0.75}px monospace`;
|
||||||
|
ctx.strokeStyle = 'black';
|
||||||
|
ctx.fillStyle = isActive ? 'white' : 'black';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
ctx.fillText(label, ...coords);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ctx.globalAlpha = 1; // reset!
|
ctx.globalAlpha = 1; // reset!
|
||||||
const playheadPosition = scale(-from / timeExtent, ...timeRange);
|
const playheadPosition = scale(-from / timeExtent, ...timeRange);
|
||||||
@ -181,6 +190,7 @@ export function pianoroll({
|
|||||||
timeframe: timeframeProp,
|
timeframe: timeframeProp,
|
||||||
fold = 0,
|
fold = 0,
|
||||||
vertical = 0,
|
vertical = 0,
|
||||||
|
labels = false,
|
||||||
ctx,
|
ctx,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const w = ctx.canvas.width;
|
const w = ctx.canvas.width;
|
||||||
@ -267,6 +277,14 @@ export function pianoroll({
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
isActive ? ctx.strokeRect(...coords) : ctx.fillRect(...coords);
|
isActive ? ctx.strokeRect(...coords) : ctx.fillRect(...coords);
|
||||||
|
if (labels) {
|
||||||
|
const label = event.value.note ?? event.value.s + (event.value.n ? `:${event.value.n}` : '');
|
||||||
|
ctx.font = `${barThickness * 0.75}px monospace`;
|
||||||
|
ctx.strokeStyle = 'black';
|
||||||
|
ctx.fillStyle = isActive ? 'white' : 'black';
|
||||||
|
ctx.textBaseline = 'top';
|
||||||
|
ctx.fillText(label, ...coords);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ctx.globalAlpha = 1; // reset!
|
ctx.globalAlpha = 1; // reset!
|
||||||
const playheadPosition = scale(-from / timeExtent, ...timeRange);
|
const playheadPosition = scale(-from / timeExtent, ...timeRange);
|
||||||
|
|||||||
@ -21,6 +21,7 @@ export function MiniRepl({
|
|||||||
onTrigger,
|
onTrigger,
|
||||||
drawTime,
|
drawTime,
|
||||||
punchcard,
|
punchcard,
|
||||||
|
punchcardLabels,
|
||||||
onPaint,
|
onPaint,
|
||||||
canvasHeight = 200,
|
canvasHeight = 200,
|
||||||
fontSize = 18,
|
fontSize = 18,
|
||||||
@ -28,6 +29,7 @@ export function MiniRepl({
|
|||||||
hideHeader = false,
|
hideHeader = false,
|
||||||
theme,
|
theme,
|
||||||
keybindings,
|
keybindings,
|
||||||
|
isLineNumbersDisplayed,
|
||||||
}) {
|
}) {
|
||||||
drawTime = drawTime || (punchcard ? [0, 4] : undefined);
|
drawTime = drawTime || (punchcard ? [0, 4] : undefined);
|
||||||
const evalOnMount = !!drawTime;
|
const evalOnMount = !!drawTime;
|
||||||
@ -61,7 +63,7 @@ export function MiniRepl({
|
|||||||
if (onPaint) {
|
if (onPaint) {
|
||||||
pat = pat.onPaint(onPaint);
|
pat = pat.onPaint(onPaint);
|
||||||
} else if (punchcard) {
|
} else if (punchcard) {
|
||||||
pat = pat.punchcard();
|
pat = pat.punchcard({ labels: punchcardLabels });
|
||||||
}
|
}
|
||||||
return pat;
|
return pat;
|
||||||
},
|
},
|
||||||
@ -160,6 +162,7 @@ export function MiniRepl({
|
|||||||
fontFamily={fontFamily}
|
fontFamily={fontFamily}
|
||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
keybindings={keybindings}
|
keybindings={keybindings}
|
||||||
|
isLineNumbersDisplayed={isLineNumbersDisplayed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{error && <div className="text-right p-1 text-md text-red-200">{error.message}</div>}
|
{error && <div className="text-right p-1 text-md text-red-200">{error.message}</div>}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ export function MiniRepl({
|
|||||||
tune,
|
tune,
|
||||||
drawTime,
|
drawTime,
|
||||||
punchcard,
|
punchcard,
|
||||||
|
punchcardLabels = true,
|
||||||
span = [0, 4],
|
span = [0, 4],
|
||||||
canvasHeight = 100,
|
canvasHeight = 100,
|
||||||
hideHeader,
|
hideHeader,
|
||||||
@ -39,7 +40,7 @@ export function MiniRepl({
|
|||||||
claviatureLabels,
|
claviatureLabels,
|
||||||
}) {
|
}) {
|
||||||
const [Repl, setRepl] = useState();
|
const [Repl, setRepl] = useState();
|
||||||
const { theme, keybindings, fontSize, fontFamily } = useSettings();
|
const { theme, keybindings, fontSize, fontFamily, isLineNumbersDisplayed } = useSettings();
|
||||||
const [activeNotes, setActiveNotes] = useState([]);
|
const [activeNotes, setActiveNotes] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// we have to load this package on the client
|
// we have to load this package on the client
|
||||||
@ -55,6 +56,7 @@ export function MiniRepl({
|
|||||||
hideOutsideView={true}
|
hideOutsideView={true}
|
||||||
drawTime={claviature ? [0, 0] : drawTime}
|
drawTime={claviature ? [0, 0] : drawTime}
|
||||||
punchcard={punchcard}
|
punchcard={punchcard}
|
||||||
|
punchcardLabels={punchcardLabels}
|
||||||
span={span}
|
span={span}
|
||||||
canvasHeight={canvasHeight}
|
canvasHeight={canvasHeight}
|
||||||
theme={themes[theme]}
|
theme={themes[theme]}
|
||||||
@ -62,6 +64,7 @@ export function MiniRepl({
|
|||||||
keybindings={keybindings}
|
keybindings={keybindings}
|
||||||
fontFamily={fontFamily}
|
fontFamily={fontFamily}
|
||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
|
isLineNumbersDisplayed={isLineNumbersDisplayed}
|
||||||
onPaint={
|
onPaint={
|
||||||
claviature
|
claviature
|
||||||
? (ctx, time, haps, drawTime) => {
|
? (ctx, time, haps, drawTime) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user