Commit graph

497 commits

Author SHA1 Message Date
Olivier Goffart
ae3e1b4680 Allow normal Element to be in the Dialog's button row with dialog-button-role 2021-10-05 09:46:20 +02:00
Olivier Goffart
e858b3e8d5 Fix TabWidget drawing with the Qt Fusion style
- The Tab must be drawn before the contents, because the style draws something under the active tab,
   outside of its region
 - Also set the QStyleOptionTab::HasFrame flag since we are in the equivalent of a QTabWidget
2021-09-30 19:43:53 +02:00
Olivier Goffart
fd435ec270 Fix the default Text color overriding a color specified in a two way binding
We just need to adjust the priority of the default binding to be a high value
(eg, less priority) since the other values must always win.

This fixes the placeholder text color
2021-09-30 12:48:19 +02:00
Simon Hausmann
d3dfd43bdc Tweak dialog error messages
Replace "should" with "must"/"can only" to emphasize that this is an error.
2021-09-30 11:27:50 +02:00
Olivier Goffart
7db9f3dfa9 Dialog: automatically add clicked callback for the standard button
And make the viewer listen to them and set them to automatically close dialogs
2021-09-30 10:21:13 +02:00
Olivier Goffart
7f05bfa309 Add the Dialog element 2021-09-29 16:25:44 +02:00
Olivier Goffart
3cf9089293 Refactor: Builtin can now have default binding on properties that are inherited from a NativeClass
And make the Window have a NativeClass parent, so it can be re-used for the Dialog
2021-09-29 16:25:44 +02:00
Simon Hausmann
fa89758dc5 Fix background color of window when viewing non-window elements
The synthetic window we "inject" in the ensure_window() pass did not
have the window-background from the style applied. This is visible
for example when viewing something like

    Rectangle { background: blue; border-radius: height / 2 }
2021-09-23 19:19:06 +02:00
Olivier Goffart
d47b679114 Fix panic of the syntax_tests 2021-09-05 09:29:00 +02:00
Olivier Goffart
a883ca0569 Optimize away Rectangle that serve no purpose
Rectangles which do not draw anything and have no x or y don't need to be in
the item tree, we can just remove them.
2021-09-05 09:29:00 +02:00
Olivier Goffart
b2392c25c7 Basic support for Multi-line TextInput 2021-09-01 16:52:37 +02:00
Simon Hausmann
ee8e5699e5 Clean up global alias handling
Remove the internal name again and pick the first exported one when
assigning ids. This avoids internal names showing up in code completion
or the internal types leaking into generated code.
2021-08-31 17:09:11 +02:00
Simon Hausmann
0d19e2d9b9 Add support for global aliases
When exporting an global multiple times under different names, make sure
that they alias in the generated code.

As a consequence, the compiler maintains the original unique name and in
Rust and C++ makes only the exported names public. In the interpreter
the internal name is theoretically still accessible from the outside.
2021-08-31 17:09:11 +02:00
Simon Hausmann
c3ca796b1d Fix missing compiler warning about duplicated ids when using id more than twice
Don't remove the id of a duplicate from the seen set, as it may appear
again.
2021-08-30 20:35:31 +02:00
Simon Hausmann
3206d6fcfc Minor cleanup
In the compiler we can set the mark that a global component is meant for
export earlier.
2021-08-27 13:36:48 +02:00
Simon Hausmann
9868b693e2 Only publish exported globals in C++ and Rust 2021-08-27 13:36:48 +02:00
Olivier Goffart
5f8cea5926 WIP interpreter API to access globals 2021-08-27 13:36:48 +02:00
Olivier Goffart
b07d52cd23 Support aliases to callbacks in globals 2021-08-24 12:36:16 +02:00
Simon Hausmann
cdca921469 Apply the default text color from the style for the color of Text and TextInput elements
We apply a default window background from the palette to all `Window`
elements, and likewise we need to apply the default text color to Text
elements to ensure a readable contrast.

This also fixes the default text color when using Qt/native style in
dark mode on macOS.
2021-08-23 15:03:18 +02:00
Olivier Goffart
b42c187ed1 Refactor the way the two-ways biding are represented internaly
Don't put them in a fake expression.
This simplifies a bit the expression handling, and will make
possible to fix analysis that needs a vew into the aliases
2021-08-20 18:26:36 +02:00
Simon Hausmann
2458ac5d02 Fix panic when calling focus() on a repeated element
When trying to reference an instance of a repeated item, for use with
ItemRc or VRef<Item>, the item_index (or id) of the ElementRc is not
directly what we want.

Adjust any element references to the repeater to to the inner instance
after creating them. Also make sure that the enclosing component is
respected in the C++ and Rust generators.

Fixes #422
2021-08-20 15:39:54 +02:00
Olivier Goffart
2c1e39f00e Fix priority when merging two_way_binding
We should not increase the priority when merging two way binding, only when
inlining.

