Skip to content

Commit

Permalink
#12 Move add section button and deactivate buttons to non-implemente…
Browse files Browse the repository at this point in the history
…d functions
  • Loading branch information
tscz committed Jan 19, 2020
1 parent 78facbc commit e1cba6d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 31 deletions.
49 changes: 39 additions & 10 deletions src/pages/structure/structurePage.tsx
Expand Up @@ -10,6 +10,7 @@ import {
Popover,
Tooltip
} from "@material-ui/core";
import AddIcon from "@material-ui/icons/Add";
import LoopIcon from "@material-ui/icons/Loop";
import PauseIcon from "@material-ui/icons/Pause";
import PlayArrowIcon from "@material-ui/icons/PlayArrow";
Expand All @@ -34,6 +35,7 @@ import {
triggeredPlay,
updatedPlaybackSettings
} from "../../states/audio/audioSlice";
import { DialogType, openedDialog } from "../../states/dialog/dialogsSlice";
import {
enabledSyncFirstMeasureStart,
LoadingStatus
Expand Down Expand Up @@ -63,6 +65,7 @@ interface PropsFromDispatch {
enabledSyncFirstMeasureStart: typeof enabledSyncFirstMeasureStart;
updatedRhythm: typeof updatedRhythm;
updatedPlaybackSettings: typeof updatedPlaybackSettings;
openedDialog: typeof openedDialog;
}

interface Props {}
Expand Down Expand Up @@ -214,11 +217,16 @@ class StructurePage extends React.Component<AllProps, State> {
/>
)}

<WaveformControlButton title="Loop" icon={<LoopIcon />} />
<WaveformControlButton
title="Loop"
icon={<LoopIcon />}
disabled={true}
/>
<WaveformControlButton
title="Metronome"
icon={<TimerIcon />}
onClick={e => this.handleClick(e)}
disabled={true}
/>
<Popover
style={{ height: "400px" }}
Expand Down Expand Up @@ -253,7 +261,23 @@ class StructurePage extends React.Component<AllProps, State> {
topRight={
<View title="Song Measures" body={<StructureNavigationView />}></View>
}
bottom={<View title="Song Structure" body={<StructureView />}></View>}
bottom={
<View
title="Song Structure"
action={
<>
<WaveformControlButton
title="Add section"
icon={<AddIcon />}
onClick={() =>
this.props.openedDialog(DialogType.ADD_SECTION)
}
/>
</>
}
body={<StructureView />}
></View>
}
></ContentLayout>
);
}
Expand All @@ -262,17 +286,21 @@ class StructurePage extends React.Component<AllProps, State> {
const WaveformControlButton = (props: {
title: string;
icon: ReactElement;
disabled?: boolean;
onClick?: (e?: any) => void;
}) => {
return (
<Tooltip title={props.title}>
<IconButton
onClick={props.onClick}
size="small"
style={{ marginTop: "8px", marginRight: "5px" }}
>
{props.icon}
</IconButton>
<>
<IconButton
onClick={props.onClick}
size="small"
style={{ marginTop: "8px", marginRight: "5px" }}
disabled={props.disabled}
>
{props.icon}
</IconButton>
</>
</Tooltip>
);
};
Expand All @@ -297,6 +325,7 @@ const mapDispatchToProps = {
triggeredPause,
enabledSyncFirstMeasureStart,
updatedRhythm,
updatedPlaybackSettings
updatedPlaybackSettings,
openedDialog
};
export default connect(mapStateToProps, mapDispatchToProps)(StructurePage);
3 changes: 2 additions & 1 deletion src/states/analysis/analysisSlice.ts
Expand Up @@ -81,7 +81,8 @@ const analysisSlice = createSlice({
state.audioDuration
);

state.sections = undefinedSection(state.measures.allIds.length - 1);
if (state.sections.allIds.length === 0)
state.sections = undefinedSection(state.measures.allIds.length - 1);
}),
reducers: {
addedSection(state, action: PayloadAction<Section>) {
Expand Down
21 changes: 1 addition & 20 deletions src/views/structure/structureView.tsx
Expand Up @@ -8,7 +8,6 @@ import {
TableHead,
TableRow
} from "@material-ui/core";
import AddIcon from "@material-ui/icons/Add";
import RemoveIcon from "@material-ui/icons/Remove";
import React, { Component } from "react";
import { connect } from "react-redux";
Expand All @@ -23,7 +22,6 @@ import {
SectionType,
updatedSection
} from "../../states/analysis/analysisSlice";
import { DialogType, openedDialog } from "../../states/dialog/dialogsSlice";
import { ApplicationState, NormalizedObjects } from "../../states/store";
import ArrayUtil from "../../util/ArrayUtil";

Expand All @@ -36,7 +34,6 @@ interface PropsFromDispatch {
addedSection: typeof addedSection;
updatedSection: typeof updatedSection;
removedSection: typeof removedSection;
openedDialog: typeof openedDialog;
}

type AllProps = PropsFromState & PropsFromDispatch;
Expand Down Expand Up @@ -153,21 +150,6 @@ class StructureView extends Component<AllProps> {
</TableRow>
);
})}
<TableRow key="last">
<TableCell component="th" scope="row">
<IconButton
onClick={() =>
this.props.openedDialog(DialogType.ADD_SECTION)
}
size="small"
>
<AddIcon></AddIcon>
</IconButton>
</TableCell>
<TableCell />
<TableCell />
<TableCell />
</TableRow>
</TableBody>
</Table>
</TableContainer>
Expand All @@ -185,7 +167,6 @@ const mapStateToProps = ({ analysis }: ApplicationState) => {
const mapDispatchToProps = {
addedSection,
updatedSection,
removedSection,
openedDialog
removedSection
};
export default connect(mapStateToProps, mapDispatchToProps)(StructureView);

0 comments on commit e1cba6d

Please sign in to comment.