Snapshot button select, and text scaling.

This commit is contained in:
Robin Davies
2024-10-12 05:33:45 -04:00
parent b0107d4490
commit 8755f849dd
3 changed files with 36 additions and 9 deletions
+2 -2
View File
@@ -342,9 +342,9 @@ export function getBorderColor(colorKey: string): string {
if (darkMode) { if (darkMode) {
if (colorKey === "grey" || colorKey === "yellow") if (colorKey === "grey" || colorKey === "yellow")
{ {
return list[700]; return list[300];
} }
return list[500]; return list[200];
} else { } else {
if (colorKey === "grey") if (colorKey === "grey")
{ {
+34 -5
View File
@@ -31,6 +31,7 @@ import SaveIconOutline from '@mui/icons-material/Save';
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import EditIconOutline from '@mui/icons-material/Edit'; import EditIconOutline from '@mui/icons-material/Edit';
import { Snapshot } from './Pedalboard'; import { Snapshot } from './Pedalboard';
import { isDarkMode } from './DarkMode';
import { colorKeys, getBackgroundColor, getBorderColor } from './MaterialColors'; import { colorKeys, getBackgroundColor, getBorderColor } from './MaterialColors';
import { PiPedalModel, PiPedalModelFactory, SnapshotModifiedEvent } from './PiPedalModel'; import { PiPedalModel, PiPedalModelFactory, SnapshotModifiedEvent } from './PiPedalModel';
@@ -49,6 +50,7 @@ export interface SnapshotButtonProps {
export interface SnapshotButtonState { export interface SnapshotButtonState {
modified: boolean; modified: boolean;
uiScale: number;
}; };
export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotButtonProps, SnapshotButtonState> { export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotButtonProps, SnapshotButtonState> {
@@ -58,14 +60,33 @@ export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotBu
super(props); super(props);
this.state = { this.state = {
modified: this.props.snapshot?.isModified ?? false, modified: this.props.snapshot?.isModified ?? false,
uiScale: 1.0
}; };
this.model = PiPedalModelFactory.getInstance(); this.model = PiPedalModelFactory.getInstance();
this.onSnapshotModified = this.onSnapshotModified.bind(this); this.onSnapshotModified = this.onSnapshotModified.bind(this);
} }
onWindowSizeChanged(width: number, height: number): void { is2x3Layout(width: number, height: number) {
return width * 2 < height * 3;
}
onWindowSizeChanged(width: number, height: number): void {
let uiScale: number;
if (this.is2x3Layout(width,height)) {
uiScale = width / 400;
} else {
uiScale = (width/3)/(400/2);
}
if (height < width) {
// 1 at 400, 2 at 600
let hUiScale = (height-340)/(400-340);
hUiScale += (height-400)/(460-400);
uiScale = Math.min(hUiScale,uiScale);
}
if (uiScale < 1) uiScale = 1;
if (uiScale > 4) uiScale = 4;
this.setState({uiScale: uiScale});
} }
onSnapshotModified(event: SnapshotModifiedEvent) { onSnapshotModified(event: SnapshotModifiedEvent) {
@@ -95,7 +116,7 @@ export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotBu
render() { render() {
let { snapshot, snapshotIndex, selected } = this.props; let { snapshot, snapshotIndex, selected } = this.props;
let { modified } = this.state; let { modified, uiScale } = this.state;
// (snapshot: Snapshot | null, index: number) { // (snapshot: Snapshot | null, index: number) {
//let state = this.state; //let state = this.state;
@@ -116,6 +137,8 @@ export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotBu
title = title + "*"; title = title + "*";
} }
let disabled = snapshot === null; let disabled = snapshot === null;
let fontSize = (16*uiScale) + "px";
return ( return (
<div style={{ display: "flex", position: "relative", flexGrow: 1, flexBasis: 1, flexFlow: "column nowrap", alignItems: "stretch", borderRadius: 16 }}> <div style={{ display: "flex", position: "relative", flexGrow: 1, flexBasis: 1, flexFlow: "column nowrap", alignItems: "stretch", borderRadius: 16 }}>
@@ -130,6 +153,12 @@ export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotBu
onClick={() => { if (snapshot) this.props.onSelectSnapshot(snapshotIndex); }} onClick={() => { if (snapshot) this.props.onSelectSnapshot(snapshotIndex); }}
> >
{/* select background mask*/}
<div style={{position: "absolute", left:0,top:0,right:0,bottom:0, visibility: this.props.selected ? "visible": "hidden",
background: isDarkMode() ? "#FFFFFF": "#000000", borderRadius: 16,
opacity: 0.2
}}
/>
<div <div
style={{ flexGrow: 1, flexShrink: 1, display: "flex", flexFlow: "column nowrap", alignItems: "stretch" }} style={{ flexGrow: 1, flexShrink: 1, display: "flex", flexFlow: "column nowrap", alignItems: "stretch" }}
onMouseDown={(ev) => { onMouseDown={(ev) => {
@@ -144,13 +173,13 @@ export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotBu
<div style={{ flexGrow: 1, display: "flex", alignItems: "center", justifyContent: "center" }}> <div style={{ flexGrow: 1, display: "flex", alignItems: "center", justifyContent: "center" }}>
<Typography display="block" color="textPrimary" align="center" variant="body1" <Typography display="block" color="textPrimary" align="center" variant="body1"
style={{ fontSize: this.props.largeText ? "30px" : undefined }} style={{ fontSize: fontSize }}
>{title}</Typography> >{title}</Typography>
</div> </div>
<Typography variant="h3" <Typography variant="h3"
style={{ style={{
position: "absolute",bottom: 0, left: 0, paddingBottom: 12, paddingLeft: 16, paddingRight: 12, position: "absolute",bottom: 0, left: 0, paddingBottom: 12, paddingLeft: 16, paddingRight: 12,
pointerEvents: "none", opacity: 0.15, fontSize: "44px", fontWeight: 900, fontFamily: "Arial Black", fontStyle: "italic" pointerEvents: "none", opacity: 0.35, fontSize: "44px", fontWeight: 900, fontFamily: "Arial Black", fontStyle: "italic"
}} }}
> >
{(snapshotIndex + 1).toString()} {(snapshotIndex + 1).toString()}
@@ -188,7 +217,7 @@ export default class SnapshotButton extends ResizeResponsiveComponent<SnapshotBu
) : ( ) : (
<div style={{ marginLeft: "auto", marginRight: 8, display: "flex", flexFlow: "row nowrap" }}> <div style={{ marginLeft: "auto", marginRight: 8, display: "flex", flexFlow: "row nowrap" }}>
<div style={{ flexGrow: 1, flexBasis: 1 }} >&nbsp;</div> <div style={{ flexGrow: 1, flexBasis: 1 }} ></div>
<IconButton color="inherit" style={{ opacity: 0.66 }} disabled={false} <IconButton color="inherit" style={{ opacity: 0.66 }} disabled={false}
onMouseDown={(ev) => { ev.stopPropagation(); /*don't prop to card*/ }} onMouseDown={(ev) => { ev.stopPropagation(); /*don't prop to card*/ }}
onClick={() => { this.props.onSaveSnapshot(snapshotIndex); }} onClick={() => { this.props.onSaveSnapshot(snapshotIndex); }}
-2
View File
@@ -236,7 +236,6 @@ export default class SnapshotPanel extends ResizeResponsiveComponent<SnapshotPan
} }
} }
bg: undefined;
render() { render() {
let snapshots = this.state.snapshots; let snapshots = this.state.snapshots;
@@ -246,7 +245,6 @@ export default class SnapshotPanel extends ResizeResponsiveComponent<SnapshotPan
height: this.props.panelHeight, height: this.props.panelHeight,
overflow: "hidden", margin: 0, overflow: "hidden", margin: 0,
paddingLeft: 16, paddingRight: 16, paddingTop: 0, paddingBottom: 24, paddingLeft: 16, paddingRight: 16, paddingTop: 0, paddingBottom: 24,
background: this.bg,
display: "flex", flexFlow: "column nowrap", alignContent: "stretch", justifyContent: "stretch" display: "flex", flexFlow: "column nowrap", alignContent: "stretch", justifyContent: "stretch"
}}> }}>