mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Rename Value::Resource
to Value::Image
This commit is contained in:
parent
6f88d78303
commit
933c1bbf59
2 changed files with 12 additions and 12 deletions
|
@ -210,7 +210,7 @@ fn to_eval_value<'cx>(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Type::Image => {
|
Type::Image => {
|
||||||
Ok(Value::Resource(ImageReference::AbsoluteFilePath(val.to_string(cx)?.value().into())))
|
Ok(Value::Image(ImageReference::AbsoluteFilePath(val.to_string(cx)?.value().into())))
|
||||||
}
|
}
|
||||||
Type::Bool => Ok(Value::Bool(val.downcast_or_throw::<JsBoolean, _>(cx)?.value())),
|
Type::Bool => Ok(Value::Bool(val.downcast_or_throw::<JsBoolean, _>(cx)?.value())),
|
||||||
Type::Object { fields, .. } => {
|
Type::Object { fields, .. } => {
|
||||||
|
@ -258,7 +258,7 @@ fn to_js_value<'cx>(
|
||||||
Value::Number(n) => JsNumber::new(cx, n).as_value(cx),
|
Value::Number(n) => JsNumber::new(cx, n).as_value(cx),
|
||||||
Value::String(s) => JsString::new(cx, s.as_str()).as_value(cx),
|
Value::String(s) => JsString::new(cx, s.as_str()).as_value(cx),
|
||||||
Value::Bool(b) => JsBoolean::new(cx, b).as_value(cx),
|
Value::Bool(b) => JsBoolean::new(cx, b).as_value(cx),
|
||||||
Value::Resource(r) => match r {
|
Value::Image(r) => match r {
|
||||||
ImageReference::None => JsUndefined::new().as_value(cx),
|
ImageReference::None => JsUndefined::new().as_value(cx),
|
||||||
ImageReference::AbsoluteFilePath(path) => JsString::new(cx, path.as_str()).as_value(cx),
|
ImageReference::AbsoluteFilePath(path) => JsString::new(cx, path.as_str()).as_value(cx),
|
||||||
ImageReference::EmbeddedData { .. } | ImageReference::EmbeddedRgbaImage { .. } => {
|
ImageReference::EmbeddedData { .. } | ImageReference::EmbeddedRgbaImage { .. } => {
|
||||||
|
|
|
@ -108,17 +108,17 @@ pub enum Value {
|
||||||
/// There is nothing in this value. That's the default.
|
/// There is nothing in this value. That's the default.
|
||||||
/// For example, a function that do not return a result would return a Value::Void
|
/// For example, a function that do not return a result would return a Value::Void
|
||||||
Void,
|
Void,
|
||||||
/// An i32 or a float
|
/// An `int` or a `float` (this is also used for unit based type such as `length` or `angle`)
|
||||||
Number(f64),
|
Number(f64),
|
||||||
/// String
|
/// Correspond to the `string` type in .60
|
||||||
String(SharedString),
|
String(SharedString),
|
||||||
/// Bool
|
/// Correspond to the `bool` type in .60
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
/// A resource (typically an image)
|
/// Correspond to the `image` type in .60
|
||||||
Resource(ImageReference),
|
Image(ImageReference),
|
||||||
/// An Array
|
/// An Array in the .60 language.
|
||||||
Array(Vec<Value>),
|
Array(Vec<Value>),
|
||||||
/// A more complex model which is not created by the interpreter itself
|
/// A more complex model which is not created by the interpreter itself (Value::Array can also be used for model)
|
||||||
Model(ModelPtr),
|
Model(ModelPtr),
|
||||||
/// An object
|
/// An object
|
||||||
Object(HashMap<String, Value>),
|
Object(HashMap<String, Value>),
|
||||||
|
@ -176,7 +176,7 @@ macro_rules! declare_value_conversion {
|
||||||
declare_value_conversion!(Number => [u32, u64, i32, i64, f32, f64, usize, isize] );
|
declare_value_conversion!(Number => [u32, u64, i32, i64, f32, f64, usize, isize] );
|
||||||
declare_value_conversion!(String => [SharedString] );
|
declare_value_conversion!(String => [SharedString] );
|
||||||
declare_value_conversion!(Bool => [bool] );
|
declare_value_conversion!(Bool => [bool] );
|
||||||
declare_value_conversion!(Resource => [ImageReference] );
|
declare_value_conversion!(Image => [ImageReference] );
|
||||||
declare_value_conversion!(Object => [HashMap<String, Value>] );
|
declare_value_conversion!(Object => [HashMap<String, Value>] );
|
||||||
declare_value_conversion!(Color => [Color] );
|
declare_value_conversion!(Color => [Color] );
|
||||||
declare_value_conversion!(Brush => [Brush] );
|
declare_value_conversion!(Brush => [Brush] );
|
||||||
|
@ -656,10 +656,10 @@ pub fn eval_expression(e: &Expression, local_context: &mut EvalLocalContext) ->
|
||||||
Expression::ResourceReference(resource_ref) => {
|
Expression::ResourceReference(resource_ref) => {
|
||||||
match resource_ref {
|
match resource_ref {
|
||||||
sixtyfps_compilerlib::expression_tree::ResourceReference::None => {
|
sixtyfps_compilerlib::expression_tree::ResourceReference::None => {
|
||||||
Value::Resource(ImageReference::None)
|
Value::Image(ImageReference::None)
|
||||||
}
|
}
|
||||||
sixtyfps_compilerlib::expression_tree::ResourceReference::AbsolutePath(path) => {
|
sixtyfps_compilerlib::expression_tree::ResourceReference::AbsolutePath(path) => {
|
||||||
Value::Resource(ImageReference::AbsoluteFilePath(path.into()))
|
Value::Image(ImageReference::AbsoluteFilePath(path.into()))
|
||||||
}
|
}
|
||||||
sixtyfps_compilerlib::expression_tree::ResourceReference::EmbeddedData(_) => panic!("Resource embedding is not supported by the interpreter")
|
sixtyfps_compilerlib::expression_tree::ResourceReference::EmbeddedData(_) => panic!("Resource embedding is not supported by the interpreter")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue