Commit graph

33 commits

Author SHA1 Message Date
Olivier Goffart
3823c1e8da Experimental support for Drag & Drop
Add a `DragArea` and `DropArea` elements.
It is currently gated as experimental.
2025-06-26 15:39:18 +02:00
Olivier Goffart
47a556d0e7 Core: Pass the MouseEvent by reference
(Prepare to add non-copy data in it)
2025-06-26 15:39:18 +02:00
Avery Townsend
8c4ccabf7d
Expose FocusReason to .slint as an argument in focus-event-changed and add focus-gained and focus-lost callbacks (#8569)
This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close #8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.

In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.

Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.

close #8387

ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope.  Pass an `FocusReason` enum to the FocusScope callbacks
2025-06-04 09:51:26 +02:00
Olivier Goffart
dc915b1af3 C++: add asserts that we are in the main thread
Some checks are pending
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
- In the timer functions
 - in the generated getter/setters and callback invocation
2025-05-28 11:29:48 +02:00
Avery Townsend
c41d4a4df3
Add FocusEventReason to FocusEvent and add a select all on keyboard focus for TextInput (#8523)
Closes #5992

Adds the enum FocusEventReason and makes it an argument for FocusEvent. This reason could eventually be exposed in Slint to solve #8387.

Using the focus reason tracking, I also added a select all on keyboard focus for TextInputs (except on macOS), which should close #5992.

ChangeLog: TextInput selects its content when focused with the keyboard on Windows and Linux
2025-05-27 07:56:13 +02:00
Olivier Goffart
c0b72cad2f
ContextMenu: show submenu on hover after a timeout
This means that the parent menu still get the mouse events

Also add the ability to close the menu programmatically
2025-02-07 13:27:32 +01:00
Olivier Goffart
7104c6e88e
Rudimentary key navigation of the popup menu (#7556)
Closing the menus is still not implemented
2025-02-07 10:01:40 +01:00
Olivier Goffart
6b4c822a4a MenuBar: C++/Rust native menubar implementation
introduce a SetupMenuBar builtin function to ease C++/Rust lowering
2025-01-08 21:16:17 +01:00
Olivier Goffart
846664ad45 WIP: native menubar using muda
Only the interpreter is implemented so far

MacOs won't work yet because we don't disable the default winit menubar

The viewer don't support removing the MenuBar yet
2025-01-08 14:05:35 +01:00
Simon Hausmann
8d85c54a6f Fix up Window::take_snapshot docs
Clarify the "performance" as discussed in the API review.
2024-12-11 17:07:23 +01:00
Olivier Goffart
e03e812984 Fix Focus in PopupWindow
Fix https://github.com/slint-ui/slint/issues/2911
2024-12-09 15:58:16 +01:00
Olivier Goffart
5bd20def0e Experimental support for MenuBar
Introduces `MenuBar{ ... }` that can be put in a Window
2024-11-20 09:25:37 +01:00
Simon Hausmann
a7a3b3f9ee Changelog: C++: Add slint::Window::take_snapshot()
Corresponds to the Rust API.
2024-11-13 12:38:36 +01:00
Brandon Fowler
6da0f55b05
Associate PopupWindows with an ID for their active popup (#6693)
Popups are stored in a HashMap and are assigned an ID so popup.close(); closes the correct popup and so a single PopupWindow cannot be opened multiple times
2024-11-04 09:17:55 +01:00
FloVanGH
14c7910d49
PopupWindow: added close-policy property (#6614)
* Update api/cpp/include/slint_window.h

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update docs/reference/src/language/builtins/elements.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update internal/core/window.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/interpreter/eval.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update internal/backends/qt/qt_window.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/interpreter/dynamic_item_tree.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/compiler/passes/materialize_fake_properties.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-24 09:27:39 +00:00
Olivier Goffart
0f8246d598
C++: add assert_main_thread to public functions in the Window
Some have it some don't. Just add it everywhere.

See https://github.com/slint-ui/slint/discussions/5762
2024-08-06 22:52:45 +02:00
Olivier Goffart
e67e46ab47 LLR: merge the popup's x and y property access in one expression 2024-07-10 17:54:03 +02:00
Simon Hausmann
419042f476 Add support for using own properties in PopupWindow's x and y properties
This allows positioning popup windows in a way that takes their width/height into account.
2024-07-10 13:43:41 +02:00
Olivier Goffart
d0cdebfee6 C++: move globals in a different struct
So that subcomponent don't depend on the root component name
which will hallow to have several root components
2024-06-14 16:26:53 +02:00
Olivier Goffart
4cc6337c42 Rust: Don't get the default font size through the root component
Planning for multi-component support
2024-06-13 13:53:07 +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
Simon Hausmann
31767eb6ab Add a clear-focus()function on all elements that have a focus() function
This is the counter-part, which removes focus from the element if it's currently focused. The window - if focused - may still be focused towards the windowing system.
2024-04-26 11:09:11 +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
Simon Hausmann
68083243b2
Add an in-out boolean color-scheme property to Palette (#4701)
This allows applications to force dark/light mode, as well as determine
which mode is active.
2024-03-26 15:44:22 +01:00
Olivier Goffart
9f0c3c94a9 C++: minimize/maximize/fullscreen API on Window 2024-02-22 13:17:50 +01:00
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
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
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
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
Simon Hausmann
11128b3b7f Document show()/hide()'s behavior of the additional strong component reference 2023-08-28 13:45:28 +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