From a4bf2c107d6e8794684aadb40ad1c28a23114370 Mon Sep 17 00:00:00 2001 From: Edward <sabinusedward@yahoo.de> Date: Mon, 1 Jun 2020 14:09:40 +0200 Subject: [PATCH] StateManager commiit --- src/Manager/StateManager.elm | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Manager/StateManager.elm diff --git a/src/Manager/StateManager.elm b/src/Manager/StateManager.elm new file mode 100644 index 0000000..418131b --- /dev/null +++ b/src/Manager/StateManager.elm @@ -0,0 +1,40 @@ +module Manager.StateManager exposing (..) +-- Own +import Manager.ModalManager exposing (Modal(..), eq_String_Modal, modalNameToString, getInputShapeFromModal) +import Util.ShapeManager exposing (Shape(..)) +import Util.Util exposing (MousePosition) + +type State + = Standby + | ActiveModal Modal + | DrawShape Shape MousePosition + +-- Operations on State +eq_String_State : String -> State -> Bool +eq_String_State string state = string==(stateNameToString state) +manageState : State -> State +manageState state = if ( (eq_String_State "ActiveModal" state) + &&(eq_String_Modal "NoModal" (getModalFromState state)) + ) + then Standby + else state +-- Transform State to other Types +stateNameToString : State -> String +stateNameToString state = + case state of + Standby -> "Standby" + ActiveModal modal -> "ActiveModal" + DrawShape _ _ -> "DrawShape" +-- Get Methods : Parameter of State +getInputShapeFromState : State -> Shape +getInputShapeFromState state = + case state of + Standby -> Empty + ActiveModal modal -> getInputShapeFromModal modal + DrawShape shape _ -> shape +getModalFromState : State -> Modal +getModalFromState state = + case state of + Standby -> NoModal + ActiveModal modal -> modal + DrawShape _ _ -> NoModal -- GitLab