Commit graph

66 commits

Author SHA1 Message Date
Tobias Hunger
d0b58760d3 chore: A few clippy fixes
Nothing systeamatic, just a bunch of fixes I stumbled over
during unrelated work.

No behavior change is intended in here...
2025-05-09 13:25:38 +02:00
Tobias Hunger
a7b6d3a13b lsp: Update ElementRcNode to return the full debug info 2025-04-01 16:10:10 +02:00
Olivier Goffart
4a5fcb27af Preview: filter invisible items out from the selection popup
Filter out elements that are clipped out (invisible or other pages) from
the selection popup
2025-02-10 13:38:43 +01:00
Yuri Astrakhan
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +01:00
Tobias Hunger
da7ba2f99c
live-preview: More filter options in Selection Popup (#7070)
* live-preview: More filter options in Selection Popup

* Hide layouts,
* Hide interactive elements
* Hide others

@szecket did a lot of UI polish that I just merged here
so that I do not need to show what I made!

* live-preview: Remove TouchArea suffix
2024-12-13 10:51:28 +13:00
Simon Hausmann
356376dca8 Remove debug output that shows in the output tab in VS code 2024-12-12 08:57:26 +01:00
Tobias Hunger
4d309f69ba live-preview: Filter in Selection Popup
Add a filter into the Selection popup to filter out
anything not matching.

If all letters are lowercase, then it will do a case-insensitive
match, if there are non-lowercase characters it will do
case-sensitive matching instead.
2024-12-10 18:21:41 +01:00
Tobias Hunger
03e02b5094 live-preview: Have the selection popup highlight locations
Have the selection popup actually highlight the hovered
object in the editor.

We did not have this use case before: We used to either
highlight after an update or never at all. Neither semantic
matches what we are doing in the selection popup, so I added
a highlight-now flag.
2024-11-27 17:26:38 +01:00
Tobias Hunger
6534ac9ab4 live-preview: Do not show components in selection popup
The component was mentioned when it was used in the code, so
filter out the frame for the component defintiton itself.
2024-11-26 10:30:18 +01:00
Tobias Hunger
11169ef149 live-preview: Prettify file names in Selection Popup 2024-11-19 20:20:14 +01:00
Tobias Hunger
9d5b9fb46a live-preview: Implement a selection stack
... that provides a model containing all the elements
at a position sorted from "front" to "back" with extra
information so that we can present the data in a nice UI
in the next step.

The selection code now filters out builtins and ignore nodes
when collecting nodes. So the following filter step does not
need to take those into account anymore.

Whether a selection candidate is actually a part of the root
component or not is now handled by looking at whether the
elements text range is inside the root component's text
range. This is closer to what users expect to happen I think.
2024-11-19 20:20:14 +01:00
Tobias Hunger
a765da347c live-preview: Unconfuse selection with a drop shadow
Unconfuse selecting something with a drop shadow. That is a
extra compiler-generated element that gets added before
the actual element we are looking for.
2024-11-07 18:33:50 +01:00
Tobias Hunger
d22f202012 live-preview: Filter out properties that make no sense
Filter out properties related to layouts that make no sense
for the current element. These are x/y coordinates and the
grid layout related properties.

It's tricky to do: The properties are looked up in the
context of the unoptimized DocumentCache, so that
(most) properties are visible. The layout information is
not available there though as base types are not resolved yet.

So the layout information is taken from the preview data.
2024-09-30 14:53:01 +02:00
Tobias Hunger
41bdadd960 live-preview: Add a CodeButton component
... and use it in places
2024-09-17 18:39:37 +02:00
Tobias Hunger
ff5e9dc050 live-preview: Polish elements selection
* Allow to select the top-level element
* Allow to select inside the currently selected element
2024-09-11 09:55:03 +02:00
Tobias Hunger
cab41c3d0c lsp: Use more TextSize
I got carried away, I replaced `u32` with `TextSize` in one place
because that's what I got and I did not want to convert... and
then I fixed the fallout.

No functional change is intended in any of this.

FIXUP
2024-09-10 13:31:52 +02:00
Olivier Goffart
686f5e43e2 Widget style: simplify -light/-dark handling
Instead of having all style duplicated and re-using a base, we just hack
into the funciton that queries the dark/light theme based on the style
suffix known at compile time.

This removes one of the problem that happens when trying to work on the
widget style with the extension, as it relies on include path hacks
2024-08-20 16:55:15 +02:00
Tobias Hunger
c9c293e3bd live-preview: Show properties of previewed element
... if no other element is selected.
2024-06-28 18:53:02 +02:00
Tobias Hunger
1b3765e53c lsp: Move node ignore code into the common section
... it is conceptually meant to be used by the language server and the
live-preview.
2024-06-21 14:40:50 +02:00
Tobias Hunger
b881d24367 janitor: Fix spelling 2024-06-19 17:01:19 +02:00
Tobias Hunger
f358454638 janitor: live-preview: Save a few copies of vecs
... does not make things noticably faster though.
2024-06-14 16:59:39 +02:00
Olivier Goffart
8add2e4ebd element_ids: Can't return a SharedString by value from the vtable
also compile the LSP
2024-06-05 01:29:58 -07:00
Tobias Hunger
704cfff41f lsp: Rename components
Only handle rename requests when on the component name in the component
definition.

Handle exports/imports in the entire project as needed.
2024-06-03 16:12:31 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Tobias Hunger
939d1be3e4 live-preview: Select based on component
... and not based on things in the same file.
2024-05-16 17:29:57 +02:00
Tobias Hunger
a6c3d2a63f live-preview: Do not mark conditional/repeated elements as resizable
... when in a layout.
2024-05-10 13:03:22 +02:00
Tobias Hunger
e10e97c944 live-preview: Add placeholder when removing the last eleemnt in a layout
Add a placeholder Rectangle into a layout whenever the last eleemnt is removed.
This makes sure we can drop into the Layout again.

Add infrastructure to find the parent element to ElementRcNode and move more
code into the ElementRcNode.
2024-04-25 10:28:15 +02:00
Tobias Hunger
c1707d52e1 live preview: Insert source code before other elements
... and use that to drop into layouts.
2024-04-23 10:56:55 +02:00
Tobias Hunger
9b2a7fc694 live preview: Prefer LogicalPoint over providing x and y 2024-04-23 10:56:55 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Tobias Hunger
7053a21749 live preview: Add a drop marker
Add a drop mark into DropInformation to visualize where an item will get added.

This is the UI side of things and some more preparational work.
2024-04-01 16:27:35 +02:00
Tobias Hunger
4451d6019a live preview: Add some testing to element selection 2024-03-25 15:42:52 +01:00
Tobias Hunger
926a385eec live preview: Do not store is_layout anymore in the ElementSelection
Get that information from the ElementNode directly instead.
2024-03-22 00:32:55 +01:00
Tobias Hunger
15fb452017 interpreter: Return the ElementRc + index, not just the ElementRc
This way we do not have to check the ElementRc once more to find the node in
its debug data.
2024-03-20 18:47:45 +01:00
Tobias Hunger
b4a20b2c47 interpreter: Rename function not part of public API
The function returns a Vec of values, so change it to use the plural form.
2024-03-20 18:47:45 +01:00
Tobias Hunger
b7d2a30b81 interpreter: Replace ComponentPositions with a simple Vec<LogicalRect>
... now that the Vec is the only member of `ComponentPosiitons`.
2024-03-20 18:47:45 +01:00
Tobias Hunger
89b7b1735c live preview: Simplify code 2024-03-19 08:58:34 +01:00
Tobias Hunger
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +01:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Tobias Hunger
3ba59dad46 lsp: Use ElementRcNode when handling properties
We recently got better support for inlined elements. Use
The `ElementRcNode` when accessing properties, so that
we can actually have a better idea which SyntaxNode we
need to work on.

This is actually not too critical as the LSP does little
inlining, but I wanted to reuse this on the preview side
as well, which does inlining much more aggressively.

Do NOT access properties in the live preview though:
It is heavily optiomized, so most properties are just
gone there;-)
2024-03-05 13:10:41 +01:00
Tobias Hunger
b0f2e8cd28 live preview: Re-enable moving and resizing when no layout is in sight
Allow moving and resizing of elements provided:

 * The element is not layout. This approximates
   "fills its parent", which is what we aim for once
   we can query type info rom within the Preview.
 * The element is not *inside* a layout
