mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Avoid the use of symlinks for source files
On Windows 10, the creation of symlinks by normal users requires enabling the developer mode, which may or may not be acceptable in corporate environments with restricted IT setups. We introduced the symlinks for the shared special key codes mapping, which instead this patch places into a shared sixtyfps-common crate.
This commit is contained in:
parent
b8cc59afca
commit
e0a942dc1c
18 changed files with 92 additions and 44 deletions
|
@ -1,5 +1,6 @@
|
|||
[workspace]
|
||||
members = [
|
||||
'sixtyfps_runtime/common',
|
||||
'sixtyfps_runtime/corelib',
|
||||
'sixtyfps_runtime/corelib_macros',
|
||||
'sixtyfps_runtime/interpreter',
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# Please contact info@sixtyfps.io for more information.
|
||||
# LICENSE END
|
||||
cargo publish --manifest-path sixtyfps_runtime/corelib_macros/Cargo.toml
|
||||
cargo publish --manifest-path sixtyfps_runtime/common/Cargo.toml
|
||||
cargo publish --manifest-path sixtyfps_compiler/Cargo.toml
|
||||
cargo publish --manifest-path sixtyfps_runtime/corelib/Cargo.toml
|
||||
cargo publish --manifest-path api/sixtyfps-rs/sixtyfps-macros/Cargo.toml
|
||||
|
|
|
@ -44,6 +44,7 @@ once_cell = "1"
|
|||
url = "2.2.1"
|
||||
dunce = "1.0.1"
|
||||
linked_hash_set = "0.1.4"
|
||||
sixtyfps-common = { version = "=0.1.6", path = "../sixtyfps_runtime/common" }
|
||||
|
||||
# for processing and embedding the rendered image (texture)
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
|
|
|
@ -447,9 +447,8 @@ impl ColorSpecific {
|
|||
|
||||
struct KeysLookup;
|
||||
|
||||
macro_rules! for_each_special_keys {
|
||||
macro_rules! special_keys_lookup {
|
||||
($($char:literal # $name:ident # $($qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||
use super::*;
|
||||
impl LookupObject for KeysLookup {
|
||||
fn for_each_entry<R>(
|
||||
&self,
|
||||
|
@ -464,7 +463,8 @@ macro_rules! for_each_special_keys {
|
|||
}
|
||||
};
|
||||
}
|
||||
mod key_codes;
|
||||
|
||||
sixtyfps_common::for_each_special_keys!(special_keys_lookup);
|
||||
|
||||
struct EasingSpecific;
|
||||
impl LookupObject for EasingSpecific {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../sixtyfps_runtime/corelib/input/key_codes.rs
|
13
sixtyfps_runtime/common/Cargo.toml
Normal file
13
sixtyfps_runtime/common/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "sixtyfps-common"
|
||||
version = "0.1.6"
|
||||
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0-only"
|
||||
description = "Helper crate for sharing code & data structures between sixtyfps-corelib and sixtyfps-compiler"
|
||||
repository = "https://github.com/sixtyfpsui/sixtyfps"
|
||||
homepage = "https://sixtyfps.io"
|
||||
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
|
@ -12,7 +12,11 @@ LICENSE END */
|
|||
|
||||
// The key code comes from https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT
|
||||
// the names comes should match with https://www.w3.org/TR/uievents-key/#named-key-attribute-values,
|
||||
for_each_special_keys![
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! for_each_special_keys {
|
||||
($macro:ident) => {
|
||||
$macro![
|
||||
'\u{0008}' # Backspace # Qt_Key_Key_Backspace # Back ;
|
||||
'\u{0009}' # Tab # Qt_Key_Key_Tab # Tab ;
|
||||
'\u{000a}' # Return # Qt_Key_Key_Enter|Qt_Key_Key_Return # NumpadEnter|Return ;
|
||||
|
@ -91,5 +95,6 @@ for_each_special_keys![
|
|||
//'\u{F745}' # Find # Qt_Key_Key_Find # ;
|
||||
//'\u{F746}' # Help # Qt_Key_Key_Help # ;
|
||||
//'\u{F747}' # ModeSwitch # Qt_Key_Key_Mode_switch # ;
|
||||
|
||||
];
|
||||
};
|
||||
}
|
23
sixtyfps_runtime/common/lib.rs
Normal file
23
sixtyfps_runtime/common/lib.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* LICENSE BEGIN
|
||||
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-only
|
||||
This file is also available under commercial licensing terms.
|
||||
Please contact info@sixtyfps.io for more information.
|
||||
LICENSE END */
|
||||
/*!
|
||||
This crate contains internal data structures and code that is shared between
|
||||
the sixtyfps-corelib and the sixtyfps-compiler(lib) crates.
|
||||
|
||||
**NOTE**: This library is an **internal** crate for the [SixtyFPS project](https://sixtyfps.io).
|
||||
This crate should **not be used directly** by applications using SixtyFPS.
|
||||
You should use the `sixtyfps` crate instead.
|
||||
|
||||
**WARNING**: This crate does not follow the semver convention for versioning and can
|
||||
only be used with `version = "=x.y.z"` in Cargo.toml.
|
||||
|
||||
*/
|
||||
|
||||
pub mod key_codes;
|
|
@ -54,6 +54,7 @@ rgb = "0.8.27"
|
|||
pin-project = "1"
|
||||
atomic-polyfill = { version = "0.1.5" }
|
||||
num-traits = { version = "0.2", default-features = false }
|
||||
sixtyfps-common = { version = "=0.1.6", path = "../common" }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
instant = { version = "0.1", features = [ "wasm-bindgen", "now" ] }
|
||||
|
|
|
@ -117,15 +117,17 @@ impl Default for InputEventFilterResult {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! for_each_special_keys {
|
||||
($($char:literal # $name:ident # $($_qt:ident)|* # $($_winit:ident)|* ;)*) => {
|
||||
$(pub const $name : char = $char;)*
|
||||
};
|
||||
}
|
||||
|
||||
/// This module contains the constant character code used to represent the keys
|
||||
#[allow(missing_docs, non_upper_case_globals)]
|
||||
pub mod key_codes;
|
||||
pub mod key_codes {
|
||||
macro_rules! declare_consts_for_special_keys {
|
||||
($($char:literal # $name:ident # $($_qt:ident)|* # $($_winit:ident)|* ;)*) => {
|
||||
$(pub const $name : char = $char;)*
|
||||
};
|
||||
}
|
||||
|
||||
sixtyfps_common::for_each_special_keys!(declare_consts_for_special_keys);
|
||||
}
|
||||
|
||||
/// KeyboardModifier provides booleans to indicate possible modifier keys
|
||||
/// on a keyboard, such as Shift, Control, etc.
|
||||
|
|
|
@ -21,6 +21,7 @@ default = ["svg"]
|
|||
|
||||
[dependencies]
|
||||
sixtyfps-corelib = { version = "=0.1.6", path = "../../corelib" }
|
||||
sixtyfps-common = { version = "=0.1.6", path = "../../common" }
|
||||
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
||||
image = { version = "0.23.14", default-features = false, features = [ "png", "jpeg" ] }
|
||||
rgb = "0.8.27"
|
||||
|
|
|
@ -331,22 +331,22 @@ fn redraw_all_windows() {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! for_each_special_keys {
|
||||
($($char:literal # $name:ident # $($_qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||
pub fn winit_key_to_string(virtual_keycode: winit::event::VirtualKeyCode) -> Option<sixtyfps_corelib::SharedString> {
|
||||
let char = match(virtual_keycode) {
|
||||
$($(winit::event::VirtualKeyCode::$winit => $char,)*)*
|
||||
_ => return None,
|
||||
};
|
||||
let mut buffer = [0; 6];
|
||||
Some(sixtyfps_corelib::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
||||
}
|
||||
};
|
||||
mod key_codes {
|
||||
macro_rules! winit_key_to_string_fn {
|
||||
($($char:literal # $name:ident # $($_qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||
pub fn winit_key_to_string(virtual_keycode: winit::event::VirtualKeyCode) -> Option<sixtyfps_corelib::SharedString> {
|
||||
let char = match(virtual_keycode) {
|
||||
$($(winit::event::VirtualKeyCode::$winit => $char,)*)*
|
||||
_ => return None,
|
||||
};
|
||||
let mut buffer = [0; 6];
|
||||
Some(sixtyfps_corelib::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
||||
}
|
||||
};
|
||||
}
|
||||
sixtyfps_common::for_each_special_keys!(winit_key_to_string_fn);
|
||||
}
|
||||
|
||||
#[path = "key_codes.rs"]
|
||||
mod key_codes;
|
||||
|
||||
fn process_window_event(
|
||||
window: Rc<dyn WinitWindow>,
|
||||
event: WindowEvent,
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../corelib/input/key_codes.rs
|
|
@ -18,6 +18,7 @@ unsafe_single_core = ["sixtyfps-corelib/unsafe_single_core"]
|
|||
|
||||
[dependencies]
|
||||
sixtyfps-corelib = { version = "=0.1.6", path = "../../corelib", default-features = false }
|
||||
sixtyfps-common = { version = "=0.1.6", path = "../../common", default-features = false }
|
||||
const-field-offset = { version = "0.1", path = "../../../helper_crates/const-field-offset" }
|
||||
rgb = "0.8.27"
|
||||
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../corelib/input/key_codes.rs
|
|
@ -22,6 +22,7 @@ const-field-offset = { version = "0.1", path = "../../../helper_crates/const-fie
|
|||
vtable = { version = "0.1", path = "../../../helper_crates/vtable" }
|
||||
sixtyfps-corelib-macros = { version = "=0.1.6", path = "../../corelib_macros" }
|
||||
sixtyfps-corelib = { version = "=0.1.6", path = "../../corelib" }
|
||||
sixtyfps-common = { version = "=0.1.6", path = "../../common" }
|
||||
euclid = "0.22.1"
|
||||
pin-weak = "1"
|
||||
once_cell = "1"
|
||||
|
|
|
@ -1578,23 +1578,25 @@ pub(crate) fn timer_event() {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! for_each_special_keys {
|
||||
($($char:literal # $name:ident # $($qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||
use crate::key_generated;
|
||||
pub fn qt_key_to_string(key: key_generated::Qt_Key) -> Option<sixtyfps_corelib::SharedString> {
|
||||
mod key_codes {
|
||||
macro_rules! define_qt_key_to_string_fn {
|
||||
($($char:literal # $name:ident # $($qt:ident)|* # $($winit:ident)|* ;)*) => {
|
||||
use crate::key_generated;
|
||||
pub fn qt_key_to_string(key: key_generated::Qt_Key) -> Option<sixtyfps_corelib::SharedString> {
|
||||
|
||||
let char = match(key) {
|
||||
$($(key_generated::$qt => $char,)*)*
|
||||
_ => return None,
|
||||
};
|
||||
let mut buffer = [0; 6];
|
||||
Some(sixtyfps_corelib::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
||||
}
|
||||
};
|
||||
let char = match(key) {
|
||||
$($(key_generated::$qt => $char,)*)*
|
||||
_ => return None,
|
||||
};
|
||||
let mut buffer = [0; 6];
|
||||
Some(sixtyfps_corelib::SharedString::from(char.encode_utf8(&mut buffer) as &str))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
sixtyfps_common::for_each_special_keys!(define_qt_key_to_string_fn);
|
||||
}
|
||||
|
||||
mod key_codes;
|
||||
|
||||
fn qt_key_to_string(key: key_generated::Qt_Key, event_text: String) -> SharedString {
|
||||
// First try to see if we received one of the non-ascii keys that we have
|
||||
// a special representation for. If that fails, try to use the provided
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../corelib/input/key_codes.rs
|
Loading…
Add table
Add a link
Reference in a new issue