Surrealism-All / SurrealismUI

A third-party UI library using Slint, I think it will give you an extraordinary experience
https://surrealism-all.github.io/SurrealismUI.github.io/
MIT License
192 stars 18 forks source link

无法编译SMenu #14

Closed ZhengLongBing closed 8 months ago

ZhengLongBing commented 8 months ago

rust版本:rustc 1.74.0 (79e9716c9 2023-11-13)

slint版本:1.3.2

slint-build版本:1.3.2

错误信息: error: failed to run custom build command for user v0.1.0 (C:\Users\ZhengLongBing\Desktop\library_loan_management_system\user) note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by: process didn't exit successfully: C:\Users\ZhengLongBing\Desktop\library_loan_management_system\target\debug\build\user-651710c26a9cf3ca\build-script-build (exit code: 101) --- stderr thread 'main' panicked at C:\Users\ZhengLongBing.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\i-slint-compiler-1.3.2\llr\lower_expression.rs:35:34: called Option::unwrap() on a None value stack backtrace: 0: std::panicking::begin_panic_handler at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\panicking.rs:597 1: core::panicking::panic_fmt at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:72 2: core::panicking::panic at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:127 3: core::option::Option::unwrap 4: i_slint_compiler::llr::lower_expression::ExpressionContext::map_property_reference 5: i_slint_compiler::llr::lower_expression::lower_expression 6: i_slint_compiler::llr::lower_expression::lower_expression 7: i_slint_compiler::llr::lower_expression::lower_expression::{{closure}} 8: core::iter::adapters::map::map_fold::{{closure}} 9: <core::slice::iter::Iter as core::iter::traits::iterator::Iterator>::fold 10: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold 11: core::iter::traits::iterator::Iterator::for_each 12: alloc::vec::Vec<T,A>::extend_trusted 13: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend 14: <alloc::vec::Vec as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter 15: <alloc::vec::Vec as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter 16: <alloc::vec::Vec as core::iter::traits::collect::FromIterator>::from_iter 17: core::iter::traits::iterator::Iterator::collect 18: i_slint_compiler::llr::lower_expression::lower_expression 19: i_slint_compiler::llr::lower_expression::lower_expression 20: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component::{{closure}} 21: i_slint_compiler::generator::handle_property_bindings_init::handle_property_inner 22: i_slint_compiler::generator::handle_property_bindings_init::{{closure}} 23: i_slint_compiler::object_tree::recurse_elem 24: i_slint_compiler::object_tree::recurse_elem 25: i_slint_compiler::generator::handle_property_bindings_init 26: i_slint_compiler::llr::lower_to_item_tree::LoweringState::map_property_reference 27: i_slint_compiler::llr::lower_to_item_tree::lower_to_item_tree 28: i_slint_compiler::generator::rust::generate 29: <core::iter::sources::once::Once as core::iter::traits::iterator::Iterator>::size_hint 30: slint_build::compile 31: <std::io::Write::write_fmt::Adapter as core::fmt::Write>::write_str 32: core::ops::function::FnOnce::call_once note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

syf20020816 commented 8 months ago

根据进一步的测试,错误应该是出在border-type:None的指向不明确 位置为第58行:修改为 border-type: BorderType.None; 并加入import { BorderType } from "../../use/index.slint";

ZhengLongBing commented 8 months ago

还是不行

