x11: Workaround nvidia driver lacking DRI
feat(mouse area): add double click
mouse area: add double click
compositor: Add code to extract adapter from x11
refactor: Extract ids_from_dev from wayland specific code
wayland: Don't crash if libwayland isn't available
feat(sctk): support for overflow widget
sctk: Fixes for cursor icon
* With multiple windows, `SetCursor` is only sent for the focused
window. Fixing a flicker between icons when two windows are using
different cursors.
* If there is a drag surface, let that surface set the cursor. And not
any other.
* Set cursor on `enter`, and when switching between CSDs and app area.
Fixes https://github.com/pop-os/libcosmic/issues/533.
improv(sctk): per-surface cursor position tracking
feat(sctk): support ShowWindowMenu
Make text wrap configurable
fix(core): state order and handling of new trees
fix: settings.decorations enables SSD
refactor(sctk): convert window actions
fix: enable the tokio feature for accesskit_unix
fix: only try to connect to clipboard if on linux
iced_wgpu: don't query Wayland on macos
Update `window_clipboard`
sctk: Unmap subsurfaces instead of immediately destroying them
Destroying a surface is immediate, rather than synchronized with
commits.
This fixes a flickering behavior with drag and drop in
cosmic-workspaces.
sctk: Add alpha setting to `Subsurface` widget
sctk: Update `sctk`, `wayland-protocols`
Update for cosmic-text undefined buffer size
Adapt to cosmic-text undefined width change
fix: unset VK_LOADER_DRIVERS_DISABLE after enumeration
Allows applications to be launched on the NVIDIA GPU with Vulkan support
Adapt to new cosmic-text
wgpu: Fix wayland device id conversion
wgpu: Fix querying adapter, even if we already have one
wgpu: fix nvidia gpu powering up in hybrid setups
cargo fmt
fix: refactor dnd impl to support responsive widget
fix: update read and write methods so they don't recurse
fix(core): replace debug_assert in diff
fix: avoid with_borrow_mut
fix: better handling of state tree
This persists widget state associated with widgets assigned custom IDs even when the tree structure changes, but resets state if the custom ID is not found.
fix: emit Event::Resized to fix nav bar in cosmic-settings
fix(image): guess the image format before decoding
iced_wgpu: Query wayland for the device to use, if possible
sctk: Support `start_drag` with drags started from touch events
sctk: Add touch support
fix: update widnow-clipboard tag
fix: clean up dnd surfaces when a window is removed
Adjust to line ending needing to be specified as part of cosmic_text::BufferLine
sctk: Add support for drag-and-drop surface offsets
This adds an offset `Vector` as an argument to `on_drag`, and allows
passing an offset to `start_drag`.
Some applications using drag and drop want the top left corner of the
drag surface (as happens without an offset). But others want the drag
surface to be offset based on where the cursor is on the widget when
starting the drag. This can just be `-1 * offset`, but may be scaled if
the drag surface is a different size from the original widget.
fix(sctk): nested popup parent
feat(mouseare): mouse enter and exit
fix(tiny_skia): damage
fix(scrollable): filter scroll events in the wrong direction
sctk: Use empty input region for subsurfaces
This seems to work, and is a better way to deal with subsurface input if
there aren't any problems. This way, input events simply go to the
parent surface, so we don't have to deal with various edge cases related
to that. (Though for compositor-side issues, we still need to fix those
for other clients.)
This helps with an issue with drag-and-drop and subsurfaces on Smithay,
and a different issue on Kwin (in KDE 5.27, at least).
Send `DataSource` events to all surfaces
Previously these events are directed to the first surface, then removed
from `sctk_events`. Which is definitely not right.
slider & toggler roundness
Update window_clipboard to pop-dnd-4
fix(tiny-skia): non-simple border scaling
the issue can be seen with sharp corners when using the screenshot portal with scaling
Add read_primary/write_primary
chore: update tag
fix: translate offer positions in scrollable
fix(winit multi-window): handle exit_on_close request
fix(scrollable): pass child layout when calculating drag destinations
fix(container): id and set_id should use content
Clean up after lock surfaces are destroyed
Call unlock on session lock
chore: update tag
fixes for dnd
sctk: Fix handling of DnD with subsurfaces (#122)
Map subsurface to parent and add offset.
refactor: remove Sync bound for Message
fix: pass correct state and layout for container widgets
fix: docs
feat: update advertised drag destinations after rebuilding an interface
fix: color format & multi-window
fix: doc
feat: winit dnd
fix: ambiguous import
chore: reexport mime from window_clipboard
chore: use tag
clippy
feat: add actions and commands for new clipboard methods
cleanup docs
feat: custom mime types for Clipboard
sctk: Fix handling of layer surface `pointer_interactivity` (#115)
A null `region` represents an infinite region (the default). To set an
empty region, we need to create a `wl_region`.
fix(tiny_skia): disable shadows due to rendering glitch
fix(winit): add static lifetimes to multi-window application update
fix(winit): add static lifetimes to application update
Use `TypeId` to identify `subscription::Map`
(cherry picked from commit
|
||
|---|---|---|
| .cargo | ||
| .github | ||
| accessibility | ||
| beacon | ||
| benches | ||
| core | ||
| debug | ||
| devtools | ||
| docs | ||
| examples | ||
| futures | ||
| graphics | ||
| highlighter | ||
| program | ||
| renderer | ||
| runtime | ||
| selector | ||
| src | ||
| test | ||
| tester | ||
| tiny_skia | ||
| wgpu | ||
| widget | ||
| winit | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CHANGELOG.md | ||
| clippy.toml | ||
| CONTRIBUTING.md | ||
| Cross.toml | ||
| DEPENDENCIES.md | ||
| LICENSE | ||
| README.md | ||
| ROADMAP.md | ||
| rustfmt.toml | ||
Features
- Simple, easy-to-use, batteries-included API
- Type-safe, reactive programming model
- Cross-platform support (Windows, macOS, Linux, and the Web)
- Responsive layout
- Built-in widgets (including text inputs, scrollables, and more!)
- Custom widget support (create your own!)
- Debug tooling with performance metrics and time traveling
- First-class support for async actions (use futures!)
- Modular ecosystem split into reusable parts:
- A renderer-agnostic native runtime enabling integration with existing systems
- Two built-in renderers leveraging
wgpuandtiny-skiaiced_wgpusupporting Vulkan, Metal and DX12iced_tiny_skiaoffering a software alternative as a fallback
- A windowing shell
Iced is currently experimental software. Take a look at the roadmap and check out the issues.
Overview
Inspired by The Elm Architecture, Iced expects you to split user interfaces into four different concepts:
- State — the state of your application
- Messages — user interactions or meaningful events that you care about
- View logic — a way to display your state as widgets that may produce messages on user interaction
- Update logic — a way to react to messages and update your state
We can build something to see how this works! Let's say we want a simple counter that can be incremented and decremented using two buttons.
We start by modelling the state of our application:
#[derive(Default)]
struct Counter {
value: i32,
}
Next, we need to define the possible user interactions of our counter: the button presses. These interactions are our messages:
#[derive(Debug, Clone, Copy)]
pub enum Message {
Increment,
Decrement,
}
Now, let's show the actual counter by putting it all together in our view logic:
use iced::widget::{button, column, text, Column};
impl Counter {
pub fn view(&self) -> Column<Message> {
// We use a column: a simple vertical layout
column![
// The increment button. We tell it to produce an
// `Increment` message when pressed
button("+").on_press(Message::Increment),
// We show the value of the counter here
text(self.value).size(50),
// The decrement button. We tell it to produce a
// `Decrement` message when pressed
button("-").on_press(Message::Decrement),
]
}
}
Finally, we need to be able to react to any produced messages and change our state accordingly in our update logic:
impl Counter {
// ...
pub fn update(&mut self, message: Message) {
match message {
Message::Increment => {
self.value += 1;
}
Message::Decrement => {
self.value -= 1;
}
}
}
}
And that's everything! We just wrote a whole user interface. Let's run it:
fn main() -> iced::Result {
iced::run(Counter::update, Counter::view)
}
Iced will automatically:
- Take the result of our view logic and layout its widgets.
- Process events from our system and produce messages for our update logic.
- Draw the resulting user interface.
Read the book, the documentation, and the examples to learn more!
Implementation details
Iced was originally born as an attempt at bringing the simplicity of Elm and The Elm Architecture into Coffee, a 2D game library I am working on.
The core of the library was implemented during May 2019 in this pull request.
The first alpha version was eventually released as
a renderer-agnostic GUI library. The library did not provide a renderer and
implemented the current tour example on top of ggez, a game library.
Since then, the focus has shifted towards providing a batteries-included, end-user-oriented GUI library, while keeping the ecosystem modular.
Contributing / Feedback
If you want to contribute, please read our contributing guidelines for more details.
Feedback is also welcome! You can create a new topic in our Discourse forum or come chat to our Discord server.
Sponsors
The development of Iced is sponsored by the Cryptowatch team at Kraken.com