Refactoring & display object bug fixing (https://github.com/enso-org/ide/pull/721)

Original commit: cf2b8296eb
This commit is contained in:
Wojciech Daniło 2020-08-14 09:23:03 +02:00 committed by GitHub
parent 36d453d762
commit 4417a9b1f7
204 changed files with 1678 additions and 1520 deletions

3
gui/.gitignore vendored
View File

@ -14,9 +14,6 @@ wasm-pack.log
# Visual Studio Code
.vscode/
# A thirdparty downloaded js
/src/rust/ensogl/lib/msdf-sys/msdfgen_wasm.js
# JavaScript
node_modules
.nvmrc

View File

@ -75,6 +75,7 @@ function command(docs) {
// === Commands ===
// ================
const DEFAULT_CRATE = 'ide'
let commands = {}
@ -105,9 +106,9 @@ commands.check.rust = async function() {
commands.build = command(`Build the sources in release mode`)
commands.build.options = {
'view-only': {
describe : 'Compile only the view part',
type : 'bool',
'crate': {
describe : 'Target crate to build',
type : 'string',
}
}
commands.build.js = async function() {
@ -116,9 +117,10 @@ commands.build.js = async function() {
}
commands.build.rust = async function(argv) {
console.log(`Building WASM target.`)
let crate = argv.viewOnly ? 'ide/lib/view' : 'ide'
let args = ['build','--target','web','--no-typescript','--out-dir',paths.dist.wasm.root,'--out-name','ide',crate]
let crate = argv.crate || DEFAULT_CRATE
let crate_sfx = crate ? ` '${crate}'` : ``
console.log(`Building WASM target${crate_sfx}.`)
let args = ['build','--target','web','--no-typescript','--out-dir',paths.dist.wasm.root,'--out-name','ide',crate]
if (argv.dev) { args.push('--dev') }
await run_cargo('wasm-pack',args)
await patch_file(paths.dist.wasm.glue, js_workaround_patcher)
@ -202,15 +204,15 @@ commands.lint.rust = async function() {
// === Watch ===
commands.watch = command(`Start a file-watch utility and run interactive mode`)
commands.watch.options = Object.assign({},commands.build.options)
commands.watch = command(`Start a file-watch utility and run interactive mode`)
commands.watch.options = Object.assign({},commands.build.options)
commands.watch.parallel = true
commands.watch.rust = async function(argv) {
let build_args = []
if (argv.viewOnly != undefined) { build_args.push(`--view-only=${argv.viewOnly}`) }
build_args = build_args.join(' ')
let target = '"' + `node ${paths.script.main} build --no-js --dev ${build_args} -- ` + cargoArgs.join(" ") + '"'
let args = ['watch','-s',`${target}`]
if (argv.crate != undefined) { build_args.push(`--crate=${argv.crate}`) }
build_args = build_args.join(' ')
let target = '"' + `node ${paths.script.main} build --no-js --dev ${build_args} -- ` + cargoArgs.join(" ") + '"'
let args = ['watch','-s',`${target}`]
await cmd.with_cwd(paths.rust.root, async () => {
await cmd.run('cargo',args)
})
@ -286,6 +288,9 @@ for (let command of commandList) {
for (let option in config.options) {
args.options(option,config.options[option])
}
for (let arg in config.args) {
args.positional(arg,config.args[arg])
}
args.options('native', {
describe : 'Run native tests',
type : 'bool',

View File

@ -161,6 +161,19 @@ are presented below:
`node ./run build`. To create platform-specific packages and installers use
`node ./run dist` instead. The final packages will be located at
`app/dist/native`.
- **Selective mode**
In order to compile only part of the project, and thus drastically shorten
the incremental compile time, you are advised to use the selective
compilation mode by passing the `--crate` option to the `build` or `watch`
command, e.g. `node ./watch --crate ensogl/example` to compile only the
renderer-related example scenes. Please note, that in order to run a scene
in a web-browser, the scene has to be compiled and has to expose a public
function with a name starting with `entry_point_`. Thus, if you compile
only selected crate, you will have access only to the example scenes that
were defined or re-exported by that crate. In particular, the `ide` crate
exposes the `entry_point_ide` function, so you have to compile it to test
your code in the Enso IDE.
### Testing, Linting, and Validation
After changing the code it's always a good idea to lint and test the code. We

View File

@ -2,7 +2,7 @@
* `build` - Helper JS scripts used by `run` script in the main directory.
* `docs` - Documentation.
* `src/js` - the JS part of IDE application.
* `src/js` - The JS part of IDE application.
* `src/rust` - All Rust crates.
## Crates

View File

@ -77,7 +77,7 @@ async function download_content(cfg) {
let main_scene_name = 'ide'
/// Prefix name of each scene defined in the WASM binary.
let wasm_fn_pfx = "run_example_"
let wasm_fn_pfx = "entry_point_"
/// Displays a debug screen which allows the user to run one of predefined debug examples.

View File

@ -7521,18 +7521,16 @@
}
},
"meow": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/meow/-/meow-7.0.1.tgz",
"integrity": "sha512-tBKIQqVrAHqwit0vfuFPY3LlzJYkEOFyKa3bPgxzNl6q/RtN8KQ+ALYEASYuFayzSAsjlhXj/JZ10rH85Q6TUw==",
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-7.1.0.tgz",
"integrity": "sha512-kq5F0KVteskZ3JdfyQFivJEj2RaA8NFsS4+r9DaMKLcUHpk5OcHS3Q0XkCXONB1mZRPsu/Y/qImKri0nwSEZog==",
"dev": true,
"requires": {
"@types/minimist": "^1.2.0",
"arrify": "^2.0.1",
"camelcase": "^6.0.0",
"camelcase-keys": "^6.2.2",
"decamelize-keys": "^1.1.0",
"hard-rejection": "^2.1.0",
"minimist-options": "^4.0.2",
"minimist-options": "4.1.0",
"normalize-package-data": "^2.5.0",
"read-pkg-up": "^7.0.1",
"redent": "^3.0.0",
@ -7541,18 +7539,6 @@
"yargs-parser": "^18.1.3"
},
"dependencies": {
"arrify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz",
"integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==",
"dev": true
},
"camelcase": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.0.0.tgz",
"integrity": "sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w==",
"dev": true
},
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
@ -7652,14 +7638,6 @@
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"dependencies": {
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"dev": true
}
}
}
}

View File

@ -600,6 +600,22 @@ dependencies = [
[[package]]
name = "ensogl"
version = "0.1.0"
dependencies = [
"ensogl-core 0.1.0",
"ensogl-text 0.1.0",
]
[[package]]
name = "ensogl-build-utilities"
version = "0.1.0"
dependencies = [
"path-clean 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ensogl-core"
version = "0.1.0"
dependencies = [
"Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)",
"assert_approx_eq 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -613,9 +629,9 @@ dependencies = [
"enso-prelude 0.1.0",
"enso-shapely 0.1.0",
"enso-types 0.1.0",
"ensogl-core-embedded-fonts 0.1.0",
"ensogl-core-msdf-sys 0.1.0",
"ensogl-system-web 0.1.0",
"ensogl-text-embedded-fonts 0.1.0",
"ensogl-text-msdf-sys 0.1.0",
"enum_dispatch 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"eval-tt 0.1.0",
"failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -638,34 +654,22 @@ dependencies = [
]
[[package]]
name = "ensogl-build-utilities"
version = "0.1.0"
dependencies = [
"path-clean 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ensogl-core-embedded-fonts"
name = "ensogl-examples"
version = "0.1.0"
dependencies = [
"enso-frp 0.1.0",
"enso-prelude 0.1.0",
"ensogl-build-utilities 0.1.0",
"zip 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ensogl-core-msdf-sys"
version = "0.1.0"
dependencies = [
"enso-prelude 0.1.0",
"ensogl-build-utilities 0.1.0",
"ensogl-core-embedded-fonts 0.1.0",
"futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"enso-shapely 0.1.0",
"ensogl-core 0.1.0",
"ensogl-text 0.1.0",
"ensogl-text-msdf-sys 0.1.0",
"js-sys 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
"logger 0.1.0",
"nalgebra 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.56 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-test 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -694,13 +698,36 @@ dependencies = [
"enso-prelude 0.1.0",
"enso-shapely 0.1.0",
"enso-types 0.1.0",
"ensogl 0.1.0",
"ensogl-core-embedded-fonts 0.1.0",
"ensogl-core-msdf-sys 0.1.0",
"ensogl-core 0.1.0",
"ensogl-text-embedded-fonts 0.1.0",
"ensogl-text-msdf-sys 0.1.0",
"wasm-bindgen-test 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"xi-rope 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ensogl-text-embedded-fonts"
version = "0.1.0"
dependencies = [
"enso-prelude 0.1.0",
"ensogl-build-utilities 0.1.0",
"zip 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ensogl-text-msdf-sys"
version = "0.1.0"
dependencies = [
"enso-prelude 0.1.0",
"ensogl-build-utilities 0.1.0",
"ensogl-text-embedded-fonts 0.1.0",
"futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
"nalgebra 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-test 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "enum_dispatch"
version = "0.2.4"
@ -1107,8 +1134,8 @@ dependencies = [
"enso-protocol 0.1.0",
"enso-shapely 0.1.0",
"ensogl 0.1.0",
"ensogl-core-msdf-sys 0.1.0",
"ensogl-system-web 0.1.0",
"ensogl-text-msdf-sys 0.1.0",
"failure 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"flo_stream 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1142,8 +1169,8 @@ dependencies = [
"enso-protocol 0.1.0",
"enso-shapely 0.1.0",
"ensogl 0.1.0",
"ensogl-core-msdf-sys 0.1.0",
"ensogl-text 0.1.0",
"ensogl-text-msdf-sys 0.1.0",
"js-sys 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
"logger 0.1.0",
"nalgebra 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -3,8 +3,10 @@
members = [
"build",
"ensogl",
"ensogl/lib/embedded-fonts",
"ensogl/lib/msdf-sys",
"ensogl/example",
"ensogl/lib/core",
"ensogl/lib/text/embedded-fonts",
"ensogl/lib/text/msdf-sys",
"ensogl/lib/text",
"ide",
"ide/lib/ast/impl",

View File

@ -8,84 +8,7 @@ edition = "2018"
crate-type = ["rlib", "cdylib"]
[features]
default = ["statistics", "no_unboxed_callbacks"]
statistics = []
no_unboxed_callbacks = []
[dependencies]
enso-callback = { version = "0.1.0" , path = "../lib/callback" }
ensogl-core-embedded-fonts = { version = "0.1.0" , path = "lib/embedded-fonts" }
ensogl-core-msdf-sys = { version = "0.1.0" , path = "lib/msdf-sys" }
enso-generics = { version = "0.1.0" , path = "../lib/generics" }
enso-prelude = { version = "0.1.0" , path = "../lib/enso-prelude" }
ensogl-system-web = { version = "0.1.0" , path = "../lib/system/web" }
code-builder = { version = "0.1.0" , path = "../lib/code-builder" }
data = { version = "0.1.0" , path = "../lib/data" }
enso-frp = { version = "0.1.0" , path = "../lib/frp" }
enso-types = { version = "0.1.0" , path = "../lib/types" }
eval-tt = { version = "0.1.0" , path = "../lib/eval-tt" }
logger = { version = "0.1.0" , path = "../lib/logger" }
optics = { version = "0.1.0" , path = "../lib/optics" }
enso-shapely = { version = "0.1.0" , path = "../lib/enso-shapely/impl" }
bit_field = { version = "0.10.0" }
console_error_panic_hook = { version = "0.1.6" }
enum_dispatch = { version = "0.2.0" }
failure = { version = "0.1.5" }
Inflector = { version = "0.11.4" }
itertools = { version = "0.8" }
js-sys = { version = "0.3.28" }
nalgebra = { version = "0.21.1" }
num_enum = { version = "0.4.2" }
num-traits = { version = "0.2" }
paste = { version = "0.1.6" }
rustc-hash = { version = "1.0.1" }
shrinkwraprs = { version = "0.3.0" }
smallvec = { version = "1.0.0" }
typenum = { version = "1.11.2" }
# We require exact version of wasm-bindgen because we do patching final js in our build process,
# and this is vulnerable to any wasm-bindgen version change.
wasm-bindgen = { version = "=0.2.58" , features = ["nightly"] }
[dependencies.web-sys]
version = "0.3.4"
features = [
'CanvasRenderingContext2d',
'CssStyleDeclaration',
'Document',
'Element',
'EventTarget',
'KeyboardEvent',
'HtmlCanvasElement',
'HtmlCollection',
'HtmlDivElement',
'HtmlElement',
'HtmlImageElement',
'Location',
'Node',
'Url',
'WebGlBuffer',
'WebGlFramebuffer',
'WebGlProgram',
'WebGlRenderingContext',
'WebGlShader',
'WebGlSync',
'WebGlTexture',
'WebGlUniformLocation',
'WebGlUniformLocation',
'WebGlVertexArrayObject',
'Window',
'console',
'EventTarget',
'Event',
'MouseEvent',
'WheelEvent',
'DomRect',
'AddEventListenerOptions'
]
[dev-dependencies]
assert_approx_eq = { version = "1.1.0" }
wasm-bindgen-test = { version = "0.3.8" }
web-test = { version = "0.1.0", path = "../lib/web-test" }
ensogl-core = { path = "lib/core" }
ensogl-text = { path = "lib/text" }

View File

@ -0,0 +1,27 @@
[package]
name = "ensogl-examples"
version = "0.1.0"
authors = ["Enso Team <contact@enso.org>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
enso-frp = { version = "0.1.0", path = "../../lib/frp" }
enso-prelude = { version = "0.1.0", path = "../../lib/enso-prelude" }
ensogl-core = { version = "0.1.0", path = "../../ensogl/lib/core" }
ensogl-text-msdf-sys = { version = "0.1.0", path = "../../ensogl/lib/text/msdf-sys" }
ensogl-text = { version = "0.1.0", path = "../../ensogl/lib/text" }
enso-shapely = { version = "0.1.0", path = "../../lib/enso-shapely/impl" }
logger = { version = "0.1.0", path = "../../lib/logger" }
wasm-bindgen = { version = "=0.2.58" , features = ["nightly","serde-serialize"] }
nalgebra = { version = "0.21.1" , features = ["serde-serialize"] }
serde_json = { version = "1.0" }
serde = { version = "1.0" , features = ["derive"] }
js-sys = { version = "0.3.28" }
[dependencies.web-sys]
version = "0.3.4"
features = []

View File

@ -1,16 +1,16 @@
#![allow(missing_docs)]
use ensogl::traits::*;
use ensogl_core::traits::*;
use ensogl_core::prelude::*;
use ensogl::system::web;
use ensogl::system::web::NodeInserter;
use ensogl::display::symbol::DomSymbol;
use ensogl_core::system::web;
use ensogl_core::system::web::NodeInserter;
use ensogl_core::display::symbol::DomSymbol;
use ensogl_core::display::symbol::geometry::Sprite;
use ensogl_core::display::symbol::geometry::SpriteSystem;
use ensogl_core::display::world::*;
use ensogl_core::display::navigation::navigator::Navigator;
use web::StyleSetter;
use ensogl::display::symbol::geometry::Sprite;
use ensogl::display::symbol::geometry::SpriteSystem;
use ensogl::display::world::*;
use ensogl::display::navigation::navigator::Navigator;
use ensogl::prelude::*;
use nalgebra::Vector2;
use nalgebra::Vector3;
@ -19,7 +19,7 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen]
#[allow(dead_code)]
#[allow(clippy::many_single_char_names)]
pub fn run_example_dom_symbols() {
pub fn entry_point_dom_symbols() {
web::forward_panic_hook_to_console();
web::set_stdout();
let world = World::new(&web::get_html_element_by_id("root").unwrap());
@ -71,8 +71,6 @@ pub fn run_example_dom_symbols() {
css3d_objects.push(object);
}
}
world.display_object().update();
let layers = vec![dom_front_layer.clone_ref(),dom_back_layer.clone_ref()];
let mut iter_to_change = 0;

View File

@ -2,14 +2,14 @@
use crate::prelude::*;
use ensogl::animation::easing::*;
use ensogl::animation;
use ensogl::system::web::AttributeSetter;
use ensogl::system::web::create_element;
use ensogl::system::web::get_element_by_id;
use ensogl::system::web::NodeInserter;
use ensogl::system::web::StyleSetter;
use ensogl::system::web;
use ensogl_core::animation::easing::*;
use ensogl_core::animation;
use ensogl_core::system::web::AttributeSetter;
use ensogl_core::system::web::create_element;
use ensogl_core::system::web::get_element_by_id;
use ensogl_core::system::web::NodeInserter;
use ensogl_core::system::web::StyleSetter;
use ensogl_core::system::web;
use js_sys::Math;
use nalgebra::Vector2;
use std::ops::Add;
@ -261,7 +261,7 @@ macro_rules! examples {
#[wasm_bindgen]
#[allow(dead_code)]
/// Runs EasingAnimator example.
pub fn run_example_easing_animator() {
pub fn entry_point_easing_animator() {
web::forward_panic_hook_to_console();
web::set_stdout();
web::set_stack_trace_limit();

View File

@ -1,13 +1,13 @@
//! An example showing usage of GlyphSystem.
use ensogl::prelude::*;
use ensogl_core::prelude::*;
use ensogl::data::color;
use ensogl::display::shape::text::glyph::font;
use ensogl::display::shape::text::glyph::system::GlyphSystem;
use ensogl::display::world::*;
use ensogl::system::web;
use ensogl_core_msdf_sys::run_once_initialized;
use ensogl_core::data::color;
use ensogl_core::display::shape::text::glyph::font;
use ensogl_core::display::shape::text::glyph::system::GlyphSystem;
use ensogl_core::display::world::*;
use ensogl_core::system::web;
use ensogl_text_msdf_sys::run_once_initialized;
use wasm_bindgen::prelude::*;
@ -15,7 +15,7 @@ use wasm_bindgen::prelude::*;
/// Main example runner.
#[wasm_bindgen]
#[allow(dead_code)]
pub fn run_example_glyph_system() {
pub fn entry_point_glyph_system() {
web::forward_panic_hook_to_console();
web::set_stdout();
run_once_initialized(|| init(&World::new(&web::get_html_element_by_id("root").unwrap())));
@ -37,6 +37,5 @@ fn init(world:&World) {
world.keep_alive_forever();
world.on_frame(move |_| {
let &_ = &line;
glyph_system.sprite_system().display_object().update();
}).forget();
}

View File

@ -0,0 +1,42 @@
//! The Visual Part of IDE.
//!
//! This crate has the all code for displaying GUI of Enso IDE application. The views provides
//! the FRP endpoints to communicate with controllers. It also have a mocked debug scenes of IDE.
#![feature(associated_type_defaults)]
#![feature(clamp)]
#![feature(drain_filter)]
#![feature(entry_insert)]
#![feature(fn_traits)]
#![feature(overlapping_marker_traits)]
#![feature(specialization)]
#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
#![feature(unboxed_closures)]
#![feature(vec_remove_item)]
#![feature(weak_into_raw)]
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![warn(missing_docs)]
#![warn(trivial_casts)]
#![warn(trivial_numeric_casts)]
#![warn(unsafe_code)]
#![warn(unused_import_braces)]
#![warn(unused_qualifications)]
#![recursion_limit="1024"]
#[allow(clippy::option_map_unit_fn)]
pub mod dom_symbols;
pub mod easing_animator;
pub mod glyph_system;
pub mod shape_system;
pub mod sprite_system;
pub mod text_field;
pub mod text_typing;
/// Common types that should be visible across the whole crate.
pub mod prelude {
pub use ensogl_core::prelude::*;
}

View File

@ -4,16 +4,16 @@
//! This file is under a heavy development. It contains commented lines of code and some code may
//! be of poor quality. Expect drastic changes.
use ensogl::prelude::*;
use ensogl_core::prelude::*;
use ensogl::display::navigation::navigator::Navigator;
use ensogl::system::web;
use ensogl_core::display::navigation::navigator::Navigator;
use ensogl_core::system::web;
use wasm_bindgen::prelude::*;
use ensogl::display::object::ObjectOps;
use ensogl::display::shape::ShapeSystem;
use ensogl::display::world::*;
use ensogl::display::shape::*;
use ensogl::data::color;
use ensogl_core::display::object::ObjectOps;
use ensogl_core::display::shape::ShapeSystem;
use ensogl_core::display::world::*;
use ensogl_core::display::shape::*;
use ensogl_core::data::color;
@ -26,7 +26,7 @@ pub fn shape() -> AnyShape {
#[wasm_bindgen]
#[allow(dead_code)]
pub fn run_example_shape_system() {
pub fn entry_point_shape_system() {
web::forward_panic_hook_to_console();
web::set_stdout();

View File

@ -1,17 +1,17 @@
#![allow(missing_docs)]
use ensogl::traits::*;
use ensogl_core::traits::*;
use ensogl::display::camera::Camera2d;
use ensogl::display::navigation::navigator::Navigator;
use ensogl::display::symbol::geometry::Sprite;
use ensogl::display::symbol::geometry::SpriteSystem;
use ensogl::display::world::*;
use ensogl::prelude::*;
use ensogl::system::web::forward_panic_hook_to_console;
use ensogl::system::web::set_stdout;
use ensogl::system::web;
use ensogl::animation;
use ensogl_core::display::camera::Camera2d;
use ensogl_core::display::navigation::navigator::Navigator;
use ensogl_core::display::symbol::geometry::Sprite;
use ensogl_core::display::symbol::geometry::SpriteSystem;
use ensogl_core::display::world::*;
use ensogl_core::prelude::*;
use ensogl_core::system::web::forward_panic_hook_to_console;
use ensogl_core::system::web::set_stdout;
use ensogl_core::system::web;
use ensogl_core::animation;
use nalgebra::Vector2;
use nalgebra::Vector3;
use wasm_bindgen::prelude::*;
@ -19,7 +19,7 @@ use wasm_bindgen::prelude::*;
#[wasm_bindgen]
#[allow(dead_code)]
pub fn run_example_sprite_system() {
pub fn entry_point_sprite_system() {
forward_panic_hook_to_console();
set_stdout();
@ -30,8 +30,8 @@ pub fn run_example_sprite_system() {
let sprite_system = SpriteSystem::new(&world);
let sprite1 = sprite_system.new_instance();
sprite1.size.set(Vector2::new(10.0, 10.0));
sprite1.mod_position(|t| *t = Vector3::new(5.0, 5.0, 0.0));
sprite1.size.set(Vector2::new(10.0,10.0));
sprite1.mod_position(|t| *t = Vector3::new(5.0,5.0,0.0));
world.add_child(&sprite_system);
@ -105,10 +105,8 @@ pub fn on_frame
y += (z * 1.25 + t * 2.00).cos() * 0.5;
z += (x * 1.25 + t * 3.25).cos() * 0.5;
let position = Vector3::new(x * 150.0 + half_width, y * 150.0 + half_height, z * 150.0);
let position = Vector3::new(x * 150.0 + half_width - 75.0, y * 150.0 + half_height - 75.0, z * 150.0);
sprite.set_position(position);
}
}
sprite_system.display_object().update();
}

View File

@ -1,13 +1,13 @@
#![allow(missing_docs)]
use ensogl::prelude::*;
use ensogl_core::prelude::*;
use ensogl::data::color;
use ensogl::display::world::World;
use ensogl::display::shape::text::glyph::font;
use ensogl::display::shape::text::text_field::TextField;
use ensogl::display::shape::text::text_field::TextFieldProperties;
use ensogl::system::web;
use ensogl_core::data::color;
use ensogl_core::display::world::World;
use ensogl_core::display::shape::text::glyph::font;
use ensogl_core::display::shape::text::text_field::TextField;
use ensogl_core::display::shape::text::text_field::TextFieldProperties;
use ensogl_core::system::web;
use nalgebra::Vector2;
use wasm_bindgen::prelude::*;
@ -27,10 +27,10 @@ Devoutly to be wish'd.";
#[wasm_bindgen]
#[allow(dead_code)]
pub fn run_example_text_field() {
pub fn entry_point_text_field() {
web::forward_panic_hook_to_console();
web::set_stdout();
ensogl_core_msdf_sys::run_once_initialized(|| {
ensogl_text_msdf_sys::run_once_initialized(|| {
let world = &World::new(&web::get_html_element_by_id("root").unwrap());
let mut fonts = font::Registry::new();
let font = fonts.get_or_load_embedded_font("DejaVuSansMono").unwrap();

View File

@ -2,23 +2,23 @@
use wasm_bindgen::prelude::*;
use ensogl::prelude::*;
use ensogl_core::prelude::*;
use ensogl::data::color;
use ensogl::display::shape::text::glyph::font;
use ensogl::display::shape::text::text_field::TextField;
use ensogl::display::shape::text::text_field::TextFieldProperties;
use ensogl::display::world::*;
use ensogl::system::web;
use ensogl_core::data::color;
use ensogl_core::display::shape::text::glyph::font;
use ensogl_core::display::shape::text::text_field::TextField;
use ensogl_core::display::shape::text::text_field::TextFieldProperties;
use ensogl_core::display::world::*;
use ensogl_core::system::web;
use nalgebra::Vector2;
#[wasm_bindgen]
#[allow(dead_code)]
pub fn run_example_text_typing() {
pub fn entry_point_text_typing() {
web::forward_panic_hook_to_console();
web::set_stdout();
ensogl_core_msdf_sys::run_once_initialized(|| {
ensogl_text_msdf_sys::run_once_initialized(|| {
let world = &World::new(&web::get_html_element_by_id("root").unwrap());
let mut fonts = font::Registry::new();
let font = fonts.get_or_load_embedded_font("DejaVuSansMono").unwrap();

View File

@ -0,0 +1,91 @@
[package]
name = "ensogl-core"
version = "0.1.0"
authors = ["Enso Team <contact@luna-lang.org>"]
edition = "2018"
[lib]
crate-type = ["rlib", "cdylib"]
[features]
default = ["statistics", "no_unboxed_callbacks"]
statistics = []
no_unboxed_callbacks = []
[dependencies]
enso-callback = { version = "0.1.0" , path = "../../../lib/callback" }
ensogl-text-embedded-fonts = { version = "0.1.0" , path = "../text/embedded-fonts" }
ensogl-text-msdf-sys = { version = "0.1.0" , path = "../text/msdf-sys" }
enso-generics = { version = "0.1.0" , path = "../../../lib/generics" }
enso-prelude = { version = "0.1.0" , path = "../../../lib/enso-prelude" }
ensogl-system-web = { version = "0.1.0" , path = "../../../lib/system/web" }
code-builder = { version = "0.1.0" , path = "../../../lib/code-builder" }
data = { version = "0.1.0" , path = "../../../lib/data" }
enso-frp = { version = "0.1.0" , path = "../../../lib/frp" }
enso-types = { version = "0.1.0" , path = "../../../lib/types" }
eval-tt = { version = "0.1.0" , path = "../../../lib/eval-tt" }
logger = { version = "0.1.0" , path = "../../../lib/logger" }
optics = { version = "0.1.0" , path = "../../../lib/optics" }
enso-shapely = { version = "0.1.0" , path = "../../../lib/enso-shapely/impl" }
bit_field = { version = "0.10.0" }
console_error_panic_hook = { version = "0.1.6" }
enum_dispatch = { version = "0.2.0" }
failure = { version = "0.1.5" }
Inflector = { version = "0.11.4" }
itertools = { version = "0.8" }
js-sys = { version = "0.3.28" }
nalgebra = { version = "0.21.1" }
num_enum = { version = "0.4.2" }
num-traits = { version = "0.2" }
paste = { version = "0.1.6" }
rustc-hash = { version = "1.0.1" }
shrinkwraprs = { version = "0.3.0" }
smallvec = { version = "1.0.0" }
typenum = { version = "1.11.2" }
# We require exact version of wasm-bindgen because we do patching final js in our build process,
# and this is vulnerable to any wasm-bindgen version change.
wasm-bindgen = { version = "=0.2.58" , features = ["nightly"] }
[dependencies.web-sys]
version = "0.3.4"
features = [
'CanvasRenderingContext2d',
'CssStyleDeclaration',
'Document',
'Element',
'EventTarget',
'KeyboardEvent',
'HtmlCanvasElement',
'HtmlCollection',
'HtmlDivElement',
'HtmlElement',
'HtmlImageElement',
'Location',
'Node',
'Url',
'WebGlBuffer',
'WebGlFramebuffer',
'WebGlProgram',
'WebGlRenderingContext',
'WebGlShader',
'WebGlSync',
'WebGlTexture',
'WebGlUniformLocation',
'WebGlUniformLocation',
'WebGlVertexArrayObject',
'Window',
'console',
'EventTarget',
'Event',
'MouseEvent',
'WheelEvent',
'DomRect',
'AddEventListenerOptions'
]
[dev-dependencies]
assert_approx_eq = { version = "1.1.0" }
wasm-bindgen-test = { version = "0.3.8" }
web-test = { version = "0.1.0", path = "../../../lib/web-test" }

View File

@ -27,11 +27,10 @@ pub mod traits {
/// Common types.
pub mod types {
use super::*;
pub use super::traits::*;
pub use object::Object;
pub use scene::Scene;
pub use scene::dom::DomScene;
pub use super::symbol::*;
pub use object::Object;
pub use object::WeakObject;
pub use super::traits::*;
}
pub use types::*;

View File

@ -5,6 +5,7 @@ use crate::prelude::*;
use crate::data::dirty;
use crate::display;
use crate::display::scene::Scene;
use crate::data::dirty::traits::*;
use crate::control::callback;
@ -179,7 +180,7 @@ impl Camera2dData {
let z_zoom_1 = 1.0;
let matrix = default();
let dirty = Dirty::new(&Logger::sub(&logger,"dirty"));
let display_object = display_object.clone2();
let display_object = display_object.clone_ref();
let zoom_update_registry = default();
let screen_update_registry = default();
display_object.set_on_updated(f_!(dirty.transform.set()));
@ -234,8 +235,8 @@ impl Camera2dData {
// https://github.com/rust-lang/rust-clippy/issues/4914
#[allow(clippy::useless_let_if_seq)]
fn update(&mut self) -> bool {
self.display_object.update();
fn update(&mut self, scene:&Scene) -> bool {
self.display_object.update(scene);
let mut changed = false;
if self.dirty.transform.check() {
self.recompute_view_matrix();
@ -370,8 +371,8 @@ impl Camera2d {
}
/// Update all dirty camera parameters and compute updated view-projection matrix.
pub fn update(&self) -> bool {
self.data.borrow_mut().update()
pub fn update(&self, scene:&Scene) -> bool {
self.data.borrow_mut().update(scene)
}
/// Adds a callback to notify when `zoom` is updated.

View File

@ -2,10 +2,8 @@
pub mod class;
pub mod transform;
pub mod weak;
pub use class::*;
pub use weak::*;
@ -16,7 +14,6 @@ pub use weak::*;
/// Common traits.
pub mod traits {
// Read the Rust Style Guide to learn more about the used naming.
pub use super::Object as TRAIT_Object;
pub use super::ObjectOps as TRAIT_ObjectOps;
pub use super::WeakObjectOps as TRAIT_WeakObjectOps;
pub use super::Object as TRAIT_Object;
pub use super::ObjectOps as TRAIT_ObjectOps;
}

File diff suppressed because it is too large Load Diff

View File

@ -151,7 +151,8 @@ impl Transform {
/// The same as `Transform` but with caching. It contains cached transformation matrix and dirty
/// flags which are set after fields are modified. You can use the `update` function to recompute
/// the matrix.
#[derive(Clone,Copy,Debug)]
#[derive(Clone,Debug)]
#[allow(missing_copy_implementations)]
pub struct CachedTransform {
transform : Transform,
transform_matrix : Matrix4<f32>,

View File

@ -912,11 +912,11 @@ impl SceneData {
}
}
fn update_camera(&self) {
fn update_camera(&self, scene:&Scene) {
// Updating camera for DOM layers. Please note that DOM layers cannot use multi-camera
// setups now, so we are using here the main camera only.
let camera = self.camera();
let changed = camera.update();
let changed = camera.update(scene);
if changed {
self.frp.camera_changed_source.emit(());
self.symbols.set_camera(camera);
@ -926,7 +926,7 @@ impl SceneData {
// Updating all other cameras (the main camera was already updated, so it will be skipped).
for view in &*self.views.all() {
view.upgrade().for_each(|v| v.camera.update());
view.upgrade().for_each(|v| v.camera.update(scene));
}
}
@ -1006,8 +1006,8 @@ impl Scene {
self.frp.frame_time_source.emit(t.local);
// Please note that `update_camera` is called first as it may trigger FRP events which
// may change display objects layout.
self.update_camera();
self.display_object.update_with(self);
self.update_camera(self);
self.display_object.update(self);
self.update_shape();
self.update_symbols();
self.handle_mouse_events();

View File

@ -179,8 +179,8 @@ impl DomScene {
pub fn manage(&self, object:&DomSymbol) {
let dom = object.dom();
let data = &self.data;
object.display_object().set_on_hide(f!(dom.remove()));
object.display_object().set_on_show(f!([data,dom] {
object.display_object().set_on_hide(f_!(dom.remove()));
object.display_object().set_on_show(f_!([data,dom] {
data.view_projection_dom.append_or_panic(&dom)
}));
self.data.view_projection_dom.append_or_panic(&object.dom());

View File

@ -4,8 +4,8 @@ use crate::prelude::*;
use crate::display::shape::text::glyph::msdf;
use ensogl_core_msdf_sys as msdf_sys;
use ensogl_core_embedded_fonts::EmbeddedFonts;
use ensogl_text_msdf_sys as msdf_sys;
use ensogl_text_embedded_fonts::EmbeddedFonts;
use msdf_sys::MsdfParameters;
use msdf_sys::Msdf;
use std::collections::hash_map::Entry;
@ -328,7 +328,7 @@ impl SharedRegistry {
mod tests {
use super::*;
use ensogl_core_embedded_fonts::EmbeddedFonts;
use ensogl_text_embedded_fonts::EmbeddedFonts;
use wasm_bindgen_test::wasm_bindgen_test;
use wasm_bindgen_test::wasm_bindgen_test_configure;
@ -346,7 +346,7 @@ mod tests {
#[wasm_bindgen_test(async)]
async fn empty_font_render_info() {
ensogl_core_msdf_sys::initialized().await;
ensogl_text_msdf_sys::initialized().await;
let font_render_info = create_test_font_render_info();
assert_eq!(TEST_FONT_NAME, font_render_info.name);
@ -356,7 +356,7 @@ mod tests {
#[wasm_bindgen_test(async)]
async fn loading_glyph_info() {
ensogl_core_msdf_sys::initialized().await;
ensogl_text_msdf_sys::initialized().await;
let font_render_info = create_test_font_render_info();
font_render_info.get_glyph_info('A');
@ -384,7 +384,7 @@ mod tests {
#[wasm_bindgen_test(async)]
async fn getting_or_creating_char() {
ensogl_core_msdf_sys::initialized().await;
ensogl_text_msdf_sys::initialized().await;
let font_render_info = create_test_font_render_info();
{

Some files were not shown because too many files have changed in this diff Show More