- Notifications
You must be signed in to change notification settings - Fork79
sciter-sdk/rust-sciter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Checkthis page for other language bindings (Delphi / D / Go / .NET / Python / Rust).
Sciter is an embeddablemultiplatform 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 thescreenshot gallery of desktop UI examplesandDirectX UI integration viaRust GFX.
Physically Sciter is a mono library which contains:
- HTML and CSS rendering engine based on the H-SMILE core used inHTMLayout,
- JavaScript inSciter.JS,
- JavaScript alikeScripting engine – core ofTIScript which by itself is based onc-smile engine,
- PersistentDatabase (a.k.a.JSON DB) based on excellent DB products ofKonstantin Knizhnik.
- Graphics module that uses native graphics primitives provided by supported platforms: Direct2D on Windows 7 and above, GDI+ on Windows XP, CoreGraphics on MacOS, Cairo on Linux/GTK. Yet there is an option to use built-inSkia/OpenGL backend on each platform.
- Network communication module, it relies on platform HTTP client primitives and/orLibcurl.
Internally it contains the following modules:
- CSS – CSS parser and the 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 the layout calculations heavy lifting. This module is also responsible for the rendering of layouts.
- input behaviors – a 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 the modules mentioned above from the particular platform details:
- Direct2D/DirectWrite graphics backend (Windows);
- GDI+ graphics backend (Windows);
- CoreGraphics backend (Mac OS X);
- Cairo backend (GTK on all Linux platforms);
- Skia/OpenGL backend (all platforms)
- core primitives – set of common primitives: string, arrays, hash maps and so on.
Sciter supports all standard elements defined in HTML5 specificationwith some additions. CSS is extended to better support the Desktop UI development, e.g. flow and flex units, vertical and horizontal alignment, OS theming.
Sciter SDK comes with a demo "browser" with a builtin DOM inspector, script debugger and documentation viewer:
Checkhttps://sciter.com website and itsdocumentation resources for engine principles, architecture and more.
- Download theSciter.TIS or Sciter.JS SDK and extract it somewhere.
- Add the corresponding target platform binaries to PATH (
bin.win
,bin.osx
orbin.lnx
). - If you do not already have it installed, you need GTK 3 development tools installed to continue:sudo apt-get install libgtk-3-dev
- Build the crate and run a minimal sciter sample:
cargo run --example minimal
. - For your apps add the following dependency to the Cargo.toml:
sciter-rs = "*"
.
Here is a minimal sciter app:
externcrate sciter;fnmain(){letmut frame = sciter::Window::new(); frame.load_file("minimal.htm"); frame.run_app();}
It looks similar to this:
In respect oftiscript or JavaScript 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:
structHandler;implHandler{fncalc_sum(&self,a:i32,b:i32) ->i32{ a + b}}impl sciter::EventHandlerforHandler{dispatch_script_call!{fn calc_sum(i32,i32);}}
And we can access this function from TIScript:
// `view` represents the window where this script is running.// `stdout` stream is a standard output stream (shell or debugger console, for example)stdout.printf("2 + 3 = %d\n",view.calc_sum(2,3));
or from #"auto" data-snippet-clipboard-copy-content="// `Window.this` represents the window where this script is running.console.log("2 + 3", Window.this.xcall("calc_sum", 2, 3));">
// `Window.this` represents the window where this script is running.console.log("2 + 3",Window.this.xcall("calc_sum",2,3));
Checkrust-sciter/examples folder for more complex usage.
- sciter::window which brings together window creation, host and event handlers.
- sciter::host with basic event handling, needs to be redesigned.
- sciter::event_handler with event handling and auto dispatching script calls to native code.
- sciter::dom for HTML DOM access and manipulation methods.
- sciter::value Rust wrapper.
- sciter::behavior_factory - global factory for native behaviors.
- sciter::graphics - platform independent graphics native interface (can be used in native behaviors).
- sciter::request - resource request object, used for custom resource downloading and handling.
- sciter::video - custom video rendering.
- sciter::archive - Sciter's compressed archive produced by
sdk/bin/packfolder
tool. - sciter::msg - backend-independent input event processing.
- sciter::om - Sciter Object Model, extending Sciter by native code.
- NSE - native Sciter extensions.
- Windows
- OSX
- Linux
- Raspberry Pi
Bindings library licensed underMIT license. Sciter Engine has theown license terms andend used license agreement for SDK usage.
About
Rust bindings for Sciter
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.