Commit graph

1614 commits

Author SHA1 Message Date
Tobias Hunger
04e11ec849 live-preview: Remove some dead code form property-view.slint 2024-09-19 15:51:56 +02:00
Tobias Hunger
74f3663932 live-preview: Remove failed attempt to have global shortcuts
It does not work too well and it breaks switching between LineEdits
in the property editor. Downside: We have no more way to delete the
selected element anymore. We could have it in a tool button, but
IMHO we should have Undo before we make it that obvious.
2024-09-19 15:51:56 +02:00
Simon Hausmann
24b2032e9f Remove stray horizontal line in library view 2024-09-19 13:25:34 +02:00
Simon Hausmann
cd1de28cd7 Make it easier to preview the properties view
Provide some dummy property data, and provide a preferred height that makes the preview show the properties.
2024-09-19 12:11:21 +02:00
szecket
860014a8f1
Cleanup columns (#6202)
* floatwidget and ResettingLineEdit updated

* ColorWidget adjusted

* most attributes visible again

* spacing more consistent and added italic to not-edited double encoding

* all controls rendering.

* consistent sizes for all column distributions.

* removed debug code and optimized logic a bit
2024-09-18 18:31:25 -04:00
Tobias Hunger
3c171f0655 live-preview: Only look at the code when comparing PropertyValues
The rest is derived from code anyway...
2024-09-18 23:22:42 +02:00
Tobias Hunger
f968b1d135 live-preview: Apply on focus change
Apply changes when the focus changes out of a 
(Resetting)LineEdit..
2024-09-18 23:22:42 +02:00
Tobias Hunger
9b47b37039 live-preview: Sort properties and split them up into groups
I was stupid this morning: The properties need to be sorted.

So I need to group the properties into groups and I also want
to be able to define in which order the groups will be listed
in the UI. So add a `priority` in addition to the group and use
group name and priority to sort properties into groups.

The test changes since the order changed and it tries to insert
based on previous/later properties.
2024-09-18 23:22:42 +02:00
Tobias Hunger
bdf173d08c live-preview: Update the down-arrow icon
... using the chevron-down icon from the codicons
icon set.
2024-09-18 21:30:18 +02:00
Olivier Goffart
aec4b9b2dd janitor: remove unused function
I added that in the previous commit, but that was actually not needed
2024-09-18 18:17:27 +02:00
Olivier Goffart
db5b4686ad property editor: Show the default value from base component when no binding exist
When no bindings exist on the component, the value that is shown in the
property editor should be the default value for that property as defined
in the base component or in the builtin element. Not just the default
value of the type
2024-09-18 18:14:28 +02:00
Tobias Hunger
0e751b1eea livve-preview: Make the color widget editable
... in a bare-bones fashion.
2024-09-18 15:38:45 +02:00
Tobias Hunger
81be4f2208 live-preview: Reset can-compile when resetting to property value
... in ResettingLineEdit.
2024-09-18 15:38:45 +02:00
Tobias Hunger
ef18244b31 live-preview: Mark wrong code as wrong again
... and fix the FloatWidget not passing on the unit, breaking
the update of property data.
2024-09-18 13:42:02 +02:00
Tobias Hunger
33afbe7cf6 live-preview: Print properties set in an element in bold 2024-09-18 10:54:10 +02:00
Tobias Hunger
902cb17865 live-preview: Don't list accessibility first 2024-09-18 10:45:03 +02:00
szecket
126ab85366 live-preview: Prettify the property editor 2024-09-17 18:39:37 +02:00
Tobias Hunger
2d8323be5a live-preview: Add a ResetButton for properties
This button can be used to remove an existing property
assignment, thus resetting to the default value the
element inherited.
2024-09-17 18:39:37 +02:00
Tobias Hunger
41bdadd960 live-preview: Add a CodeButton component
... and use it in places
2024-09-17 18:39:37 +02:00
Florian Blasius
a32b0ac6d0 live-preview: Refactoring of property editor ui code 2024-09-17 18:39:37 +02:00
Tobias Hunger
ca64212369 live-preview: Less model updates for property editor
Move the model into an extra porperty and move information
irrelevant for the UI behind a callback, so that changing that info
will not invalidate the UI.
2024-09-17 10:29:31 +02:00
Olivier Goffart
adaa19d7f2
Slintpad: add an about dialog
Back in Slint 1.6, slintpad had a "welcome" page that explained what it is.
But the welcome page was removed in commit 588ee3e474
Now it's hard for someone who click on a link to slintpad.com to know
what it is and get a link to Slint.

Add an "about" entry in the menu that shows the previous welcome page as
a dialog

ChangeLog: Slintpad: add "about" entry in the menu.
2024-09-16 18:42:14 +02:00
Tobias Hunger
1ca3726e4e live-preview: Fix size being displayed wrongly
Stop abusing the init callback, abuse the changed callback instead ;-)

