-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hotKey): bind hotKeys from setting.json
- Loading branch information
Showing
30 changed files
with
242 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
external convertReactMouseEventToJsEvent : ReactEventRe.Mouse.t => Js.t({..}) = "%identity"; | ||
external convertReactKeyboardEventToJsEvent : | ||
ReactEventRe.Keyboard.t => Js.t({..}) = | ||
"%identity"; | ||
|
||
external convertReactFormEventToJsEvent : ReactEventRe.Form.t => Js.t({..}) = "%identity"; | ||
external convertReactMouseEventToJsEvent : ReactEventRe.Mouse.t => Js.t({..}) = | ||
"%identity"; | ||
|
||
external convertReactFormEventToJsEvent : ReactEventRe.Form.t => Js.t({..}) = | ||
"%identity"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type hotKeyAction = | ||
| Redo | ||
| Undo | ||
| Duplicate | ||
| Delete; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/service/record/editor/hotKeys/OperateHotKeysService.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
open HotKeysType; | ||
|
||
let getHandleFuncByHotKeyAction = hotKeyAction => { | ||
let uiState = UIStateService.getState(); | ||
let dispatch = UIStateService.getDispatch(); | ||
let isCurrentSceneTreeNodeCanBeOperate = | ||
GameObjectLogicService.isCurrentSceneTreeNodeCanBeOperate | ||
|> StateLogicService.getStateToGetData; | ||
|
||
|
||
switch (hotKeyAction) { | ||
| Undo => (() => AllHistoryService.handleUndo(uiState, dispatch)) | ||
| Redo => ( | ||
() => | ||
OperateStateHistoryService.hasRedoState( | ||
AllStateData.getHistoryState(), | ||
) ? | ||
AllHistoryService.redoHistoryState(uiState, dispatch) | ||
|> StateHistoryService.getAndRefreshStateForHistory : | ||
() | ||
) | ||
|
||
| Duplicate => ( | ||
() => | ||
isCurrentSceneTreeNodeCanBeOperate ? | ||
MainEditorLeftHeader.Method.cloneCurrentSceneTreeNode( | ||
(uiState, dispatch), | ||
(), | ||
(), | ||
) : | ||
() | ||
) | ||
| Delete => ( | ||
() => | ||
isCurrentSceneTreeNodeCanBeOperate ? | ||
MainEditorLeftHeader.Method.disposeCurrentSceneTreeNode( | ||
(uiState, dispatch), | ||
(), | ||
(), | ||
) : | ||
() | ||
) | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
open SettingType; | ||
|
||
let create = () => {debug: None, redoUndo: None}; | ||
let create = () => {debug: None, redoUndo: None, hotKeys: None}; |
40 changes: 40 additions & 0 deletions
40
src/service/state/editor/setting/HotKeysSettingEditorService.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
open EditorType; | ||
|
||
open HotKeysType; | ||
|
||
let unsafeGetHotKeys = ({settingRecord}) => | ||
OperateSettingService.unsafeGetHotKeys(settingRecord); | ||
|
||
let _preventBrowserHotKeys = event => { | ||
let e = ReactEventType.convertReactKeyboardEventToJsEvent(event); | ||
|
||
EventHelper.preventDefault(e); | ||
}; | ||
|
||
let _handleHotKeyFunc = hotKeyDataArray => | ||
hotKeyDataArray | ||
|> Js.Array.forEach(((hotKeys, hotKeyAction)) => | ||
hotKeys | ||
|> Js.Array.joinWith(",") | ||
|. HotKeysJs.hotkeys((e, handler) => { | ||
_preventBrowserHotKeys(e); | ||
|
||
let handleFunc = | ||
OperateHotKeysService.getHandleFuncByHotKeyAction(hotKeyAction); | ||
|
||
handleFunc(); | ||
}) | ||
); | ||
|
||
let bindHotKeys = editorState => { | ||
let hotKeySetting = editorState |> unsafeGetHotKeys; | ||
[| | ||
(hotKeySetting.redo, Redo), | ||
(hotKeySetting.undo, Undo), | ||
(hotKeySetting.duplicate, Duplicate), | ||
(hotKeySetting.delete, Delete), | ||
|] | ||
|> _handleHotKeyFunc; | ||
|
||
editorState; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.