Update cbindgen and enable MouseCursor::move

cbindgen 0.21 was released which contains https://github.com/eqrion/cbindgen/pull/724
which allow to use raw identifier in enums shared with C++.
So now we can have `MouseCursor.move` in slint  despite it being a rust keyword

Note that the strum macro also have trouble with the raw identifier, so we
take that in account in the conversion functions in the interpreter
This commit is contained in:
Olivier Goffart 2022-04-04 09:59:14 +02:00 committed by Olivier Goffart
parent c24a51aaba
commit 40c98d6d05
9 changed files with 17 additions and 5 deletions

View file

@ -42,5 +42,5 @@ slint-interpreter = { version = "=0.2.2", path="../../internal/interpreter", def
[build-dependencies]
anyhow = "1.0"
cbindgen = "0.20"
cbindgen = "0.21"
proc-macro2 = "1.0.11"

View file

@ -886,6 +886,7 @@ Depending on the backend and used OS unidirectional resize cursors may be replac
* **`text`**: A cursor indicating selectable text.
* **`alias`**: An alias or shortcut is being created.
* **`copy`**: A copy is being created.
* **`move`**: Something is to be moved.
* **`no-drop`**: Something cannot be dropped here.
* **`not-allowed`**: An action is not allowed
* **`grab`**: Something is grabbable.

View file

@ -536,6 +536,7 @@ impl PlatformWindow for GLWindow {
MouseCursor::text => winit::window::CursorIcon::Text,
MouseCursor::alias => winit::window::CursorIcon::Alias,
MouseCursor::copy => winit::window::CursorIcon::Copy,
MouseCursor::r#move => winit::window::CursorIcon::Move,
MouseCursor::no_drop => winit::window::CursorIcon::NoDrop,
MouseCursor::not_allowed => winit::window::CursorIcon::NotAllowed,
MouseCursor::grab => winit::window::CursorIcon::Grab,

View file

@ -1529,6 +1529,7 @@ impl PlatformWindow for QtWindow {
MouseCursor::text => key_generated::Qt_CursorShape_IBeamCursor,
MouseCursor::alias => key_generated::Qt_CursorShape_DragLinkCursor,
MouseCursor::copy => key_generated::Qt_CursorShape_DragCopyCursor,
MouseCursor::r#move => key_generated::Qt_CursorShape_DragMoveCursor,
MouseCursor::no_drop => key_generated::Qt_CursorShape_ForbiddenCursor,
MouseCursor::not_allowed => key_generated::Qt_CursorShape_ForbiddenCursor,
MouseCursor::grab => key_generated::Qt_CursorShape_OpenHandCursor,

View file

@ -216,6 +216,7 @@ impl TypeRegister {
"text",
"alias",
"copy",
"move",
"no-drop",
"not-allowed",
"grab",

View file

@ -699,7 +699,7 @@ pub enum MouseCursor {
//vertical_text,
alias,
copy,
//r#move,
r#move,
no_drop,
not_allowed,
grab,

View file

@ -271,7 +271,10 @@ macro_rules! declare_value_enum_conversion {
($ty:ty, $n:ident) => {
impl From<$ty> for Value {
fn from(v: $ty) -> Self {
Value::EnumerationValue(stringify!($n).to_owned(), v.to_string().replace('_', "-"))
Value::EnumerationValue(
stringify!($n).to_owned(),
v.to_string().trim_start_matches("r#").replace('_', "-"),
)
}
}
impl TryInto<$ty> for Value {
@ -285,7 +288,11 @@ macro_rules! declare_value_enum_conversion {
}
<$ty>::from_str(value.as_str())
.or_else(|_| <$ty>::from_str(&value.as_str().replace('-', "_")))
.or_else(|_| {
let norm = value.as_str().replace('-', "_");
<$ty>::from_str(&norm)
.or_else(|_| <$ty>::from_str(&format!("r#{}", norm)))
})
.map_err(|_| ())
}
_ => Err(()),

View file

@ -14,6 +14,7 @@ TestCase := Rectangle {
width: 10phx;
height: 10phx;
clicked => { touch1+=1; }
mouse-cursor: move;
TouchArea {
y: 2phx;
height: 2phx;

View file

@ -20,6 +20,6 @@ regex = "1.4"
toml_edit = "0.6.0"
xshell = "0.1.6"
serde_json = "1.0"
cbindgen = "0.20"
cbindgen = "0.21"
proc-macro2 = "1.0.11"
which = "4.2.4"