Also merge the initial size calculation into one place. This fixes the
preview showing the wrong sizes. It does introduce a bit of flicker though
as the UI is rendered in the wrong state once and then immediently corrects
itself.

That is annoying, but strictly better than staying in the wrong state till
the user does something.

Closes: #5954
2024-09-16 15:54:40 +02:00
Olivier Goffart
461632717a
fmt: Fix moving comments on the next line
Don't change any whitespace before or after a comment.
We were already preserving whitespaces after comment, do the same for
whitespaces before comments

ChangeLog: formatter: don't change whitespaces or newlines before comments
2024-09-16 13:02:14 +02:00
Olivier Goffart
ca6d9af2ba live-preview: Use a checkerboard as the background
Also have a slightly bigger preferred size by default when the previewed
component is very small
2024-09-16 10:13:01 +02:00
Simon Hausmann
c1863072a8 winit: Clean up backend creation API
Use a builder pattern, which also allows configuring the event loop builder.

Fixes #6103

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-09-16 10:11:00 +02:00
Tobias Hunger
1697226fc1 live-preview: Use the entire screen when preferred-size of a UI is 0
Use the entire screen-space (minus borders) when the preferred size
of a UI is 0 and we are asking to reset to the preferred size.

I was reluctant to implement this before as I think it is surprising
to start with a huge size when the size info is most likely wrong...
People typically render outside the component's area in that case.

Now that we clip away anything that is not inside the UI area, I think
this is discoverable enough now: When resizing you will see the UI
getting clipped after all.

