diff --git a/src/Manager/StateManager.elm b/src/Manager/StateManager.elm new file mode 100644 index 0000000000000000000000000000000000000000..418131b456b6a7a7b0a7b1fcb695bc7f2f627b10 --- /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