Commit graph

371 commits

Author SHA1 Message Date
Jocelyn Turcotte
678c7678e9 C++ API for KeyEvent.repeat
Add a new dispatch_key_press_repeat_event function to dispatch auto-repeated
key events.
2023-11-29 09:31:31 +01:00
Simon Hausmann
42d575262e
Fix SharedString::end() throwing an exception when MSVC iterator debugging is enabled (#4017)
Don't dereference end() of a string_view.

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-11-27 18:11:55 +01:00
Olivier Goffart
e008019243 C++: Fix warning on macOS about unused variable 2023-11-17 10:58:20 +01:00
Olivier Goffart
f043234890 C++: fix (private) properties of type EasingCurve
tests/cases/properties/animation_props_depends.slint in previous commit
added a property<easing> and that didn't work with C++
2023-11-03 15:11:06 +01:00
Olivier Goffart
1efd83621d Refactor: Merge KeyInputEvent and KeyEvent
Both structure are bascially the same and only used internally, no need
to have the two.

The only difference was that one had the modifiers and the other one
not. But we can just set the modifier at the point we were converting
between the two.
2023-11-02 12:16:40 +01:00
Olivier Goffart
ac8fd60091 Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)

The following used to work:

```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
    in property <[int]> mods;
    VerticalBox {
        alignment: start;
        for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
    }
}
```