错误信息: error: failed to run custom build command for user v0.1.0 (C:\Users\ZhengLongBing\Desktop\library_loan_management_system\user) note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by: process didn't exit successfully: C:\Users\ZhengLongBing\Desktop\library_loan_management_system\target\debug\build\user-651710c26a9cf3ca\build-script-build (exit code: 101) --- stderr thread 'main' panicked at C:\Users\ZhengLongBing.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\i-slint-compiler-1.3.2\llr\lower_expression.rs:35:34: called Option::unwrap() on a None value stack backtrace: 0: std::panicking::begin_panic_handler at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\panicking.rs:597 1: core::panicking::panic_fmt at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:72 2: core::panicking::panic at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:127 3: core::option::Option::unwrap 4: i_slint_compiler::llr::lower_expression::ExpressionContext::map_property_reference 5: i_slint_compiler::llr::lower_expression::lower_expression 6: i_slint_compiler::llr::lower_expression::lower_expression 7: i_slint_compiler::llr::lower_expression::lower_expression::{{closure}} 8: core::iter::adapters::map::map_fold::{{closure}} 9: <core::slice::iter::Iter as core::iter::traits::iterator::Iterator>::fold 10: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold 11: core::iter::traits::iterator::Iterator::for_each 12: alloc::vec::Vec<T,A>::extend_trusted 13: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend 14: <alloc::vec::Vec as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter 15: <alloc::vec::Vec as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter 16: <alloc::vec::Vec as core::iter::traits::collect::FromIterator>::from_iter 17: core::iter::traits::iterator::Iterator::collect 18: i_slint_compiler::llr::lower_expression::lower_expression 19: i_slint_compiler::llr::lower_expression::lower_expression 20: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component::{{closure}} 21: i_slint_compiler::generator::handle_property_bindings_init::handle_property_inner 22: i_slint_compiler::generator::handle_property_bindings_init::{{closure}} 23: i_slint_compiler::object_tree::recurse_elem 24: i_slint_compiler::object_tree::recurse_elem 25: i_slint_compiler::generator::handle_property_bindings_init 26: i_slint_compiler::llr::lower_to_item_tree::LoweringState::map_property_reference 27: i_slint_compiler::llr::lower_to_item_tree::lower_to_item_tree 28: i_slint_compiler::generator::rust::generate 29: <core::iter::sources::once::Once as core::iter::traits::iterator::Iterator>::size_hint 30: slint_build::compile 31: <std::io::Write::write_fmt::Adapter as core::fmt::Write>::write_str 32: core::ops::function::FnOnce::call_once note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

syf20020816 commented 8 months ago

https://github.com/Surrealism-All/SurrealismUI/releases/tag/v0.3.1

ZhengLongBing commented 8 months ago

老哥,还是不行啊!

错误信息: error: failed to run custom build command for user v0.1.0 (C:\Users\ZhengLongBing\Desktop\library_loan_management_system\user) note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by: process didn't exit successfully: C:\Users\ZhengLongBing\Desktop\library_loan_management_system\target\debug\build\user-651710c26a9cf3ca\build-script-build (exit code: 101) --- stderr thread 'main' panicked at C:\Users\ZhengLongBing.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\i-slint-compiler-1.3.2\llr\lower_expression.rs:35:34: called Option::unwrap() on a None value stack backtrace: 0: std::panicking::begin_panic_handler at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\panicking.rs:597 1: core::panicking::panic_fmt at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:72 2: core::panicking::panic at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\panicking.rs:127 3: core::option::Option::unwrap 4: i_slint_compiler::llr::lower_expression::ExpressionContext::map_property_reference 5: i_slint_compiler::llr::lower_expression::lower_expression 6: i_slint_compiler::llr::lower_expression::lower_expression 7: i_slint_compiler::llr::lower_expression::lower_expression::{{closure}} 8: core::iter::adapters::map::map_fold::{{closure}} 9: <core::slice::iter::Iter as core::iter::traits::iterator::Iterator>::fold 10: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold 11: core::iter::traits::iterator::Iterator::for_each 12: alloc::vec::Vec<T,A>::extend_trusted 13: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend 14: <alloc::vec::Vec as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter 15: <alloc::vec::Vec as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter 16: <alloc::vec::Vec as core::iter::traits::collect::FromIterator>::from_iter 17: core::iter::traits::iterator::Iterator::collect 18: i_slint_compiler::llr::lower_expression::lower_expression 19: i_slint_compiler::llr::lower_expression::lower_expression 20: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component::{{closure}} 21: i_slint_compiler::generator::handle_property_bindings_init::handle_property_inner 22: i_slint_compiler::generator::handle_property_bindings_init::{{closure}} 23: i_slint_compiler::object_tree::recurse_elem 24: i_slint_compiler::object_tree::recurse_elem 25: i_slint_compiler::generator::handle_property_bindings_init 26: i_slint_compiler::llr::lower_to_item_tree::LoweringState::map_property_reference 27: i_slint_compiler::llr::lower_to_item_tree::lower_to_item_tree 28: i_slint_compiler::generator::rust::generate 29: <core::iter::sources::once::Once as core::iter::traits::iterator::Iterator>::size_hint 30: slint_build::compile 31: <std::io::Write::write_fmt::Adapter as core::fmt::Write>::write_str 32: core::ops::function::FnOnce::call_once note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

