Features/trigger widget #101

Merged
A-Nilfgaardian merged 4 commits from features/trigger-widget into master 2021-02-09 23:58:27 +00:00
3 changed files with 82 additions and 1 deletions
Showing only changes of commit 2d65121f22 - Show all commits

View File

@ -13,6 +13,20 @@ class TriggerWidget extends React.Component<any, any> {
this.props.dispatch({type: 'trigger/decreaseChannel'}); this.props.dispatch({type: 'trigger/decreaseChannel'});
} }
// Trigger Type
changeTriggerType = () => {
this.props.dispatch({type: 'trigger/changeTriggerType'});
}
// Trigger Level
increaseTriggerLevel = () => {
this.props.dispatch({type: 'trigger/increaseTriggerLevel'});
}
decreaseTriggerLevel = () => {
this.props.dispatch({type: 'trigger/decreaseTriggerLevel'});
}
render() { render() {
return ( return (
<div className="TriggerWidget"> <div className="TriggerWidget">
@ -39,6 +53,44 @@ class TriggerWidget extends React.Component<any, any> {
</button> </button>
</div> </div>
<div className="TriggerWidgetAdjustTriggerType">
<button
className="MinusButton"
onClick={() => this.changeTriggerType()}>
-
</button>
<label
className="AdjustChannelBlockValue"
style={{color: this.props.triggerWidget.channelColorsList[this.props.triggerWidget.triggerChannel-1]}}
>
{this.props.triggerWidget.triggerType.toString()}
</label>
<button
className="PlusButton"
onClick={() => this.changeTriggerType()}>
+
</button>
</div>
<div className="TriggerWidgetAdjustTriggerLevel">
<button
className="MinusButton"
onClick={() => this.decreaseTriggerLevel()}>
-
</button>
<label
className="AdjustChannelBlockValue"
style={{color: this.props.triggerWidget.channelColorsList[this.props.triggerWidget.triggerChannel-1]}}
>
{this.props.triggerWidget.triggerLevel.toString()}
</label>
<button
className="PlusButton"
onClick={() => this.increaseTriggerLevel()}>
+
</button>
</div>
</div> </div>
) )
} }

View File

@ -15,3 +15,11 @@
padding-left: 2vw; padding-left: 2vw;
padding-right: 2vw; padding-right: 2vw;
} }
.TriggerWidgetAdjustTriggerType {
margin-top: 1vh;
}
.TriggerWidgetAdjustTriggerLevel {
margin-top: 1vh;
}

View File

@ -31,6 +31,27 @@ export default function(state = initialState, action: {type: any, payload: any})
...state, ...state,
triggerChannel: state.triggerChannel - 1 triggerChannel: state.triggerChannel - 1
}; };
case "trigger/changeTriggerType":
if (state.triggerType == TriggerType.RisingEdge) {
return {
...state,
triggerType: TriggerType.FallingEdge
}
}
return {
...state,
triggerType: TriggerType.RisingEdge
}
case "trigger/increaseTriggerLevel":
return {
...state,
triggerLevel: state.triggerLevel + 1
};
case "trigger/decreaseTriggerLevel":
return {
...state,
triggerLevel: state.triggerLevel - 1
};
default: default:
return state; return state;
} }