Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ windowless = []
[dependencies]
libc = "0.2"
lazy_static = "1.0"
bitflags = "1.0"

[target.'cfg(target_vendor = "apple")'.dependencies]
objc = "0.2"
Expand Down
6 changes: 2 additions & 4 deletions examples/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,8 @@ impl sciter::EventHandler for EventHandler {
}

fn check_options() {
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO as u8 // Enables `Sciter.machineName()`
| sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO as u8 // Enables opening file dialog (`view.selectFile()`)
)).ok();
let mask = (sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO | sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO).bits() as u8;
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(mask)).ok();

for arg in std::env::args() {
if arg.starts_with("--sciter-gfx=") {
Expand Down
6 changes: 2 additions & 4 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ fn main() {
let html = include_bytes!("minimal.htm");

// Step 2: Enable the features we need in our tiscript code.
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO as u8 // Enables `Sciter.machineName()`. Required for opening file dialog (`view.selectFile()`)
| sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO as u8 // Enables opening file dialog (`view.selectFile()`)
)).unwrap();
let mask = (sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO | sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO).bits() as u8;
sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(mask)).unwrap();

// Enable debug mode for all windows, so that we can inspect them via Inspector.
sciter::set_options(sciter::RuntimeOptions::DebugMode(true)).unwrap();
Expand Down
103 changes: 48 additions & 55 deletions src/capi/scbehavior.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,54 +158,54 @@ pub enum DRAW_EVENTS {


/// Event groups for subscription.
#[repr(C)]
#[derive(Copy, Clone)]
#[derive(Debug, PartialOrd, PartialEq)]
pub enum EVENT_GROUPS
{ /// Attached/detached.
HANDLE_INITIALIZATION = 0x0000,
/// Mouse events.
HANDLE_MOUSE = 0x0001,
/// Key events.
HANDLE_KEY = 0x0002,
/// Focus events, if this flag is set it also means that element it attached to is focusable.
HANDLE_FOCUS = 0x0004,
/// Scroll events.
HANDLE_SCROLL = 0x0008,
/// Timer event.
HANDLE_TIMER = 0x0010,
/// Size changed event.
HANDLE_SIZE = 0x0020,
/// Drawing request (event).
HANDLE_DRAW = 0x0040,
/// Requested data has been delivered.
HANDLE_DATA_ARRIVED = 0x080,

/// Logical, synthetic events:
/// `BUTTON_CLICK`, `HYPERLINK_CLICK`, etc.,
/// a.k.a. notifications from intrinsic behaviors.
HANDLE_BEHAVIOR_EVENT = 0x0100,
/// Behavior specific methods.
HANDLE_METHOD_CALL = 0x0200,
/// Behavior specific methods.
HANDLE_SCRIPTING_METHOD_CALL = 0x0400,

/// Behavior specific methods using direct `tiscript::value`'s.
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
HANDLE_TISCRIPT_METHOD_CALL = 0x0800,

/// System drag-n-drop.
HANDLE_EXCHANGE = 0x1000,
/// Touch input events.
HANDLE_GESTURE = 0x2000,
/// SOM passport and asset requests.
HANDLE_SOM = 0x8000,

/// All of them.
HANDLE_ALL = 0xFFFF,

/// Special value for getting subscription flags.
SUBSCRIPTIONS_REQUEST = -1,
bitflags! {
#[repr(C)]
pub struct EVENT_GROUPS: u32 {
/// Attached/detached.
const HANDLE_INITIALIZATION = 0x0000;
/// Mouse events.
const HANDLE_MOUSE = 0x0001;
/// Key events.
const HANDLE_KEY = 0x0002;
/// Focus events, if this flag is set it also means that element it attached to is focusable.
const HANDLE_FOCUS = 0x0004;
/// Scroll events.
const HANDLE_SCROLL = 0x0008;
/// Timer event.
const HANDLE_TIMER = 0x0010;
/// Size changed event.
const HANDLE_SIZE = 0x0020;
/// Drawing request (event).
const HANDLE_DRAW = 0x0040;
/// Requested data has been delivered.
const HANDLE_DATA_ARRIVED = 0x0080;

/// Logical, synthetic events:
/// `BUTTON_CLICK`, `HYPERLINK_CLICK`, etc.,
/// a.k.a. notifications from intrinsic behaviors.
const HANDLE_BEHAVIOR_EVENT = 0x0100;
/// Behavior specific methods.
const HANDLE_METHOD_CALL = 0x0200;
/// Behavior specific methods.
const HANDLE_SCRIPTING_METHOD_CALL = 0x0400;

/// Behavior specific methods using direct `tiscript::value`'s.
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
const HANDLE_TISCRIPT_METHOD_CALL = 0x0800;

/// System drag-n-drop.
const HANDLE_EXCHANGE = 0x1000;
/// Touch input events.
const HANDLE_GESTURE = 0x2000;
/// SOM passport and asset requests.
const HANDLE_SOM = 0x8000;

/// All of them.
const HANDLE_ALL = 0xFFFF;

/// Special value for getting subscription flags.
const SUBSCRIPTIONS_REQUEST = 0xFFFFFFFF; // since -1 as u32
}
}

#[repr(C)]
Expand Down Expand Up @@ -542,10 +542,3 @@ pub enum BEHAVIOR_EVENTS
}


impl ::std::ops::BitOr for EVENT_GROUPS {
type Output = EVENT_GROUPS;
fn bitor(self, rhs: Self::Output) -> Self::Output {
let rn = (self as UINT) | (rhs as UINT);
unsafe { ::std::mem::transmute(rn) }
}
}
85 changes: 43 additions & 42 deletions src/capi/scdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ pub enum LOAD_RESULT {
}

/// Script runtime options.
#[repr(C)]
#[derive(Debug)]
#[allow(missing_docs)]
pub enum SCRIPT_RUNTIME_FEATURES
{
ALLOW_FILE_IO = 0x1,
ALLOW_SOCKET_IO = 0x2,
ALLOW_EVAL = 0x4,
ALLOW_SYSINFO = 0x8,
bitflags! {
#[repr(C)]
#[allow(missing_docs)]
pub struct SCRIPT_RUNTIME_FEATURES: u8 {
const ALLOW_FILE_IO = 0x1;
const ALLOW_SOCKET_IO = 0x2;
const ALLOW_EVAL = 0x4;
const ALLOW_SYSINFO = 0x8;
}
}

/// Sciter graphics rendering backend.
Expand Down Expand Up @@ -74,6 +74,14 @@ pub enum GFX_LAYER

/// Skia backend with OpenGL rendering.
SKIA_OPENGL = 5,
/// vulkan
SKIA_VULKAN = 6,
#[cfg(osx)]
SKIA_METAL = 7,
#[cfg(windows)]
SKIA_DX12 = 8,
// auto
SKIA_GPU = 9,
}

#[repr(C)]
Expand Down Expand Up @@ -120,30 +128,32 @@ pub enum SCITER_RT_OPTIONS
}

