slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
15.92k stars 524 forks source link

live-preview: Add component renaming #5432

Closed hunger closed 1 week ago

hunger commented 2 weeks ago

https://github.com/slint-ui/slint/assets/73267/60a593e9-d101-4bcd-8590-7c335de64624

You notice that I somehow broke the minimum size of the elements in the component list: That needs fixing before merge:-) Any idea what I am doing wrong? I do force the height to min-height, I thought that would work.

There is a bit of a hack in here do to the extra element we inject into the code to select which component to preview... we need to have some API in the interpreter to set this, so we do not have to meddle with the sources. I can not rename in that injected element without breaking the code in the editor... so I hide the injected code. That unfortunately means I can not compile-test the change before applying it. The renaming seems to work pretty reliably (even in big projects!), so I hope the missing compile test is not going to be a problem.

hunger commented 1 week ago

I included a few UI improvements in the last push. You can only have one component in name edit mode and the text no longer squashes.

hunger commented 1 week ago

I did some more playing with renaming in big demos: Looks like the renaming code has some trouble with resolving relative paths to imported files. Not strictly related to this PR, but needs fixing :-) Fixed in #5434

hunger commented 1 week ago

Somehow I have globals in my list of components... they all have is_global() == false, so something seems to be going wrong somewhere:-/ But apart from those, I can now rename all user-defined components in a big demo without triggering errors.

hunger commented 1 week ago

I would appreciate getting this in... I need the functionality. Yes, the workflow is not ideal, I agree.

My Big-Plan(TM) right now is this:

hunger commented 1 week ago

No change, just a rebase to make github happy.