2024-02-28 22:33:39 +01:00
Tobias Hunger
e668a0a91e live preview: Fix thinko leading to wrong elements getting selected
The `SelectedElement` does not need a `debug_index` as the interesting node
is fully specified by the source location it already contains.
2024-02-28 22:33:39 +01:00
Tobias Hunger
1f44bdad2f live preview: Store selected node, not just the selected element 2024-02-28 15:53:49 +01:00
Tobias Hunger
a51feb47d6 live preview: Factor ot some common conditions
... so I can reuse them later to find a good drop
location.
2024-02-27 13:24:41 +01:00
Tobias Hunger
c29854a6fc live preview: Rename ElementRcNode's on_* to with_
That was actually commented on during review, but I apparently
managed to back out that change again.
2024-02-27 13:24:41 +01:00
Tobias Hunger
171c9e215a live preview: Drop elements into layouts (MVP!)
This is the minimum layout support: It drops elements
into a layout right before the layout's closing brace.
2024-02-26 22:19:29 +01:00
Tobias Hunger
b4e36f1174 live preview: Use selection based on nodes
Now that we keep information on all nodes, use that to do more
"fine grained" selection: We select based on nodes, not elements in
the element tree now.

This assumes that a source locartion based on file path and offset in
that file is enough to define the nodes of an element.
2024-02-26 11:24:27 +01:00
Olivier Goffart
a3c99555a0 LSP: fix compilation without the preview features
Use the format test to test this compilation
2024-02-26 11:14:02 +01:00
Tobias Hunger
23cc7cde61 live preview: Move reselection of element code into element_selection module 2024-02-23 10:06:36 +01:00