Commit graph

168 commits

Author SHA1 Message Date
Tobias Hunger
1b88f70086 live-preview: Add a "show preview" button into the component list
... It is *UGLY*, really *UGLY*. But it works ;-)
2024-06-24 14:10:16 +02:00
Tobias Hunger
35b61fa852 live-preview: Show a label of the component currently visible
* Make the location a click-target that asks the editor to navigate to that
  component
2024-06-24 14:10:16 +02:00
Tobias Hunger
37d6922983 live_preview: Wire up component renaming 2024-06-21 14:40:50 +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
1f0262c7a7 Update tools/lsp/preview/drop_location.rs
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2024-06-19 11:45:37 +02:00
Tobias Hunger
15ac565737 live_preview: Show file local components in Library 2024-06-19 11:45:37 +02:00
Tobias Hunger
49d4fc5d0f live-preview: Handle add_new_component 2024-06-19 11:45:37 +02:00
Tobias Hunger
97daf41245 live-preview: Add a button to add a new component with
... and make it trigger a function in preview.rs.
2024-06-19 11:45:37 +02:00
Tobias Hunger
eb60c26398 live-preview: Filter out artifical component the live preview adds
... that implementation detail should not leak to the users.
2024-06-17 17:39:35 +02:00
Tobias Hunger
8d9ea63284 live-preview: Keep a document cache handy 2024-06-14 16:59:39 +02:00
Tobias Hunger
67200c81ff live-preview: Compile-test element moves in can_move function
Compile test the result of an element move in the `can_move` function
to catch all cases where the move would be problematic.

Shuffle some test code around to allow for testing this new
functionality.
2024-06-14 16:59:39 +02:00
Tobias Hunger
c55f0a9b0e compiler: Add a snapshotter to help create snapshots of compiler state
Use this snapshot to keep a unoptimized typeloader around, so that the preview
does not need to do another parsing run.

Move the document cache in the preview over to use the snapshot.
2024-06-12 10:15:29 +02:00
Tobias Hunger
d657ee65af live-preview: Handle known components using our local DocumentCache 2024-06-12 10:15:29 +02:00
Tobias Hunger
6c034372a1 lsp: Encapsulate DocumentCache better
The Document cache is a specialized typeloader now, make it provide the
necessary APIs directly, so that we can be sure nobody will do anything
that breaks the data:-)
2024-06-12 10:15:29 +02:00
Tobias Hunger
64d2b6117b live-preview: Use a document cache in the preview as well
It has so much better information and we do not want to go back to the LSP
side to get that!
2024-06-12 10:15:29 +02: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
29eb0d0600 live-preview: Move all the text edit code into a new module 2024-05-17 09:56:37 +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
3453c7bc9e lsp: Simplify parameters passed to ElementRcNode::parent()
We can find a good root element ourtselves, no need for a user to provide it.

split out parent fixup
2024-05-10 13:03:22 +02:00
Tobias Hunger
eb2f791f3c live preview: Move repeated/conditional elements, too
Now that we move elements with ids, lets also move conditional and repeated
elements.

They have the same problem as elements with ids: They will probably break when
moved into different elements.
2024-05-08 12:49:27 +02:00
Tobias Hunger
34f8a0e96c live-preview: Make layouts movable
... so layouts can get moved about now! Whohoo.
2024-05-02 14:58:47 +02:00
Tobias Hunger
3d34c3be6d live-preview: Move already placed elements
Allow to move already placed elements in Design Mode of the live preview.

Todo: GridLayout is not supported yet.
2024-04-29 22:50:29 +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
69b8e8d57c live preview: Implement drop marker mapping for elements
... so we know what to do when dropping near tghe border of elements that
accept drops in a layout.
2024-04-23 10:56:55 +02:00
Olivier Goffart
d4741efac0 testing: rename the init function 2024-04-18 18:45:31 +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
21b73769a5 live preview: Provide the kind of layout to the UI
... so we can have a better idea what we need to visualize.

Move the decision on which color to use into the slint file as well:
A designer should make that call, not a developer ;-)
2024-03-22 00:32:55 +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
543bff941f live preview: Introduce a SelectionRectangle struct 2024-03-19 08:58:34 +01:00
Tobias Hunger
6ee2eec8a4 live preview: Do not try to set length to NaN
Also handle inifinite values while at it...

Fixes: #4848
2024-03-18 16:24:56 +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
feb96bb03b preview: Add more data to ComponentInformation
Add `fills_aprent` and `default_properties` to
`ComponentInformation`. The first is a bool showing
whether the Component will fill its parent or not.

The later is a set of properties that the UI will set
when the widget gets dropped.

Refactor the data passing a bit: Keep the data on known
components around. Pass only the component name into
the UI, but pass the entire `ComponentInformation` to
the `drop_location` methods.
2024-03-06 17:31:08 +01:00
Tobias Hunger
d0fc025bc8 live preview: Do not drop on elements that can not have children
Slpit up `lookup_type_for_child_elemnt` (in the compiler) into the
part that looks at the element itself only (called `accepts_child_element`)
and the part that looks at the child.

When deciding whether we can drop something into another element in
the live preview, we know the child type is going to be OK, even when
the `TypeRegister` does not contain it yet (as it is not imported yet).
2024-03-06 12:15:10 +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
3ad3a42656 live preview: Do import handling in drop_location
Remove the AddComponent and the AdjustSelection messages
from the communication between LSP and preview.

Also remove the code to delete an element.
2024-03-01 18:54:40 +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
6ab0a30192 live preview: Disable moving/resizing of selected elements 2024-02-28 22:33:39 +01:00
Tobias Hunger
a0b862b096 live preview: Delete an element again
* Refactor the code a bit: Move element edit functions
  into the `element_edit` module below `language`
2024-02-28 15:53:49 +01:00
Tobias Hunger
1f44bdad2f live preview: Store selected node, not just the selected element 2024-02-28 15:53:49 +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
Tobias Hunger
df1db6aafe live preview: Retrieve ElementSelection from preview_state
... and not the selected element directly. This will allow to move
more code into the proper submodules.
2024-02-23 10:06:36 +01:00