From f8f617c97fcb2df3dbefc9527d974151e367cb60 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 18 Sep 2017 16:52:11 +0200 Subject: Implement basic experiment mode with timeline The timeline doesn't trigger anything yet, but the visual element is in place and connected. --- src/containers/timeline/PlayButtonContainer.js | 23 ++++++++++++++++++++++ .../timeline/TimelineControlsContainer.js | 22 +++++++++++++++++++++ src/containers/timeline/TimelineLabelsContainer.js | 15 ++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/containers/timeline/PlayButtonContainer.js create mode 100644 src/containers/timeline/TimelineControlsContainer.js create mode 100644 src/containers/timeline/TimelineLabelsContainer.js (limited to 'src/containers/timeline') diff --git a/src/containers/timeline/PlayButtonContainer.js b/src/containers/timeline/PlayButtonContainer.js new file mode 100644 index 00000000..6d4a9f25 --- /dev/null +++ b/src/containers/timeline/PlayButtonContainer.js @@ -0,0 +1,23 @@ +import {connect} from "react-redux"; +import {pauseSimulation, playSimulation} from "../../actions/simulation/playback"; +import PlayButtonComponent from "../../components/timeline/PlayButtonComponent"; + +const mapStateToProps = state => { + return { + isPlaying: state.isPlaying, + }; +}; + +const mapDispatchToProps = dispatch => { + return { + onPlay: () => dispatch(playSimulation()), + onPause: () => dispatch(pauseSimulation()), + }; +}; + +const PlayButtonContainer = connect( + mapStateToProps, + mapDispatchToProps +)(PlayButtonComponent); + +export default PlayButtonContainer; diff --git a/src/containers/timeline/TimelineControlsContainer.js b/src/containers/timeline/TimelineControlsContainer.js new file mode 100644 index 00000000..e5c89060 --- /dev/null +++ b/src/containers/timeline/TimelineControlsContainer.js @@ -0,0 +1,22 @@ +import {connect} from "react-redux"; +import TimelineControlsComponent from "../../components/timeline/TimelineControlsComponent"; + +const mapStateToProps = state => { + let sectionTicks = []; + if (state.currentExperimentId !== -1) { + const sectionIds = state.objects.path[state.objects.experiment[state.currentExperimentId].pathId].sectionIds; + sectionTicks = sectionIds.map(sectionId => state.objects.section[sectionId].startTick); + } + + return { + currentTick: state.currentTick, + lastSimulatedTick: state.lastSimulatedTick, + sectionTicks, + }; +}; + +const TimelineControlsContainer = connect( + mapStateToProps +)(TimelineControlsComponent); + +export default TimelineControlsContainer; diff --git a/src/containers/timeline/TimelineLabelsContainer.js b/src/containers/timeline/TimelineLabelsContainer.js new file mode 100644 index 00000000..b6ff0774 --- /dev/null +++ b/src/containers/timeline/TimelineLabelsContainer.js @@ -0,0 +1,15 @@ +import {connect} from "react-redux"; +import TimelineLabelsComponent from "../../components/timeline/TimelineLabelsComponent"; + +const mapStateToProps = state => { + return { + currentTick: state.currentTick, + lastSimulatedTick: state.lastSimulatedTick, + }; +}; + +const TimelineLabelsContainer = connect( + mapStateToProps +)(TimelineLabelsComponent); + +export default TimelineLabelsContainer; -- cgit v1.2.3