This fixes the iot-dashboard's devices widget which were sometimes not
transparent as they should have been.
This was not deterministic because the order in which the two way binding are
merged is not deterministic because of hash table, and sometimes one binding
ended up having a higher priority as it should have had.
2021-08-17 11:57:35 +02:00
Olivier Goffart
143510b593 Set the width of items in a ListView
Fixes #408
2021-08-13 11:57:56 +02:00
Olivier Goffart
7859e2f06e Fix opacity property at the root of a repeated element in layout
This fix the layout of the printing-queue in the printer demo
2021-08-12 20:10:21 +02:00
Simon Hausmann
01e2a14322 Remove unused properties from globals
The fluent style has a bunch of unused global color properties, which can be removed - for example.
2021-08-12 16:33:37 +02:00
Olivier Goffart
a5689a6389 Flickable: Ignore repeated child elements in geometry computation to avoid compiler panic
This fixes a panic but ideally, we should merge the layout info of each children

cc #407
2021-08-12 16:17:13 +02:00
Olivier Goffart
d5b1a95f74 Turn the "duplicated id" error into a warning
Just for compatibility reason with 0.1.0, this is going to be turned
back into an error at a later point
2021-08-12 13:47:11 +02:00
Olivier Goffart
c25538c982 Normalize identifiers to - instead of _
As a result
 - The error messages will now show the error with `-` instead of `_`
 - The LSP will auto-complete with -
 - The interpreter's list of properties will list the property with '-'
   (but we made the change so that set_property, get_property, and so on
   work also if passed a '-')
2021-08-10 22:21:01 +02:00
Tobias Hunger
bac4d895ce Janitor: Fix clippy::while_let_on_iterator 2021-08-09 13:19:34 +02:00
Tobias Hunger
ce30f9b989 Janitor: Fix clippy::extra_unused_lifetimes 2021-08-09 13:19:34 +02:00
Tobias Hunger
52869170c1 Janitor: Fix clippy::identity_op 2021-08-09 13:19:34 +02:00
Olivier Goffart
a89d83e58f Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@sixtyfps.io>
2021-08-06 15:58:13 +02:00
Olivier Goffart
b5f34fd1d7 Make it an error to use dynamic tabs in the TabWidget 2021-08-06 15:58:13 +02:00
Olivier Goffart
d41839abe3 Compiler pass for the TabWidget
it will lower the TabWidget into a TabWidgetImpl and the tabs into TabImpl
2021-08-06 15:58:13 +02:00
Tobias Hunger
ff76aa8953 Janitor: Fix clippy::blocks_in_if_conditions 2021-08-05 23:41:56 +02:00
Tobias Hunger
24a2021226 Janitor: Fix clippy::needless_borrow 2021-08-04 22:50:35 +02:00
Simon Hausmann
38cf156bf9 Fix regression of two-way binding on default geom'ed properties causing binding loop
Commit 064c39d625 introduced the regression that
if a two-way binding was set on a property that we'd also set a default geometry
on, we'd end up applying that on the two-way binding, causing a binding loop.

set_binding_if_not_set needs to only set the binding if... there's really none yet.

Fixes #385
2021-08-03 23:24:49 +02:00
Olivier Goffart
1dab4c35d9 For embedded data, store the extension in the binary
This is usefull for the detection of SVG
2021-08-03 16:15:31 +02:00
Simon Hausmann
064c39d625 Fix disappearing elements with implicit width/height
When an element gets its width and height from the parent through an implicit 100% binding,
those bindings were missing when an animation was pre-defined.

The provided new-type wrapper offers a function to deal with replacing just
binding expression, instead of the
expression *and* the animation.

Fixes #376
2021-08-02 16:31:10 +02:00
Simon Hausmann
f91864f827 Minor cleanup: remove stray dbg! 2021-08-02 15:51:29 +02:00
Tobias Hunger
85f7c93c87 Janitor: Use approx_eq when checking for integer
Use approx_eq when comparing the value.trunc() to value. We want to
allow these values to be calculated, so they might end up slightly off.
2021-07-30 09:27:48 +02:00
Tobias Hunger
f3171a87e1 Janitor: Fix clippy::map_entry 2021-07-30 09:27:48 +02:00
Tobias Hunger
ec7b7f751b Janitor: Fix clippy::or_fun_call 2021-07-30 09:27:48 +02:00
Tobias Hunger
e5bb7762b9 Janitor: Fix clippy::useless_conversion 2021-07-30 09:27:48 +02:00
Tobias Hunger
f7f5a33c67 Janitor: Fix clippy::useless_format 2021-07-30 09:27:48 +02:00
Olivier Goffart
b0b3912c27 Add support for the visible property 2021-07-29 15:02:25 +02:00
Olivier Goffart
bd52f4d444 Allow the clip property to be a dynamic property 2021-07-29 15:02:25 +02:00
Simon Hausmann
2b5badcae2 Fix cargo fmt 2021-07-28 17:08:27 +02:00
Simon Hausmann
be05b54fa1 Tweak error message for conditionals/for in grid
Will adapt the tests in the next commit

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-07-28 17:08:27 +02:00
Simon Hausmann
e8727e98c5 Produce an error message when using if or for in grid layouts
An early error is better than a build error at compile time of generated code.
2021-07-28 17:08:27 +02:00