Rust bindings for Sciter
Rust
Latest commit 10029ce Oct 26, 2016 @pravic version 0.4.1
Permalink
Failed to load latest commit information.
examples example: add fire_event demo from #10. Oct 25, 2016
src dom: implement send/post/fire events. Oct 25, 2016
tests fix 1.7.0 issues Apr 4, 2016
.gitignore git ignore Mar 18, 2016
Cargo.toml version 0.4.1 Oct 25, 2016
README.md update license Apr 18, 2016
appveyor.yml add appveyor integration Apr 4, 2016

README.md

Rust bindings for Sciter

Build status Join the chat at https://gitter.im/pravic/rust-sciter

Check this page for another language bindings.


Sciter is an embeddable multiplatform HTML/CSS/script engine with GPU accelerated rendering designed to render modern desktop application UI. It's a compact, single dll/dylib/so file (4-8 mb), engine without any additional dependencies.

Check the screenshot gallery of the desktop UI examples and DirectX UI integration via Rust GFX.

Physically Sciter is a mono library which contains:

Internally it contains the following modules:

  • CSS – CSS parser and collection of parsed CSS rules, etc.
  • HTML DOM – HTML parser and DOM tree implementation.
  • layout managers – collection of various layout managers – text layout, default block layout, flex layouts. Support of positioned floating elements is also here. This module does layout calculations heavy lifting. This module is also responsible for rendering of layouts.
  • input behaviors – collection of built-in behaviors – code behind "active" DOM elements: <input>, <select>, <textarea>, etc.
  • script module – source-to-bytecode compiler and virtual machine (VM) with compacting garbage collector (GC). This module also contains runtime implementation of standard classes and objects: Array, Object, Function and others.
  • script DOM – runtime classes that expose DOM and DOM view (a.k.a. window) to the script.
  • graphics abstraction layer – abstract graphics implementation that isolates modules above from particular platform details
    • Direct2D/DirectWrite graphics backend implementation (Windows);
    • GDI+ graphics backend implementation (Windows);
    • CoreGraphics backend implementation (Mac OS X);
    • Cairo backend implementation (GTK on all platforms including Linuxes);
  • core primitives – set of common primitives: string, arrays, hash maps and so on.

Sciter supports all standard elements defined in HTML5 specification with some additions. CSS extended to better support Desktop UI development, e.g. flow and flex units, vertical and horizontal alignment, OS theming.

Sciter SDK comes with demo "browser" with builtin DOM inspector, script debugger and documentation browser:

Sciter tools

Check http://sciter.com website and its documentation resources for engine principles, architecture and more.

Getting started:

  1. Download Sciter SDK and extract it somewhere.
  2. Add target platform binaries to PATH (bin, bin.osx or bin.gtk) and install Sciter shared library to your LIBRARY_PATH.
  3. Build library and run the minimal sciter sample: cargo run --example minimal.
  4. For your apps add the following dependency to the Cargo.toml: sciter-rs = "*".

Brief look:

Here is a minimal sciter app:

extern crate sciter;

fn main() {
    let mut frame = sciter::Window::new();
    frame.load_file("minimal.htm");
    frame.run_app(true);
}

It looks similar like this:

Minimal sciter sample

Interoperability

In respect of tiscript functions calling:

use sciter::{Element, Value};

let root = Element::from_window(hwnd);
let result: Value = root.call_function("namespace.name", &make_args!(1,"2",3));

Calling rust from script can be implemented as following:

struct Handler;

impl Handler {
  fn calc_sum(&self, a: i32, b: i32) -> i32 {
    a + b
  }
}

impl sciter::EventHandler for Handler {
  dispatch_script_call! {
    fn calc_sum(i32, i32);
  }
}

And we can access this function from script:

// `view` represents window where script is runnung.
// `stdout` stream is a standard output stream (shell or debugger console, for example)

stdout.printf("2 + 3 = %d\n", view.calc_sum(2, 3));

Check rust-sciter/examples folder for more complex usage.

Library documentation.

What supported right now:

Platforms:

  • Windows
  • OSX
  • Linux

License

Bindings library licensed under MIT license. Sciter Engine has the own license terms and end used license agreement for SDK usage.