ZhengLongBing commented 8 months ago

rust代码:

slint::include_modules!();

fn main() -> Result<(), slint::PlatformError>{
    let app=App::new()?;
    app.run().unwrap();
    Ok(())
}

slint代码:

import { SMenu } from "../../SurrealismUI/index.slint";
component App inherits Window{
    height: 600px;
    width: 1000px;
    SMenu {
        theme: Dark;     
    }
}   
syf20020816 commented 8 months ago

感谢您的提出,最终测试结果是这是一个存在于Slint内部的一个问题 原生Image组件的colorize属性无法接收in-out类型属性在states中的更改值 目前我正在进行修复,正式的0.3.1版本请耐心等待到12点前

ZhengLongBing commented 8 months ago

我刚刚也找出是下面这个代码错了问题,但我完全不理解这个错在哪里了

states [
    hover when area.has-hover:{
      icon.colorize : hover-icon-color;
    }
  ]

修复完后,可以详细讲讲吗?

syf20020816 commented 8 months ago

colorize导致的问题None (None of the issues caused by colorize)

error: failed to run custom build command for `test-surrealism-ui v0.1.0 (E:\test_try\test-surrealism-ui)`

Caused by:
  process didn't exit successfully: `E:\test_try\test-surrealism-ui\target\debug\build\test-surrealism-ui-3cc0a1385e4ea351\build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', E:\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b\i-slint-compiler-1.3.2\llr\lower_expression.rs:35:34
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

原因 reason

非同作用域的组件之间的状态判断变化的传递失效

The transmission failure of state judgment changes between components with different scopes

模拟代码

可以看到下方两个TouchArea中的是一摸一样的,唯一不同的是第一种将Outter提取到外部进行封装,但就是因为这个封装导致了状态传递的失效

It can be seen that the two TouchArea below are exactly the same, with the only difference being that the first method extracts the Outter externally for encapsulation, but it is precisely because of this encapsulation that the state transfer fails

component Outter inherits Rectangle{
  in-out property <brush> in-color : get-color();
  pure public function get-color()->brush {
      return #f60;
  }
    Image {
      colorize: in-color;
      source: UseIcons.icons.Avatar;
    }
}

export component App inherits Window {
  height: 400px;
  width: 200px;
  title: @tr("Slint + SurrealismUI + Rust");
  VerticalLayout {
    spacing: 20px;
    //none issue
    TouchArea {
      height: 200px;
      states [
          hover when self.has-hover: {
              o.in-color : #19c51f;
          }
      ]
      o:=Outter{}
    }
    //no issue
    TouchArea {
      height: 200px;
      states [
        hover when self.has-hover: {
            n.in-color : #19c51f;
        }
      ]
      n:=Rectangle {
        in-out property <brush> in-color : get-color();
        pure public function get-color()->brush {
          return #f60;
        }
        m:=Image {
          source: UseIcons.icons.Avatar;
          colorize: in-color;
        }
      }
    }
  }
}