structure AppWith = struct open AppType fun updateSquares (squares, newX, newY, item) = Vector.mapi (fn (idx, el) => if idx = newX then Vector.mapi (fn (iidx, iel) => if iidx = newY then item else iel) el else el) squares fun addSquare (app, newX, newY, arrowX, arrowY) : app_type = let val { mode , squares , arrowX = _ , arrowY = _ , canvasWidth , canvasHeight , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app val yAxis = Vector.sub (squares, newX) val undoData = Vector.sub (yAxis, newY) val undo = undoData :: undo val redo = [] val item = {r = r, g = g, b = b, a = a} val squares = updateSquares (squares, newX, newY, item) in { mode = mode , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun arrowX (app, arrowX) = let val { mode , squares , arrowX = _ , arrowY , canvasWidth , canvasHeight , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app in { mode = mode , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun arrowY (app, arrowY) = let val { mode , squares , arrowX , arrowY = _ , canvasWidth , canvasHeight , windowWidth , windowHeight , xClickPoints , yClickPoints , showGraph , mouseX , mouseY , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app in { mode = mode , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun windowResize (app: app_type, windowWidth, windowHeight) : app_type = let val { mode , xClickPoints = _ , yClickPoints = _ , windowWidth = _ , windowHeight = _ , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , mouseX , mouseY , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app val (xClickPoints, yClickPoints) = ClickPoints.generate (windowWidth, windowHeight, canvasWidth, canvasHeight) in { mode = mode , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , mouseX = mouseX , mouseY = mouseY , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun mousePosition (app: app_type, mouseX, mouseY) = let val { mode , mouseX = _ , mouseY = _ , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun graphVisibility (app: app_type, shouldShowGraph) = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph = _ , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = shouldShowGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun mode (app: app_type, newMode) = let val { mode = _ , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app in { mode = newMode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun fileBrowserAndPath (app: app_type, fileBrowser, path) = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath = _ , fileBrowser = _ , fileBrowserIdx , r , g , b , a , modalNum , undo , redo } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = path , fileBrowser = fileBrowser , fileBrowserIdx = 0 , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun fileBrowserIdx (app: app_type, newFileBrowserIdx) = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx = _ , r , g , b , a , modalNum , undo , redo } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = newFileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = modalNum , undo = undo , redo = redo } end fun modalNum (app: app_type, newNum) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a , modalNum = _ , undo , redo } = app in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = newNum , undo = undo , redo = redo } end fun r (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r = _ , g , b , a , modalNum , undo , redo } = app val r = modalNum in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = 0 , undo = undo , redo = redo } end fun g (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r , g = _ , b , a , modalNum , undo , redo } = app val g = modalNum in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = 0 , undo = undo , redo = redo } end fun b (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r , g , b = _ , a , modalNum , undo , redo } = app val b = modalNum in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = 0 , undo = undo , redo = redo } end fun a (app: app_type) : app_type = let val { mode , mouseX , mouseY , xClickPoints , yClickPoints , windowWidth , windowHeight , squares , arrowX , arrowY , canvasWidth , canvasHeight , showGraph , openFilePath , fileBrowser , fileBrowserIdx , r , g , b , a = _ , modalNum , undo , redo } = app val a = modalNum in { mode = mode , mouseX = mouseX , mouseY = mouseY , squares = squares , arrowX = arrowX , arrowY = arrowY , canvasWidth = canvasWidth , canvasHeight = canvasHeight , windowWidth = windowWidth , windowHeight = windowHeight , xClickPoints = xClickPoints , yClickPoints = yClickPoints , showGraph = showGraph , openFilePath = openFilePath , fileBrowser = fileBrowser , fileBrowserIdx = fileBrowserIdx , r = r , g = g , b = b , a = a , modalNum = 0 , undo = undo , redo = redo } end (* todo: fun useSquaresAndSetNormalMode (app: app_type, squares, canvasWidth, canvasHeight) = *) end