/// Window flags
#[repr(C)]
pub enum SCITER_CREATE_WINDOW_FLAGS {
/// child window only, if this flag is set all other flags ignored.
SW_CHILD = 1,
/// toplevel window, has titlebar.
SW_TITLEBAR = 1 << 1,
/// has resizeable frame.
SW_RESIZEABLE = 1 << 2,
/// is tool window.
SW_TOOL = 1 << 3,
/// has minimize / maximize buttons.
SW_CONTROLS = 1 << 4,
/// glassy window - "Acrylic" on Windows and "Vibrant" on macOS.
SW_GLASSY = 1 << 5,
/// transparent window (e.g. `WS_EX_LAYERED` on Windows, macOS is supported too).
SW_ALPHA = 1 << 6,
/// main window of the app, will terminate the app on close.
SW_MAIN = 1 << 7,
/// the window is created as topmost window.
SW_POPUP = 1 << 8,
/// make this window inspector ready.
SW_ENABLE_DEBUG = 1 << 9,
/// it has its own script VM.
SW_OWNS_VM = 1 << 10,
bitflags! {
#[repr(C)]
pub struct SCITER_CREATE_WINDOW_FLAGS: u32 {
/// child window only, if this flag is set all other flags ignored.
const SW_CHILD = 1;
/// toplevel window, has titlebar.
const SW_TITLEBAR = 1 << 1;
/// has resizeable frame.
const SW_RESIZEABLE = 1 << 2;
/// is tool window.
const SW_TOOL = 1 << 3;
/// has minimize / maximize buttons.
const SW_CONTROLS = 1 << 4;
/// glassy window - "Acrylic" on Windows and "Vibrant" on macOS.
const SW_GLASSY = 1 << 5;
/// transparent window (e.g. `WS_EX_LAYERED` on Windows, macOS is supported too).
const SW_ALPHA = 1 << 6;
/// main window of the app, will terminate the app on close.
const SW_MAIN = 1 << 7;
/// the window is created as topmost window.
const SW_POPUP = 1 << 8;
/// make this window inspector ready.
const SW_ENABLE_DEBUG = 1 << 9;
/// it has its own script VM.
const SW_OWNS_VM = 1 << 10;
}
}

impl Default for SCITER_CREATE_WINDOW_FLAGS {
Expand All @@ -152,15 +162,6 @@ impl Default for SCITER_CREATE_WINDOW_FLAGS {
}
}

/// Flags can be OR'ed as `SW_MAIN|SW_ALPHA`.
impl ::std::ops::BitOr for SCITER_CREATE_WINDOW_FLAGS {
type Output = SCITER_CREATE_WINDOW_FLAGS;
fn bitor(self, rhs: Self::Output) -> Self::Output {
let rn = (self as UINT) | (rhs as UINT);
unsafe { ::std::mem::transmute(rn) }
}
}

#[repr(C)]
#[derive(Debug, PartialOrd, PartialEq)]
pub enum SCITER_NOTIFICATION {
Expand Down
Loading