mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 11:52:59 +03:00
Auto Layouts (#3937)
This commit is contained in:
parent
a6b5db9021
commit
06cfafca09
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/debug-scene-text-grid-visualization [wasm, linux]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚥 GUI view/debug_scene/text-grid-visualization"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-unknown-linux-gnu --target-dir dist/intellij_wasm_linux --package debug-scene-text-grid-visualization" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/debug-scene-text-grid-visualization [wasm, macos]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚥 GUI view/debug_scene/text-grid-visualization"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target aarch64-apple-darwin --target-dir dist/intellij_wasm_macos --package debug-scene-text-grid-visualization" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/debug-scene-text-grid-visualization [wasm, windows]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚥 GUI view/debug_scene/text-grid-visualization"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-pc-windows-msvc --target-dir dist/intellij_wasm_windows --package debug-scene-text-grid-visualization" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/debug-scene-text-grid-visualization [wasm]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚥 GUI view/debug_scene/text-grid-visualization"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target-dir dist/intellij_wasm --package debug-scene-text-grid-visualization" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-base [wasm, linux]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build base"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-unknown-linux-gnu --target-dir dist/intellij_wasm_linux --package enso-build-base" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-base [wasm, macos]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build base"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target aarch64-apple-darwin --target-dir dist/intellij_wasm_macos --package enso-build-base" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-base [wasm, windows]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build base"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-pc-windows-msvc --target-dir dist/intellij_wasm_windows --package enso-build-base" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/clippy-enso-build-base-wasm.xml
Normal file
27
.idea/runConfigurations/clippy-enso-build-base-wasm.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-base [wasm]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build base"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target-dir dist/intellij_wasm --package enso-build-base" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-macros [wasm, linux]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build macros"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-unknown-linux-gnu --target-dir dist/intellij_wasm_linux --package enso-build-macros" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-macros [wasm, macos]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build macros"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target aarch64-apple-darwin --target-dir dist/intellij_wasm_macos --package enso-build-macros" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-macros [wasm, windows]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build macros"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-pc-windows-msvc --target-dir dist/intellij_wasm_windows --package enso-build-macros" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/clippy-enso-build-macros-wasm.xml
Normal file
27
.idea/runConfigurations/clippy-enso-build-macros-wasm.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/enso-build-macros [wasm]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build macros"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target-dir dist/intellij_wasm --package enso-build-macros" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-example-auto-layout [wasm, linux]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🧸 Example auto-layout"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-unknown-linux-gnu --target-dir dist/intellij_wasm_linux --package ensogl-example-auto-layout" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-example-auto-layout [wasm, macos]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🧸 Example auto-layout"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target aarch64-apple-darwin --target-dir dist/intellij_wasm_macos --package ensogl-example-auto-layout" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-example-auto-layout [wasm, windows]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🧸 Example auto-layout"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-pc-windows-msvc --target-dir dist/intellij_wasm_windows --package ensogl-example-auto-layout" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-example-auto-layout [wasm]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🧸 Example auto-layout"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target-dir dist/intellij_wasm --package ensogl-example-auto-layout" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/clippy-ensogl-slider-wasm-linux.xml
Normal file
27
.idea/runConfigurations/clippy-ensogl-slider-wasm-linux.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-slider [wasm, linux]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🎨 EnsoGl component/slider"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-unknown-linux-gnu --target-dir dist/intellij_wasm_linux --package ensogl-slider" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/clippy-ensogl-slider-wasm-macos.xml
Normal file
27
.idea/runConfigurations/clippy-ensogl-slider-wasm-macos.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-slider [wasm, macos]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🎨 EnsoGl component/slider"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target aarch64-apple-darwin --target-dir dist/intellij_wasm_macos --package ensogl-slider" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-slider [wasm, windows]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🎨 EnsoGl component/slider"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target x86_64-pc-windows-msvc --target-dir dist/intellij_wasm_windows --package ensogl-slider" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/clippy-ensogl-slider-wasm.xml
Normal file
27
.idea/runConfigurations/clippy-ensogl-slider-wasm.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="clippy/ensogl-slider [wasm]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🎨 EnsoGl component/slider"
|
||||
>
|
||||
<option name="command" value="clippy --all-targets --target wasm32-unknown-unknown --target-dir dist/intellij_wasm --package ensogl-slider" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="doc-test/debug-scene-text-grid-visualization [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚥 GUI view/debug_scene/text-grid-visualization"
|
||||
>
|
||||
<option name="command" value="test --doc --target-dir dist/intellij_native --package debug-scene-text-grid-visualization" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/doc-test-enso-build-base-native.xml
Normal file
27
.idea/runConfigurations/doc-test-enso-build-base-native.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="doc-test/enso-build-base [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build base"
|
||||
>
|
||||
<option name="command" value="test --doc --target-dir dist/intellij_native --package enso-build-base" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="doc-test/enso-build-macros [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build macros"
|
||||
>
|
||||
<option name="command" value="test --doc --target-dir dist/intellij_native --package enso-build-macros" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="doc-test/ensogl-example-auto-layout [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🧸 Example auto-layout"
|
||||
>
|
||||
<option name="command" value="test --doc --target-dir dist/intellij_native --package ensogl-example-auto-layout" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/doc-test-ensogl-slider-native.xml
Normal file
27
.idea/runConfigurations/doc-test-ensogl-slider-native.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="doc-test/ensogl-slider [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🎨 EnsoGl component/slider"
|
||||
>
|
||||
<option name="command" value="test --doc --target-dir dist/intellij_native --package ensogl-slider" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="test/debug-scene-text-grid-visualization [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚥 GUI view/debug_scene/text-grid-visualization"
|
||||
>
|
||||
<option name="command" value="test --all-targets --target-dir dist/intellij_native --package debug-scene-text-grid-visualization" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/test-enso-build-base-native.xml
Normal file
27
.idea/runConfigurations/test-enso-build-base-native.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="test/enso-build-base [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build base"
|
||||
>
|
||||
<option name="command" value="test --all-targets --target-dir dist/intellij_native --package enso-build-base" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/test-enso-build-macros-native.xml
Normal file
27
.idea/runConfigurations/test-enso-build-macros-native.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="test/enso-build-macros [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🚧 Build macros"
|
||||
>
|
||||
<option name="command" value="test --all-targets --target-dir dist/intellij_native --package enso-build-macros" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="test/ensogl-example-auto-layout [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🧸 Example auto-layout"
|
||||
>
|
||||
<option name="command" value="test --all-targets --target-dir dist/intellij_native --package ensogl-example-auto-layout" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
27
.idea/runConfigurations/test-ensogl-slider-native.xml
Normal file
27
.idea/runConfigurations/test-ensogl-slider-native.xml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
<component name="#ProjectRunConfigurationManager">
|
||||
<configuration
|
||||
default="false"
|
||||
name="test/ensogl-slider [native]"
|
||||
type="CargoCommandRunConfiguration"
|
||||
factoryName="Cargo Command"
|
||||
folderName="🎨 EnsoGl component/slider"
|
||||
>
|
||||
<option name="command" value="test --all-targets --target-dir dist/intellij_native --package ensogl-slider" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
|
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -2367,6 +2367,7 @@ dependencies = [
|
||||
"boolinator",
|
||||
"enso-macro-utils",
|
||||
"itertools 0.8.2",
|
||||
"paste 1.0.9",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
@ -2575,6 +2576,14 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ensogl-example-auto-layout"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ensogl-core",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ensogl-example-complex-shape-system"
|
||||
version = "0.1.0"
|
||||
@ -2776,6 +2785,7 @@ name = "ensogl-examples"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ensogl-example-animation",
|
||||
"ensogl-example-auto-layout",
|
||||
"ensogl-example-complex-shape-system",
|
||||
"ensogl-example-custom-shape-system",
|
||||
"ensogl-example-dom-symbols",
|
||||
|
@ -79,27 +79,21 @@ impl Fixture {
|
||||
/// After returning, the IDE is in a state with new project opened and ready to work
|
||||
/// (after libraries' compilation).
|
||||
pub async fn new_project(&self) {
|
||||
let project = self.ide.presenter.view().project();
|
||||
let controller = self.ide.presenter.controller();
|
||||
let project_management =
|
||||
controller.manage_projects().expect("Cannot access Managing Project API");
|
||||
|
||||
let expect_prompt = project.show_prompt.next_event();
|
||||
project_management.create_new_project(None).await.expect("Failed to create new project");
|
||||
expect_prompt.await;
|
||||
}
|
||||
|
||||
/// After returning, the IDE is in a state with the project opened and ready to work
|
||||
/// (after libraries' compilation).
|
||||
pub async fn load_project(&self, name: String) {
|
||||
let project = self.ide.presenter.view().project();
|
||||
let controller = self.ide.presenter.controller();
|
||||
let project_management =
|
||||
controller.manage_projects().expect("Cannot access Managing Project API");
|
||||
|
||||
let expect_prompt = project.show_prompt.next_event();
|
||||
project_management.open_project_by_name(name).await.expect("Failed to open project");
|
||||
expect_prompt.await;
|
||||
}
|
||||
|
||||
/// Get the Project View.
|
||||
|
@ -259,8 +259,6 @@ impl Project {
|
||||
eval_ view.redo (model.redo());
|
||||
|
||||
values_computed <- source::<()>();
|
||||
values_computed_first_time <- values_computed.constant(true).on_change().constant(());
|
||||
view.show_prompt <+ values_computed_first_time;
|
||||
view.values_updated <+ values_computed;
|
||||
|
||||
eval_ view.save_project_snapshot(model.save_project_snapshot());
|
||||
|
@ -213,8 +213,8 @@ impl EntryData {
|
||||
fn update_layout(&self, contour: Contour, text_padding: f32, text_y_offset: f32) {
|
||||
let size = contour.size;
|
||||
self.text.set_xy(Vector2(text_padding - size.x / 2.0, text_y_offset));
|
||||
self.separator.size.set(Vector2(separator::ICON_WIDTH, size.y));
|
||||
self.ellipsis.size.set(Vector2(ellipsis::ICON_WIDTH, size.y));
|
||||
self.separator.set_size(Vector2(separator::ICON_WIDTH, size.y));
|
||||
self.ellipsis.set_size(Vector2(ellipsis::ICON_WIDTH, size.y));
|
||||
}
|
||||
|
||||
fn set_default_color(&self, color: color::Lcha) {
|
||||
|
@ -206,7 +206,7 @@ impl Model {
|
||||
/// fit into [`size`], it is cropped by the rectangular [`mask`] and shifted left. So that
|
||||
/// the user always sees the right (most important) part of the breadcrumbs.
|
||||
fn update_layout(&self, content_size: Vector2, size: Vector2) {
|
||||
self.mask.size.set(size);
|
||||
self.mask.set_size(size);
|
||||
let grid_view_center = Vector2(size.x / 2.0, -size.y / 2.0);
|
||||
self.mask.set_xy(grid_view_center);
|
||||
let offset = self.offset(content_size, size);
|
||||
|
@ -318,11 +318,11 @@ impl Data {
|
||||
};
|
||||
let bg_height = entry_size.y + overlap;
|
||||
// See comment in [`Self::update_shadow`] method.
|
||||
let shadow_addition = self.background.size.get().y - self.background.height.get();
|
||||
let shadow_addition = self.background.computed_size().y - self.background.height.get();
|
||||
let bg_sprite_height = bg_height + shadow_addition;
|
||||
let bg_y = -gap_over_header + overlap / 2.0 + local_scope_offset;
|
||||
self.background.set_y(bg_y);
|
||||
self.background.size.set(Vector2(bg_width, bg_sprite_height));
|
||||
self.background.set_size(Vector2(bg_width, bg_sprite_height));
|
||||
self.background.height.set(bg_height);
|
||||
let width = grid_style.column_width();
|
||||
let left = -width / 2.0 + style.padding;
|
||||
@ -379,7 +379,7 @@ impl Data {
|
||||
entry_size: Vector2,
|
||||
) {
|
||||
if header_position.position != Vector2::default() {
|
||||
let bg_width = self.background.size.get().x;
|
||||
let bg_width = self.background.computed_size().x;
|
||||
let bg_height = self.background.height.get();
|
||||
let distance_to_section_top =
|
||||
header_position.y_range.end() - header_position.position.y;
|
||||
@ -393,7 +393,7 @@ impl Data {
|
||||
// is not visible outside the component group background.
|
||||
let shadow_size = style.header_shadow_size.min(distance_to_section_bottom);
|
||||
let bg_sprite_height = bg_height + shadow_size * 2.0;
|
||||
self.background.size.set(Vector2(bg_width, bg_sprite_height));
|
||||
self.background.set_size(Vector2(bg_width, bg_sprite_height));
|
||||
let header_shadow_peak = entry_size.y / 2.0;
|
||||
let height_multiplier = (distance_to_section_top / header_shadow_peak).min(1.0);
|
||||
self.background.shadow_height_multiplier.set(height_multiplier);
|
||||
|
@ -84,7 +84,7 @@ macro_rules! define_icons {
|
||||
match self {$(
|
||||
Self::$variant => {
|
||||
let view = $name::View::new();
|
||||
view.size.set(size);
|
||||
view.set_size(size);
|
||||
let color_fn = Box::new(f!([view]()
|
||||
color::Lcha::from(color::Rgba::from(view.color.get()))
|
||||
));
|
||||
|
@ -268,7 +268,7 @@ impl Model {
|
||||
|
||||
fn update_style(&self, style: &AllStyles) {
|
||||
self.background.bg_color.set(style.panel.background_color.into());
|
||||
self.background.size.set(style.background_sprite_size());
|
||||
self.background.set_size(style.background_sprite_size());
|
||||
self.section_navigator.update_layout(style);
|
||||
|
||||
self.breadcrumbs.set_xy(style.breadcrumbs_pos());
|
||||
@ -283,7 +283,7 @@ impl Model {
|
||||
// The `pos` is mouse position in Component List Panel space (the origin is in the middle of
|
||||
// the panel).
|
||||
fn is_hovered(&self, pos: Vector2) -> bool {
|
||||
let size = self.background.size.get();
|
||||
let size = self.background.computed_size();
|
||||
let viewport = BoundingBox::from_center_and_size(default(), size);
|
||||
viewport.contains(pos)
|
||||
}
|
||||
|
@ -234,7 +234,6 @@ fn init(app: &Application) {
|
||||
}
|
||||
});
|
||||
|
||||
root_view.project().show_prompt();
|
||||
|
||||
// === Profiling ===
|
||||
|
||||
|
@ -75,7 +75,7 @@ impl BubbleChartModel {
|
||||
views.iter().zip(data_inner.iter()).for_each(|(view, item)| {
|
||||
let size = self.size.get();
|
||||
self.display_object.add_child(&view);
|
||||
view.size.set(size);
|
||||
view.set_size(size);
|
||||
view.radius.set(item.z);
|
||||
view.position.set(Vector2(item.x, item.y) - size / 2.0);
|
||||
});
|
||||
|
@ -273,7 +273,7 @@ impl BreadcrumbsModel {
|
||||
crate::MACOS_TRAFFIC_LIGHTS_CONTENT_HEIGHT + BACKGROUND_PADDING * 2.0;
|
||||
let width_with_shadow = background_width + MAGIC_SHADOW_MARGIN * 2.0;
|
||||
let height_with_shadow = background_height + MAGIC_SHADOW_MARGIN * 2.0;
|
||||
self.background.size.set(Vector2(width_with_shadow, height_with_shadow));
|
||||
self.background.set_size(Vector2(width_with_shadow, height_with_shadow));
|
||||
self.background.set_x(width / 2.0);
|
||||
self.background.set_y(-HEIGHT / 2.0);
|
||||
}
|
||||
|
@ -349,13 +349,13 @@ impl BreadcrumbModel {
|
||||
let height = self.height();
|
||||
let offset = SEPARATOR_MARGIN + SEPARATOR_SIZE / 2.0;
|
||||
|
||||
self.view.size.set(Vector2::new(width, height));
|
||||
self.view.set_size(Vector2::new(width, height));
|
||||
self.fade_in(0.0);
|
||||
let separator_size = (SEPARATOR_SIZE + PADDING * 2.0).max(0.0);
|
||||
let icon_size = (ICON_SIZE + PADDING * 2.0).max(0.0);
|
||||
self.separator.size.set(Vector2::new(separator_size, separator_size));
|
||||
self.separator.set_size(Vector2::new(separator_size, separator_size));
|
||||
self.separator.set_x((offset - width / 2.0).round());
|
||||
self.icon.size.set(Vector2::new(icon_size, icon_size));
|
||||
self.icon.set_size(Vector2::new(icon_size, icon_size));
|
||||
let x_position = offset + PADDING + ICON_SIZE / 2.0 + LEFT_MARGIN + ICON_LEFT_MARGIN;
|
||||
self.icon.set_x(x_position.round());
|
||||
|
||||
|
@ -172,7 +172,7 @@ impl ProjectNameModel {
|
||||
let y_center = y_top - height / 2.0;
|
||||
|
||||
self.text_field.set_position(Vector3(x_left, y_center + TEXT_SIZE / 2.0, 0.0));
|
||||
self.view.size.set(Vector2(width, height));
|
||||
self.view.set_size(Vector2(width, height));
|
||||
self.view.set_position(Vector3(x_center, y_center, 0.0));
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ macro_rules! define_line {
|
||||
fn snap_local(&self, point: Vector2<f32>) -> Option<Vector2<f32>> {
|
||||
// FIXME: These bounds check should not be required and should be removed once
|
||||
// issue #689 is resolved.
|
||||
let height = self.size.get().y;
|
||||
let height = self.computed_size().y;
|
||||
let y = point.y.clamp(-height / 2.0, height / 2.0);
|
||||
Some(Vector2(0.0, y))
|
||||
}
|
||||
@ -679,25 +679,25 @@ impl LayoutLine for front::line::View {
|
||||
fn layout_v(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x, start.y + len / 2.0);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs() + LINE_SIDES_OVERLAP);
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
fn layout_h(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x + len / 2.0, start.y);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs() + LINE_SIDES_OVERLAP);
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
fn layout_v_no_overlap(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x, start.y + len / 2.0);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs());
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
fn layout_h_no_overlap(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x + len / 2.0, start.y);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs());
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
}
|
||||
@ -706,25 +706,25 @@ impl LayoutLine for back::line::View {
|
||||
fn layout_v(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x, start.y + len / 2.0);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs() + LINE_SIDES_OVERLAP);
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
fn layout_h(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x + len / 2.0, start.y);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs() + LINE_SIDES_OVERLAP);
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
fn layout_v_no_overlap(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x, start.y + len / 2.0);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs());
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
fn layout_h_no_overlap(&self, start: Vector2<f32>, len: f32) {
|
||||
let pos = Vector2(start.x + len / 2.0, start.y);
|
||||
let size = Vector2(LINE_SHAPE_WIDTH, len.abs());
|
||||
self.size.set(size);
|
||||
self.set_size(size);
|
||||
self.set_xy(pos);
|
||||
}
|
||||
}
|
||||
@ -1305,10 +1305,10 @@ impl EdgeModelData {
|
||||
display_object.add_child(&back);
|
||||
display_object.add_child(&joint);
|
||||
|
||||
front.side_line.mod_rotation(|r| r.z = RIGHT_ANGLE);
|
||||
back.side_line.mod_rotation(|r| r.z = RIGHT_ANGLE);
|
||||
front.side_line2.mod_rotation(|r| r.z = RIGHT_ANGLE);
|
||||
back.side_line2.mod_rotation(|r| r.z = RIGHT_ANGLE);
|
||||
front.side_line.set_rotation_z(RIGHT_ANGLE);
|
||||
back.side_line.set_rotation_z(RIGHT_ANGLE);
|
||||
front.side_line2.set_rotation_z(RIGHT_ANGLE);
|
||||
back.side_line2.set_rotation_z(RIGHT_ANGLE);
|
||||
|
||||
let frp = Frp::new(network);
|
||||
let source_height = default();
|
||||
@ -1400,12 +1400,12 @@ impl EdgeModelData {
|
||||
let joint_position = snap_data.position - self.display_object.position().xy();
|
||||
self.joint.set_xy(joint_position);
|
||||
let joint_size = LINE_WIDTH + PADDING;
|
||||
self.joint.size.set(Vector2(joint_size, joint_size));
|
||||
self.joint.set_size(Vector2(joint_size, joint_size));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.focus_none();
|
||||
self.joint.size.set(Vector2::zero());
|
||||
self.joint.set_size(Vector2::<f32>::zero());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1536,7 +1536,7 @@ impl EdgeModelData {
|
||||
let corner1_angle = (angle + angle_overlap) * side;
|
||||
let corner1_angle = if is_down { corner1_angle } else { side_right_angle };
|
||||
|
||||
bg.corner.size.set(corner1_size);
|
||||
bg.corner.set_size(corner1_size);
|
||||
bg.corner.start_angle.set(corner1_start_angle);
|
||||
bg.corner.angle.set(corner1_angle);
|
||||
bg.corner.radius.set(corner1_radius);
|
||||
@ -1544,7 +1544,7 @@ impl EdgeModelData {
|
||||
bg.corner.set_xy(corner1);
|
||||
if !fully_attached {
|
||||
bg.corner.dim.set(Vector2(node_half_width, source_node_half_height));
|
||||
fg.corner.size.set(corner1_size);
|
||||
fg.corner.set_size(corner1_size);
|
||||
fg.corner.start_angle.set(corner1_start_angle);
|
||||
fg.corner.angle.set(corner1_angle);
|
||||
fg.corner.radius.set(corner1_radius);
|
||||
@ -1552,7 +1552,7 @@ impl EdgeModelData {
|
||||
fg.corner.dim.set(Vector2(node_half_width, source_node_half_height));
|
||||
fg.corner.set_xy(corner1);
|
||||
} else {
|
||||
fg.corner.size.set(zero());
|
||||
fg.corner.set_size(Vector2(0.0, 0.0));
|
||||
bg.corner.dim.set(Vector2(INFINITE, INFINITE));
|
||||
}
|
||||
|
||||
@ -1574,7 +1574,7 @@ impl EdgeModelData {
|
||||
let bg_line_start = Vector2(side * bg_line_x, 0.0);
|
||||
if fully_attached {
|
||||
let bg_line_len = side * side_line_len;
|
||||
fg.side_line.size.set(zero());
|
||||
fg.side_line.set_size(Vector2(0.0, 0.0));
|
||||
bg.side_line.layout_h(bg_line_start, bg_line_len);
|
||||
} else {
|
||||
let bg_max_len = NODE_PADDING + side_line_shift;
|
||||
@ -1618,10 +1618,10 @@ impl EdgeModelData {
|
||||
} else if fully_attached {
|
||||
let main_line_start_y = port_line_start.y + port_line_len;
|
||||
let main_line_start = Vector2(port_line_start.x, main_line_start_y);
|
||||
fg.main_line.size.set(zero());
|
||||
fg.main_line.set_size(Vector2(0.0, 0.0));
|
||||
bg.main_line.layout_v(main_line_start, main_line_len - port_line_len);
|
||||
} else {
|
||||
bg.main_line.size.set(zero());
|
||||
bg.main_line.set_size(Vector2(0.0, 0.0));
|
||||
fg.main_line.layout_v(port_line_start, main_line_len);
|
||||
}
|
||||
}
|
||||
@ -1680,8 +1680,8 @@ impl EdgeModelData {
|
||||
let corner3_angle = if is_right_side { 0.0 } else { -RIGHT_ANGLE };
|
||||
|
||||
if fully_attached {
|
||||
fg.corner3.size.set(zero());
|
||||
bg.corner3.size.set(corner3_size);
|
||||
fg.corner3.set_size(Vector2(0.0, 0.0));
|
||||
bg.corner3.set_size(corner3_size);
|
||||
bg.corner3.start_angle.set(corner3_angle);
|
||||
bg.corner3.angle.set(RIGHT_ANGLE);
|
||||
bg.corner3.radius.set(corner3_radius);
|
||||
@ -1689,8 +1689,8 @@ impl EdgeModelData {
|
||||
bg.corner3.dim.set(Vector2(INFINITE, INFINITE));
|
||||
bg.corner3.set_xy(corner3);
|
||||
} else {
|
||||
bg.corner3.size.set(zero());
|
||||
fg.corner3.size.set(corner3_size);
|
||||
bg.corner3.set_size(Vector2(0.0, 0.0));
|
||||
fg.corner3.set_size(corner3_size);
|
||||
fg.corner3.start_angle.set(corner3_angle);
|
||||
fg.corner3.angle.set(RIGHT_ANGLE);
|
||||
fg.corner3.radius.set(corner3_radius);
|
||||
@ -1704,8 +1704,8 @@ impl EdgeModelData {
|
||||
let corner2_angle = if is_right_side { -RIGHT_ANGLE } else { 0.0 };
|
||||
|
||||
if fully_attached {
|
||||
fg.corner2.size.set(zero());
|
||||
bg.corner2.size.set(corner1_size);
|
||||
fg.corner2.set_size(Vector2(0.0, 0.0));
|
||||
bg.corner2.set_size(corner1_size);
|
||||
bg.corner2.start_angle.set(corner2_angle);
|
||||
bg.corner2.angle.set(RIGHT_ANGLE);
|
||||
bg.corner2.radius.set(corner2_radius);
|
||||
@ -1713,8 +1713,8 @@ impl EdgeModelData {
|
||||
bg.corner2.dim.set(Vector2(INFINITE, INFINITE));
|
||||
bg.corner2.set_xy(corner2);
|
||||
} else {
|
||||
bg.corner2.size.set(zero());
|
||||
fg.corner2.size.set(corner1_size);
|
||||
bg.corner2.set_size(Vector2(0.0, 0.0));
|
||||
fg.corner2.set_size(corner1_size);
|
||||
fg.corner2.start_angle.set(corner2_angle);
|
||||
fg.corner2.angle.set(RIGHT_ANGLE);
|
||||
fg.corner2.radius.set(corner2_radius);
|
||||
@ -1737,10 +1737,10 @@ impl EdgeModelData {
|
||||
let main_line_start = Vector2(side * corner1_target.x, corner1.y);
|
||||
|
||||
if fully_attached {
|
||||
fg.main_line.size.set(zero());
|
||||
fg.main_line.set_size(Vector2(0.0, 0.0));
|
||||
bg.main_line.layout_v(main_line_start, main_line_len);
|
||||
} else {
|
||||
bg.main_line.size.set(zero());
|
||||
bg.main_line.set_size(Vector2(0.0, 0.0));
|
||||
fg.main_line.layout_v(main_line_start, main_line_len);
|
||||
}
|
||||
|
||||
@ -1749,17 +1749,17 @@ impl EdgeModelData {
|
||||
let arrow_pos = Vector2(main_line_start.x, arrow_y);
|
||||
let arrow_size = Vector2(ARROW_SIZE_X, ARROW_SIZE_Y);
|
||||
if fully_attached {
|
||||
fg.arrow.size.set(zero());
|
||||
bg.arrow.size.set(arrow_size);
|
||||
fg.arrow.set_size(Vector2(0.0, 0.0));
|
||||
bg.arrow.set_size(arrow_size);
|
||||
bg.arrow.set_xy(arrow_pos);
|
||||
} else {
|
||||
bg.arrow.size.set(zero());
|
||||
fg.arrow.size.set(arrow_size);
|
||||
bg.arrow.set_size(Vector2(0.0, 0.0));
|
||||
fg.arrow.set_size(arrow_size);
|
||||
fg.arrow.set_xy(arrow_pos);
|
||||
}
|
||||
} else {
|
||||
bg.arrow.size.set(zero());
|
||||
fg.arrow.size.set(zero());
|
||||
bg.arrow.set_size(Vector2(0.0, 0.0));
|
||||
fg.arrow.set_size(Vector2(0.0, 0.0));
|
||||
}
|
||||
|
||||
|
||||
@ -1773,23 +1773,23 @@ impl EdgeModelData {
|
||||
let side_line2_len = side * (corner3_x - corner2_x);
|
||||
let side_line2_start = Vector2(side * corner2_x, corner2_y + corner2_radius);
|
||||
if fully_attached {
|
||||
fg.side_line2.size.set(zero());
|
||||
fg.side_line2.set_size(Vector2(0.0, 0.0));
|
||||
bg.side_line2.layout_h(side_line2_start, side_line2_len);
|
||||
} else {
|
||||
bg.side_line2.size.set(zero());
|
||||
bg.side_line2.set_size(Vector2(0.0, 0.0));
|
||||
fg.side_line2.layout_h(side_line2_start, side_line2_len);
|
||||
}
|
||||
|
||||
port_line_len = corner3_y - port_line_start.y;
|
||||
} else {
|
||||
fg.arrow.size.set(zero());
|
||||
bg.arrow.size.set(zero());
|
||||
fg.corner3.size.set(zero());
|
||||
bg.corner3.size.set(zero());
|
||||
fg.corner2.size.set(zero());
|
||||
bg.corner2.size.set(zero());
|
||||
fg.side_line2.size.set(zero());
|
||||
bg.side_line2.size.set(zero());
|
||||
fg.arrow.set_size(Vector2(0.0, 0.0));
|
||||
bg.arrow.set_size(Vector2(0.0, 0.0));
|
||||
fg.corner3.set_size(Vector2(0.0, 0.0));
|
||||
bg.corner3.set_size(Vector2(0.0, 0.0));
|
||||
fg.corner2.set_size(Vector2(0.0, 0.0));
|
||||
bg.corner2.set_size(Vector2(0.0, 0.0));
|
||||
fg.side_line2.set_size(Vector2(0.0, 0.0));
|
||||
bg.side_line2.set_size(Vector2(0.0, 0.0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -625,10 +625,10 @@ impl NodeModel {
|
||||
let height = self.height();
|
||||
let size = Vector2(width, height);
|
||||
let padded_size = size + Vector2(PADDING, PADDING) * 2.0;
|
||||
self.backdrop.size.set(padded_size);
|
||||
self.background.size.set(padded_size);
|
||||
self.drag_area.size.set(padded_size);
|
||||
self.error_indicator.size.set(padded_size);
|
||||
self.backdrop.set_size(padded_size);
|
||||
self.background.set_size(padded_size);
|
||||
self.drag_area.set_size(padded_size);
|
||||
self.error_indicator.set_size(padded_size);
|
||||
self.vcs_indicator.set_size(padded_size);
|
||||
let x_offset_to_node_center = x_offset_to_node_center(width);
|
||||
self.backdrop.set_x(x_offset_to_node_center);
|
||||
@ -638,9 +638,8 @@ impl NodeModel {
|
||||
self.vcs_indicator.set_x(x_offset_to_node_center);
|
||||
|
||||
let action_bar_width = ACTION_BAR_WIDTH;
|
||||
self.action_bar.mod_position(|t| {
|
||||
t.x = x_offset_to_node_center + width / 2.0 + CORNER_RADIUS + action_bar_width / 2.0;
|
||||
});
|
||||
self.action_bar
|
||||
.set_x(x_offset_to_node_center + width / 2.0 + CORNER_RADIUS + action_bar_width / 2.0);
|
||||
self.action_bar.frp.set_size(Vector2::new(action_bar_width, ACTION_BAR_HEIGHT));
|
||||
|
||||
let visualization_offset = visualization_offset(width);
|
||||
|
@ -172,7 +172,7 @@ impl Model {
|
||||
let index = index as f32;
|
||||
let padding = BUTTON_PADDING;
|
||||
let offset = BUTTON_OFFSET;
|
||||
button.mod_position(|p| p.x = ((1.0 + padding) * index + offset) * icon_size.x);
|
||||
button.set_x(((1.0 + padding) * index + offset) * icon_size.x);
|
||||
button.frp.set_size(icon_size);
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ impl Model {
|
||||
button_width * (button_count + hover_padding + offset + padding) + HOVER_EXTENSION_X;
|
||||
let hover_height = button_width * 2.0;
|
||||
let hover_ara_size = Vector2::new(hover_width, hover_height);
|
||||
self.hover_area.size.set(hover_ara_size);
|
||||
self.hover_area.set_size(hover_ara_size);
|
||||
let center_offset = -size.x / 2.0 + hover_ara_size.x / 2.0;
|
||||
let padding_offset = -0.5 * hover_padding * button_width - HOVER_EXTENSION_X / 2.0;
|
||||
self.hover_area.set_x(center_offset + padding_offset);
|
||||
|
@ -232,7 +232,7 @@ impl Model {
|
||||
let origin = Vector2(TEXT_OFFSET, 0.0);
|
||||
self.ports.set_xy(origin);
|
||||
self.label.set_xy(origin);
|
||||
self.label.mod_position(|t| t.y += TEXT_SIZE / 2.0);
|
||||
self.label.modify_position(|t| t.y += TEXT_SIZE / 2.0);
|
||||
|
||||
self
|
||||
}
|
||||
@ -338,9 +338,9 @@ impl Model {
|
||||
let size = Vector2(width, height);
|
||||
let port_shape = port.payload_mut().init_shape(size, node::HEIGHT);
|
||||
|
||||
port_shape.mod_position(|t| t.x = unit * index as f32);
|
||||
port_shape.set_x(unit * index as f32);
|
||||
if DEBUG {
|
||||
port_shape.mod_position(|t| t.y = DEBUG_PORT_OFFSET)
|
||||
port_shape.set_y(DEBUG_PORT_OFFSET)
|
||||
}
|
||||
|
||||
if is_header {
|
||||
|
@ -102,10 +102,10 @@ impl Shape {
|
||||
let viz = viz::View::new();
|
||||
|
||||
let width_padded = size.x + 2.0 * PADDING_X;
|
||||
hover.size.set(Vector2::new(width_padded, hover_height));
|
||||
viz.size.set(Vector2::new(width_padded, size.y));
|
||||
hover.mod_position(|t| t.x = size.x / 2.0);
|
||||
viz.mod_position(|t| t.x = size.x / 2.0);
|
||||
hover.set_size(Vector2::new(width_padded, hover_height));
|
||||
viz.set_size(Vector2::new(width_padded, size.y));
|
||||
hover.set_x(size.x / 2.0);
|
||||
viz.set_x(size.x / 2.0);
|
||||
viz.color.set(color::Rgba::transparent().into());
|
||||
|
||||
root.add_child(&hover);
|
||||
|
@ -214,7 +214,7 @@ impl Model {
|
||||
self.label.set_property_default(text::Size(input::area::TEXT_SIZE));
|
||||
self.label.remove_all_cursors();
|
||||
|
||||
self.label.mod_position(|t| t.y = input::area::TEXT_SIZE / 2.0);
|
||||
self.label.set_y(input::area::TEXT_SIZE / 2.0);
|
||||
|
||||
self
|
||||
}
|
||||
|
@ -362,8 +362,8 @@ macro_rules! fn_helper {
|
||||
#[allow(unused_variables)]
|
||||
fn $name(&self, $($arg : $arg_tp),*) {
|
||||
match self {
|
||||
Self::Single ($this) => $($body1)*,
|
||||
Self::Multi ($this) => $($body2)*,
|
||||
Self::Single ($this) => { $($body1)* }
|
||||
Self::Multi ($this) => { $($body2)* }
|
||||
}
|
||||
}
|
||||
)*};
|
||||
@ -392,7 +392,7 @@ impl PortShapeView {
|
||||
}
|
||||
|
||||
fn_both! {
|
||||
set_size (this,t:Vector2) {this.size.set(t)}
|
||||
set_size (this,t:Vector2) {this.set_size(t);}
|
||||
set_size_multiplier (this,t:f32) {this.size_multiplier.set(t)}
|
||||
set_color (this,t:color::Rgba) {this.color_rgb.set(t.opaque.into())}
|
||||
set_opacity (this,t:f32) {this.opacity.set(t)}
|
||||
|
@ -173,7 +173,7 @@ impl StatusIndicator {
|
||||
);
|
||||
|
||||
eval frp.input.set_size ((size)
|
||||
model.shape.size.set(*size);
|
||||
model.shape.set_size(*size);
|
||||
);
|
||||
|
||||
has_status <- frp.status.map(|status| status.is_some());
|
||||
|
@ -387,12 +387,12 @@ impl ContainerModel {
|
||||
let dom = self.view.background_dom.dom();
|
||||
let bg_dom = self.fullscreen_view.background_dom.dom();
|
||||
let size = size.into();
|
||||
self.size.set(size);
|
||||
self.display_object().set_size(size);
|
||||
if self.is_fullscreen.get() {
|
||||
// self.fullscreen_view.background.shape.radius.set(CORNER_RADIUS);
|
||||
// self.fullscreen_view.background.shape.sprite.size.set(size);
|
||||
// self.view.background.shape.sprite.size.set(zero());
|
||||
self.view.overlay.size.set(zero());
|
||||
// self.fullscreen_view.background.shape.sprite.set_size(size);
|
||||
// self.view.background.shape.sprite.set_size(zero());
|
||||
self.view.overlay.set_size(Vector2(0.0, 0.0));
|
||||
dom.set_style_or_warn("width", "0");
|
||||
dom.set_style_or_warn("height", "0");
|
||||
bg_dom.set_style_or_warn("width", format!("{}px", size[0]));
|
||||
@ -402,13 +402,13 @@ impl ContainerModel {
|
||||
// self.view.background.shape.radius.set(CORNER_RADIUS);
|
||||
self.view.overlay.radius.set(CORNER_RADIUS);
|
||||
self.view.background.radius.set(CORNER_RADIUS);
|
||||
self.view.overlay.size.set(size);
|
||||
self.view.background.size.set(size + 2.0 * Vector2(PADDING, PADDING));
|
||||
self.view.overlay.set_size(size);
|
||||
self.view.background.set_size(size + 2.0 * Vector2(PADDING, PADDING));
|
||||
dom.set_style_or_warn("width", format!("{}px", size[0]));
|
||||
dom.set_style_or_warn("height", format!("{}px", size[1]));
|
||||
bg_dom.set_style_or_warn("width", "0");
|
||||
bg_dom.set_style_or_warn("height", "0");
|
||||
// self.fullscreen_view.background.shape.sprite.size.set(zero());
|
||||
// self.fullscreen_view.background.shape.sprite.set_size(zero());
|
||||
|
||||
let action_bar_size = Vector2::new(size.x, ACTION_BAR_HEIGHT);
|
||||
self.action_bar.frp.set_size.emit(action_bar_size);
|
||||
@ -651,7 +651,7 @@ impl Container {
|
||||
frp::extend! { network
|
||||
eval_ action_bar.on_container_reset_position(model.drag_root.set_xy(Vector2::zero()));
|
||||
drag_action <- app.cursor.frp.scene_position_delta.gate(&action_bar.container_drag_state);
|
||||
eval drag_action ((mouse) model.drag_root.mod_xy(|pos| pos - mouse.xy()));
|
||||
eval drag_action ((mouse) model.drag_root.update_xy(|pos| pos - mouse.xy()));
|
||||
}
|
||||
|
||||
// FIXME[mm]: If we set the size right here, we will see spurious shapes in some
|
||||
|
@ -181,8 +181,8 @@ impl Icons {
|
||||
fn place_shape_in_slot<S: Shape>(&self, view: &ShapeView<S>, index: usize) {
|
||||
let icon_size = self.icon_size();
|
||||
let index = index as f32;
|
||||
view.mod_position(|p| p.x = index * icon_size.x + node::CORNER_RADIUS);
|
||||
view.size.set(icon_size)
|
||||
view.set_x(index * icon_size.x + node::CORNER_RADIUS);
|
||||
view.set_size(icon_size);
|
||||
}
|
||||
|
||||
fn icon_size(&self) -> Vector2 {
|
||||
@ -197,7 +197,7 @@ impl Icons {
|
||||
}
|
||||
|
||||
fn set_size(&self, size: Vector2) {
|
||||
self.size.set(size);
|
||||
self.display_object().set_size(size);
|
||||
self.icon_root.set_x(-size.x / 2.0);
|
||||
self.place_shape_in_slot(&self.drag_icon, 0);
|
||||
self.place_shape_in_slot(&self.reset_position_icon, 1);
|
||||
@ -288,9 +288,9 @@ impl Model {
|
||||
}
|
||||
|
||||
fn set_size(&self, size: Vector2) {
|
||||
self.size.set(size);
|
||||
self.hover_area.size.set(size);
|
||||
self.background.size.set(size);
|
||||
self.display_object().set_size(size);
|
||||
self.hover_area.set_size(size);
|
||||
self.background.set_size(size);
|
||||
self.icons.set_size(size);
|
||||
|
||||
let height = size.y;
|
||||
|
@ -2085,7 +2085,7 @@ impl GraphEditorModel {
|
||||
pub fn set_node_position(&self, node_id: impl Into<NodeId>, position: Vector2) {
|
||||
let node_id = node_id.into();
|
||||
if let Some(node) = self.nodes.get_cloned_ref(&node_id) {
|
||||
node.mod_position(|t| {
|
||||
node.modify_position(|t| {
|
||||
t.x = position.x;
|
||||
t.y = position.y;
|
||||
});
|
||||
@ -2185,7 +2185,7 @@ impl GraphEditorModel {
|
||||
if let Some(edge) = self.edges.get_cloned_ref(&edge_id) {
|
||||
if let Some(edge_source) = edge.source() {
|
||||
if let Some(node) = self.nodes.get_cloned_ref(&edge_source.node_id) {
|
||||
edge.mod_position(|p| {
|
||||
edge.modify_position(|p| {
|
||||
p.x = node.position().x + node.model().width() / 2.0;
|
||||
p.y = node.position().y;
|
||||
});
|
||||
@ -3286,7 +3286,7 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
|
||||
edge.view.frp.source_height.emit(cursor::DEFAULT_RADIUS);
|
||||
edge.view.frp.target_position.emit(-position.xy());
|
||||
edge.view.frp.redraw.emit(());
|
||||
edge.mod_position(|p| {
|
||||
edge.modify_position(|p| {
|
||||
p.x = position.x;
|
||||
p.y = position.y;
|
||||
});
|
||||
@ -3307,7 +3307,7 @@ fn new_graph_editor(app: &Application) -> GraphEditor {
|
||||
edge.view.frp.source_height.emit(node_height);
|
||||
edge.view.frp.target_position.emit(-node_pos.xy());
|
||||
edge.view.frp.redraw.emit(());
|
||||
edge.mod_position(|p| {
|
||||
edge.modify_position(|p| {
|
||||
p.x = node_pos.x + node_width/2.0;
|
||||
p.y = node_pos.y;
|
||||
});
|
||||
@ -3963,12 +3963,12 @@ mod tests {
|
||||
// Create 2nd node below the 1st one and move it slightly to the right.
|
||||
graph_editor.nodes().select(node_1_id);
|
||||
let (node_2_id, node_2) = graph_editor.add_node_by(&press_add_node_shortcut);
|
||||
node_2.mod_x(|x| x + 16.0);
|
||||
node_2.update_x(|x| x + 16.0);
|
||||
|
||||
// Create 3rd node below the 2nd one and move it slightly down and far to the right.
|
||||
graph_editor.nodes().select(node_2_id);
|
||||
let (_, node_3) = graph_editor.add_node_by(&press_add_node_shortcut);
|
||||
node_2.mod_xy(|pos| pos + Vector2(800.0, -7.0));
|
||||
node_2.update_xy(|pos| pos + Vector2(800.0, -7.0));
|
||||
|
||||
// Create 4th node by clicking (+) button when camera is roughly centered at the 1st node.
|
||||
let small_displacement = Vector2(8.0, 9.0);
|
||||
|
@ -127,7 +127,7 @@ impl Model {
|
||||
/// Set size of the documentation view.
|
||||
fn set_size(&self, size: Vector2) {
|
||||
self.size.set(size);
|
||||
self.overlay.size.set(size);
|
||||
self.overlay.set_size(size);
|
||||
self.reload_style();
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl ProjectList {
|
||||
color <- all(&color,&init)._0();
|
||||
label_size <- all(&label_size,&init)._0();
|
||||
|
||||
eval size ((size) background.size.set(*size));
|
||||
eval size ((size) background.set_size(*size););
|
||||
eval list_size ((size) list.resize(*size));
|
||||
eval list_y ((y) list.set_y(*y));
|
||||
eval caption_xy ((xy) caption.set_xy(*xy));
|
||||
|
@ -26,7 +26,6 @@ use ensogl::application::Application;
|
||||
use ensogl::display;
|
||||
use ensogl::system::web;
|
||||
use ensogl::system::web::dom;
|
||||
use ensogl::Animation;
|
||||
use ensogl::DEPRECATED_Animation;
|
||||
use ensogl_hardcoded_theme::Theme;
|
||||
use ide_view_graph_editor::NodeSource;
|
||||
@ -84,10 +83,6 @@ ensogl::define_endpoints! {
|
||||
undo(),
|
||||
/// Redo the last undone action.
|
||||
redo(),
|
||||
/// Show the prompt informing about tab key if it is not disabled.
|
||||
show_prompt(),
|
||||
/// Disable the prompt. It will be hidden if currently visible.
|
||||
disable_prompt(),
|
||||
// Enable Debug Mode of Graph Editor.
|
||||
enable_debug_mode(),
|
||||
// Disable Debug Mode of Graph Editor.
|
||||
@ -124,30 +119,6 @@ ensogl::define_endpoints! {
|
||||
|
||||
|
||||
|
||||
// ==============
|
||||
// === Shapes ===
|
||||
// ==============
|
||||
|
||||
mod prompt_background {
|
||||
use super::*;
|
||||
|
||||
ensogl::shape! {
|
||||
(style:Style, color_rgba:Vector4<f32>) {
|
||||
let width = Var::<Pixels>::from("input_size.x");
|
||||
let height = Var::<Pixels>::from("input_size.y");
|
||||
|
||||
let corner_radius = style.get_number(ensogl_hardcoded_theme::graph_editor::prompt::background::corner_radius);
|
||||
let shape = Rect((&width,&height));
|
||||
let shape = shape.corners_radius(corner_radius.px());
|
||||
let bg = shape.fill(color_rgba);
|
||||
|
||||
bg.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// =============
|
||||
// === Model ===
|
||||
// =============
|
||||
@ -276,8 +247,6 @@ struct Model {
|
||||
searcher: SearcherVariant,
|
||||
code_editor: code_editor::View,
|
||||
fullscreen_vis: Rc<RefCell<Option<visualization::fullscreen::Panel>>>,
|
||||
prompt_background: prompt_background::View,
|
||||
prompt: ensogl_text::Text,
|
||||
open_dialog: Rc<OpenDialog>,
|
||||
debug_mode_popup: debug_mode_popup::View,
|
||||
}
|
||||
@ -291,8 +260,6 @@ impl Model {
|
||||
let graph_editor = app.new_view::<GraphEditor>();
|
||||
let code_editor = app.new_view::<code_editor::View>();
|
||||
let fullscreen_vis = default();
|
||||
let prompt_background = prompt_background::View::new();
|
||||
let prompt = ensogl_text::Text::new(app);
|
||||
let debug_mode_popup = debug_mode_popup::View::new(app);
|
||||
let window_control_buttons = ARGS.is_in_cloud.unwrap_or_default().as_some_from(|| {
|
||||
let window_control_buttons = app.new_view::<crate::window_control_buttons::View>();
|
||||
@ -303,16 +270,9 @@ impl Model {
|
||||
let window_control_buttons = Immutable(window_control_buttons);
|
||||
let open_dialog = Rc::new(OpenDialog::new(app));
|
||||
|
||||
prompt_background.add_child(&prompt);
|
||||
prompt.set_content("Press the tab key to search for components.");
|
||||
scene.layers.panel.add(&prompt_background);
|
||||
scene.layers.main.remove(&prompt);
|
||||
prompt.add_to_scene_layer(&scene.layers.panel_text);
|
||||
|
||||
display_object.add_child(&graph_editor);
|
||||
display_object.add_child(&code_editor);
|
||||
display_object.add_child(&searcher);
|
||||
display_object.add_child(&prompt_background);
|
||||
display_object.add_child(&debug_mode_popup);
|
||||
display_object.remove_child(&searcher);
|
||||
|
||||
@ -327,8 +287,6 @@ impl Model {
|
||||
searcher,
|
||||
code_editor,
|
||||
fullscreen_vis,
|
||||
prompt_background,
|
||||
prompt,
|
||||
open_dialog,
|
||||
debug_mode_popup,
|
||||
}
|
||||
@ -512,7 +470,6 @@ impl View {
|
||||
let project_list = &model.open_dialog.project_list;
|
||||
let file_browser = &model.open_dialog.file_browser;
|
||||
let searcher_anchor = DEPRECATED_Animation::<Vector2<f32>>::new(network);
|
||||
let prompt_visibility = Animation::new(network);
|
||||
|
||||
// FIXME[WD]: Think how to refactor it, as it needs to be done before model, as we do not
|
||||
// want shader recompilation. Model uses styles already.
|
||||
@ -522,9 +479,6 @@ impl View {
|
||||
app.themes.update();
|
||||
let input_change_delay = frp::io::timer::Timeout::new(network);
|
||||
|
||||
let style_sheet = &scene.style_sheet;
|
||||
let styles = StyleWatchFrp::new(style_sheet);
|
||||
|
||||
if let Some(window_control_buttons) = &*model.window_control_buttons {
|
||||
let initial_size = &window_control_buttons.size.value();
|
||||
model.graph_editor.input.space_for_window_buttons(initial_size);
|
||||
@ -723,48 +677,7 @@ impl View {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// === Prompt ===
|
||||
|
||||
init <- source::<()>();
|
||||
let prompt_bg_color_path = ensogl_hardcoded_theme::graph_editor::prompt::background;
|
||||
let prompt_bg_padding_path = ensogl_hardcoded_theme::graph_editor::prompt::background::padding;
|
||||
let prompt_color_path = ensogl_hardcoded_theme::graph_editor::prompt::text;
|
||||
let prompt_size_path = ensogl_hardcoded_theme::graph_editor::prompt::text::size;
|
||||
let prompt_bg_color = styles.get_color(prompt_bg_color_path);
|
||||
prompt_bg_color <- all(&prompt_bg_color,&init)._0();
|
||||
let prompt_bg_padding = styles.get_number(prompt_bg_padding_path);
|
||||
prompt_bg_padding <- all(&prompt_bg_padding,&init)._0();
|
||||
let prompt_color = styles.get_color(prompt_color_path);
|
||||
prompt_color <- all(&prompt_color,&init)._0();
|
||||
let prompt_size = styles.get_number(prompt_size_path);
|
||||
prompt_size <- all(&prompt_size,&init)._0();
|
||||
|
||||
disable_after_opening_searcher <- frp.searcher.filter_map(|s| s.map(|_| ()));
|
||||
disable <- any(frp.disable_prompt,disable_after_opening_searcher);
|
||||
disabled <- disable.constant(true);
|
||||
show_prompt <- frp.show_prompt.gate_not(&disabled);
|
||||
|
||||
prompt_visibility.target <+ show_prompt.constant(1.0);
|
||||
prompt_visibility.target <+ disable.constant(0.0);
|
||||
_eval <- all_with4(&prompt_visibility.value,&prompt_bg_color,&prompt_color,&prompt_size,
|
||||
f!([model](weight,bg_color,color,size) {
|
||||
let mut bg_color = *bg_color;
|
||||
bg_color.alpha *= weight;
|
||||
let mut color = *color;
|
||||
color.alpha *= weight;
|
||||
model.prompt_background.color_rgba.set(bg_color.into());
|
||||
model.prompt.set_property(.., color);
|
||||
model.prompt.set_property_default(ensogl_text::Size(*size));
|
||||
})
|
||||
);
|
||||
_eval <- all_with3(&model.prompt.width,&prompt_size,&prompt_bg_padding,
|
||||
f!([model](width,size,padding) {
|
||||
model.prompt.set_x(- *width / 2.0);
|
||||
model.prompt_background.size.set(Vector2(*width + padding, *size + padding));
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
// === Disabling Navigation ===
|
||||
|
||||
@ -788,7 +701,6 @@ impl View {
|
||||
}
|
||||
model.searcher.setup_anchor(network, &searcher_anchor.value);
|
||||
init.emit(());
|
||||
std::mem::forget(prompt_visibility);
|
||||
|
||||
Self { model, frp }
|
||||
}
|
||||
@ -850,9 +762,6 @@ impl application::View for View {
|
||||
(Press, "!is_searcher_opened", "cmd o", "show_open_dialog"),
|
||||
(Press, "is_searcher_opened", "escape", "close_searcher"),
|
||||
(Press, "open_dialog_shown", "escape", "close_open_dialog"),
|
||||
(Press, "", "tab", "disable_prompt"),
|
||||
(Press, "", "cmd o", "disable_prompt"),
|
||||
(Press, "", "space", "disable_prompt"),
|
||||
(Press, "", "cmd alt shift t", "toggle_style"),
|
||||
(Press, "", "cmd s", "save_project_snapshot"),
|
||||
(Press, "", "cmd z", "undo"),
|
||||
|
@ -222,7 +222,7 @@ impl Model {
|
||||
0.0
|
||||
};
|
||||
let bg_height = HEIGHT + 2.0 * MAGIC_SHADOW_MARGIN;
|
||||
self.background.size.set(Vector2(bg_width, bg_height));
|
||||
self.background.set_size(Vector2(bg_width, bg_height));
|
||||
self.background.set_y(-HEIGHT / 2.0);
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ impl Model {
|
||||
|
||||
let size = Vector2(width, height);
|
||||
self.shape.set_xy(Vector2(size.x, -size.y) / 2.0);
|
||||
self.shape.size.set(size);
|
||||
self.shape.set_size(size);
|
||||
size
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ async fn adding_node_with_add_node_button() {
|
||||
|
||||
// If there is a free space, the new node is created in the center of screen.
|
||||
let camera = scene.layers.main.camera();
|
||||
camera.mod_xy(|pos| pos + Vector2(1000.0, 1000.0));
|
||||
camera.update_xy(|pos| pos + Vector2(1000.0, 1000.0));
|
||||
wait_a_frame().await;
|
||||
graph_editor.nodes().deselect_all();
|
||||
let (node_id, node_source, _) = add_node_with_add_node_button(&graph_editor, "1").await;
|
||||
|
@ -620,17 +620,6 @@ define_themes! { [light:0, dark:1]
|
||||
,graph_editor::node::actions::button::hovered;
|
||||
toggled_hovered = Lcha(0.55,0.5,0.12,1.0) , Lcha(0.85,0.5,0.12,1.0);
|
||||
}
|
||||
prompt {
|
||||
background = application::background, application::background;
|
||||
background {
|
||||
corner_radius = 14.0, 14.0;
|
||||
padding = 14.0, 14.0;
|
||||
}
|
||||
text = Rgba(0.078,0.067,0.137,0.85) , Lcha(1.0,0.0,0.0,0.7);
|
||||
text {
|
||||
size = 20.0, 20.0;
|
||||
}
|
||||
}
|
||||
add_node_button {
|
||||
margin = 14.0, 14.0;
|
||||
size = 60.0, 60.0;
|
||||
|
@ -315,7 +315,7 @@ impl<Shape: ButtonShape> View<Shape> {
|
||||
let events = &model.shape.events;
|
||||
|
||||
frp::extend! { network
|
||||
eval frp.set_size ((&size) model.shape.size.set(size));
|
||||
eval frp.set_size ((&size) model.shape.set_size(size););
|
||||
frp.source.size <+ frp.set_size;
|
||||
|
||||
// Mouse
|
||||
|
@ -259,7 +259,7 @@ impl DropDownMenu {
|
||||
|
||||
icon_size <- all(frp.input.set_icon_size,frp.input.set_icon_padding);
|
||||
eval icon_size (((size,padding)) {
|
||||
model.icon.size.set(size-2.0*padding);
|
||||
model.icon.set_size(size-2.0*padding);
|
||||
});
|
||||
|
||||
resize_menu <- all(model.selection_menu.size,frp.input.set_icon_size,frp.input.set_menu_offset_y);
|
||||
@ -281,7 +281,7 @@ impl DropDownMenu {
|
||||
overlay_size <- all(model.label.frp.width,frp.input.set_icon_size);
|
||||
eval overlay_size ([model]((text_width,icon_size)) {
|
||||
let size = Vector2::new(text_width + icon_size.x,icon_size.y);
|
||||
model.icon_overlay.size.set(size);
|
||||
model.icon_overlay.set_size(size);
|
||||
model.icon_overlay.set_x(-text_width/2.0);
|
||||
});
|
||||
|
||||
|
@ -121,7 +121,7 @@ impl component::Model for Model {
|
||||
|
||||
impl Model {
|
||||
fn set_size(&self, size: Vector2) {
|
||||
self.background.size.set(size);
|
||||
self.background.set_size(size);
|
||||
}
|
||||
|
||||
fn set_content(&self, t: &str) {
|
||||
|
@ -267,8 +267,8 @@ impl FlameGraph {
|
||||
/// position as the root display object).
|
||||
pub fn set_origin(&mut self, new_origin: f64) {
|
||||
let delta = (self.origin_x - new_origin) as f32;
|
||||
self.marks.iter().for_each(|mark| mark.mod_x(|pos| pos - delta));
|
||||
self.blocks.iter().for_each(|block| block.mod_x(|pos| pos - delta));
|
||||
self.marks.iter().for_each(|mark| mark.update_x(|pos| pos - delta));
|
||||
self.blocks.iter().for_each(|block| block.update_x(|pos| pos - delta));
|
||||
self.origin_x = new_origin
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ impl component::Model for Model {
|
||||
|
||||
impl Model {
|
||||
fn set_size(&self, size: Vector2) {
|
||||
self.background.size.set(size);
|
||||
self.background.set_size(size);
|
||||
}
|
||||
|
||||
fn set_content(&self, t: &str) {
|
||||
|
@ -10,7 +10,6 @@ use enso_frp as frp;
|
||||
use ensogl_core::application::Application;
|
||||
use ensogl_core::data::color;
|
||||
use ensogl_core::display;
|
||||
use ensogl_core::display::geometry::compound::sprite;
|
||||
use ensogl_core::display::scene::Layer;
|
||||
use ensogl_core::display::Attribute;
|
||||
|
||||
@ -150,20 +149,17 @@ pub trait Entry: CloneRef + Debug + display::Object + 'static {
|
||||
// === ShapeWithEntryContour ===
|
||||
|
||||
/// The trait implemented by all shapes sharing the contour of an entry.
|
||||
pub trait ShapeWithEntryContour {
|
||||
pub trait ShapeWithEntryContour: display::Object {
|
||||
/// Padding added to the shape to avoid antialiasing issues.
|
||||
const PADDING_PX: f32 = 5.0;
|
||||
|
||||
/// Get the size parameter.
|
||||
fn size(&self) -> &ProxyParam<sprite::Size>;
|
||||
|
||||
/// Get the corner radius parameter.
|
||||
fn corner_radius(&self) -> &ProxyParam<Attribute<f32>>;
|
||||
|
||||
/// Update shape's contour.
|
||||
fn set_contour(&self, contour: Contour) {
|
||||
let padding = Vector2(Self::PADDING_PX, Self::PADDING_PX) * 2.0;
|
||||
self.size().set(contour.size + padding);
|
||||
self.set_size(contour.size + padding);
|
||||
self.corner_radius().set(contour.corners_radius);
|
||||
}
|
||||
}
|
||||
@ -171,10 +167,6 @@ pub trait ShapeWithEntryContour {
|
||||
macro_rules! implement_shape_with_entry_contour {
|
||||
() => {
|
||||
impl ShapeWithEntryContour for View {
|
||||
fn size(&self) -> &ProxyParam<sprite::Size> {
|
||||
&self.size
|
||||
}
|
||||
|
||||
fn corner_radius(&self) -> &ProxyParam<Attribute<f32>> {
|
||||
&self.corner_radius
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ ensogl_core::shape! {
|
||||
/// Updates the shape's viewport. The position and size of the sprite will be updated. See
|
||||
/// [module's docs](mod@self) for more info.
|
||||
pub fn set_viewport(shape: &View, viewport: Viewport) {
|
||||
shape.size.set(viewport.size());
|
||||
shape.set_size(viewport.size());
|
||||
shape.set_xy(viewport.center_point());
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ impl Model {
|
||||
let height = self.height();
|
||||
let size = Vector2(width, height);
|
||||
let padded_size = size + padding * 2.0;
|
||||
self.background.size.set(padded_size);
|
||||
self.background.set_size(padded_size);
|
||||
let text_origin = Vector2(text_offset - size.x / 2.0, text_size / 2.0);
|
||||
self.label.set_xy(text_origin);
|
||||
padded_size
|
||||
|
@ -236,8 +236,8 @@ impl<E: Entry> Model<E> {
|
||||
let shadow = Vector2(2.0 * SHADOW_PX, 2.0 * SHADOW_PX);
|
||||
let entry_width = view.size.x - 2.0 * entry_padding;
|
||||
self.entries.set_x(-view.size.x / 2.0 + entry_padding);
|
||||
self.background.size.set(view.size + padding + shadow + margin);
|
||||
self.overlay.size.set(view.size + padding + shadow + margin);
|
||||
self.background.set_size(view.size + padding + shadow + margin);
|
||||
self.overlay.set_size(view.size + padding + shadow + margin);
|
||||
self.scrolled_area.set_y(view.size.y / 2.0 - view.position_y);
|
||||
self.entries.update_entries(visible_entries, entry_width, style_prefix);
|
||||
}
|
||||
@ -601,7 +601,7 @@ where E::Model: Default
|
||||
}));
|
||||
eval frp.selection_size ([model](size) {
|
||||
let margin = Vector2(SHAPE_MARGIN, SHAPE_MARGIN);
|
||||
model.selection.size.set(*size + 2.0 * margin)
|
||||
model.selection.set_size(*size + 2.0 * margin);
|
||||
});
|
||||
eval_ frp.hide_selection (model.selection.unset_parent());
|
||||
|
||||
|
@ -204,7 +204,7 @@ impl Model {
|
||||
self.v_scrollbar.set_x(scrollbar_y);
|
||||
self.h_scrollbar.set_x(size.x / 2.0);
|
||||
self.v_scrollbar.set_y(-size.y / 2.0);
|
||||
self.mask.size.set(size);
|
||||
self.mask.set_size(size);
|
||||
self.mask.set_x(size.x / 2.0);
|
||||
self.mask.set_y(-size.y / 2.0);
|
||||
}
|
||||
|
@ -142,11 +142,11 @@ impl Model {
|
||||
/// render the shadow.
|
||||
pub fn set_size(&self, size: Vector2, shadow_padding: Vector2) {
|
||||
let size_with_shadow = size + shadow_padding;
|
||||
self.background.size.set(size_with_shadow);
|
||||
self.left_overflow.size.set(size_with_shadow);
|
||||
self.right_overflow.size.set(size_with_shadow);
|
||||
self.background.set_size(size_with_shadow);
|
||||
self.left_overflow.set_size(size_with_shadow);
|
||||
self.right_overflow.set_size(size_with_shadow);
|
||||
let padding = Vector2(self.padding.get() * 2.0, self.padding.get() * 2.0);
|
||||
self.track.size.set(size_with_shadow - padding);
|
||||
self.track.set_size(size_with_shadow - padding);
|
||||
|
||||
let left_padding = LABEL_OFFSET;
|
||||
let overflow_icon_size = size.y;
|
||||
@ -160,8 +160,8 @@ impl Model {
|
||||
self.right_overflow.set_x(overflow_icon_offset);
|
||||
|
||||
let track_handle_size = Vector2::new(size.y / 2.0, size.y);
|
||||
self.track_handle_left.size.set(track_handle_size);
|
||||
self.track_handle_right.size.set(track_handle_size);
|
||||
self.track_handle_left.set_size(track_handle_size);
|
||||
self.track_handle_right.set_size(track_handle_size);
|
||||
}
|
||||
|
||||
/// Update the position of the captions based on the size of the shape and the text size. Takes
|
||||
|
@ -98,7 +98,7 @@ impl component::Model for Model {
|
||||
|
||||
impl Model {
|
||||
fn set_size(&self, size: Vector2) {
|
||||
self.line.size.set(size + Vector2::new(CAP_WIDTH + HOVER_PADDING, 0.0));
|
||||
self.line.set_size(size + Vector2::new(CAP_WIDTH + HOVER_PADDING, 0.0));
|
||||
}
|
||||
|
||||
fn set_color(&self, color: Lcha) {
|
||||
|
@ -195,7 +195,7 @@ impl Model {
|
||||
.borrow()
|
||||
.deref()
|
||||
.iter()
|
||||
.for_each(|line| line.mod_x(|x| x + delta))
|
||||
.for_each(|line| line.update_x(|x| x + delta))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,9 +243,9 @@ impl Model {
|
||||
/// Set the component size.
|
||||
pub fn set_size(&self, size: Vector2<f32>) {
|
||||
let margin = Vector2(COMPONENT_MARGIN * 2.0, COMPONENT_MARGIN * 2.0);
|
||||
self.background.size.set(size + margin);
|
||||
self.track.size.set(size + margin);
|
||||
self.thumb.size.set(size + margin);
|
||||
self.background.set_size(size + margin);
|
||||
self.track.set_size(size + margin);
|
||||
self.thumb.set_size(size + margin);
|
||||
}
|
||||
|
||||
/// Set the color of the slider track or thumb.
|
||||
@ -299,8 +299,8 @@ impl Model {
|
||||
pub fn set_overflow_marker_shape(&self, (size, orientation): &(f32, SliderOrientation)) {
|
||||
let margin = Vector2(COMPONENT_MARGIN * 2.0, COMPONENT_MARGIN * 2.0);
|
||||
let size = Vector2(*size, *size) * OVERFLOW_MARKER_SIZE + margin;
|
||||
self.overflow_lower.size.set(size);
|
||||
self.overflow_upper.size.set(size);
|
||||
self.overflow_lower.set_size(size);
|
||||
self.overflow_upper.set_size(size);
|
||||
match orientation {
|
||||
SliderOrientation::Horizontal => {
|
||||
self.overflow_lower.set_rotation_z(std::f32::consts::FRAC_PI_2);
|
||||
|
@ -72,7 +72,7 @@ def_unit!(SdfWeight(f32) = 0.0);
|
||||
macro_rules! with_formatting_properties {
|
||||
($macro_name:ident) => {
|
||||
$macro_name! {
|
||||
size : Size,
|
||||
font_size : Size,
|
||||
color : color::Lcha,
|
||||
weight : Weight,
|
||||
width : Width,
|
||||
@ -445,7 +445,7 @@ impl<T: Copy + Debug> Spanned<T> {
|
||||
macro_rules! with_formatting_property_diffs {
|
||||
($macro_name:ident) => {
|
||||
$macro_name! {
|
||||
Size: f32 = 0.0,
|
||||
FontSize: f32 = 0.0,
|
||||
Weight: i32 = 0,
|
||||
Width: i32 = 0,
|
||||
SdfWeight: f32 = 0.0,
|
||||
@ -502,8 +502,8 @@ pub trait PropertyDiffApply<Diff> {
|
||||
fn apply_diff(&self, diff: Diff) -> Self;
|
||||
}
|
||||
|
||||
impl PropertyDiffApply<SizeDiff> for Size {
|
||||
fn apply_diff(&self, diff: SizeDiff) -> Self {
|
||||
impl PropertyDiffApply<FontSizeDiff> for Size {
|
||||
fn apply_diff(&self, diff: FontSizeDiff) -> Self {
|
||||
let value = self.value + diff.value;
|
||||
let value = if value < 0.0 { 0.0 } else { value };
|
||||
Size { value }
|
||||
|
@ -309,7 +309,7 @@ impl View {
|
||||
let x = x + truncation.x_after_last_glyph();
|
||||
truncation.ellipsis.set_xy(Vector2(x, truncation.y()));
|
||||
truncation.ellipsis.scale.set(truncation.scale);
|
||||
truncation.ellipsis.size.set(truncation.dim());
|
||||
truncation.ellipsis.set_size(truncation.dim());
|
||||
let was_truncated = self.truncation.borrow().is_some();
|
||||
*self.truncation.borrow_mut() = Some(truncation);
|
||||
if !was_truncated {
|
||||
|
@ -183,7 +183,7 @@ impl Selection {
|
||||
f!([model](ascender,descender) {
|
||||
let height = ascender - descender;
|
||||
model.view.set_y(height / 2.0 + descender);
|
||||
model.view.size.modify(|t| Vector2(t.x, CURSOR_PADDING * 2.0 + height));
|
||||
model.view.set_size_y(CURSOR_PADDING * 2.0 + height);
|
||||
})
|
||||
);
|
||||
|
||||
@ -219,7 +219,7 @@ impl Selection {
|
||||
let view_x = (abs_width/2.0) * side;
|
||||
model.display_object.set_xy(*p);
|
||||
model.right_side.set_x(abs_width);
|
||||
model.view.size.modify(|t| Vector2(view_width,t.y));
|
||||
model.view.set_size_x(view_width);
|
||||
model.view.set_x(view_x);
|
||||
})
|
||||
);
|
||||
|
@ -725,7 +725,7 @@ impl TextModel {
|
||||
let lines = Lines::new(Self::new_line_helper(
|
||||
&app.display.default_scene.frp.frame_time,
|
||||
&display_object,
|
||||
buffer.formatting.size().default.value,
|
||||
buffer.formatting.font_size().default.value,
|
||||
));
|
||||
let width_dirty = default();
|
||||
let height_dirty = default();
|
||||
@ -782,7 +782,7 @@ impl TextModel {
|
||||
let line = Self::new_line_helper(
|
||||
&self.app.display.default_scene.frp.frame_time,
|
||||
&self.display_object,
|
||||
self.buffer.formatting.size().default.value,
|
||||
self.buffer.formatting.font_size().default.value,
|
||||
);
|
||||
self.init_line(&line);
|
||||
line
|
||||
@ -1300,7 +1300,7 @@ impl TextModel {
|
||||
let mut column = Column(0);
|
||||
let mut to_be_truncated = 0;
|
||||
let mut truncated = false;
|
||||
let default_size = self.buffer.formatting.size().default;
|
||||
let default_size = self.buffer.formatting.font_size().default;
|
||||
let line_index = Line::from_in_context_snapped(self, view_line);
|
||||
self.with_shaped_line(line_index, |shaped_line| {
|
||||
match shaped_line {
|
||||
@ -1336,7 +1336,8 @@ impl TextModel {
|
||||
let style = line_style_iter.next().unwrap_or_default();
|
||||
prev_cluster_byte_off = glyph_byte_start;
|
||||
|
||||
let scale = shaped_glyph_set.units_per_em as f32 / style.size.value;
|
||||
let scale =
|
||||
shaped_glyph_set.units_per_em as f32 / style.font_size.value;
|
||||
let ascender = shaped_glyph_set.ascender as f32 / scale;
|
||||
let descender = shaped_glyph_set.descender as f32 / scale;
|
||||
let gap = shaped_glyph_set.line_gap as f32 / scale;
|
||||
@ -1361,11 +1362,14 @@ impl TextModel {
|
||||
line_metrics = line_metrics.concat(Some(glyph_line_metrics));
|
||||
|
||||
let render_info = &shaped_glyph.render_info;
|
||||
let glyph_render_offset = render_info.offset.scale(style.size.value);
|
||||
let glyph_render_offset =
|
||||
render_info.offset.scale(style.font_size.value);
|
||||
glyph.set_color(style.color);
|
||||
glyph.skip_color_animation();
|
||||
glyph.set_sdf_weight(style.sdf_weight.value);
|
||||
glyph.set_size(formatting::Size(style.size.value * magic_scale));
|
||||
glyph.set_font_size(formatting::Size(
|
||||
style.font_size.value * magic_scale,
|
||||
));
|
||||
glyph.set_properties(shaped_glyph_set.non_variable_variations);
|
||||
glyph.set_glyph_id(shaped_glyph.id());
|
||||
glyph.x_advance.set(x_advance);
|
||||
@ -1388,7 +1392,7 @@ impl TextModel {
|
||||
let line_style = self.buffer.sub_style(*offset..);
|
||||
let mut line_style_iter = line_style.iter_bytes();
|
||||
let style = line_style_iter.next().unwrap_or_default();
|
||||
let scale = shaped_glyph_set.units_per_em as f32 / style.size.value;
|
||||
let scale = shaped_glyph_set.units_per_em as f32 / style.font_size.value;
|
||||
let ascender = shaped_glyph_set.ascender as f32 / scale;
|
||||
let descender = shaped_glyph_set.descender as f32 / scale;
|
||||
let gap = shaped_glyph_set.line_gap as f32 / scale;
|
||||
@ -1469,7 +1473,7 @@ impl TextModel {
|
||||
if let Some(cursor) = &last_cursor {
|
||||
cursor.right_side().add_child(glyph);
|
||||
glyph.attached_to_cursor.set(true);
|
||||
glyph.mod_x(|p| p - last_cursor_target_x);
|
||||
glyph.update_x(|p| p - last_cursor_target_x);
|
||||
attached_glyphs.push(glyph.downgrade());
|
||||
}
|
||||
column += Column(1);
|
||||
@ -1491,7 +1495,7 @@ impl TextModel {
|
||||
if let Some(glyph) = glyph.upgrade() {
|
||||
self.lines.borrow_mut()[line].add_child(&glyph);
|
||||
let pos_x = selection.position_target.value().x;
|
||||
glyph.mod_xy(|pos| Vector2(pos.x + pos_x, 0.0));
|
||||
glyph.update_xy(|pos| Vector2(pos.x + pos_x, 0.0));
|
||||
glyph.attached_to_cursor.set(false);
|
||||
}
|
||||
}
|
||||
@ -1513,7 +1517,7 @@ impl TextModel {
|
||||
fn property_change_invalidates_cache(property: impl Into<formatting::PropertyTag>) -> bool {
|
||||
let tag = property.into();
|
||||
match tag {
|
||||
formatting::PropertyTag::Size => true,
|
||||
formatting::PropertyTag::FontSize => true,
|
||||
formatting::PropertyTag::Color => false,
|
||||
formatting::PropertyTag::Weight => true,
|
||||
formatting::PropertyTag::Width => true,
|
||||
|
@ -16,7 +16,7 @@ use ensogl_core::application::command::FrpNetworkProvider;
|
||||
use ensogl_core::data::color;
|
||||
use ensogl_core::data::color::Rgba;
|
||||
use ensogl_core::display;
|
||||
use ensogl_core::display::layout::Alignment;
|
||||
use ensogl_core::display::layout::alignment;
|
||||
use ensogl_core::display::scene::Scene;
|
||||
use ensogl_core::display::symbol::geometry::SpriteSystem;
|
||||
use ensogl_core::display::symbol::material::Material;
|
||||
@ -194,7 +194,7 @@ impl ensogl_core::display::shape::CustomSystemData<glyph_shape::Shape> for Syste
|
||||
*data.model.geometry_material.borrow_mut() = SpriteSystem::default_geometry_material();
|
||||
data.model.do_not_use_shape_definition.set(true);
|
||||
|
||||
sprite_system.set_alignment(Alignment::bottom_left());
|
||||
sprite_system.unsafe_set_alignment(alignment::Dim2::left_bottom());
|
||||
scene.variables.add("msdf_range", GlyphRenderInfo::MSDF_PARAMS.range as f32);
|
||||
scene.variables.add("msdf_size", size);
|
||||
|
||||
@ -409,12 +409,12 @@ impl Glyph {
|
||||
}
|
||||
|
||||
/// Size getter.
|
||||
pub fn size(&self) -> Size {
|
||||
pub fn font_size(&self) -> Size {
|
||||
Size(self.view.font_size.get())
|
||||
}
|
||||
|
||||
/// Size setter.
|
||||
pub fn set_size(&self, size: Size) {
|
||||
pub fn set_font_size(&self, size: Size) {
|
||||
let size = size.value;
|
||||
self.view.font_size.set(size);
|
||||
let opt_glyph_info = self.view.data.borrow().font.glyph_info(
|
||||
@ -423,7 +423,7 @@ impl Glyph {
|
||||
self.glyph_id.get(),
|
||||
);
|
||||
if let Some(glyph_info) = opt_glyph_info {
|
||||
self.view.size.set(glyph_info.scale.scale(size))
|
||||
self.view.set_size(glyph_info.scale.scale(size));
|
||||
} else {
|
||||
error!("Cannot find glyph render info for glyph id: {:?}.", self.glyph_id.get());
|
||||
}
|
||||
@ -443,7 +443,7 @@ impl Glyph {
|
||||
if let Some(glyph_info) = opt_glyph_info {
|
||||
self.view.atlas_index.set(glyph_info.msdf_texture_glyph_id as f32);
|
||||
self.update_atlas();
|
||||
self.view.size.set(glyph_info.scale.scale(self.size().value));
|
||||
self.view.set_size(glyph_info.scale.scale(self.font_size().value));
|
||||
} else {
|
||||
// This should not happen. Fonts contain special glyph for missing characters.
|
||||
warn!("Cannot find glyph render info for glyph id: {:?}.", glyph_id);
|
||||
|
@ -227,12 +227,12 @@ impl<Shape: ColorableShape + 'static> ToggleButton<Shape> {
|
||||
|
||||
// === Input Processing ===
|
||||
|
||||
eval frp.set_size ((size) model.icon.size.set(*size));
|
||||
eval frp.set_size ((size) model.icon.set_size(*size););
|
||||
|
||||
|
||||
// === State ===
|
||||
|
||||
toggle <- any_(frp.toggle,icon.mouse_down_primary);
|
||||
toggle <- any_(frp.toggle, icon.mouse_down_primary);
|
||||
frp.source.state <+ frp.state.not().sample(&toggle);
|
||||
frp.source.state <+ frp.set_state;
|
||||
|
||||
|
@ -45,15 +45,12 @@ impl BoundingBox {
|
||||
BoundingBox { top, bottom, left, right }
|
||||
}
|
||||
|
||||
/// Return a bounding box given by the position and size. The position interpreted as the
|
||||
/// top-right corner and size as the extension along the positive x and y-axis. Negative sizes
|
||||
/// are valid.
|
||||
/// Constructor.
|
||||
pub fn from_position_and_size(position: Vector2, size: Vector2) -> Self {
|
||||
Self::from_corners(position, position + size)
|
||||
}
|
||||
|
||||
/// Return a bounding box given by the center and size. Negative sizes
|
||||
/// are valid.
|
||||
/// Constructor.
|
||||
pub fn from_center_and_size(position: Vector2, size: Vector2) -> Self {
|
||||
Self::from_corners(position - size / 2.0, position + size / 2.0)
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ impl Camera2dData {
|
||||
let display_object = display::object::Instance::new();
|
||||
let zoom_update_registry = default();
|
||||
let screen_update_registry = default();
|
||||
display_object.mod_position(|p| p.z = 1.0);
|
||||
display_object.modify_position(|p| p.z = 1.0);
|
||||
dirty.projection.set();
|
||||
let network = frp::Network::new("Camera2d");
|
||||
frp::extend! { network
|
||||
@ -363,11 +363,11 @@ impl Camera2dData {
|
||||
}
|
||||
|
||||
fn set_rotation(&mut self, yaw: f32, pitch: f32, roll: f32) {
|
||||
self.display_object.mod_rotation(|r| *r = Vector3::new(yaw, pitch, roll))
|
||||
self.display_object.modify_rotation(|r| *r = Vector3::new(yaw, pitch, roll))
|
||||
}
|
||||
|
||||
fn mod_position_keep_zoom<F: FnOnce(&mut Vector3<f32>)>(&mut self, f: F) {
|
||||
self.display_object.mod_position(f)
|
||||
self.display_object.modify_position(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,5 +6,3 @@
|
||||
// ==============
|
||||
|
||||
pub mod alignment;
|
||||
|
||||
pub use alignment::Alignment;
|
||||
|
@ -4,110 +4,437 @@ use crate::prelude::*;
|
||||
|
||||
|
||||
|
||||
// =================
|
||||
// === Alignment ===
|
||||
// =================
|
||||
// ===============================
|
||||
// === 1-dimensional Alignment ===
|
||||
// ===============================
|
||||
|
||||
/// Alignment abstraction. Example usage is camera origin placement allowing it to behave correctly
|
||||
/// when scaling the scene.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
/// One-dimensional alignment.
|
||||
///
|
||||
/// In one dimension the alignment is either start, center, or end. In 2 dimensions, [`Start`] means
|
||||
/// "left" horizontally and "bottom" vertically, while [`End`] means "right" horizontally and "top"
|
||||
/// vertically.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct Alignment {
|
||||
pub horizontal: Horizontal,
|
||||
pub vertical: Vertical,
|
||||
}
|
||||
|
||||
/// Horizontal alignments.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum Horizontal {
|
||||
Left,
|
||||
pub enum Dim1 {
|
||||
Start,
|
||||
Center,
|
||||
Right,
|
||||
End,
|
||||
}
|
||||
|
||||
/// Vertical alignments.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
/// Constructors
|
||||
#[allow(missing_docs)]
|
||||
pub enum Vertical {
|
||||
Top,
|
||||
Center,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
|
||||
// === Smart Constructors ===
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[allow(missing_docs)]
|
||||
impl Alignment {
|
||||
/// Constructor.
|
||||
pub fn new(horizontal: Horizontal, vertical: Vertical) -> Self {
|
||||
Self { horizontal, vertical }
|
||||
impl Dim1 {
|
||||
pub fn left() -> Self {
|
||||
Self::Start
|
||||
}
|
||||
|
||||
pub fn center() -> Self {
|
||||
Self::new(Horizontal::Center, Vertical::Center)
|
||||
Self::Center
|
||||
}
|
||||
pub fn bottom_left() -> Self {
|
||||
Self::new(Horizontal::Left, Vertical::Bottom)
|
||||
pub fn right() -> Self {
|
||||
Self::End
|
||||
}
|
||||
pub fn bottom_right() -> Self {
|
||||
Self::new(Horizontal::Right, Vertical::Bottom)
|
||||
pub fn bottom() -> Self {
|
||||
Self::Start
|
||||
}
|
||||
pub fn bottom_center() -> Self {
|
||||
Self::new(Horizontal::Center, Vertical::Bottom)
|
||||
}
|
||||
pub fn top_left() -> Self {
|
||||
Self::new(Horizontal::Left, Vertical::Top)
|
||||
}
|
||||
pub fn top_right() -> Self {
|
||||
Self::new(Horizontal::Right, Vertical::Top)
|
||||
}
|
||||
pub fn top_center() -> Self {
|
||||
Self::new(Horizontal::Center, Vertical::Top)
|
||||
}
|
||||
pub fn center_left() -> Self {
|
||||
Self::new(Horizontal::Left, Vertical::Center)
|
||||
}
|
||||
pub fn center_right() -> Self {
|
||||
Self::new(Horizontal::Right, Vertical::Center)
|
||||
pub fn top() -> Self {
|
||||
Self::End
|
||||
}
|
||||
}
|
||||
|
||||
impl Dim1 {
|
||||
/// A normalized value of the alignment, in the range [0.0, 1.0].
|
||||
pub fn normalized(self) -> f32 {
|
||||
match self {
|
||||
Dim1::Start => 0.0,
|
||||
Dim1::Center => 0.5,
|
||||
Dim1::End => 1.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// === Defaults ===
|
||||
|
||||
impl Default for Horizontal {
|
||||
impl Default for Dim1 {
|
||||
fn default() -> Self {
|
||||
Self::Left
|
||||
}
|
||||
}
|
||||
impl Default for Vertical {
|
||||
fn default() -> Self {
|
||||
Self::Bottom
|
||||
}
|
||||
}
|
||||
impl Default for Alignment {
|
||||
fn default() -> Self {
|
||||
let horizontal = default();
|
||||
let vertical = default();
|
||||
Self { horizontal, vertical }
|
||||
Self::Start
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Horizontal> for Horizontal {
|
||||
fn from(t: &Horizontal) -> Self {
|
||||
impl From<&Dim1> for Dim1 {
|
||||
fn from(t: &Dim1) -> Self {
|
||||
*t
|
||||
}
|
||||
}
|
||||
impl From<&Vertical> for Vertical {
|
||||
fn from(t: &Vertical) -> Self {
|
||||
*t
|
||||
|
||||
|
||||
|
||||
// ========================================
|
||||
// === 1-dimensional Optional Alignment ===
|
||||
// ========================================
|
||||
|
||||
/// Optional version of `Dim1`. It expresses an alignment that could not be set. It can be used for
|
||||
/// example as an alignment override.
|
||||
#[derive(Clone, Copy, Debug, Deref, DerefMut, Default, PartialEq, Eq, From)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct OptDim1 {
|
||||
pub value: Option<Dim1>,
|
||||
}
|
||||
|
||||
/// Constructors
|
||||
#[allow(missing_docs)]
|
||||
impl OptDim1 {
|
||||
pub fn left() -> Self {
|
||||
Self::from(Some(Dim1::left()))
|
||||
}
|
||||
pub fn center() -> Self {
|
||||
Self::from(Some(Dim1::center()))
|
||||
}
|
||||
pub fn right() -> Self {
|
||||
Self::from(Some(Dim1::right()))
|
||||
}
|
||||
pub fn bottom() -> Self {
|
||||
Self::from(Some(Dim1::bottom()))
|
||||
}
|
||||
pub fn top() -> Self {
|
||||
Self::from(Some(Dim1::top()))
|
||||
}
|
||||
}
|
||||
impl From<&Alignment> for Alignment {
|
||||
fn from(t: &Alignment) -> Self {
|
||||
*t
|
||||
|
||||
|
||||
|
||||
// ===============================
|
||||
// === 2-dimensional Alignment ===
|
||||
// ===============================
|
||||
|
||||
/// Two-dimensional alignment. It is equivalent to [`Vector2<Dim1>`], but also has many handy
|
||||
/// associated functions.
|
||||
#[derive(Clone, Copy, Debug, Deref, Default, PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct Dim2 {
|
||||
pub vector: Vector2<Dim1>,
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
impl Dim2 {
|
||||
/// Constructor.
|
||||
pub fn new(horizontal: Dim1, vertical: Dim1) -> Self {
|
||||
Self { vector: Vector2(horizontal, vertical) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Dim2 {
|
||||
/// A normalized value of the alignment, in the range [0.0, 1.0].
|
||||
pub fn normalized(self) -> Vector2<f32> {
|
||||
Vector2(self.vector.x.normalized(), self.vector.y.normalized())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ========================================
|
||||
// === 2-dimensional Optional Alignment ===
|
||||
// ========================================
|
||||
|
||||
/// Optional version of `Dim2`. It expresses an alignment that could not be set. It can be used for
|
||||
/// example as an alignment override.
|
||||
#[derive(Clone, Copy, Debug, Deref, DerefMut, Default, PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct OptDim2 {
|
||||
pub vector: Vector2<OptDim1>,
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
impl OptDim2 {
|
||||
/// Constructor.
|
||||
pub fn new(horizontal: OptDim1, vertical: OptDim1) -> Self {
|
||||
Self { vector: Vector2(horizontal, vertical) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ======================================
|
||||
// === 2-dimensional Alignment Macros ===
|
||||
// ======================================
|
||||
|
||||
/// Runs the provided macro with two alignment anchor arrays, one for horizontal and one for
|
||||
/// vertical. For example, if run with the arguments `f [args]`, it results in:
|
||||
///
|
||||
/// ```text
|
||||
/// f!{ [args] [left center right] [bottom center top] }
|
||||
/// ```
|
||||
///
|
||||
/// The `[args]` argument is optional.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_dim2_anchors {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$f! { $([$($args)*])? [left center right] [bottom center top] }
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs the provided macro with an alignment anchor matrix. For example, if run with the arguments
|
||||
/// `f [args]`, it results in:
|
||||
///
|
||||
/// ```text
|
||||
/// f!{ [args] [left bottom] [left center] ... [center bottom] ... [bottom top] }
|
||||
/// ```
|
||||
///
|
||||
/// The `[args]` argument is optional.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_dim2_anchors_cartesian {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$crate::with_alignment_dim2_anchors! {enso_shapely::cartesian [$f $([$($args)*])?] }
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs the provided macro with an alignment anchor matrix annotated with a name for the anchor
|
||||
/// pair. The name is created as `$x_$y` with the exception for both anchors being `center`, then
|
||||
/// the name is simply `center`. For example, if run with the arguments `f [args]`, it results in:
|
||||
///
|
||||
/// ```text
|
||||
/// f!{ [args]
|
||||
/// [left_bottom left bottom]
|
||||
/// [left_center left center]
|
||||
/// ...
|
||||
/// [center_bottom center bottom]
|
||||
/// [center center center]
|
||||
/// [center_top center top]
|
||||
/// ...
|
||||
/// [bottom top]
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// The `[args]` argument is optional.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_dim2_named_anchors_cartesian {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$crate::with_alignment_dim2_anchors_cartesian! {
|
||||
$crate::with_alignment_dim2_named_anchors_cartesian [$f $([$($args)*])?]
|
||||
}
|
||||
};
|
||||
([$($fs:tt)*] $($ts:tt)*) => {
|
||||
$crate::with_alignment_dim2_named_anchors_cartesian! {@ [$($fs)*] [] $($ts)*}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[center center] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_dim2_named_anchors_cartesian! {@ $fs [$($out)* [center center center]] [$($ts)*]}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[$x:ident $y:ident] $($ts:tt)*]) => { paste! {
|
||||
$crate::with_alignment_dim2_named_anchors_cartesian! {@ $fs [$($out)* [[<$x _ $y>] $x $y]] [$($ts)*]}
|
||||
}};
|
||||
(@ [$f:path $([$($args:tt)*])?] $out:tt []) => {
|
||||
$f! { $([$($args)*])? $out }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===============================================
|
||||
// === 2-dimensional Optional Alignment Macros ===
|
||||
// ===============================================
|
||||
|
||||
/// Runs the provided macro with two arrays of anchors for horizontal and vertical alignment.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_opt_dim2_anchors {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$f! { $([$($args)*])?
|
||||
[[left] [center] [right] [default] []]
|
||||
[[bottom] [center] [top] [default] []]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs the provided macro with an alignment anchor matrix. For example, if run with the arguments
|
||||
/// `f [args]`, it results in:
|
||||
///
|
||||
/// ```text
|
||||
/// f!{ [args] [left bottom] [left center] ... [center bottom] ... [bottom top] }
|
||||
/// ```
|
||||
///
|
||||
/// The `[args]` argument is optional.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_opt_dim2_matrix {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$crate::with_alignment_opt_dim2_anchors! {enso_shapely::cartesian [$f $([$($args)*])?] }
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs the provided macro with an optional alignment anchor matrix. The passed values are of form
|
||||
/// `[name [x_anchor] [y_anchor]]`. The values [`x_anchor`] and [`y_anchor`] are optional and can be
|
||||
/// missing. The name is created as `$x_$y` with the exception for both anchors being 'center' or
|
||||
/// 'default', when the name is simply 'center' or 'default', respectively. For example, if run with
|
||||
/// the arguments `f [args]`, it results in:
|
||||
///
|
||||
/// ```text
|
||||
/// f!{
|
||||
/// [left_bottom [left][bottom]]
|
||||
/// [left_center [left][center]]
|
||||
/// [left_top [left][top]]
|
||||
/// [left_default [left][default]]
|
||||
/// [left [left][]]
|
||||
/// ...
|
||||
/// ```
|
||||
/// The 'default' value means that the alignment should be set to its default value. The `[args]`
|
||||
/// argument is optional.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_opt_dim2_named_matrix_sparse {
|
||||
($(#$meta:tt)* $f:path $([$($args:tt)*])?) => {
|
||||
$crate::with_alignment_opt_dim2_matrix! {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse [$(#$meta)* $f $([$($args)*])?]
|
||||
}
|
||||
};
|
||||
([$($fs:tt)*] $($ts:tt)*) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {@ [$($fs)*] [] $($ts)*}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[center] [center]] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [center [center] [center]]] [$($ts)*]
|
||||
}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[center] []] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [center_x [center] []]] [$($ts)*]
|
||||
}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[] [center]] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [center_y [] [center]]] [$($ts)*]
|
||||
}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[default] [default]] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [default [default] [default]]] [$($ts)*]
|
||||
}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[default] []] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [default_x [default] []]] [$($ts)*]
|
||||
}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[] [default]] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [default_y [] [default]]] [$($ts)*]
|
||||
}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[[$x:ident] [$y:ident]] $($ts:tt)*]) => { paste! {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [[<$x _ $y>] [$x] [$y]]] [$($ts)*]
|
||||
}
|
||||
}};
|
||||
(@ $fs:tt [$($out:tt)*] [[[$x:ident] []] $($ts:tt)*]) => { paste! {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [[<$x>] [$x] []]] [$($ts)*]
|
||||
}
|
||||
}};
|
||||
(@ $fs:tt [$($out:tt)*] [[[] [$y:ident]] $($ts:tt)*]) => { paste! {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
@ $fs [$($out)* [[<$y>] [] [$y]]] [$($ts)*]
|
||||
}
|
||||
}};
|
||||
(@ $fs:tt [$($out:tt)*] [[[] []] $($ts:tt)*]) => { paste! {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {@ $fs [$($out)*] [$($ts)*]}
|
||||
}};
|
||||
(@ [$(#$meta:tt)* $f:path $([$($args:tt)*])?] $out:tt []) => {
|
||||
$f! { $(#$meta)* $([$($args)*])? $out }
|
||||
};
|
||||
}
|
||||
|
||||
/// Runs the provided macro with an optional alignment anchor matrix. For example, if run with the
|
||||
/// arguments `f [args]`, it results in:
|
||||
///
|
||||
/// ```text
|
||||
/// f!{
|
||||
/// [left_bottom [left][bottom]]
|
||||
/// [left_center [left][center]]
|
||||
/// [left_top [left][top]]
|
||||
/// [left_default [left][default]]
|
||||
/// [center_bottom [center][bottom]]
|
||||
/// ...
|
||||
/// ```
|
||||
/// The 'default' value means that the alignment should be set to its default value. The `[args]`
|
||||
/// argument is optional.
|
||||
#[macro_export]
|
||||
macro_rules! with_alignment_opt_dim2_named_matrix {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix_sparse! {
|
||||
$crate::with_alignment_opt_dim2_named_matrix [$f $([$($args)*])?]
|
||||
}
|
||||
};
|
||||
([$($fs:tt)*] $($ts:tt)*) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix! {@ [$($fs)*] [] $($ts)*}
|
||||
};
|
||||
(@ $fs:tt [$($out:tt)*] [[$n:ident [$x:ident] [$y:ident]] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix! {@ $fs [$($out)* [$n [$x] [$y]]] [$($ts)*]}
|
||||
};
|
||||
(@ $fs:tt $out:tt [[$n:ident [$x:ident] []] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix! {@ $fs $out [$($ts)*]}
|
||||
};
|
||||
(@ $fs:tt $out:tt [[$n:ident [] [$y:ident]] $($ts:tt)*]) => {
|
||||
$crate::with_alignment_opt_dim2_named_matrix! {@ $fs $out [$($ts)*]}
|
||||
};
|
||||
(@ [$f:path $([$($args:tt)*])?] $out:tt []) => {
|
||||
$f! { $([$($args)*])? $out }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ============================================
|
||||
// === 2-dimensional Alignment Constructors ===
|
||||
// ============================================
|
||||
|
||||
macro_rules! gen_dim2_cons {
|
||||
([$([$f:ident $x:ident $y:ident])*]) => { paste! {
|
||||
impl Dim2 {$(
|
||||
/// Constructor.
|
||||
pub fn $f() -> Self {
|
||||
Self::new(Dim1::$x(), Dim1::$y())
|
||||
}
|
||||
|
||||
/// Change the alignment.
|
||||
pub fn [<align_ $f>](&mut self) {
|
||||
*self = Self::$f();
|
||||
}
|
||||
)*}
|
||||
}}
|
||||
}
|
||||
|
||||
with_alignment_dim2_named_anchors_cartesian!(gen_dim2_cons);
|
||||
|
||||
|
||||
|
||||
// =====================================================
|
||||
// === 2-dimensional Optional Alignment Constructors ===
|
||||
// =====================================================
|
||||
|
||||
macro_rules! gen_opt_dim2_cons {
|
||||
([$([$f:ident [$x:ident] [$y:ident]])*]) => {
|
||||
// We disable the clippy check because we are generating a `default` method here.
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
impl OptDim2 {$(
|
||||
/// Constructor.
|
||||
pub fn $f() -> Self {
|
||||
Self::new(OptDim1::$x(), OptDim1::$y())
|
||||
}
|
||||
)*}
|
||||
}
|
||||
}
|
||||
|
||||
with_alignment_opt_dim2_named_matrix!(gen_opt_dim2_cons);
|
||||
|
||||
|
||||
|
||||
// ================================================
|
||||
// === 2-dimensional Optional Alignment Setters ===
|
||||
// ================================================
|
||||
|
||||
macro_rules! gen_opt_dim2_setters {
|
||||
([$([$f:ident [$($x:ident)?] [$($y:ident)?]])*]) => { paste! {
|
||||
impl OptDim2 {$(
|
||||
/// Constructor.
|
||||
pub fn [<align_ $f>](&mut self) {
|
||||
$(self.x = OptDim1::$x();)?
|
||||
$(self.y = OptDim1::$y();)?
|
||||
}
|
||||
)*}
|
||||
}}
|
||||
}
|
||||
|
||||
with_alignment_opt_dim2_named_matrix_sparse!(gen_opt_dim2_setters);
|
||||
|
@ -11,6 +11,7 @@ use crate::display::scene::layer::Layer;
|
||||
|
||||
pub mod event;
|
||||
pub mod instance;
|
||||
pub mod layout;
|
||||
pub mod transformation;
|
||||
|
||||
pub use instance::Any;
|
||||
@ -25,6 +26,8 @@ pub use instance::*;
|
||||
/// Common traits.
|
||||
pub mod traits {
|
||||
// Read the Rust Style Guide to learn more about the used naming.
|
||||
pub use super::AutoLayoutOps as TRAIT_AutoLayoutOps;
|
||||
pub use super::LayoutOps as TRAIT_LayoutOps;
|
||||
pub use super::Object as TRAIT_Object;
|
||||
pub use super::ObjectOps as TRAIT_ObjectOps;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
251
lib/rust/ensogl/core/src/display/object/layout.rs
Normal file
251
lib/rust/ensogl/core/src/display/object/layout.rs
Normal file
@ -0,0 +1,251 @@
|
||||
//! Display object layout utilities.
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
use unit2::Fraction;
|
||||
use unit2::Percent;
|
||||
|
||||
|
||||
|
||||
// ============
|
||||
// === Unit ===
|
||||
// ============
|
||||
|
||||
/// Unit for display object layout.
|
||||
#[derive(Clone, Copy, Debug, Display, PartialEq, From)]
|
||||
pub enum Unit {
|
||||
/// Pixel distance.
|
||||
Pixels(f32),
|
||||
/// Fraction of the unused space, if any. For example, if you set the layout gap to be
|
||||
/// `1.fr()`, all the gaps will have the same size to fill all the space in the parent
|
||||
/// container.
|
||||
Fraction(Fraction),
|
||||
/// Percent of the parent size.
|
||||
Percent(Percent),
|
||||
}
|
||||
|
||||
impl Unit {
|
||||
/// Matcher for the [`Pixels`] variant.
|
||||
pub fn as_pixels(self) -> Option<f32> {
|
||||
match self {
|
||||
Unit::Pixels(pixels) => Some(pixels),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Matcher for the [`Fraction`] variant.
|
||||
pub fn as_fraction(self) -> Option<Fraction> {
|
||||
match self {
|
||||
Self::Fraction(f) => Some(f),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Matcher for the [`Fraction`] variant. Returns default value if the variant does not match.
|
||||
pub fn as_fraction_or_default(self) -> Fraction {
|
||||
match self {
|
||||
Self::Fraction(f) => f,
|
||||
_ => default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the unit to a pixel value.
|
||||
pub fn resolve(&self, parent_size: f32, free_space: f32, total_fraction: Fraction) -> f32 {
|
||||
match self {
|
||||
Unit::Pixels(value) => *value,
|
||||
Unit::Percent(value) => value.unchecked_raw() / 100.0 * parent_size,
|
||||
Unit::Fraction(value) =>
|
||||
value.unchecked_raw() / total_fraction.unchecked_raw() * free_space,
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the unit to fixed pixel value. If the unit was set to be a fraction or percent, it
|
||||
/// will result in 0. This is mostly used in layout algorithm.
|
||||
pub fn resolve_pixels_or_default(&self) -> f32 {
|
||||
match self {
|
||||
Unit::Pixels(value) => *value,
|
||||
Unit::Fraction(_) => 0.0,
|
||||
Unit::Percent(_) => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the unit to fixed pixel value. If the unit was set to be a fraction or percent, it
|
||||
/// will return [`None`].
|
||||
pub fn resolve_pixels(&self) -> Option<f32> {
|
||||
match self {
|
||||
Unit::Pixels(value) => Some(*value),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the unit to fixed pixel value. If the unit was set to be a fraction, it will return
|
||||
/// [`None`].
|
||||
pub fn resolve_const_and_percent(&self, parent_size: f32) -> Option<f32> {
|
||||
match self {
|
||||
Unit::Pixels(value) => Some(*value),
|
||||
Unit::Percent(value) => Some(value.unchecked_raw() / 100.0 * parent_size),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Unit {
|
||||
fn default() -> Self {
|
||||
Self::Pixels(0.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for Unit {
|
||||
fn from(value: i32) -> Self {
|
||||
Self::Pixels(value as f32)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ============
|
||||
// === Size ===
|
||||
// ============
|
||||
|
||||
/// The resizing of display objects.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, From)]
|
||||
pub enum Size {
|
||||
/// In this mode, the display object size will be set to the size of its content. In case of
|
||||
/// siplay object with no children, their size will be set to 0.
|
||||
#[default]
|
||||
Hug,
|
||||
/// In this mode, the display object size is provided explicitly.
|
||||
Fixed(Unit),
|
||||
}
|
||||
|
||||
impl Size {
|
||||
/// Checks whether the resizing mode is [`Size::Hug`].
|
||||
pub fn is_hug(self) -> bool {
|
||||
self == Size::Hug
|
||||
}
|
||||
|
||||
/// Checks whether the resizing mode is [`Size::Fixed`].
|
||||
pub fn is_fixed(self) -> bool {
|
||||
matches!(self, Size::Fixed(_))
|
||||
}
|
||||
|
||||
/// Matcher for the [`Pixels`] variant.
|
||||
pub fn as_pixels(self) -> Option<f32> {
|
||||
match self {
|
||||
Size::Fixed(unit) => unit.as_pixels(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Matcher for the [`Fraction`] variant. Returns default value if the variant does not match.
|
||||
pub fn as_fraction(self) -> Option<Fraction> {
|
||||
match self {
|
||||
Size::Fixed(unit) => unit.as_fraction(),
|
||||
Size::Hug => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve the unit to fixed pixel value. If the unit was set to be a fraction or percent, it
|
||||
/// will result in 0. This is mostly used in layout algorithm.
|
||||
pub fn resolve_pixels_or_default(&self) -> f32 {
|
||||
match self {
|
||||
Size::Fixed(unit) => unit.resolve_pixels_or_default(),
|
||||
Size::Hug => 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f32> for Size {
|
||||
fn from(value: f32) -> Self {
|
||||
Self::Fixed(Unit::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for Size {
|
||||
fn from(value: i32) -> Self {
|
||||
Self::Fixed(Unit::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Fraction> for Size {
|
||||
fn from(value: Fraction) -> Self {
|
||||
Self::Fixed(Unit::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Percent> for Size {
|
||||
fn from(value: Percent) -> Self {
|
||||
Self::Fixed(Unit::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===================
|
||||
// === SideSpacing ===
|
||||
// ===================
|
||||
|
||||
/// Data model used for expressing margin and padding.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct SideSpacing<T = Unit> {
|
||||
pub start: T,
|
||||
pub end: T,
|
||||
}
|
||||
|
||||
impl<T> SideSpacing<T> {
|
||||
/// Constructor.
|
||||
pub fn new(start: T, end: T) -> Self {
|
||||
Self { start, end }
|
||||
}
|
||||
|
||||
/// A sum of start and end values.
|
||||
pub fn total(self) -> T
|
||||
where T: Add<Output = T> {
|
||||
self.start + self.end
|
||||
}
|
||||
}
|
||||
|
||||
impl SideSpacing<Unit> {
|
||||
/// Resolve the unit to a pixel value.
|
||||
pub fn resolve(
|
||||
self,
|
||||
parent_size: f32,
|
||||
free_space: f32,
|
||||
total_fraction: Fraction,
|
||||
) -> SideSpacing<f32> {
|
||||
SideSpacing::new(
|
||||
self.start.resolve(parent_size, free_space, total_fraction),
|
||||
self.end.resolve(parent_size, free_space, total_fraction),
|
||||
)
|
||||
}
|
||||
|
||||
/// Resolve the unit to fixed pixel value. If the unit was set to be a fraction or percent, it
|
||||
/// will result in 0. This is mostly used in layout algorithm.
|
||||
pub fn resolve_pixels_or_default(self) -> SideSpacing<f32> {
|
||||
SideSpacing::new(
|
||||
self.start.resolve_pixels_or_default(),
|
||||
self.end.resolve_pixels_or_default(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Matcher for the [`Fraction`] variant. Returns default value if the variant does not match.
|
||||
pub fn as_fraction_or_default(self) -> SideSpacing<Fraction> {
|
||||
SideSpacing::new(self.start.as_fraction_or_default(), self.end.as_fraction_or_default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy> From<T> for SideSpacing<T> {
|
||||
fn from(value: T) -> Self {
|
||||
Self { start: value, end: value }
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the provided macro with a list of entries in a form of `[axis_name dim2_name dim1_name]`,
|
||||
/// like `[x left start]`. It defines the mapping between the dim1 and dim2 names.
|
||||
#[macro_export]
|
||||
macro_rules! with_display_object_side_spacing_matrix {
|
||||
($f:path $([$($args:tt)*])?) => {
|
||||
$f! { $([$($args)*])? [[x left start] [x right end] [y bottom start] [y top end]] }
|
||||
}
|
||||
}
|
@ -202,18 +202,6 @@ impl CachedTransformation {
|
||||
// === Getters ===
|
||||
|
||||
impl CachedTransformation {
|
||||
pub fn position(&self) -> Vector3<f32> {
|
||||
self.transform.position
|
||||
}
|
||||
|
||||
pub fn rotation(&self) -> Vector3<f32> {
|
||||
self.transform.rotation
|
||||
}
|
||||
|
||||
pub fn scale(&self) -> Vector3<f32> {
|
||||
self.transform.scale
|
||||
}
|
||||
|
||||
pub fn matrix(&self) -> Matrix4<f32> {
|
||||
self.matrix
|
||||
}
|
||||
@ -223,46 +211,35 @@ impl CachedTransformation {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! gen_transform {
|
||||
($name: ident) => {
|
||||
paste! {
|
||||
impl CachedTransformation {
|
||||
pub fn $name(&self) -> Vector3<f32> {
|
||||
self.transform.$name
|
||||
}
|
||||
|
||||
// === Setters ===
|
||||
pub fn [<$name _mut>](&mut self) -> &mut Vector3<f32> {
|
||||
self.dirty = true;
|
||||
&mut self.transform.$name
|
||||
}
|
||||
|
||||
impl CachedTransformation {
|
||||
pub fn position_mut(&mut self) -> &mut Vector3<f32> {
|
||||
self.dirty = true;
|
||||
&mut self.transform.position
|
||||
}
|
||||
pub fn [<set_ $name>](&mut self, t: Vector3<f32>) {
|
||||
*self.[<$name _mut>]() = t;
|
||||
}
|
||||
|
||||
pub fn rotation_mut(&mut self) -> &mut Vector3<f32> {
|
||||
self.dirty = true;
|
||||
&mut self.transform.rotation
|
||||
}
|
||||
pub fn [<update_ $name>]<F: FnOnce(Vector3<f32>) -> Vector3<f32>>(&mut self, f: F) {
|
||||
*self.[<$name _mut>]() = f(self.$name());
|
||||
}
|
||||
|
||||
pub fn scale_mut(&mut self) -> &mut Vector3<f32> {
|
||||
self.dirty = true;
|
||||
&mut self.transform.scale
|
||||
}
|
||||
|
||||
pub fn set_position(&mut self, t: Vector3<f32>) {
|
||||
*self.position_mut() = t;
|
||||
}
|
||||
|
||||
pub fn set_rotation(&mut self, t: Vector3<f32>) {
|
||||
*self.rotation_mut() = t;
|
||||
}
|
||||
|
||||
pub fn set_scale(&mut self, t: Vector3<f32>) {
|
||||
*self.scale_mut() = t;
|
||||
}
|
||||
|
||||
pub fn mod_position<F: FnOnce(&mut Vector3<f32>)>(&mut self, f: F) {
|
||||
f(self.position_mut());
|
||||
}
|
||||
|
||||
pub fn mod_rotation<F: FnOnce(&mut Vector3<f32>)>(&mut self, f: F) {
|
||||
f(self.rotation_mut());
|
||||
}
|
||||
|
||||
pub fn mod_scale<F: FnOnce(&mut Vector3<f32>)>(&mut self, f: F) {
|
||||
f(self.scale_mut());
|
||||
}
|
||||
pub fn [<modify_ $name>]<F: FnOnce(&mut Vector3<f32>)>(&mut self, f: F) {
|
||||
f(self.[<$name _mut>]());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
gen_transform!(position);
|
||||
gen_transform!(rotation);
|
||||
gen_transform!(scale);
|
||||
|
@ -749,7 +749,7 @@ impl SceneData {
|
||||
debug!("Initializing.");
|
||||
let display_mode = display_mode.clone_ref();
|
||||
let dom = Dom::new();
|
||||
let display_object = display::object::Root::new();
|
||||
let display_object = display::object::Root::new_named("Scene");
|
||||
let variables = UniformScope::new();
|
||||
let dirty = Dirty::new(on_mut);
|
||||
let symbols_dirty = &dirty.symbols;
|
||||
|
@ -64,10 +64,10 @@ use crate::prelude::*;
|
||||
use crate::system::gpu::types::*;
|
||||
|
||||
use crate::display;
|
||||
use crate::display::object::instance::GenericLayoutApi;
|
||||
use crate::display::scene::Scene;
|
||||
use crate::display::shape::primitive::shader;
|
||||
use crate::display::symbol;
|
||||
use crate::display::symbol::geometry::compound::sprite;
|
||||
use crate::display::symbol::geometry::Sprite;
|
||||
use crate::display::symbol::geometry::SpriteSystem;
|
||||
use crate::display::symbol::material;
|
||||
@ -105,11 +105,7 @@ pub trait Shape: 'static + Sized + AsRef<Self::InstanceParams> {
|
||||
fn pointer_events() -> bool;
|
||||
fn always_above() -> Vec<ShapeSystemId>;
|
||||
fn always_below() -> Vec<ShapeSystemId>;
|
||||
fn new_instance_params(
|
||||
sprite: &Sprite,
|
||||
gpu_params: &Self::GpuParams,
|
||||
id: InstanceIndex,
|
||||
) -> ShapeWithSize<Self>;
|
||||
fn new_instance_params(gpu_params: &Self::GpuParams, id: InstanceIndex) -> Self;
|
||||
fn new_gpu_params(shape_system: &ShapeSystemModel) -> Self::GpuParams;
|
||||
fn shape_def(style_watch: &display::shape::StyleWatch) -> def::AnyShape;
|
||||
fn flavor(_data: &Self::ShapeData) -> ShapeSystemFlavor {
|
||||
@ -167,46 +163,16 @@ pub struct ShapeSystemFlavor {
|
||||
|
||||
|
||||
|
||||
// =====================
|
||||
// === ShapeWithSize ===
|
||||
// =====================
|
||||
|
||||
/// A shape with its size parameter.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Debug, Deref)]
|
||||
pub struct ShapeWithSize<S> {
|
||||
#[deref]
|
||||
shape: S,
|
||||
pub size: ProxyParam<sprite::Size>,
|
||||
}
|
||||
|
||||
impl<S> ShapeWithSize<S> {
|
||||
/// Constructor.
|
||||
pub fn new(shape: S, size: ProxyParam<sprite::Size>) -> Self {
|
||||
Self { shape, size }
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Shape> ShapeWithSize<S> {
|
||||
/// Swap in-place the shape definition with another one.
|
||||
pub(crate) fn swap(&self, other: &ShapeWithSize<S>) {
|
||||
self.size.swap(&other.size);
|
||||
self.shape.as_ref().swap(other.shape.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// =====================
|
||||
// === ShapeInstance ===
|
||||
// =====================
|
||||
|
||||
/// A visible shape instance, bound to a particular [`ShapeSystem`].
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Deref, Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct ShapeInstance<S> {
|
||||
#[deref]
|
||||
pub shape: ShapeWithSize<S>,
|
||||
shape: S,
|
||||
pub sprite: RefCell<Sprite>,
|
||||
display_object: display::object::Instance,
|
||||
}
|
||||
@ -221,11 +187,17 @@ impl<S> ShapeInstance<S> {
|
||||
impl<S: Shape> ShapeInstance<S> {
|
||||
/// Swap in-place the shape definition with another one.
|
||||
pub(crate) fn swap(&self, other: &Self) {
|
||||
self.shape.swap(&other.shape);
|
||||
self.shape.as_ref().swap(other.shape.as_ref());
|
||||
self.sprite.swap(&other.sprite);
|
||||
for child in other.display_object.remove_all_children() {
|
||||
self.display_object.add_child(&child);
|
||||
}
|
||||
self.display_object.replace_children(other.display_object.remove_all_children());
|
||||
// This function is called during display object hierarchy update, before updating children
|
||||
// of this display object, but after updating its layout. Thus, we need to update the layout
|
||||
// of the new sprite. Please note, that changing layout in the middle of the display object
|
||||
// refresh could lead to wrong results if the new child layout is different than the
|
||||
// old one (for example, if the parent display object resizing mode wa set to "hug"
|
||||
// and the new child has bigger size, the parent would also need to be updated).
|
||||
// However, we control the layout of the sprite, so we know it did not change.
|
||||
self.display_object.refresh_layout();
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,14 +269,18 @@ impl<S: Shape> ShapeSystem<S> {
|
||||
Self { data }.init_refresh_on_style_change()
|
||||
}
|
||||
|
||||
// FIXME: the following 2 fns look similar
|
||||
/// Constructor of a new shape instance.
|
||||
#[profile(Debug)]
|
||||
pub fn new_instance(&self) -> ShapeInstance<S> {
|
||||
let sprite = self.model.sprite_system.new_instance();
|
||||
sprite.allow_grow();
|
||||
let id = sprite.instance_id;
|
||||
let shape = S::new_instance_params(&sprite, &self.gpu_params, id);
|
||||
let display_object = display::object::Instance::new();
|
||||
let shape = S::new_instance_params(&self.gpu_params, id);
|
||||
let display_object = display::object::Instance::new_named("ShapeSystem");
|
||||
display_object.add_child(&sprite);
|
||||
// FIXME: workaround:
|
||||
// display_object.use_auto_layout();
|
||||
let sprite = RefCell::new(sprite);
|
||||
ShapeInstance { sprite, shape, display_object }
|
||||
}
|
||||
@ -312,11 +288,14 @@ impl<S: Shape> ShapeSystem<S> {
|
||||
#[profile(Debug)]
|
||||
pub(crate) fn instantiate(&self) -> (ShapeInstance<S>, symbol::GlobalInstanceId) {
|
||||
let sprite = self.model.sprite_system.new_instance();
|
||||
sprite.allow_grow();
|
||||
let instance_id = sprite.instance_id;
|
||||
let global_id = sprite.global_instance_id;
|
||||
let shape = S::new_instance_params(&sprite, &self.gpu_params, instance_id);
|
||||
let display_object = display::object::Instance::new();
|
||||
let shape = S::new_instance_params(&self.gpu_params, instance_id);
|
||||
let display_object = display::object::Instance::new_named("ShapeSystem");
|
||||
display_object.add_child(&sprite);
|
||||
// FIXME: workaround:
|
||||
// display_object.use_auto_layout();
|
||||
let sprite = RefCell::new(sprite);
|
||||
let shape = ShapeInstance { sprite, shape, display_object };
|
||||
(shape, global_id)
|
||||
@ -597,7 +576,6 @@ macro_rules! _shape {
|
||||
use $crate::display::shape::PixelDistance;
|
||||
use $crate::display::shape::system::ProxyParam;
|
||||
use $crate::system::gpu::data::InstanceIndex;
|
||||
use $crate::display::shape::ShapeWithSize;
|
||||
use $crate::display::shape::system::*;
|
||||
|
||||
|
||||
@ -638,15 +616,12 @@ macro_rules! _shape {
|
||||
}
|
||||
|
||||
fn new_instance_params(
|
||||
sprite: &Sprite,
|
||||
gpu_params:&Self::GpuParams,
|
||||
id: InstanceIndex
|
||||
) -> ShapeWithSize<Shape> {
|
||||
let size = ProxyParam::new(sprite.size.clone_ref());
|
||||
) -> Shape {
|
||||
$(let $gpu_param = ProxyParam::new(gpu_params.$gpu_param.at(id));)*
|
||||
let params = Self::InstanceParams { $($gpu_param),* };
|
||||
let shape = Shape { params };
|
||||
ShapeWithSize::new(shape, size)
|
||||
Shape { params }
|
||||
}
|
||||
|
||||
fn new_gpu_params(
|
||||
|
@ -10,7 +10,6 @@ use crate::debug::Stats;
|
||||
use crate::display;
|
||||
use crate::display::attribute::EraseOnDrop;
|
||||
use crate::display::layout::alignment;
|
||||
use crate::display::layout::Alignment;
|
||||
use crate::display::symbol::material::Material;
|
||||
use crate::display::symbol::Symbol;
|
||||
use crate::display::symbol::SymbolId;
|
||||
@ -67,6 +66,7 @@ pub struct Size {
|
||||
attr: Attribute<Vector2<f32>>,
|
||||
}
|
||||
|
||||
|
||||
// === Setters ===
|
||||
|
||||
impl HasItem for Size {
|
||||
@ -125,20 +125,21 @@ pub struct SizedObject {
|
||||
impl SizedObject {
|
||||
fn new(attr: Attribute<Vector2<f32>>, transform: &Attribute<Matrix4<f32>>) -> Self {
|
||||
let size = Size::new(attr);
|
||||
let display_object = display::object::Instance::new();
|
||||
let display_object = display::object::Instance::new_named("Sprite");
|
||||
let weak_display_object = display_object.downgrade();
|
||||
let network = &display_object.network;
|
||||
frp::extend! { network
|
||||
eval_ display_object.on_updated ([transform] {
|
||||
eval_ display_object.on_updated ([transform, size] {
|
||||
if let Some(display_object) = weak_display_object.upgrade() {
|
||||
transform.set(display_object.transformation_matrix())
|
||||
transform.set(display_object.transformation_matrix());
|
||||
size.set(display_object.computed_size());
|
||||
}
|
||||
});
|
||||
}
|
||||
Self { size, display_object }.init()
|
||||
}
|
||||
|
||||
/// Init display object bindings. In particular defines the behavior of the show and hide
|
||||
/// Init display object bindings. In particular define the behavior of the show and hide
|
||||
/// callbacks.
|
||||
fn init(self) -> Self {
|
||||
let size = &self.size;
|
||||
@ -170,7 +171,6 @@ impl CellGetter for SizedObject {
|
||||
impl CellSetter for SizedObject {
|
||||
fn set(&self, v: Vector2) {
|
||||
self.size.set(v);
|
||||
self.display_object.set_bounding_box(v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,12 +275,13 @@ impl display::Object for Sprite {
|
||||
#[derive(Clone, CloneRef, Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct SpriteSystem {
|
||||
pub symbol: Symbol,
|
||||
transform: Buffer<Matrix4<f32>>,
|
||||
uv: Buffer<Vector2<f32>>,
|
||||
size: Buffer<Vector2<f32>>,
|
||||
alignment: Uniform<Vector2<f32>>,
|
||||
stats: Stats,
|
||||
pub symbol: Symbol,
|
||||
transform: Buffer<Matrix4<f32>>,
|
||||
uv: Buffer<Vector2<f32>>,
|
||||
size: Buffer<Vector2<f32>>,
|
||||
alignment: Uniform<Vector2<f32>>,
|
||||
alignment_value: Rc<Cell<alignment::Dim2>>,
|
||||
stats: Stats,
|
||||
}
|
||||
|
||||
impl SpriteSystem {
|
||||
@ -296,12 +297,13 @@ impl SpriteSystem {
|
||||
let uv = point_scope.add_buffer("uv");
|
||||
let transform = instance_scope.add_buffer("transform");
|
||||
let size = instance_scope.add_buffer("size");
|
||||
let initial_alignment = Self::uv_offset(Alignment::center());
|
||||
let alignment_value = Rc::new(Cell::new(alignment::Dim2::center()));
|
||||
let initial_alignment = alignment_value.get().normalized();
|
||||
let alignment = symbol.variables().add_or_panic("alignment", initial_alignment);
|
||||
|
||||
stats.inc_sprite_system_count();
|
||||
|
||||
let this = Self { symbol, transform, uv, size, alignment, stats };
|
||||
let this = Self { symbol, transform, uv, size, alignment, alignment_value, stats };
|
||||
this.init_attributes();
|
||||
this.init_shader();
|
||||
this
|
||||
@ -313,6 +315,7 @@ impl SpriteSystem {
|
||||
let transform = self.transform.at(instance.instance_id);
|
||||
let size = self.size.at(instance.instance_id);
|
||||
let sprite = Sprite::new(&self.symbol, instance, transform, size, &self.stats);
|
||||
sprite.unsafe_set_forced_origin_alignment(self.alignment_value.get());
|
||||
self.add_child(&sprite);
|
||||
sprite
|
||||
}
|
||||
@ -333,8 +336,14 @@ impl SpriteSystem {
|
||||
}
|
||||
|
||||
/// Set alignment of sprites.
|
||||
pub fn set_alignment(&self, alignment: Alignment) {
|
||||
self.alignment.set(Self::uv_offset(alignment));
|
||||
///
|
||||
/// # Safety
|
||||
/// It is advised not to use this function. Use display object auto-layout instead. This
|
||||
/// function can be called only before creating sprites, as its changes will not be
|
||||
/// propagated to sprite instances.
|
||||
pub fn unsafe_set_alignment(&self, alignment: alignment::Dim2) {
|
||||
self.alignment_value.set(alignment);
|
||||
self.alignment.set(alignment.normalized());
|
||||
}
|
||||
|
||||
/// Run the renderer.
|
||||
@ -413,20 +422,6 @@ impl SpriteSystem {
|
||||
material.set_main("output_color = vec4(0.0,0.0,0.0,1.0); output_id=vec4(0.0,0.0,0.0,0.0);");
|
||||
material
|
||||
}
|
||||
|
||||
fn uv_offset(alignment: Alignment) -> Vector2<f32> {
|
||||
let x = match alignment.horizontal {
|
||||
alignment::Horizontal::Left => 0.0,
|
||||
alignment::Horizontal::Center => 0.5,
|
||||
alignment::Horizontal::Right => 1.0,
|
||||
};
|
||||
let y = match alignment.vertical {
|
||||
alignment::Vertical::Top => 1.0,
|
||||
alignment::Vertical::Center => 0.5,
|
||||
alignment::Vertical::Bottom => 0.0,
|
||||
};
|
||||
Vector2::new(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
impl display::Object for SpriteSystem {
|
||||
|
@ -288,7 +288,7 @@ impl Cursor {
|
||||
eval radius.value ((v) model.for_each_view(|vw| vw.radius.set(*v)));
|
||||
eval size.value ([model] (v) {
|
||||
let dim = Vector2(v.x+SIDES_PADDING,v.y+SIDES_PADDING);
|
||||
model.for_each_view(|vw| vw.size.set(dim));
|
||||
model.for_each_view(|vw| {vw.set_size(dim);});
|
||||
});
|
||||
|
||||
alpha <- all_with(&color_alpha.value,&inactive_fade.value,|s,t| s*t);
|
||||
|
@ -22,6 +22,8 @@
|
||||
#![feature(slice_as_chunks)]
|
||||
#![feature(local_key_cell_methods)]
|
||||
#![feature(auto_traits)]
|
||||
#![feature(int_roundings)]
|
||||
#![feature(let_chains)]
|
||||
// === Standard Linter Configuration ===
|
||||
#![deny(non_ascii_idents)]
|
||||
#![warn(unsafe_code)]
|
||||
|
@ -102,7 +102,7 @@ macro_rules! with_texture_format_relations { ($f:ident $args:tt) => { $crate::$f
|
||||
#[macro_export]
|
||||
macro_rules! with_all_texture_types_cartesians {
|
||||
([$f:ident] [$($out:tt)*]) => {
|
||||
shapely::cartesian! { [[$f]] [Owned GpuOnly RemoteImage] [$($out)*] }
|
||||
shapely::cartesian! { [$f] [Owned GpuOnly RemoteImage] [$($out)*] }
|
||||
};
|
||||
([$f:ident _] $out:tt) => {
|
||||
$f! { $out }
|
||||
|
@ -9,6 +9,7 @@ crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
ensogl-example-animation = { path = "animation" }
|
||||
ensogl-example-auto-layout = { path = "auto-layout" }
|
||||
ensogl-example-complex-shape-system = { path = "complex-shape-system" }
|
||||
ensogl-example-custom-shape-system = { path = "custom-shape-system" }
|
||||
ensogl-example-dom-symbols = { path = "dom-symbols" }
|
||||
|
16
lib/rust/ensogl/example/auto-layout/Cargo.toml
Normal file
16
lib/rust/ensogl/example/auto-layout/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "ensogl-example-auto-layout"
|
||||
version = "0.1.0"
|
||||
authors = ["Enso Team <contact@enso.org>"]
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
ensogl-core = { path = "../../core" }
|
||||
wasm-bindgen = { workspace = true }
|
||||
|
||||
# Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options.
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = false
|
91
lib/rust/ensogl/example/auto-layout/src/lib.rs
Normal file
91
lib/rust/ensogl/example/auto-layout/src/lib.rs
Normal file
@ -0,0 +1,91 @@
|
||||
//! Example scene showing the usage of display object auto-layout.
|
||||
|
||||
// === Standard Linter Configuration ===
|
||||
#![deny(non_ascii_idents)]
|
||||
#![warn(unsafe_code)]
|
||||
#![allow(clippy::bool_to_int_with_if)]
|
||||
#![allow(clippy::let_and_return)]
|
||||
|
||||
use ensogl_core::display::shape::*;
|
||||
use ensogl_core::display::world::*;
|
||||
use ensogl_core::prelude::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use ensogl_core::data::color;
|
||||
use ensogl_core::display;
|
||||
use ensogl_core::display::navigation::navigator::Navigator;
|
||||
use ensogl_core::display::object::ObjectOps;
|
||||
|
||||
|
||||
|
||||
// ==============
|
||||
// === Shapes ===
|
||||
// ==============
|
||||
|
||||
mod rectangle {
|
||||
use super::*;
|
||||
ensogl_core::shape! {
|
||||
(style: Style, color: Vector4<f32>) {
|
||||
let width = Var::<Pixels>::from("input_size.x");
|
||||
let height = Var::<Pixels>::from("input_size.y");
|
||||
let rect = Rect((&width, &height)).corners_radius(10.0.px());
|
||||
let shape = rect.fill(color::Rgba(0.0,0.0,0.0,0.2));
|
||||
shape.into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===================
|
||||
// === Entry Point ===
|
||||
// ===================
|
||||
|
||||
|
||||
/// The example entry point.
|
||||
#[entry_point]
|
||||
#[allow(dead_code)]
|
||||
pub fn main() {
|
||||
let world = World::new().displayed_in("root");
|
||||
let scene = &world.default_scene;
|
||||
let camera = scene.camera().clone_ref();
|
||||
let navigator = Navigator::new(scene, &camera);
|
||||
|
||||
let rect1 = rectangle::View::new();
|
||||
rect1.set_size(Vector2::new(100.0, 100.0));
|
||||
rect1.color.set(color::Rgba::new(0.5, 0.0, 0.0, 0.3).into());
|
||||
|
||||
let rect2 = rectangle::View::new();
|
||||
rect2.set_size(Vector2::new(100.0, 100.0));
|
||||
rect2.color.set(color::Rgba::new(0.5, 0.0, 0.0, 0.3).into());
|
||||
|
||||
let root = display::object::Instance::new();
|
||||
root.set_size(Vector2::new(300.0, 100.0));
|
||||
root.use_auto_layout();
|
||||
root.add_child(&rect1);
|
||||
root.add_child(&rect2);
|
||||
world.add_child(&root);
|
||||
|
||||
warn!("rect1: {:?}", rect1.display_object());
|
||||
|
||||
let r = rect1.clone_ref();
|
||||
let mut i = 0;
|
||||
world
|
||||
.on
|
||||
.before_frame
|
||||
.add(move |_| {
|
||||
if i == 10 {
|
||||
warn!("rect1: {:?}", r.display_object());
|
||||
// warn!("rect1 sprite: {:?}", r.sprite.borrow().display_object());
|
||||
}
|
||||
i += 1;
|
||||
})
|
||||
.forget();
|
||||
|
||||
world.keep_alive_forever();
|
||||
mem::forget(navigator);
|
||||
mem::forget(root);
|
||||
mem::forget(rect1);
|
||||
mem::forget(rect2);
|
||||
warn!("Hello World!");
|
||||
}
|
@ -90,15 +90,15 @@ pub fn main() {
|
||||
style_watch.get("base_color");
|
||||
|
||||
let view1 = shape::View::new();
|
||||
view1.size.set(Vector2::new(300.0, 300.0));
|
||||
view1.mod_position(|t| *t = Vector3::new(50.0, 50.0, 0.0));
|
||||
view1.set_size((300.0, 300.0));
|
||||
view1.set_position(Vector3::new(50.0, 50.0, 0.0));
|
||||
|
||||
let mask_layer = scene::layer::Layer::new("MaskLayer");
|
||||
scene.layers.node_searcher.set_mask(&mask_layer);
|
||||
|
||||
let mask = mask::View::new();
|
||||
mask.size.set(Vector2::new(300.0, 300.0));
|
||||
mask.mod_position(|t| *t = Vector3::new(-50.0, 0.0, 0.0));
|
||||
mask.set_size((300.0, 300.0));
|
||||
mask.set_position(Vector3::new(-50.0, 0.0, 0.0));
|
||||
|
||||
// FIXME[WD]: scissor box should not be computed from the left screen border. It should be
|
||||
// affected by the camera position.
|
||||
@ -107,8 +107,8 @@ pub fn main() {
|
||||
scene.layers.main.set_scissor_box(Some(&scissor_box));
|
||||
|
||||
let view2 = shape::View::new();
|
||||
view2.size.set(Vector2::new(300.0, 300.0));
|
||||
view2.mod_position(|t| *t = Vector3::new(50.0, 0.0, 0.0));
|
||||
view2.set_size((300.0, 300.0));
|
||||
view2.set_position(Vector3::new(50.0, 0.0, 0.0));
|
||||
|
||||
world.add_child(&view1);
|
||||
world.add_child(&mask);
|
||||
|
@ -52,8 +52,8 @@ pub fn main() {
|
||||
let navigator = Navigator::new(scene, &camera);
|
||||
|
||||
let view = shape::View::new();
|
||||
view.size.set(Vector2::new(300.0, 300.0));
|
||||
view.mod_position(|t| *t = Vector3::new(50.0, 50.0, 0.0));
|
||||
view.set_size((300.0, 300.0));
|
||||
view.set_position(Vector3::new(50.0, 50.0, 0.0));
|
||||
|
||||
world.add_child(&view);
|
||||
world.keep_alive_forever();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user