diff --git a/README.md b/README.md index bf7cab8a7492..14f15d8bcda4 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,23 @@ -# New Byte Order repository +# Luna Studio ## Requirements -### Common - -* [Stack](http://haskellstack.org/) - -### For backend - -* pkg-config (```brew install pkg-config```, not required on Windows) -* ZeroMQ (```brew install zmq```, for Windows download [zmq.zip](https://s3-eu-west-1.amazonaws.com/luna-zmq-win/zmq.zip)) - -### For frontend - -* [NodeJS](http://nodejs.org/) -* [Supervisord](http://supervisord.org/) -* [Bower](https://bower.io) (```npm install -g bower```) -* [Brunch](http://brunch.io) v.1.8.5 (```npm install -g brunch@1.8.5```) -* `happy`, `hsc2hs`, `hscolour` - ```$ cd ~ && stack install happy hsc2hs hscolour``` - - -## Building backend - -0. On Windows, unpack [zmq.zip](https://s3-eu-west-1.amazonaws.com/luna-zmq-win/zmq.zip) to c:\zmq and modify (or create) environment variables: - * append c:\zmq\include to CPATH (equivalently, pass `--extra-include-dirs=c:\zmq\include` to stack) - * append c:\zmq\lib to LIBRARY_PATH (equivalently, pass `--extra-lib-dirs=c:\zmq\lib` to stack) - * append c:\zmq\bin to PATH - -```shell -$ git clone git@github.com:luna/luna-studio.git -$ cd luna-studio -$ REPO_DIR=`pwd` -$ cd $REPO_DIR/build/backend -$ stack build --copy-bins --fast --install-ghc -``` - -## Building frontend - -Currently not tested on Windows - -```shell -$ cd $REPO_DIR/nodelab -$ npm install -$ bower install --allow-root -$ brunch build # -P -- for production build -``` - -## Running - -### Backend - -```shell -$ cd $REPO_DIR/supervisor -$ supervisord # will start everyting -$ supervisorctl status # for status -$ supervisorctl restart all # to restart everyting -$ supervisorctl tail -f logger # to tail logger output (see supervisord manual for more) -``` - -### GUI - -```shell -$ cd $REPO_DIR/nodelab -$ brunch watch --server # or serve $REPO_DIR/nodelab/www using any HTTP server -``` - -### Run GUI in Atom - -Create folder ```.luna-atom``` (name can be changed) and export path to it as ```LUNA_HOME```. Then: - -```shell -$ cd $REPO_DIR/nodelab -$ npm install -g less -$ python3 ./script/atom_install.py -$ python3 ./script/atom_run.py -``` - -Every change in nodelab code requires rerun of ```atom_install.py``` script and reload of Atom (OSX shortcut: ```ctrl + alt + cmd + L```, Linux shortcut: ```ctrl + shift + F5```). - - -## Known problems - -* If you have experienced problems like: ```Oops. Connection to the server was closed. Please reload page to reconnect again.``` open browser console and ```setBackendAddress("ws://localhost:8088")``` and reload browser. - -* Building frontend may currently not work until you install `ghc` globally. It happens on OS X El Capitan, so in that case: -```brew install ghc```. This issue is caused by `happy` package - see https://github.com/commercialhaskell/stack/issues/1258 for more information. - -* Installing atom dependencies on **Windows** resulting in ```MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".```, missing python etc. Solution from [here](https://github.com/chjj/pty.js/issues/60) - 1. open up a new cmd as administrator and run this command: - 1. ```npm install --global --production windows-build-tools``` - 2. ```npm config set msvs_version 2015 --global``` - 2. close all instances of shell/cmd, reopen a cmd (regular this time, non-administrator) return to your directory where you are trying to run npm install and run it again +TODO: GHC reqs + +## Building + 1. Download `luna-manager` from http://luna-lang.org/luna-manager + 2. Use `bash` as your shell environment. Other shells will be supported in the future. + 3. Run `luna-manager develop luna-studio`, which will create a directory at `~/luna-develop`. You can optionally pass `--path PATH` command line argument to manually specify the destination. + 4. For your convenience export following environment variables: + * `export LUNA_DEV=~/luna-develop` + * `export LUNA_STUDIO_DEV=$LUNA_DEV/apps/luna-studio` + + 5. Change your working directory to `cd $LUNA_STUDIO_DEV` + 6. Run `source luna-shell.sh` which will setup your development environment. + 7. To build `luna-studio` from sources call `./build`. For further usage information call `./build --help`. + 8. After successful build you can test your new `luna-studio` version at `./dist/bin/main/luna-studio`. Use `--help` for available running options. + +## Build environment + * Your luna-studio build environment `$LUNA_STUDIO_DEV` is a `git` repository and you can use it just as a regular source code repository. + * If you use `git clean -x` git will remove the `$LUNA_STUDIO_DEV/dist` directory content, which contains dependencies needed for building `luna-studio`, which were downloaded there by `luna-manager`. To setup them again again call `luna-manager develop luna-studio --path $LUNA_DEV --download-dependencies`. + diff --git a/bootstrap.hs b/bootstrap.hs index 601143e3b651..78062063d9d0 100755 --- a/bootstrap.hs +++ b/bootstrap.hs @@ -1,5 +1,5 @@ #!/usr/bin/env stack --- stack --resolver lts-8.2 --install-ghc runghc --package base --package exceptions --package shelly --package text --package directory --package system-filepath --verbose -- -hide-all-packages +-- stack --resolver lts-8.2 --install-ghc runghc --package base --package exceptions --package shelly --package text --package directory --package system-filepath -- -hide-all-packages {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} @@ -177,7 +177,7 @@ generateLunaShellScript = do nodeBinPath = current tools "node" supportedNodeVersion "bin" addLdLibraryPath = "export LD_LIBRARY_PATH=" <> Shelly.toTextIgnore lbsPath paths = preparePaths [stackPath, pyenvShimsFolder, pyenvBinFolder, nodeBinPath] - addPath = "export PATH=" <> paths <> ":" <> stackPaths <> ":" <> ":$PATH" + addPath = "export PATH=" <> paths <> ":" <> T.strip stackPaths <> ":$PATH" pyenvEnviromentVar = "export PYENV_ROOT=" <> (Shelly.toTextIgnore $ current tools "python" "pyenv") loadPython = "pyenv" <> " local " <> Shelly.toTextIgnore supportedPythonVersion lunaShellPath = current lunaShell @@ -185,10 +185,11 @@ generateLunaShellScript = do liftIO $ Data.Text.IO.writeFile (encodeString lunaShellPath) fullCode stackSetupForLunaStudio :: (MonadIO m, MonadSh m, Shelly.MonadShControl m) => m () -stackSetupForLunaStudio = Shelly.chdir "luna-studio" $ do - Shelly.echo "install GHCJS" +stackSetupForLunaStudio = do current <- currentPath - Shelly.cmd (current stack) "setup" + Shelly.chdir (current "luna-studio") $ do + Shelly.echo "install GHCJS" + Shelly.cmd (current stack) "setup" main :: IO () diff --git a/libs/luna-empire/test/FileLoadSpec.hs b/libs/luna-empire/test/FileLoadSpec.hs index d020a8c5f6f7..ff26db3cd89a 100644 --- a/libs/luna-empire/test/FileLoadSpec.hs +++ b/libs/luna-empire/test/FileLoadSpec.hs @@ -16,6 +16,7 @@ import qualified Data.Text as Text import qualified Data.Text.IO as Text import Data.Text.Span (LeftSpacedSpan (..), SpacedSpan (..)) import Empire.ASTOp (runASTOp) +import qualified Empire.ASTOps.Modify as ASTModify import qualified Empire.ASTOps.Parse as ASTParse import qualified Empire.ASTOps.Print as ASTPrint import qualified Empire.ASTOps.Read as ASTRead @@ -1326,6 +1327,80 @@ spec = around withChannels $ parallel $ do let loc' = loc |> foo (input, _) <- Graph.withGraph loc' $ runASTOp $ GraphBuilder.getEdgePortMapping Graph.movePort loc' (outPortRef input [Port.Projection 0]) 2 + it "removes last port in top-level def" $ \env -> do + let initialCode = Text.pack $ normalizeQQ [r| + def foo aaaa: + «0»c = aaaa + 2 + c + |] + code <- evalEmp env $ do + Library.createLibrary Nothing "TestPath" + let loc = GraphLocation "TestPath" $ Breadcrumb [] + Graph.loadCode loc initialCode + [foo] <- Graph.getNodes loc + let loc' = loc |>= foo ^. Node.nodeId + (input, _) <- Graph.withGraph loc' $ runASTOp $ GraphBuilder.getEdgePortMapping + Graph.removePort loc' (outPortRef input [Port.Projection 0]) + code <- Graph.withUnit loc $ use Graph.code + return code + normalizeQQ (Text.unpack code) `shouldBe` normalizeQQ [r| + def foo: + «0»c = aaaa + 2 + c + |] + it "removes last port in nested def" $ \env -> do + let initialCode = Text.pack $ normalizeQQ [r| + def main: + «2»def foo aaaa: + «0»c = aaaa + 2 + c + «1»d = foo 3 + d + |] + code <- evalEmp env $ do + Library.createLibrary Nothing "TestPath" + let loc = GraphLocation "TestPath" $ Breadcrumb [] + Graph.loadCode loc initialCode + [main] <- Graph.getNodes loc + let loc' = loc |>= main ^. Node.nodeId + nodes <- Graph.getNodes loc' + let Just foo = find (\node -> node ^. Node.name == Just "foo") nodes + loc'' = loc' |> foo ^. Node.nodeId + (input, _) <- Graph.withGraph loc'' $ runASTOp $ GraphBuilder.getEdgePortMapping + Graph.removePort loc'' (outPortRef input [Port.Projection 0]) + code <- Graph.withUnit loc $ use Graph.code + return code + normalizeQQ (Text.unpack code) `shouldBe` normalizeQQ [r| + def main: + «2»def foo: + «0»c = aaaa + 2 + c + «1»d = foo 3 + d + |] + it "doesn't remove last port in a lambda" $ let + initialCode = [r| + def main: + «0»foo = aaaa: + aaaa + 3 + «1»c = foo 2 2 + c + |] + expectedCode = [r| + def main: + foo = aaaa: + aaaa + 3 + c = foo 3 3 + c + |] + in specifyCodeChange initialCode expectedCode $ \loc -> do + Just foo <- Graph.withGraph loc $ runASTOp $ Graph.getNodeIdForMarker 0 + Just c <- Graph.withGraph loc $ runASTOp $ Graph.getNodeIdForMarker 1 + let loc' = loc |> foo + (input, _) <- Graph.withGraph loc' $ runASTOp $ GraphBuilder.getEdgePortMapping + Graph.removePort loc' (outPortRef input [Port.Projection 0]) + `catch` (\(_e::ASTModify.CannotRemovePortException) -> return ()) + Graph.setNodeExpression loc c "foo 3 3" it "removes port in a lambda" $ let initialCode = [r| def main: diff --git a/luna-package.yaml b/luna-package.yaml index 5e20c562c9bd..3023f50913fd 100644 --- a/luna-package.yaml +++ b/luna-package.yaml @@ -23,6 +23,7 @@ packages: deps: - zmq-1.0.0 - atom-1.18.0 + - winSW-1.0.0 appType: GuiApp synopsis: studio synopsis @@ -33,8 +34,8 @@ packages: path: https://s3-us-west-2.amazonaws.com/packages-luna/linux/studio/zmq/zmq.tar.gz deps: [] windows.x64: - path: https://s3-eu-west-1.amazonaws.com/luna-zmq-win/zmq.zip - deps: [] + path: https://s3-us-west-2.amazonaws.com/packages-luna/windows/zmq/zmq1.zip + deps: [] darwin.x64: path: https://s3-us-west-2.amazonaws.com/packages-luna/darwin/studio/zmq/zmq.zip deps: [] @@ -58,8 +59,8 @@ packages: path: https://github.com/atom/atom/releases/download/v1.18.0/atom.x86_64.rpm deps: [] windows.x64: - path: https://github.com/atom/atom/releases/download/v1.18.0/atom-windows.zip - deps: [] + path: https://github.com/atom/atom/releases/download/v1.18.0/atom-windows.zip + deps: [] darwin.x64: path: https://github.com/atom/atom/releases/download/v1.18.0/atom-mac.zip deps: [] @@ -76,3 +77,11 @@ packages: deps: [] appType: BatchApp synopsis: studio synopsis + winSW: + versions: + 1.0.0: + windows.x64: + path: https://s3-us-west-2.amazonaws.com/packages-luna/windows/WinSW/WinSW.zip + deps: [] + appType: BatchApp + synopsis: winSW synopsis diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/App.hs b/luna-studio/node-editor/src/NodeEditor/Handler/App.hs index 389aa3e7e5c3..dfade26cd415 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/App.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/App.hs @@ -12,22 +12,24 @@ import qualified NodeEditor.Event.Atom as Atom import NodeEditor.Event.Event (Event (Atom, Init, Shortcut, UI)) import NodeEditor.Event.Mouse (mousePosition) import qualified NodeEditor.Event.Shortcut as Shortcut -import NodeEditor.Event.UI (UIEvent (AppEvent)) +import NodeEditor.Event.UI (UIEvent (AppEvent, SidebarEvent)) import qualified NodeEditor.React.Event.App as App +import qualified NodeEditor.React.Event.Sidebar as Sidebar import NodeEditor.State.Action (actionsClosingOnMouseLeave) import NodeEditor.State.Global (State) import qualified NodeEditor.State.Global as Global import qualified NodeEditor.State.UI as UI handle :: Event -> Maybe (Command Global.State ()) -handle (UI (AppEvent (App.MouseMove evt _))) = Just $ Global.ui . UI.mousePos <~ mousePosition evt -handle (UI (AppEvent App.Resize )) = Just updateScene -handle (UI (AppEvent App.MouseLeave )) = Just $ endActions actionsClosingOnMouseLeave -handle (Shortcut (Shortcut.Event command _)) = Just $ handleCommand command -handle Init = Just $ Batch.getProgram def >> Batch.searchNodes -handle (Atom (Atom.SetFile path) ) = Just $ setFile path -handle (Atom Atom.UnsetFile ) = Just unsetFile -handle _ = Nothing +handle (UI (AppEvent (App.MouseMove evt _))) = Just $ Global.ui . UI.mousePos <~ mousePosition evt +handle (UI (SidebarEvent (Sidebar.MouseMove evt _ _))) = Just $ Global.ui . UI.mousePos <~ mousePosition evt +handle (UI (AppEvent App.Resize )) = Just updateScene +handle (UI (AppEvent App.MouseLeave )) = Just $ endActions actionsClosingOnMouseLeave +handle (Shortcut (Shortcut.Event command _)) = Just $ handleCommand command +handle Init = Just $ Batch.getProgram def >> Batch.searchNodes +handle (Atom (Atom.SetFile path)) = Just $ setFile path +handle (Atom Atom.UnsetFile) = Just unsetFile +handle _ = Nothing handleCommand :: Shortcut.Command -> Command State () diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/Camera.hs b/luna-studio/node-editor/src/NodeEditor/Handler/Camera.hs index 1b4374a844c5..42412243d218 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/Camera.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/Camera.hs @@ -2,34 +2,36 @@ module NodeEditor.Handler.Camera ( handle ) where -import Common.Action.Command (Command) +import Common.Action.Command (Command) import Common.Prelude -import LunaStudio.Data.Vector2 (Vector2 (Vector2)) -import NodeEditor.Action.Camera (centerGraph, panCamera, panDown, panDrag, panLeft, panRight, panUp, resetCamera, resetPan, - resetZoom, startPanDrag, startZoomDrag, stopPanDrag, stopZoomDrag, wheelZoom, zoomDrag, zoomIn, - zoomOut) -import NodeEditor.Event.Event (Event (Shortcut, UI)) -import NodeEditor.Event.Mouse (mousePosition) -import qualified NodeEditor.Event.Mouse as Mouse -import qualified NodeEditor.Event.Shortcut as Shortcut -import NodeEditor.Event.UI (UIEvent (AppEvent)) -import qualified NodeEditor.React.Event.App as App -import NodeEditor.State.Action (Action (continue)) -import NodeEditor.State.Global (State) -import React.Flux (MouseEvent, wheelDeltaX, wheelDeltaY) +import LunaStudio.Data.Vector2 (Vector2 (Vector2)) +import NodeEditor.Action.Camera (centerGraph, panCamera, panDown, panDrag, panLeft, panRight, panUp, resetCamera, resetPan, + resetZoom, startPanDrag, startZoomDrag, stopPanDrag, stopZoomDrag, wheelZoom, zoomDrag, + zoomIn, zoomOut) +import NodeEditor.Event.Event (Event (Shortcut, UI)) +import NodeEditor.Event.Mouse (mousePosition) +import qualified NodeEditor.Event.Mouse as Mouse +import qualified NodeEditor.Event.Shortcut as Shortcut +import NodeEditor.Event.UI (UIEvent (AppEvent, SidebarEvent)) +import qualified NodeEditor.React.Event.App as App +import qualified NodeEditor.React.Event.Sidebar as Sidebar +import NodeEditor.State.Action (Action (continue)) +import NodeEditor.State.Global (State) +import React.Flux (MouseEvent, wheelDeltaX, wheelDeltaY) -- TODO[react]: Consider mac trackpad!!! handle :: Event -> Maybe (Command State ()) -handle (Shortcut (Shortcut.Event command _)) = Just $ handleCommand command -handle (UI (AppEvent (App.MouseDown e _))) = Just $ handleMouseDown e -handle (UI (AppEvent (App.MouseMove e _))) = Just $ handleMouseMove e -handle (UI (AppEvent (App.MouseUp _))) = Just $ continue stopPanDrag >> continue stopZoomDrag -handle (UI (AppEvent (App.Wheel m w))) = Just $ handleMouseWheel m delta where +handle (Shortcut (Shortcut.Event command _)) = Just $ handleCommand command +handle (UI (AppEvent (App.MouseDown e _))) = Just $ handleMouseDown e +handle (UI (AppEvent (App.MouseMove e _))) = Just $ handleMouseMove e +handle (UI (SidebarEvent (Sidebar.MouseMove e _ _))) = Just $ handleMouseMove e +handle (UI (AppEvent (App.MouseUp _))) = Just $ continue stopPanDrag >> continue stopZoomDrag +handle (UI (AppEvent (App.Wheel m w))) = Just $ handleMouseWheel m delta where deltaX = fromIntegral $ -(wheelDeltaX w) deltaY = fromIntegral $ -(wheelDeltaY w) delta = Vector2 deltaX deltaY -handle _ = Nothing +handle _ = Nothing -- TODO consider using state and below approach diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/Connect.hs b/luna-studio/node-editor/src/NodeEditor/Handler/Connect.hs index cc3b5507dab4..b5cb22ee116c 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/Connect.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/Connect.hs @@ -19,7 +19,7 @@ import NodeEditor.State.Global (State) handle :: Event -> Maybe (Command State ()) handle (UI (ConnectionEvent (Connection.MouseDown evt connId end'))) = Just $ handleConnectionMouseDown evt connId end' handle (UI (AppEvent (App.MouseMove evt _ ))) = Just $ continue $ handleMove evt -handle (UI (SidebarEvent (Sidebar.MouseMove evt _ ))) = Just $ continue $ handleMove evt +handle (UI (SidebarEvent (Sidebar.MouseMove evt _ _ ))) = Just $ continue $ handleMove evt handle (UI (AppEvent (App.MouseUp evt ))) = Just $ continue $ handleMouseUp evt handle (UI (AppEvent App.Click )) = Just $ continue (end :: Connect -> Command State ()) handle (UI (PortEvent (Port.MouseUp portRef ))) = Just $ continue $ handlePortMouseUp portRef diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/ConnectionPen.hs b/luna-studio/node-editor/src/NodeEditor/Handler/ConnectionPen.hs index df7d5ffc2b46..796b4666931f 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/ConnectionPen.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/ConnectionPen.hs @@ -9,18 +9,20 @@ import NodeEditor.Action.ConnectionPen (connectMove, disconnectMove, s stopDisconnecting) import NodeEditor.Event.Event (Event, Event (UI)) import qualified NodeEditor.Event.Mouse as Mouse -import NodeEditor.Event.UI (UIEvent (AppEvent)) +import NodeEditor.Event.UI (UIEvent (AppEvent, SidebarEvent)) import qualified NodeEditor.React.Event.App as App +import qualified NodeEditor.React.Event.Sidebar as Sidebar import NodeEditor.State.Action (Action (continue)) import NodeEditor.State.Global (State) import React.Flux (MouseEvent) handle :: Event -> Maybe (Command State ()) -handle (UI (AppEvent (App.MouseDown evt timestamp))) = Just $ handleMouseDown evt timestamp -handle (UI (AppEvent (App.MouseMove evt timestamp))) = Just $ continue (connectMove evt timestamp) >> continue (disconnectMove evt timestamp) -handle (UI (AppEvent (App.MouseUp _))) = Just $ continue stopConnecting >> continue stopDisconnecting -handle _ = Nothing +handle (UI (AppEvent (App.MouseDown evt timestamp))) = Just $ handleMouseDown evt timestamp +handle (UI (AppEvent (App.MouseMove evt timestamp))) = Just $ continue (connectMove evt timestamp) >> continue (disconnectMove evt timestamp) +handle (UI (SidebarEvent (Sidebar.MouseMove evt _ timestamp))) = Just $ continue (connectMove evt timestamp) >> continue (disconnectMove evt timestamp) +handle (UI (AppEvent (App.MouseUp _))) = Just $ continue stopConnecting >> continue stopDisconnecting +handle _ = Nothing handleMouseDown :: MouseEvent -> Timestamp -> Command State () handleMouseDown evt timestamp diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/MultiSelection.hs b/luna-studio/node-editor/src/NodeEditor/Handler/MultiSelection.hs index 0b3ff4b45363..c2cbcb2b4aff 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/MultiSelection.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/MultiSelection.hs @@ -7,15 +7,17 @@ import Common.Prelude import NodeEditor.Action.MultiSelection (startMultiSelection, stopMultiSelection, updateMultiSelection) import NodeEditor.Event.Event (Event (UI)) import qualified NodeEditor.Event.Mouse as Mouse -import NodeEditor.Event.UI (UIEvent (AppEvent)) +import NodeEditor.Event.UI (UIEvent (AppEvent, SidebarEvent)) import qualified NodeEditor.React.Event.App as App +import qualified NodeEditor.React.Event.Sidebar as Sidebar import NodeEditor.State.Action (Action (continue)) import NodeEditor.State.Global (State) handle :: Event -> Maybe (Command State ()) -handle (UI (AppEvent (App.MouseDown evt _))) = Just $ when shouldProceed $ startMultiSelection evt where +handle (UI (AppEvent (App.MouseDown evt _))) = Just $ when shouldProceed $ startMultiSelection evt where shouldProceed = Mouse.withoutMods evt Mouse.leftButton -handle (UI (AppEvent (App.MouseMove evt _))) = Just $ continue $ updateMultiSelection evt -handle (UI (AppEvent (App.MouseUp _))) = Just $ continue stopMultiSelection -handle _ = Nothing +handle (UI (AppEvent (App.MouseMove evt _))) = Just $ continue $ updateMultiSelection evt +handle (UI (SidebarEvent (Sidebar.MouseMove evt _ _))) = Just $ continue $ updateMultiSelection evt +handle (UI (AppEvent (App.MouseUp _))) = Just $ continue stopMultiSelection +handle _ = Nothing diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/Node.hs b/luna-studio/node-editor/src/NodeEditor/Handler/Node.hs index 8cac41cc4128..fcff57ea998a 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/Node.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/Node.hs @@ -15,9 +15,10 @@ import qualified NodeEditor.Event.Keys as Keys import NodeEditor.Event.Mouse (mousePosition, workspacePosition) import qualified NodeEditor.Event.Mouse as Mouse import qualified NodeEditor.Event.Shortcut as Shortcut -import NodeEditor.Event.UI (UIEvent (AppEvent, NodeEvent)) +import NodeEditor.Event.UI (UIEvent (AppEvent, NodeEvent, SidebarEvent)) import qualified NodeEditor.React.Event.App as App import qualified NodeEditor.React.Event.Node as Node +import qualified NodeEditor.React.Event.Sidebar as Sidebar import NodeEditor.React.Model.Node.ExpressionNode (NodeLoc) import qualified NodeEditor.React.Model.Node.ExpressionNode as Node import NodeEditor.State.Action (Action (continue)) @@ -27,22 +28,23 @@ import React.Flux (MouseEvent, mouseBu handle :: Event -> Maybe (Command State ()) handle (Shortcut (Shortcut.Event command _)) = Just $ handleCommand command -handle (UI (NodeEvent (Node.MouseDown mevt nl))) = Just $ handleMouseDown mevt nl -handle (UI (AppEvent (App.MouseMove mevt _ ))) = Just $ handleMouseMove mevt -handle (UI (AppEvent (App.Movement move ))) = Just $ handleMovement move -handle (UI (AppEvent (App.MouseUp mevt ))) = Just $ handleMouseUp mevt -handle (UI (NodeEvent (Node.Enter nl))) = Just $ withJustM (getExpressionNode nl) enterNode -handle (UI (NodeEvent (Node.EditExpression nl))) = Just $ Node.editExpression nl -handle (UI (NodeEvent (Node.EditName nl))) = Just $ Node.editName nl -handle (UI (NodeEvent (Node.Select kevt nl))) = Just $ when (mouseCtrlKey kevt || mouseMetaKey kevt) $ toggleSelect nl -handle (UI (NodeEvent (Node.SetExpression nl expr))) = Just $ setNodeExpression nl expr -handle (UI (NodeEvent (Node.PortEditString portRef portDef))) = Just $ void $ localSetPortDefault portRef portDef -handle (UI (NodeEvent (Node.PortApplyString kevt portRef portDef))) = Just $ when (Keys.withoutMods kevt Keys.enter) $ setPortDefault portRef portDef -handle (UI (NodeEvent (Node.PortSetPortDefault portRef portDef))) = Just $ setPortDefault portRef portDef -handle (UI (NodeEvent (Node.PortInitSlider _ portRef sliderInit))) = Just $ PortControl.startMoveSlider portRef sliderInit -handle (UI (NodeEvent (Node.MouseEnter nl))) = Just $ Node.handleMouseEnter nl -handle (UI (NodeEvent (Node.MouseLeave nl))) = Just $ Node.handleMouseLeave nl -handle (UI (NodeEvent (Node.ShowFullError nl))) = Just $ Node.showFullError nl +handle (UI (NodeEvent (Node.MouseDown mevt nl ))) = Just $ handleMouseDown mevt nl +handle (UI (AppEvent (App.MouseMove mevt _ ))) = Just $ handleMouseMove mevt +handle (UI (SidebarEvent (Sidebar.MouseMove mevt _ _))) = Just $ handleMouseMove mevt +handle (UI (AppEvent (App.Movement move ))) = Just $ handleMovement move +handle (UI (AppEvent (App.MouseUp mevt ))) = Just $ handleMouseUp mevt +handle (UI (NodeEvent (Node.Enter nl ))) = Just $ withJustM (getExpressionNode nl) enterNode +handle (UI (NodeEvent (Node.EditExpression nl ))) = Just $ Node.editExpression nl +handle (UI (NodeEvent (Node.EditName nl ))) = Just $ Node.editName nl +handle (UI (NodeEvent (Node.Select kevt nl ))) = Just $ when (mouseCtrlKey kevt || mouseMetaKey kevt) $ toggleSelect nl +handle (UI (NodeEvent (Node.SetExpression nl expr))) = Just $ setNodeExpression nl expr +handle (UI (NodeEvent (Node.PortEditString portRef portDef))) = Just $ void $ localSetPortDefault portRef portDef +handle (UI (NodeEvent (Node.PortApplyString kevt portRef portDef))) = Just $ when (Keys.withoutMods kevt Keys.enter) $ setPortDefault portRef portDef +handle (UI (NodeEvent (Node.PortSetPortDefault portRef portDef))) = Just $ setPortDefault portRef portDef +handle (UI (NodeEvent (Node.PortInitSlider _ portRef sliderInit))) = Just $ PortControl.startMoveSlider portRef sliderInit +handle (UI (NodeEvent (Node.MouseEnter nl))) = Just $ Node.handleMouseEnter nl +handle (UI (NodeEvent (Node.MouseLeave nl))) = Just $ Node.handleMouseLeave nl +handle (UI (NodeEvent (Node.ShowFullError nl))) = Just $ Node.showFullError nl handle _ = Nothing diff --git a/luna-studio/node-editor/src/NodeEditor/Handler/Sidebar.hs b/luna-studio/node-editor/src/NodeEditor/Handler/Sidebar.hs index 9180f20ca7a4..76be61abd1f7 100644 --- a/luna-studio/node-editor/src/NodeEditor/Handler/Sidebar.hs +++ b/luna-studio/node-editor/src/NodeEditor/Handler/Sidebar.hs @@ -21,7 +21,7 @@ handle (UI (SidebarEvent (Sidebar.ToggleOutputMode nl))) handle (UI (SidebarEvent (Sidebar.RemovePort (OutPortRef' portRef)))) = Just $ Batch.removePort portRef handle (UI (SidebarEvent (Sidebar.AddPort (OutPortRef' portRef)))) = Just $ Batch.addPort portRef Nothing handle (UI (AppEvent (App.MouseMove evt _))) = Just $ handleAppMove evt -handle (UI (SidebarEvent (Sidebar.MouseMove evt nodeLoc))) = Just $ handleSidebarMove evt nodeLoc +handle (UI (SidebarEvent (Sidebar.MouseMove evt nodeLoc _))) = Just $ handleSidebarMove evt nodeLoc handle (UI (AppEvent (App.MouseUp evt))) = Just $ continue $ handleMouseUp evt handle (UI (SidebarEvent (Sidebar.EditPortName portRef))) = Just $ editPortName portRef handle _ = Nothing diff --git a/luna-studio/node-editor/src/NodeEditor/React/Event/Sidebar.hs b/luna-studio/node-editor/src/NodeEditor/React/Event/Sidebar.hs index 04ab864eb1d2..2745a2e85d7e 100644 --- a/luna-studio/node-editor/src/NodeEditor/React/Event/Sidebar.hs +++ b/luna-studio/node-editor/src/NodeEditor/React/Event/Sidebar.hs @@ -5,6 +5,7 @@ module NodeEditor.React.Event.Sidebar where import Common.Prelude +import Data.Timestamp (Timestamp) import LunaStudio.Data.NodeLoc (NodeLoc) import LunaStudio.Data.PortRef (AnyPortRef, OutPortRef) import React.Flux (MouseEvent) @@ -12,7 +13,7 @@ import React.Flux (MouseEvent) data Event = AddPort AnyPortRef - | MouseMove MouseEvent NodeLoc + | MouseMove MouseEvent NodeLoc Timestamp | RemovePort AnyPortRef | EditPortName OutPortRef | ToggleInputMode NodeLoc diff --git a/luna-studio/node-editor/src/NodeEditor/React/Model/NodeEditor.hs b/luna-studio/node-editor/src/NodeEditor/React/Model/NodeEditor.hs index 4a1107a00034..8fef3c8e92c8 100644 --- a/luna-studio/node-editor/src/NodeEditor/React/Model/NodeEditor.hs +++ b/luna-studio/node-editor/src/NodeEditor/React/Model/NodeEditor.hs @@ -235,3 +235,7 @@ getVisualizations ne = concatMap getVisualizationsForNode . Map.toList $ ne ^. n argPortsNum = ExpressionNode.countArgPorts n visualizers = nv ^. Visualization.visualizers map (VisualizationProperties nl isExpanded argPortsNum visualizers) . Map.elems $ nv ^. Visualization.visualizations + +seperateVisualizationsViaSelectionOfNode :: [VisualizationProperties] -> NodeEditor -> ([VisualizationProperties], [VisualizationProperties]) +seperateVisualizationsViaSelectionOfNode visProps ne = partition predicate visProps where + predicate = maybe False (view ExpressionNode.isSelected) . flip getExpressionNode ne . view Visualization.visPropNodeLoc diff --git a/luna-studio/node-editor/src/NodeEditor/React/View/NodeEditor.hs b/luna-studio/node-editor/src/NodeEditor/React/View/NodeEditor.hs index 7a9f08bff198..07ee4f3b0a6c 100644 --- a/luna-studio/node-editor/src/NodeEditor/React/View/NodeEditor.hs +++ b/luna-studio/node-editor/src/NodeEditor/React/View/NodeEditor.hs @@ -89,6 +89,7 @@ nodeEditor = React.defineView name $ \(ref, ne') -> do isAnyVisActive = any (\visProp -> elem (visProp ^. visPropVisualization . visualizationMode) [Preview, FullScreen, Focused]) visualizations isAnyFullscreen = any (\visProp -> elem (visProp ^. visPropVisualization . visualizationMode) [Preview, FullScreen]) visualizations nodesWithVis = Set.fromList $ map (^. visPropNodeLoc) visualizations + (selectedNodeVis, notSelectedNodeVis) = NodeEditor.seperateVisualizationsViaSelectionOfNode visualizations ne case ne ^. NodeEditor.graphStatus of GraphLoaded -> div_ [ "className" $= Style.prefixFromList ( ["studio-window"] @@ -119,7 +120,8 @@ nodeEditor = React.defineView name $ \(ref, ne') -> do (not . null $ ne ^. NodeEditor.posHalfConnections) (filterOutSearcherIfNotRelated (n ^. Node.nodeLoc) maybeSearcher) (Set.filter (ExpressionNode.containsNode (n ^. Node.nodeLoc)) nodesWithVis) - forM_ visualizations $ nodeVisualization_ ref visLibPath + forM_ selectedNodeVis $ nodeVisualization_ ref visLibPath + forM_ notSelectedNodeVis $ nodeVisualization_ ref visLibPath planeNewConnection_ $ do forKeyed_ (ne ^. NodeEditor.posHalfConnections) $ uncurry halfConnection_ diff --git a/luna-studio/node-editor/src/NodeEditor/React/View/Sidebar.hs b/luna-studio/node-editor/src/NodeEditor/React/View/Sidebar.hs index 7b521a32ce8c..20dde1007c78 100644 --- a/luna-studio/node-editor/src/NodeEditor/React/View/Sidebar.hs +++ b/luna-studio/node-editor/src/NodeEditor/React/View/Sidebar.hs @@ -7,6 +7,7 @@ module NodeEditor.React.View.Sidebar import Common.Prelude import qualified Data.Aeson as Aeson +import Data.Timestamp (Timestamp (Timestamp)) import qualified JS.Config as Config import JS.Scene (inputSidebarId, outputSidebarId) import qualified JS.UI as UI @@ -80,7 +81,7 @@ sidebar = React.defineView "sidebar" $ \(ref, maySearcher, node) -> do [ "className" $= Style.prefixFromList classes , onDoubleClick $ \e _ -> [stopPropagation e] , onMouseDown $ \e _ -> [stopPropagation e] - , onMouseMove $ \e m -> stopPropagation e : dispatch ref (UI.SidebarEvent $ Sidebar.MouseMove m nodeLoc) + , onMouseMove $ \e m -> stopPropagation e : dispatch ref (UI.SidebarEvent $ Sidebar.MouseMove m nodeLoc (Timestamp (evtTimestamp e))) ] $ div_ [ "key" $= "activeArea" diff --git a/runner/src/StudioRunner.hs b/runner/src/StudioRunner.hs index a3cdd84ff47c..2db3fe5d2251 100644 --- a/runner/src/StudioRunner.hs +++ b/runner/src/StudioRunner.hs @@ -254,7 +254,7 @@ runLocal = do atom <- atomAppPath config <- configPath kill <- killSupervisorBinPath - liftIO $ Environment.setEnv "LUNA_STUDIO_CONFIG_GUI_PATH" (encodeString $ atomHome) + liftIO $ Environment.setEnv "LUNA_STUDIO_GUI_CONFIG_PATH" (encodeString $ atomHome) liftIO $ Environment.setEnv "LUNA_STUDIO_LOG_PATH" (encodeString logs) liftIO $ Environment.setEnv "LUNA_STUDIO_BACKEND_PATH" (encodeString backendBins) liftIO $ Environment.setEnv "LUNA_STUDIO_GUI_PATH" (encodeString atom) @@ -277,7 +277,7 @@ runPackage = case currentHost of atom <- atomAppPath config <- configPath kill <- killSupervisorBinPath - liftIO $ Environment.setEnv "LUNA_STUDIO_CONFIG_GUI_PATH" (encodeString $ atomHome "atom") + liftIO $ Environment.setEnv "LUNA_STUDIO_GUI_CONFIG_PATH" (encodeString $ atomHome "atom") liftIO $ Environment.setEnv "LUNA_STUDIO_LOG_PATH" (encodeString logs) liftIO $ Environment.setEnv "LUNA_STUDIO_BACKEND_PATH" (encodeString backendBins) liftIO $ Environment.setEnv "LUNA_STUDIO_GUI_PATH" (encodeString atom) @@ -292,7 +292,7 @@ runPackage = case currentHost of atom <- atomAppPath config <- configPath kill <- killSupervisorBinPath - liftIO $ Environment.setEnv "LUNA_STUDIO_CONFIG_GUI_PATH" (encodeString $ atomHome "atom") + liftIO $ Environment.setEnv "LUNA_STUDIO_GUI_CONFIG_PATH" (encodeString $ atomHome "atom") liftIO $ Environment.setEnv "LUNA_STUDIO_LOG_PATH" (encodeString logs) liftIO $ Environment.setEnv "LUNA_STUDIO_BACKEND_PATH" (encodeString backendBins) liftIO $ Environment.setEnv "LUNA_STUDIO_GUI_PATH" (encodeString atom) diff --git a/supervisor/supervisord-linux.conf b/supervisor/supervisord-linux.conf index efb9eb1594b0..eee1c34ed96d 100644 --- a/supervisor/supervisord-linux.conf +++ b/supervisor/supervisord-linux.conf @@ -125,7 +125,7 @@ serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket ;serverurl=AUTO ; override serverurl computation (childutils) [program:luna-atom] -environment=ATOM_HOME=%(ENV_LUNA_STUDIO_CONFIG_GUI_PATH)s +environment=ATOM_HOME=%(ENV_LUNA_STUDIO_GUI_CONFIG_PATH)s command=%(ENV_LUNA_STUDIO_GUI_PATH)s -w %(ENV_LUNA_STUDIO_ATOM_ARG)s priority=2 process_name=luna-atom diff --git a/supervisor/supervisord-mac.conf b/supervisor/supervisord-mac.conf index 8acdae003973..3e605fc983e6 100644 --- a/supervisor/supervisord-mac.conf +++ b/supervisor/supervisord-mac.conf @@ -125,7 +125,7 @@ serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket ;serverurl=AUTO ; override serverurl computation (childutils) [program:luna-atom] -environment=ATOM_HOME=%(ENV_LUNA_STUDIO_CONFIG_GUI_PATH)s +environment=ATOM_HOME=%(ENV_LUNA_STUDIO_GUI_CONFIG_PATH)s command=%(ENV_LUNA_STUDIO_GUI_PATH)s %(ENV_LUNA_STUDIO_ATOM_ARG)s priority=2 process_name=luna-atom