But we fixed array conversion and this caused a regression with empty
array
2023-11-01 11:30:59 +01:00
Simon Hausmann
1441719f61
Fix cross-compilation of C++ interpreter API to 32-bit architecture (#3810)
cbindgen doesn't reliably tranfser the 64-bit/32-bit #ifdefs around ValueOpaque.
Instead, move Value onto the heap by using a Box.

Fixes #3653
2023-10-31 17:33:49 +01:00
Olivier Goffart
d55803d290 Models: fix writing data doesn't update ListView model data property
This fixes a couple of bug:
 - Bug #3740 happens because `Repeater::model_set_row_data` did not use
   the inner.offset to get the instance (So that's the `val == 106` part
   of the test)
 - But I went ahead and also tested what happenned if you changed the
   model from the "outside" using the `model[i] = `, and that was not
   implemented, hence the move of the code from
   `Repeater::model_set_row_data` to `RepeaterTracker::row_changed`,
   That does need Pin though, so Pin was added everywhere
 - C++ is not affected by bug #3740, because because the C++ listview
   don't do the "allocate only visible" optimization. But the
   "val == 1106" part of the test would fail so this patch also moces
   the update from  `model_set_row_data` to `row_changed`.
   But following that we don't set the state as Dirty in `row_changed`,
   the write_to_model test started filling  because the `row_added`
   function was missing an update of the index on every further items

The change in the interpreter prevent a borrow_mut from causing trouble.
The Value really don't need to be in a RefCell anyway

Fix #3740
2023-10-31 13:41:31 +01:00
Olivier Goffart
78d273e599 Revert "Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)"
This reverts commit 1162ebbb79.

Because otherwise if we keep the elements, their internal state is kept
and this causes bug #2598

Fixes #2598
2023-10-23 16:52:03 +02:00
Olivier Goffart
5bf2c7192b Fix panic with very large ListView
In `ItemRc::find_sibling` we currently do:
 1. get the range
 2. check that the next index is within the range
 3. call `get_subtree`

The problem is that get_subtree itselg will call 'ensure_updated' which
will do the relayout of the ListView and may get a different range of
element.

So don't query the range before and just have get_subtree to return an
empty ItemWeak if we are out of the actual range.

Couldn't really find a way to make a test since this is called from
the accessibility code which is hard to test as is

For #3700
2023-10-21 14:03:39 +02:00
Olivier Goffart
f4dd08783c janitor: C++: make the code more readable by having the type explicit 2023-10-19 18:09:14 +02:00
Olivier Goffart
172dcfa775 C++: fix crash when accessing empty model from Slint
Fixes #3704
2023-10-19 18:09:14 +02:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
Olivier Goffart
347b2d0fbf C++: Don't use optional::value
It is not available when targetting older macOs since it can throw an
exception that needs library support
2023-10-11 07:57:57 +02:00
Olivier Goffart
b88a3caacd swrenderer: Put the rotation feature behind a freature gate
We're not ready to make the API public as we want to have the API as
part of the Window rather than part of the renderer
2023-10-09 18:07:23 +02:00
Olivier Goffart
414a9e85e7 Expose swrenderer screen rotation to C++ and esp-idf 2023-10-09 18:07:23 +02:00
Olivier Goffart
091dd0a7b9 Rename dynamic_component to dynamic_item_tree 2023-10-09 11:01:56 +02:00
Olivier Goffart
a5488d6285 Rename RepeatedComponent -> RepeatedItemTree
And some more cleanups
2023-10-09 11:01:56 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
Olivier Goffart
4c0a435196 Implement TouchArea::scroll-event
Closes #1280
2023-10-07 07:59:53 +02:00
Olivier Goffart
e0fd9a6105 WIP: Add item_geometry to the ComponentVTable
(unused yet)
2023-09-13 16:08:37 +02:00
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +02:00
Olivier Goffart
cf19749943
Make a pass to remove the Expression::Return instruction
So it doesn't appear in the LLR and the C++ codegen can be simplified.
In particular, this removes the need to throw/catch exception to handle return
across generated lambdas
2023-09-06 14:10:26 +02:00
Olivier Goffart
73ff86cf5a C++: Move the PhysicalRegion in the SofwtareRenderer 2023-08-30 14:59:41 +02:00
Olivier Goffart
932db7ac38 C++: make Platform::duration_since_start non-const and pure
When SLINT_FEATURE_FREESTANDING is set, it must be re-implemented
otherwise the time doesn't pass
2023-08-30 14:59:41 +02:00
Olivier Goffart
c47e6cd029 C++: Api changes in the WindowAdapter
- s/physical_size/size/ (consistant with the slint::Window API)
 - remove const of virtual function  (they don't need to be const and
   make implementation potentially easier)
 - Move the WindowProperties in it
2023-08-30 14:59:41 +02:00
Simon Hausmann
040019c7b6
doc: Fix link to set_physical_size 2023-08-29 07:02:31 +02:00
Simon Hausmann
d160eb7a31
Add support for set_position(), position(), and set_physical_size() to the C++ WindowAdapter (#3367)
Closes #3349
2023-08-28 18:43:04 +02:00
Olivier Goffart
ded66231d1 C++: polish the clipboard patch
- make sure the Platform::Clipboard type is properly documented
 - Use the actual enum in the interface (even though it is
   #[non_exhaustive] so we need to slience a warning)

CC: #3265
2023-08-28 14:34:23 +02:00
Simon Hausmann
67423b288f Add documentation to the WindowAdapters to explain the basic message passing protocol
... and provide hints in there about implementing window close requests.

Note: The links to set_size() and set_position() are not resolved, as
these virtual functions are still missing from the WindowAdapter base
class.
2023-08-28 13:45:28 +02:00
Simon Hausmann
11128b3b7f Document show()/hide()'s behavior of the additional strong component reference 2023-08-28 13:45:28 +02:00
Ian McFarlane
1de7b1512c
Expose clipboard_text accessors to C++ (#3265) 2023-08-28 12:26:40 +02:00
Olivier Goffart
d23ba885ca
C++: add WindowAdaptor::update_window_properties 2023-08-25 13:58:55 +02:00
Olivier Goffart
7904493e1c C++: dispatch close request and activation change 2023-08-24 17:27:04 +02:00
Olivier Goffart
725a259e3a
C++: move the window related stuff in its own header (#3339)
slint.h starts to be quite big, and lots of it is because of Window, so
move Window to its own header
2023-08-24 15:51:50 +02:00
Olivier Goffart
541e7137c6
Backends: don't resize the WindowItem in set_visible
We already query the size right after the call to set_visible in the
WindowInner::show()
2023-08-24 13:15:28 +02:00
Olivier Goffart
f611091470 C++ docs: don't use backtick for Class or method name
because otherwise doxygen don't make links

(also implements the `renderer()` funciton in the doc example)
2023-08-22 11:29:57 +02:00
Olivier Goffart
3e46680c16
C++: improve slint::platform docs (#3319) 2023-08-22 11:24:30 +02:00
Olivier Goffart
146ed520e8
C++: rename SLINT_FEATURE_STD in SLINT_FEATURE_FREESTANDING with the opposite meaning 2023-08-21 16:52:30 +02:00
Olivier Goffart
1288bb6848 C++ Rgb565Pixel: Invert red and blue 2023-08-15 14:45:33 +02:00
darknight
37488f015d Refactoring: define macro rules to group builtin structs
apply new macro for struct declaration, type register,
doc generation, cpp header generation, struct-value conversion.
2023-08-03 11:01:18 +02:00
Simon Hausmann
0c9199b17f
Add support for flipping borrowed OpenGL textures vertically (#3205)
Closes #2986

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-08-02 13:11:13 +02:00
Olivier Goffart
0a8f9c585a
C++: expose special key codes constants 2023-07-31 15:11:57 +02:00
Simon Hausmann
d681864a3b c++: Fix missing platform API Docs
- Fix pre-processor include search path setup so that pre-processing
  slint.h finds slint_internal.h and (most importantly)
  slint_generated_public.h for the feature defines.
- Add missing documentation that caused doxygen errors.
2023-07-31 11:45:01 +02:00
Simon Hausmann
8c289fe3cc Fix doxygen formatting for slint::interpreter::Value::operator== 2023-07-31 11:45:01 +02:00
Olivier Goffart
f3b2b5d457
Improve documentation of AbstractRenderer 2023-07-28 12:18:34 +02:00
Olivier Goffart
fd7fc5ab9b C++, remove the experimental flag
The platform namespace is now always enabled.
2023-07-28 10:36:08 +02:00
Olivier Goffart
3a807e46c1
Renderer feature refactor 2023-07-27 19:11:24 +02:00
Olivier Goffart
c3bec089fe C++: Rename slint_platform.h -> slint-platform.h 2023-07-27 15:42:11 +02:00
Olivier Goffart
643512f60a C++: rename slint_intepreter.h to slint-interpreter.h 2023-07-27 15:42:11 +02:00