The big size also avoids confusion when nothing shows up :-)
2024-09-13 15:06:51 +02:00
Tobias Hunger
e0426353a8
live-preview: Improve icons in hide/show sidebar buttons (#6128) 2024-09-13 09:06:02 -04:00
Simon Hausmann
f410ff3eef macOs: Remove "About" entry from preview
It's not implemented and it panics in muda :)
2024-09-13 14:43:14 +02:00
Tobias Hunger
86f2e397c9
live-preview: Prettify group component (#6127) 2024-09-13 08:11:31 -04:00
szecket
0bdf44b12f live-preview: Prettify the statusbar 2024-09-13 13:51:31 +02:00
szecket
f79043c70b
live-preview: Prettify the HeaderView (#6117)
* live-preview: Polish the header-view

* live-preview: Clean up the previous patch a bit

---------

Co-authored-by: Tobias Hunger <tobias.hunger@slint.dev>
2024-09-13 23:14:09 +12:00
Tobias Hunger
0ae32b5a33 live-preview: Clip drawing outside of ComponentContainer
Clip anything the previewed UI wants to draw outside
of the area the previewed component claims to be using.

There are several reasons to do this:

 * A window will clip the contained component
 * Selection outside of the area taken up by the
   root component can not be selected or interacted
   with
 * It is more obvious that you are doing something
   wrong when your UI is clipped. Before we happily
   showed the right thing in the preview and then
   failed hard when using that component.
2024-09-13 12:11:49 +02:00
Olivier Goffart
10e7c83020 live-preview: don't set x and y When dropping an element
This means that, when the parent is not a layout, the widgets are
always dropped in the middle of the parent, and then one can place
place it to the right position.

In particular, for widget that expaneds to the size of their parent by
default, this does the right thing

Fixes #6098
2024-09-13 10:06:40 +02:00
Nigel Breslaw
b36a66e405
Enable more js/tsc biome rules
noUselessConstructor
useNodejsImportProtocol
noImplicitAnyLet
2024-09-13 10:04:39 +02:00
Tobias Hunger
eed03345b5 live-preview: Fix property editing
Whow, what a stupid mistake I had there!

Closes: #6097
2024-09-12 20:53:08 +02:00
Tobias Hunger
58472748c4 live-preview: Be more precise when resizing
... by specifying *which* of the set of geometries we
are based on.
2024-09-12 20:53:08 +02:00
Nigel Breslaw
2bee820ccf
Start to enable default javscript/typescript lint rules
This enables the recommended rules useConst and useImportType
2024-09-12 16:08:52 +02:00
Tobias Hunger
2bdacb7547 live-preview: Compile-test adding components
We did not have the compile-test infrastructure when
implementing the addition of new components into a UI. Use that
infrastructure, it catches some places where we can not actually
drop into that the previous heuristic missed.
2024-09-12 15:04:21 +02:00
Tobias Hunger
7323aa2641 slintpad: Biome fixes
Add configuration excluding generated JS files for biome in slintpad.

Let biome fix lints and format of everything.
2024-09-12 15:03:18 +02:00
Tobias Hunger
b95f0e62c8 live-preview: Always unselect when clicking onto background
Always unseelct the currently selected item when clicking onto
the background around the previewed UI.
2024-09-12 13:53:39 +02:00
Simon Hausmann
2ccc468b27 Fix location of comment 2024-09-12 13:30:55 +02:00
Olivier Goffart
524360d306 live-preview: Hide "Timer" from the lcomponent library
Timer is not really a visual element and it doesn't really make sense
to put it on the library at this point
2024-09-12 13:29:36 +02:00
Olivier Goffart
e693257572 live-preview: round the x and y properties when dropping
Otherwise we end up with values such as

```slint
    SpinBox {
        minimum: 0;
        value: 42;
        maximum: 100;
        x: 94.44821px;
        y: 108.07013px;
    }
```

Which doesn't make much sense
2024-09-12 13:29:18 +02:00
Simon Hausmann
5825cb4f46 Use command instead of control for the status text when running on macOS 2024-09-12 12:48:34 +02:00
Olivier Goffart
3bc758bc3f Janitor: deps update 2024-09-11 17:19:36 +02:00
Tobias Hunger
026e723029 live-preview: Add buttons to hide sidebars 2024-09-11 16:16:18 +02:00
Tobias Hunger
b01f0f926b live-preview: Add statusline with help text 2024-09-11 16:08:27 +02:00
Olivier Goffart
ea3a6e2087 Viewer: use Display to print the error message
For example, running the viewer with a DISPLAY wrongly set:

Before the patch:

```
thread 'main' panicked at tools/viewer/main.rs:123:32:
called `Result::unwrap()` on an `Err` value: Other("Could not initialize backend.\nError from Winit backend: Error initializing winit event loop: the requested operation is not supported by Winit\nError from LinuxKMS backend: Timeout while waiting to activate session\nNo backends configured.")
stack backtrace:
[...]
```

If just using `?` instead of `.unwrap()`:

```
Error: Other("Could not initialize backend.\nError from Winit backend: Error initializing winit event loop: the requested operation is not supported by Winit\nError from LinuxKMS backend: Timeout while waiting to activate session\nNo backends configured.")
```

If using an wrapper that uses Display for Debug

```
Error: Could not initialize backend.
Error from Winit backend: Error initializing winit event loop: the requested operation is not supported by Winit
Error from LinuxKMS backend: Timeout while waiting to activate session
No backends configured.
```
2024-09-11 15:25:35 +02:00
Tobias Hunger
f5667b4d2b live-preview: Clean up icon handling 2024-09-11 13:22:04 +02:00