2024-09-19 05:30:12 +02:00
|
|
|
//! Scrollables let users navigate an endless amount of content with a scrollbar.
|
|
|
|
|
//!
|
|
|
|
|
//! # Example
|
|
|
|
|
//! ```no_run
|
|
|
|
|
//! # mod iced { pub mod widget { pub use iced_widget::*; } }
|
|
|
|
|
//! # pub type State = ();
|
|
|
|
|
//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
2025-09-17 23:49:01 +02:00
|
|
|
//! use iced::widget::{column, scrollable, space};
|
2024-09-19 05:30:12 +02:00
|
|
|
//!
|
|
|
|
|
//! enum Message {
|
|
|
|
|
//! // ...
|
|
|
|
|
//! }
|
|
|
|
|
//!
|
|
|
|
|
//! fn view(state: &State) -> Element<'_, Message> {
|
|
|
|
|
//! scrollable(column![
|
|
|
|
|
//! "Scroll me!",
|
2025-09-17 23:49:01 +02:00
|
|
|
//! space().height(3000),
|
2024-09-19 05:30:12 +02:00
|
|
|
//! "You did it!",
|
|
|
|
|
//! ]).into()
|
|
|
|
|
//! }
|
|
|
|
|
//! ```
|
2024-03-05 04:42:25 +01:00
|
|
|
use crate::container;
|
2025-11-28 08:28:03 +01:00
|
|
|
use crate::core::alignment;
|
2024-07-12 19:10:52 +02:00
|
|
|
use crate::core::border::{self, Border};
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
use crate::core::clipboard::DndDestinationRectangles;
|
|
|
|
|
use iced_runtime::core::widget::Id;
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
use std::borrow::Cow;
|
|
|
|
|
|
|
|
|
|
use crate::core::event;
|
2023-03-04 05:37:11 +01:00
|
|
|
use crate::core::keyboard;
|
|
|
|
|
use crate::core::layout;
|
|
|
|
|
use crate::core::mouse;
|
|
|
|
|
use crate::core::overlay;
|
|
|
|
|
use crate::core::renderer;
|
2025-11-28 08:28:03 +01:00
|
|
|
use crate::core::text;
|
2024-09-08 16:00:22 +02:00
|
|
|
use crate::core::time::{Duration, Instant};
|
2023-03-04 05:37:11 +01:00
|
|
|
use crate::core::touch;
|
|
|
|
|
use crate::core::widget::operation::{self, Operation};
|
|
|
|
|
use crate::core::widget::tree::{self, Tree};
|
2024-09-10 22:38:30 +02:00
|
|
|
use crate::core::window;
|
2023-03-04 05:37:11 +01:00
|
|
|
use crate::core::{
|
2025-02-02 20:45:29 +01:00
|
|
|
self, Background, Clipboard, Color, Element, Event, InputMethod, Layout,
|
2025-11-28 22:02:17 +01:00
|
|
|
Length, Padding, Pixels, Point, Rectangle, Shadow, Shell, Size, Theme,
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
Vector, Widget, id::Internal,
|
2019-10-25 03:47:34 +02:00
|
|
|
};
|
|
|
|
|
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
use iced_runtime::{Action, Task, task};
|
2023-04-17 13:55:40 -07:00
|
|
|
pub use operation::scrollable::{AbsoluteOffset, RelativeOffset};
|
2019-11-21 13:47:20 +01:00
|
|
|
/// A widget that can vertically display an infinite amount of content with a
|
|
|
|
|
/// scrollbar.
|
2024-09-19 05:30:12 +02:00
|
|
|
///
|
|
|
|
|
/// # Example
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
|
|
|
|
|
/// # pub type State = ();
|
|
|
|
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
2025-09-17 23:49:01 +02:00
|
|
|
/// use iced::widget::{column, scrollable, space};
|
2024-09-19 05:30:12 +02:00
|
|
|
///
|
|
|
|
|
/// enum Message {
|
|
|
|
|
/// // ...
|
|
|
|
|
/// }
|
|
|
|
|
///
|
|
|
|
|
/// fn view(state: &State) -> Element<'_, Message> {
|
|
|
|
|
/// scrollable(column![
|
|
|
|
|
/// "Scroll me!",
|
2025-09-17 23:49:01 +02:00
|
|
|
/// space().height(3000),
|
2024-09-19 05:30:12 +02:00
|
|
|
/// "You did it!",
|
|
|
|
|
/// ]).into()
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
2024-01-21 17:56:01 +01:00
|
|
|
pub struct Scrollable<
|
|
|
|
|
'a,
|
|
|
|
|
Message,
|
|
|
|
|
Theme = crate::Theme,
|
|
|
|
|
Renderer = crate::Renderer,
|
|
|
|
|
> where
|
2024-03-24 05:03:09 +01:00
|
|
|
Theme: Catalog,
|
2025-11-28 08:28:03 +01:00
|
|
|
Renderer: text::Renderer,
|
2022-06-07 03:26:48 +02:00
|
|
|
{
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
id: Id,
|
|
|
|
|
scrollbar_id: Id,
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
name: Option<Cow<'a, str>>,
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
description: Option<iced_accessibility::Description<'a>>,
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
label: Option<Vec<iced_accessibility::accesskit::NodeId>>,
|
2023-03-08 11:33:13 +11:00
|
|
|
width: Length,
|
2019-11-21 13:47:20 +01:00
|
|
|
height: Length,
|
2023-06-27 22:30:54 +02:00
|
|
|
direction: Direction,
|
2025-11-28 06:08:20 +01:00
|
|
|
auto_scroll: bool,
|
2024-01-21 17:56:01 +01:00
|
|
|
content: Element<'a, Message, Theme, Renderer>,
|
2023-04-17 13:55:40 -07:00
|
|
|
on_scroll: Option<Box<dyn Fn(Viewport) -> Message + 'a>>,
|
2024-03-24 05:03:09 +01:00
|
|
|
class: Theme::Class<'a>,
|
2024-10-23 21:07:45 +02:00
|
|
|
last_status: Option<Status>,
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
2019-10-29 03:29:29 +01:00
|
|
|
|
2024-01-21 17:56:01 +01:00
|
|
|
impl<'a, Message, Theme, Renderer> Scrollable<'a, Message, Theme, Renderer>
|
2022-06-07 03:26:48 +02:00
|
|
|
where
|
2024-03-24 05:03:09 +01:00
|
|
|
Theme: Catalog,
|
2025-11-28 08:28:03 +01:00
|
|
|
Renderer: text::Renderer,
|
2022-06-07 03:26:48 +02:00
|
|
|
{
|
2024-02-24 19:46:44 +01:00
|
|
|
/// Creates a new vertical [`Scrollable`].
|
2024-01-21 17:56:01 +01:00
|
|
|
pub fn new(
|
|
|
|
|
content: impl Into<Element<'a, Message, Theme, Renderer>>,
|
2024-07-30 22:21:52 +02:00
|
|
|
) -> Self {
|
|
|
|
|
Self::with_direction(content, Direction::default())
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 13:04:37 +01:00
|
|
|
/// Creates a new [`Scrollable`] with the given [`Direction`].
|
2024-07-30 22:21:52 +02:00
|
|
|
pub fn with_direction(
|
|
|
|
|
content: impl Into<Element<'a, Message, Theme, Renderer>>,
|
|
|
|
|
direction: impl Into<Direction>,
|
2024-03-24 05:03:09 +01:00
|
|
|
) -> Self {
|
2024-07-11 07:58:33 +02:00
|
|
|
Scrollable {
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
id: Id::unique(),
|
|
|
|
|
scrollbar_id: Id::unique(),
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
name: None,
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
description: None,
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
label: None,
|
2024-07-11 07:58:33 +02:00
|
|
|
width: Length::Shrink,
|
|
|
|
|
height: Length::Shrink,
|
2024-07-30 22:21:52 +02:00
|
|
|
direction: direction.into(),
|
2025-11-28 06:08:20 +01:00
|
|
|
auto_scroll: false,
|
2024-07-11 07:58:33 +02:00
|
|
|
content: content.into(),
|
|
|
|
|
on_scroll: None,
|
|
|
|
|
class: Theme::default(),
|
2024-10-23 21:07:45 +02:00
|
|
|
last_status: None,
|
2024-07-11 07:58:33 +02:00
|
|
|
}
|
2025-08-21 23:06:07 +02:00
|
|
|
.enclose()
|
2024-02-24 19:46:44 +01:00
|
|
|
}
|
|
|
|
|
|
2025-08-21 23:06:07 +02:00
|
|
|
fn enclose(mut self) -> Self {
|
2024-07-18 13:22:53 +02:00
|
|
|
let size_hint = self.content.as_widget().size_hint();
|
|
|
|
|
|
|
|
|
|
if self.direction.horizontal().is_none() {
|
|
|
|
|
self.width = self.width.enclose(size_hint.width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if self.direction.vertical().is_none() {
|
|
|
|
|
self.height = self.height.enclose(size_hint.height);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-01 04:26:35 +01:00
|
|
|
/// Makes the [`Scrollable`] scroll horizontally, with default [`Scrollbar`] settings.
|
|
|
|
|
pub fn horizontal(self) -> Self {
|
|
|
|
|
self.direction(Direction::Horizontal(Scrollbar::default()))
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-11 13:04:37 +01:00
|
|
|
/// Sets the [`Direction`] of the [`Scrollable`].
|
2024-07-11 07:58:33 +02:00
|
|
|
pub fn direction(mut self, direction: impl Into<Direction>) -> Self {
|
|
|
|
|
self.direction = direction.into();
|
2025-08-21 23:06:07 +02:00
|
|
|
self.enclose()
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2025-08-23 02:41:52 +02:00
|
|
|
/// Sets the [`widget::Id`] of the [`Scrollable`].
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
pub fn id(mut self, id: impl Into<core::widget::Id>) -> Self {
|
|
|
|
|
self.id = id.into();
|
2022-08-04 03:55:41 +02:00
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-08 11:33:13 +11:00
|
|
|
/// Sets the width of the [`Scrollable`].
|
|
|
|
|
pub fn width(mut self, width: impl Into<Length>) -> Self {
|
|
|
|
|
self.width = width.into();
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 13:47:20 +01:00
|
|
|
/// Sets the height of the [`Scrollable`].
|
2023-02-04 12:24:13 +01:00
|
|
|
pub fn height(mut self, height: impl Into<Length>) -> Self {
|
|
|
|
|
self.height = height.into();
|
2019-11-21 13:47:20 +01:00
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-04 20:46:27 +07:00
|
|
|
/// Sets a function to call when the [`Scrollable`] is scrolled.
|
|
|
|
|
///
|
2023-04-17 13:55:40 -07:00
|
|
|
/// The function takes the [`Viewport`] of the [`Scrollable`]
|
|
|
|
|
pub fn on_scroll(mut self, f: impl Fn(Viewport) -> Message + 'a) -> Self {
|
2021-06-04 20:46:27 +07:00
|
|
|
self.on_scroll = Some(Box::new(f));
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Anchors the vertical [`Scrollable`] direction to the top.
|
|
|
|
|
pub fn anchor_top(self) -> Self {
|
|
|
|
|
self.anchor_y(Anchor::Start)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Anchors the vertical [`Scrollable`] direction to the bottom.
|
|
|
|
|
pub fn anchor_bottom(self) -> Self {
|
|
|
|
|
self.anchor_y(Anchor::End)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Anchors the horizontal [`Scrollable`] direction to the left.
|
|
|
|
|
pub fn anchor_left(self) -> Self {
|
|
|
|
|
self.anchor_x(Anchor::Start)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Anchors the horizontal [`Scrollable`] direction to the right.
|
|
|
|
|
pub fn anchor_right(self) -> Self {
|
|
|
|
|
self.anchor_x(Anchor::End)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Sets the [`Anchor`] of the horizontal direction of the [`Scrollable`], if applicable.
|
|
|
|
|
pub fn anchor_x(mut self, alignment: Anchor) -> Self {
|
2024-07-11 04:37:03 +02:00
|
|
|
match &mut self.direction {
|
2024-07-16 19:05:46 +02:00
|
|
|
Direction::Horizontal(horizontal)
|
2024-07-11 04:37:03 +02:00
|
|
|
| Direction::Both { horizontal, .. } => {
|
|
|
|
|
horizontal.alignment = alignment;
|
|
|
|
|
}
|
2024-07-12 19:57:39 +02:00
|
|
|
Direction::Vertical { .. } => {}
|
2024-07-11 04:37:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Sets the [`Anchor`] of the vertical direction of the [`Scrollable`], if applicable.
|
|
|
|
|
pub fn anchor_y(mut self, alignment: Anchor) -> Self {
|
2024-07-11 04:37:03 +02:00
|
|
|
match &mut self.direction {
|
2024-07-16 19:05:46 +02:00
|
|
|
Direction::Vertical(vertical)
|
2024-07-11 04:37:03 +02:00
|
|
|
| Direction::Both { vertical, .. } => {
|
|
|
|
|
vertical.alignment = alignment;
|
|
|
|
|
}
|
2024-07-12 19:57:39 +02:00
|
|
|
Direction::Horizontal { .. } => {}
|
2024-07-11 04:37:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 19:57:39 +02:00
|
|
|
/// Embeds the [`Scrollbar`] into the [`Scrollable`], instead of floating on top of the
|
|
|
|
|
/// content.
|
|
|
|
|
///
|
|
|
|
|
/// The `spacing` provided will be used as space between the [`Scrollbar`] and the contents
|
|
|
|
|
/// of the [`Scrollable`].
|
|
|
|
|
pub fn spacing(mut self, new_spacing: impl Into<Pixels>) -> Self {
|
2024-07-11 07:58:33 +02:00
|
|
|
match &mut self.direction {
|
2024-07-16 19:05:46 +02:00
|
|
|
Direction::Horizontal(scrollbar)
|
|
|
|
|
| Direction::Vertical(scrollbar) => {
|
|
|
|
|
scrollbar.spacing = Some(new_spacing.into().0);
|
2024-07-11 07:58:33 +02:00
|
|
|
}
|
2024-07-12 19:57:39 +02:00
|
|
|
Direction::Both { .. } => {}
|
2024-07-11 07:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-28 06:08:20 +01:00
|
|
|
/// Sets whether the user should be allowed to auto-scroll the [`Scrollable`]
|
|
|
|
|
/// with the middle mouse button.
|
|
|
|
|
///
|
|
|
|
|
/// By default, it is disabled.
|
|
|
|
|
pub fn auto_scroll(mut self, auto_scroll: bool) -> Self {
|
|
|
|
|
self.auto_scroll = auto_scroll;
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
/// Sets the style of this [`Scrollable`].
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self
|
|
|
|
|
where
|
|
|
|
|
Theme::Class<'a>: From<StyleFn<'a, Theme>>,
|
|
|
|
|
{
|
|
|
|
|
self.class = (Box::new(style) as StyleFn<'a, Theme>).into();
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Sets the style class of the [`Scrollable`].
|
|
|
|
|
#[cfg(feature = "advanced")]
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn class(mut self, class: impl Into<Theme::Class<'a>>) -> Self {
|
|
|
|
|
self.class = class.into();
|
2020-01-06 21:01:09 +01:00
|
|
|
self
|
|
|
|
|
}
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
|
|
|
|
|
#[cfg(feature = "a11y")]
|
2024-10-21 10:42:08 -04:00
|
|
|
/// Sets the name of the [`Scrollable`].
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self {
|
|
|
|
|
self.name = Some(name.into());
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "a11y")]
|
2024-10-21 10:42:08 -04:00
|
|
|
/// Sets the description of the [`Scrollable`].
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
pub fn description_widget(
|
|
|
|
|
mut self,
|
|
|
|
|
description: &impl iced_accessibility::Describes,
|
|
|
|
|
) -> Self {
|
|
|
|
|
self.description = Some(iced_accessibility::Description::Id(
|
|
|
|
|
description.description(),
|
|
|
|
|
));
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "a11y")]
|
2024-10-21 10:42:08 -04:00
|
|
|
/// Sets the description of the [`Scrollable`].
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self {
|
|
|
|
|
self.description =
|
|
|
|
|
Some(iced_accessibility::Description::Text(description.into()));
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "a11y")]
|
2024-10-21 10:42:08 -04:00
|
|
|
/// Sets the label of the [`Scrollable`].
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self {
|
|
|
|
|
self.label =
|
|
|
|
|
Some(label.label().into_iter().map(|l| l.into()).collect());
|
|
|
|
|
self
|
|
|
|
|
}
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
2020-01-06 21:01:09 +01:00
|
|
|
|
2023-06-27 22:30:54 +02:00
|
|
|
/// The direction of [`Scrollable`].
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
|
pub enum Direction {
|
|
|
|
|
/// Vertical scrolling
|
2024-07-16 19:05:46 +02:00
|
|
|
Vertical(Scrollbar),
|
2023-06-27 22:30:54 +02:00
|
|
|
/// Horizontal scrolling
|
2024-07-16 19:05:46 +02:00
|
|
|
Horizontal(Scrollbar),
|
2023-06-27 22:30:54 +02:00
|
|
|
/// Both vertical and horizontal scrolling
|
|
|
|
|
Both {
|
|
|
|
|
/// The properties of the vertical scrollbar.
|
2024-07-11 07:58:33 +02:00
|
|
|
vertical: Scrollbar,
|
2023-06-27 22:30:54 +02:00
|
|
|
/// The properties of the horizontal scrollbar.
|
2024-07-11 07:58:33 +02:00
|
|
|
horizontal: Scrollbar,
|
2023-06-27 22:30:54 +02:00
|
|
|
},
|
2023-05-26 20:27:17 -04:00
|
|
|
}
|
|
|
|
|
|
2023-06-27 22:30:54 +02:00
|
|
|
impl Direction {
|
2024-07-11 08:11:19 +02:00
|
|
|
/// Returns the horizontal [`Scrollbar`], if any.
|
2024-07-11 07:58:33 +02:00
|
|
|
pub fn horizontal(&self) -> Option<&Scrollbar> {
|
2023-05-26 20:27:17 -04:00
|
|
|
match self {
|
2024-07-16 19:05:46 +02:00
|
|
|
Self::Horizontal(scrollbar) => Some(scrollbar),
|
2023-06-27 22:30:54 +02:00
|
|
|
Self::Both { horizontal, .. } => Some(horizontal),
|
2024-07-16 19:05:46 +02:00
|
|
|
Self::Vertical(_) => None,
|
2023-05-26 20:27:17 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 08:11:19 +02:00
|
|
|
/// Returns the vertical [`Scrollbar`], if any.
|
2024-07-11 07:58:33 +02:00
|
|
|
pub fn vertical(&self) -> Option<&Scrollbar> {
|
2023-05-26 20:27:17 -04:00
|
|
|
match self {
|
2024-07-16 19:05:46 +02:00
|
|
|
Self::Vertical(scrollbar) => Some(scrollbar),
|
2023-06-27 22:30:54 +02:00
|
|
|
Self::Both { vertical, .. } => Some(vertical),
|
2024-07-16 19:05:46 +02:00
|
|
|
Self::Horizontal(_) => None,
|
2023-05-26 20:27:17 -04:00
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 18:50:10 -03:00
|
|
|
|
|
|
|
|
fn align(&self, delta: Vector) -> Vector {
|
|
|
|
|
let horizontal_alignment =
|
|
|
|
|
self.horizontal().map(|p| p.alignment).unwrap_or_default();
|
|
|
|
|
|
|
|
|
|
let vertical_alignment =
|
|
|
|
|
self.vertical().map(|p| p.alignment).unwrap_or_default();
|
|
|
|
|
|
|
|
|
|
let align = |alignment: Anchor, delta: f32| match alignment {
|
|
|
|
|
Anchor::Start => delta,
|
|
|
|
|
Anchor::End => -delta,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Vector::new(
|
|
|
|
|
align(horizontal_alignment, delta.x),
|
|
|
|
|
align(vertical_alignment, delta.y),
|
|
|
|
|
)
|
|
|
|
|
}
|
2023-05-26 20:27:17 -04:00
|
|
|
}
|
|
|
|
|
|
2023-06-27 22:30:54 +02:00
|
|
|
impl Default for Direction {
|
2023-05-26 20:27:17 -04:00
|
|
|
fn default() -> Self {
|
2024-07-16 19:05:46 +02:00
|
|
|
Self::Vertical(Scrollbar::default())
|
2023-05-26 20:27:17 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 08:11:19 +02:00
|
|
|
/// A scrollbar within a [`Scrollable`].
|
2023-06-27 22:30:54 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2024-07-11 07:58:33 +02:00
|
|
|
pub struct Scrollbar {
|
2023-02-04 12:24:13 +01:00
|
|
|
width: f32,
|
|
|
|
|
margin: f32,
|
|
|
|
|
scroller_width: f32,
|
2024-07-12 15:11:30 +02:00
|
|
|
alignment: Anchor,
|
2024-07-12 19:57:39 +02:00
|
|
|
spacing: Option<f32>,
|
2022-11-19 10:29:37 -08:00
|
|
|
}
|
|
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
impl Default for Scrollbar {
|
2022-11-19 10:29:37 -08:00
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
2023-02-04 12:24:13 +01:00
|
|
|
width: 10.0,
|
|
|
|
|
margin: 0.0,
|
|
|
|
|
scroller_width: 10.0,
|
2024-07-12 15:11:30 +02:00
|
|
|
alignment: Anchor::Start,
|
2024-07-12 19:57:39 +02:00
|
|
|
spacing: None,
|
2022-11-19 10:29:37 -08:00
|
|
|
}
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
2022-11-19 10:29:37 -08:00
|
|
|
}
|
2022-07-27 06:49:20 +02:00
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
impl Scrollbar {
|
2024-07-11 08:11:19 +02:00
|
|
|
/// Creates new [`Scrollbar`] for use in a [`Scrollable`].
|
2022-11-19 10:29:37 -08:00
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self::default()
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
2025-02-01 00:21:41 +00:00
|
|
|
/// Create a [`Scrollbar`] with zero width to allow a [`Scrollable`] to scroll without a visible
|
|
|
|
|
/// scroller.
|
|
|
|
|
pub fn hidden() -> Self {
|
|
|
|
|
Self::default().width(0).scroller_width(0)
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Sets the scrollbar width of the [`Scrollbar`] .
|
2023-02-04 12:24:13 +01:00
|
|
|
pub fn width(mut self, width: impl Into<Pixels>) -> Self {
|
2023-05-10 17:09:29 -07:00
|
|
|
self.width = width.into().0.max(0.0);
|
2022-11-19 10:29:37 -08:00
|
|
|
self
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Sets the scrollbar margin of the [`Scrollbar`] .
|
2023-02-04 12:24:13 +01:00
|
|
|
pub fn margin(mut self, margin: impl Into<Pixels>) -> Self {
|
|
|
|
|
self.margin = margin.into().0;
|
2022-11-19 10:29:37 -08:00
|
|
|
self
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Sets the scroller width of the [`Scrollbar`] .
|
2023-02-04 12:24:13 +01:00
|
|
|
pub fn scroller_width(mut self, scroller_width: impl Into<Pixels>) -> Self {
|
2023-05-10 17:09:29 -07:00
|
|
|
self.scroller_width = scroller_width.into().0.max(0.0);
|
2022-11-19 10:29:37 -08:00
|
|
|
self
|
|
|
|
|
}
|
2023-06-12 21:04:43 -07:00
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Sets the [`Anchor`] of the [`Scrollbar`] .
|
|
|
|
|
pub fn anchor(mut self, alignment: Anchor) -> Self {
|
2023-06-12 21:04:43 -07:00
|
|
|
self.alignment = alignment;
|
|
|
|
|
self
|
|
|
|
|
}
|
2024-07-11 07:58:33 +02:00
|
|
|
|
2024-07-12 19:57:39 +02:00
|
|
|
/// Sets whether the [`Scrollbar`] should be embedded in the [`Scrollable`], using
|
|
|
|
|
/// the given spacing between itself and the contents.
|
2024-07-11 07:58:33 +02:00
|
|
|
///
|
|
|
|
|
/// An embedded [`Scrollbar`] will always be displayed, will take layout space,
|
|
|
|
|
/// and will not float over the contents.
|
2024-07-12 19:57:39 +02:00
|
|
|
pub fn spacing(mut self, spacing: impl Into<Pixels>) -> Self {
|
|
|
|
|
self.spacing = Some(spacing.into().0);
|
2024-07-11 07:58:33 +02:00
|
|
|
self
|
|
|
|
|
}
|
2023-06-12 21:04:43 -07:00
|
|
|
}
|
|
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
/// The anchor of the scroller of the [`Scrollable`] relative to its [`Viewport`]
|
|
|
|
|
/// on a given axis.
|
2023-06-12 21:04:43 -07:00
|
|
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
2024-07-12 15:11:30 +02:00
|
|
|
pub enum Anchor {
|
|
|
|
|
/// Scroller is anchoer to the start of the [`Viewport`].
|
2023-06-12 21:04:43 -07:00
|
|
|
#[default]
|
|
|
|
|
Start,
|
2024-07-12 15:11:30 +02:00
|
|
|
/// Content is aligned to the end of the [`Viewport`].
|
2023-06-12 21:04:43 -07:00
|
|
|
End,
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-02 19:53:16 +01:00
|
|
|
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
|
|
|
|
for Scrollable<'_, Message, Theme, Renderer>
|
2022-11-19 10:29:37 -08:00
|
|
|
where
|
2024-03-24 05:03:09 +01:00
|
|
|
Theme: Catalog,
|
2025-11-28 08:28:03 +01:00
|
|
|
Renderer: text::Renderer,
|
2022-11-19 10:29:37 -08:00
|
|
|
{
|
2022-12-24 21:27:44 -08:00
|
|
|
fn tag(&self) -> tree::Tag {
|
|
|
|
|
tree::Tag::of::<State>()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn state(&self) -> tree::State {
|
|
|
|
|
tree::State::new(State::new())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn children(&self) -> Vec<Tree> {
|
|
|
|
|
vec![Tree::new(&self.content)]
|
|
|
|
|
}
|
|
|
|
|
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
fn diff(&mut self, tree: &mut Tree) {
|
2024-10-18 10:11:22 -04:00
|
|
|
tree.diff_children(std::slice::from_mut(&mut self.content));
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
2024-01-05 17:46:33 +01:00
|
|
|
fn size(&self) -> Size<Length> {
|
|
|
|
|
Size {
|
|
|
|
|
width: self.width,
|
|
|
|
|
height: self.height,
|
|
|
|
|
}
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn layout(
|
2025-08-20 22:42:15 +02:00
|
|
|
&mut self,
|
2023-08-30 06:36:24 +02:00
|
|
|
tree: &mut Tree,
|
2022-07-27 06:49:20 +02:00
|
|
|
renderer: &Renderer,
|
|
|
|
|
limits: &layout::Limits,
|
|
|
|
|
) -> layout::Node {
|
2025-05-03 04:15:18 +02:00
|
|
|
let mut layout = |right_padding, bottom_padding| {
|
|
|
|
|
layout::padded(
|
|
|
|
|
limits,
|
|
|
|
|
self.width,
|
|
|
|
|
self.height,
|
|
|
|
|
Padding {
|
|
|
|
|
right: right_padding,
|
|
|
|
|
bottom: bottom_padding,
|
|
|
|
|
..Padding::ZERO
|
|
|
|
|
},
|
|
|
|
|
|limits| {
|
2025-08-21 23:06:07 +02:00
|
|
|
let is_horizontal = self.direction.horizontal().is_some();
|
|
|
|
|
let is_vertical = self.direction.vertical().is_some();
|
|
|
|
|
|
|
|
|
|
let child_limits = layout::Limits::with_compression(
|
2025-06-26 14:48:56 -06:00
|
|
|
limits.min(),
|
2025-05-03 04:15:18 +02:00
|
|
|
Size::new(
|
2025-08-21 23:06:07 +02:00
|
|
|
if is_horizontal {
|
2025-05-03 04:15:18 +02:00
|
|
|
f32::INFINITY
|
|
|
|
|
} else {
|
|
|
|
|
limits.max().width
|
|
|
|
|
},
|
2025-08-21 23:06:07 +02:00
|
|
|
if is_vertical {
|
2025-05-03 04:15:18 +02:00
|
|
|
f32::INFINITY
|
|
|
|
|
} else {
|
|
|
|
|
limits.max().height
|
|
|
|
|
},
|
|
|
|
|
),
|
2025-08-21 23:06:07 +02:00
|
|
|
Size::new(is_horizontal, is_vertical),
|
2025-05-03 04:15:18 +02:00
|
|
|
);
|
|
|
|
|
|
2025-08-20 22:42:15 +02:00
|
|
|
self.content.as_widget_mut().layout(
|
2025-05-03 04:15:18 +02:00
|
|
|
&mut tree.children[0],
|
|
|
|
|
renderer,
|
|
|
|
|
&child_limits,
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
match self.direction {
|
2024-07-16 19:05:46 +02:00
|
|
|
Direction::Vertical(Scrollbar {
|
|
|
|
|
width,
|
|
|
|
|
margin,
|
2024-07-12 19:57:39 +02:00
|
|
|
spacing: Some(spacing),
|
2024-07-16 19:05:46 +02:00
|
|
|
..
|
2025-05-03 04:15:18 +02:00
|
|
|
})
|
|
|
|
|
| Direction::Horizontal(Scrollbar {
|
2024-07-16 19:05:46 +02:00
|
|
|
width,
|
|
|
|
|
margin,
|
2024-07-12 19:57:39 +02:00
|
|
|
spacing: Some(spacing),
|
2024-07-16 19:05:46 +02:00
|
|
|
..
|
2025-05-03 04:15:18 +02:00
|
|
|
}) => {
|
|
|
|
|
let is_vertical =
|
|
|
|
|
matches!(self.direction, Direction::Vertical(_));
|
|
|
|
|
|
|
|
|
|
let padding = width + margin * 2.0 + spacing;
|
|
|
|
|
let state = tree.state.downcast_mut::<State>();
|
|
|
|
|
|
|
|
|
|
let status_quo = layout(
|
|
|
|
|
if is_vertical && state.is_scrollbar_visible {
|
|
|
|
|
padding
|
|
|
|
|
} else {
|
|
|
|
|
0.0
|
|
|
|
|
},
|
|
|
|
|
if !is_vertical && state.is_scrollbar_visible {
|
|
|
|
|
padding
|
|
|
|
|
} else {
|
|
|
|
|
0.0
|
|
|
|
|
},
|
|
|
|
|
);
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-05-03 04:15:18 +02:00
|
|
|
let is_scrollbar_visible = if is_vertical {
|
|
|
|
|
status_quo.children()[0].size().height
|
|
|
|
|
> status_quo.size().height
|
|
|
|
|
} else {
|
|
|
|
|
status_quo.children()[0].size().width
|
|
|
|
|
> status_quo.size().width
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if state.is_scrollbar_visible == is_scrollbar_visible {
|
|
|
|
|
status_quo
|
|
|
|
|
} else {
|
|
|
|
|
log::trace!("Scrollbar status quo has changed");
|
|
|
|
|
state.is_scrollbar_visible = is_scrollbar_visible;
|
|
|
|
|
|
|
|
|
|
layout(
|
|
|
|
|
if is_vertical && state.is_scrollbar_visible {
|
|
|
|
|
padding
|
2024-07-11 07:58:33 +02:00
|
|
|
} else {
|
2025-05-03 04:15:18 +02:00
|
|
|
0.0
|
2024-07-11 07:58:33 +02:00
|
|
|
},
|
2025-05-03 04:15:18 +02:00
|
|
|
if !is_vertical && state.is_scrollbar_visible {
|
|
|
|
|
padding
|
2024-07-11 07:58:33 +02:00
|
|
|
} else {
|
2025-05-03 04:15:18 +02:00
|
|
|
0.0
|
2024-07-11 07:58:33 +02:00
|
|
|
},
|
2025-05-03 04:15:18 +02:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ => layout(0.0, 0.0),
|
|
|
|
|
}
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-28 03:53:47 +02:00
|
|
|
fn operate(
|
2025-08-20 22:42:15 +02:00
|
|
|
&mut self,
|
2022-07-28 03:53:47 +02:00
|
|
|
tree: &mut Tree,
|
|
|
|
|
layout: Layout<'_>,
|
2022-12-24 21:27:44 -08:00
|
|
|
renderer: &Renderer,
|
2024-08-08 01:25:00 +02:00
|
|
|
operation: &mut dyn Operation,
|
2022-07-28 03:53:47 +02:00
|
|
|
) {
|
2022-08-04 03:55:41 +02:00
|
|
|
let state = tree.state.downcast_mut::<State>();
|
|
|
|
|
|
2023-07-27 01:02:28 +02:00
|
|
|
let bounds = layout.bounds();
|
|
|
|
|
let content_layout = layout.children().next().unwrap();
|
|
|
|
|
let content_bounds = content_layout.bounds();
|
|
|
|
|
let translation =
|
|
|
|
|
state.translation(self.direction, bounds, content_bounds);
|
|
|
|
|
|
|
|
|
|
operation.scrollable(
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
Some(&self.id),
|
2023-07-27 01:02:28 +02:00
|
|
|
bounds,
|
2024-05-10 18:50:10 -03:00
|
|
|
content_bounds,
|
2023-07-27 01:02:28 +02:00
|
|
|
translation,
|
2024-12-03 22:03:06 +01:00
|
|
|
state,
|
2023-07-27 01:02:28 +02:00
|
|
|
);
|
2022-08-04 03:55:41 +02:00
|
|
|
|
2025-08-23 01:44:17 +02:00
|
|
|
operation.traverse(&mut |operation| {
|
2025-08-29 04:25:52 +02:00
|
|
|
self.content.as_widget_mut().operate(
|
2025-08-23 01:44:17 +02:00
|
|
|
&mut tree.children[0],
|
|
|
|
|
layout.children().next().unwrap(),
|
|
|
|
|
renderer,
|
|
|
|
|
operation,
|
|
|
|
|
);
|
|
|
|
|
});
|
2022-07-28 03:53:47 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-25 22:06:06 +02:00
|
|
|
fn update(
|
2022-07-27 06:49:20 +02:00
|
|
|
&mut self,
|
|
|
|
|
tree: &mut Tree,
|
2025-02-03 03:22:10 +01:00
|
|
|
event: &Event,
|
2022-07-27 06:49:20 +02:00
|
|
|
layout: Layout<'_>,
|
2023-06-08 20:11:59 +02:00
|
|
|
cursor: mouse::Cursor,
|
2022-07-27 06:49:20 +02:00
|
|
|
renderer: &Renderer,
|
|
|
|
|
clipboard: &mut dyn Clipboard,
|
|
|
|
|
shell: &mut Shell<'_, Message>,
|
2023-07-15 10:04:25 -07:00
|
|
|
_viewport: &Rectangle,
|
2024-10-25 19:28:18 +02:00
|
|
|
) {
|
2025-05-30 17:03:58 +00:00
|
|
|
const AUTOSCROLL_DEADZONE: f32 = 20.0;
|
2025-11-28 06:29:25 +01:00
|
|
|
const AUTOSCROLL_SMOOTHNESS: f32 = 1.5;
|
2025-05-30 17:03:58 +00:00
|
|
|
|
2024-03-08 13:34:36 +01:00
|
|
|
let state = tree.state.downcast_mut::<State>();
|
|
|
|
|
let bounds = layout.bounds();
|
|
|
|
|
let cursor_over_scrollable = cursor.position_over(bounds);
|
|
|
|
|
|
|
|
|
|
let content = layout.children().next().unwrap();
|
|
|
|
|
let content_bounds = content.bounds();
|
|
|
|
|
|
|
|
|
|
let scrollbars =
|
|
|
|
|
Scrollbars::new(state, self.direction, bounds, content_bounds);
|
|
|
|
|
|
|
|
|
|
let (mouse_over_y_scrollbar, mouse_over_x_scrollbar) =
|
|
|
|
|
scrollbars.is_mouse_over(cursor);
|
|
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let last_offsets = (state.offset_x, state.offset_y);
|
|
|
|
|
|
2024-09-08 16:00:22 +02:00
|
|
|
if let Some(last_scrolled) = state.last_scrolled {
|
|
|
|
|
let clear_transaction = match event {
|
|
|
|
|
Event::Mouse(
|
|
|
|
|
mouse::Event::ButtonPressed(_)
|
|
|
|
|
| mouse::Event::ButtonReleased(_)
|
|
|
|
|
| mouse::Event::CursorLeft,
|
|
|
|
|
) => true,
|
|
|
|
|
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
|
|
|
|
last_scrolled.elapsed() > Duration::from_millis(100)
|
|
|
|
|
}
|
|
|
|
|
_ => last_scrolled.elapsed() > Duration::from_millis(1500),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if clear_transaction {
|
|
|
|
|
state.last_scrolled = None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let mut update = || {
|
2025-05-30 17:03:58 +00:00
|
|
|
if let Some(scroller_grabbed_at) = state.y_scroller_grabbed_at() {
|
2024-10-23 21:07:45 +02:00
|
|
|
match event {
|
|
|
|
|
Event::Mouse(mouse::Event::CursorMoved { .. })
|
|
|
|
|
| Event::Touch(touch::Event::FingerMoved { .. }) => {
|
|
|
|
|
if let Some(scrollbar) = scrollbars.y {
|
2025-02-03 05:45:51 +01:00
|
|
|
let Some(cursor_position) =
|
|
|
|
|
cursor.land().position()
|
2024-10-23 21:07:45 +02:00
|
|
|
else {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
state.scroll_y_to(
|
|
|
|
|
scrollbar.scroll_percentage_y(
|
|
|
|
|
scroller_grabbed_at,
|
|
|
|
|
cursor_position,
|
|
|
|
|
),
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let _ = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
shell.capture_event();
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
2024-04-26 01:19:49 +02:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
_ => {}
|
2024-04-26 01:19:49 +02:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
} else if mouse_over_y_scrollbar {
|
|
|
|
|
match event {
|
|
|
|
|
Event::Mouse(mouse::Event::ButtonPressed(
|
|
|
|
|
mouse::Button::Left,
|
|
|
|
|
))
|
|
|
|
|
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
|
|
|
|
let Some(cursor_position) = cursor.position() else {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
if let (Some(scroller_grabbed_at), Some(scrollbar)) = (
|
|
|
|
|
scrollbars.grab_y_scroller(cursor_position),
|
|
|
|
|
scrollbars.y,
|
|
|
|
|
) {
|
|
|
|
|
state.scroll_y_to(
|
|
|
|
|
scrollbar.scroll_percentage_y(
|
|
|
|
|
scroller_grabbed_at,
|
|
|
|
|
cursor_position,
|
|
|
|
|
),
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
state.interaction = Interaction::YScrollerGrabbed(
|
|
|
|
|
scroller_grabbed_at,
|
|
|
|
|
);
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let _ = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
shell.capture_event();
|
2024-04-26 01:19:49 +02:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
_ => {}
|
2024-04-26 01:19:49 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
if let Some(scroller_grabbed_at) = state.x_scroller_grabbed_at() {
|
2024-10-23 21:07:45 +02:00
|
|
|
match event {
|
|
|
|
|
Event::Mouse(mouse::Event::CursorMoved { .. })
|
|
|
|
|
| Event::Touch(touch::Event::FingerMoved { .. }) => {
|
2025-02-03 05:45:51 +01:00
|
|
|
let Some(cursor_position) = cursor.land().position()
|
|
|
|
|
else {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
if let Some(scrollbar) = scrollbars.x {
|
|
|
|
|
state.scroll_x_to(
|
|
|
|
|
scrollbar.scroll_percentage_x(
|
|
|
|
|
scroller_grabbed_at,
|
|
|
|
|
cursor_position,
|
|
|
|
|
),
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let _ = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
shell.capture_event();
|
2024-04-26 01:19:49 +02:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
_ => {}
|
2024-04-26 01:19:49 +02:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
} else if mouse_over_x_scrollbar {
|
|
|
|
|
match event {
|
|
|
|
|
Event::Mouse(mouse::Event::ButtonPressed(
|
|
|
|
|
mouse::Button::Left,
|
|
|
|
|
))
|
|
|
|
|
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
|
|
|
|
let Some(cursor_position) = cursor.position() else {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-04-26 01:19:49 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
if let (Some(scroller_grabbed_at), Some(scrollbar)) = (
|
|
|
|
|
scrollbars.grab_x_scroller(cursor_position),
|
|
|
|
|
scrollbars.x,
|
|
|
|
|
) {
|
|
|
|
|
state.scroll_x_to(
|
|
|
|
|
scrollbar.scroll_percentage_x(
|
|
|
|
|
scroller_grabbed_at,
|
|
|
|
|
cursor_position,
|
|
|
|
|
),
|
2024-03-08 13:34:36 +01:00
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
2024-10-23 21:07:45 +02:00
|
|
|
);
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
state.interaction = Interaction::XScrollerGrabbed(
|
|
|
|
|
scroller_grabbed_at,
|
|
|
|
|
);
|
2024-10-23 21:07:45 +02:00
|
|
|
|
|
|
|
|
let _ = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
|
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
shell.capture_event();
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ => {}
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-11-28 06:29:25 +01:00
|
|
|
if matches!(state.interaction, Interaction::AutoScrolling { .. })
|
|
|
|
|
&& matches!(
|
|
|
|
|
event,
|
|
|
|
|
Event::Mouse(
|
|
|
|
|
mouse::Event::ButtonPressed(_)
|
|
|
|
|
| mouse::Event::WheelScrolled { .. }
|
|
|
|
|
) | Event::Touch(_)
|
|
|
|
|
| Event::Keyboard(_)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
state.interaction = Interaction::None;
|
|
|
|
|
shell.capture_event();
|
2025-11-28 08:28:03 +01:00
|
|
|
shell.invalidate_layout();
|
|
|
|
|
shell.request_redraw();
|
2025-11-28 06:29:25 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
if state.last_scrolled.is_none()
|
|
|
|
|
|| !matches!(
|
2024-10-23 21:07:45 +02:00
|
|
|
event,
|
|
|
|
|
Event::Mouse(mouse::Event::WheelScrolled { .. })
|
2024-10-25 19:28:18 +02:00
|
|
|
)
|
|
|
|
|
{
|
2025-10-15 22:17:39 +02:00
|
|
|
let translation =
|
|
|
|
|
state.translation(self.direction, bounds, content_bounds);
|
|
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let cursor = match cursor_over_scrollable {
|
|
|
|
|
Some(cursor_position)
|
|
|
|
|
if !(mouse_over_x_scrollbar
|
|
|
|
|
|| mouse_over_y_scrollbar) =>
|
|
|
|
|
{
|
2025-10-15 22:17:39 +02:00
|
|
|
mouse::Cursor::Available(cursor_position + translation)
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
2025-10-15 22:17:39 +02:00
|
|
|
_ => cursor.levitate() + translation,
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-02-12 08:46:35 +01:00
|
|
|
let had_input_method = shell.input_method().is_enabled();
|
2025-02-03 17:12:08 +01:00
|
|
|
|
2024-10-25 22:06:06 +02:00
|
|
|
self.content.as_widget_mut().update(
|
2024-10-23 21:07:45 +02:00
|
|
|
&mut tree.children[0],
|
2025-02-03 03:22:10 +01:00
|
|
|
event,
|
2024-10-23 21:07:45 +02:00
|
|
|
content,
|
|
|
|
|
cursor,
|
|
|
|
|
renderer,
|
|
|
|
|
clipboard,
|
|
|
|
|
shell,
|
|
|
|
|
&Rectangle {
|
|
|
|
|
y: bounds.y + translation.y,
|
|
|
|
|
x: bounds.x + translation.x,
|
|
|
|
|
..bounds
|
|
|
|
|
},
|
2024-10-25 19:28:18 +02:00
|
|
|
);
|
2025-01-10 07:12:31 +09:00
|
|
|
|
2025-08-07 22:36:02 +02:00
|
|
|
if !had_input_method
|
2025-05-01 13:03:54 +00:00
|
|
|
&& let InputMethod::Enabled { cursor, .. } =
|
2025-02-03 17:12:08 +01:00
|
|
|
shell.input_method_mut()
|
2025-08-07 22:36:02 +02:00
|
|
|
{
|
2025-05-01 13:03:54 +00:00
|
|
|
*cursor = *cursor - translation;
|
2025-01-10 07:12:31 +09:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-03-10 16:18:06 -06:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
if matches!(
|
|
|
|
|
event,
|
|
|
|
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
|
|
|
|
| Event::Touch(
|
|
|
|
|
touch::Event::FingerLifted { .. }
|
|
|
|
|
| touch::Event::FingerLost { .. }
|
|
|
|
|
)
|
|
|
|
|
) {
|
2025-05-30 17:03:58 +00:00
|
|
|
state.interaction = Interaction::None;
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
if shell.is_event_captured() {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
match event {
|
|
|
|
|
Event::Mouse(mouse::Event::WheelScrolled { delta }) => {
|
|
|
|
|
if cursor_over_scrollable.is_none() {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-02-03 03:22:10 +01:00
|
|
|
let delta = match *delta {
|
2024-10-23 21:07:45 +02:00
|
|
|
mouse::ScrollDelta::Lines { x, y } => {
|
|
|
|
|
let is_shift_pressed =
|
|
|
|
|
state.keyboard_modifiers.shift();
|
2024-05-13 21:16:19 -05:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
// macOS automatically inverts the axes when Shift is pressed
|
|
|
|
|
let (x, y) = if cfg!(target_os = "macos")
|
|
|
|
|
&& is_shift_pressed
|
|
|
|
|
{
|
2024-05-13 21:16:19 -05:00
|
|
|
(y, x)
|
|
|
|
|
} else {
|
|
|
|
|
(x, y)
|
|
|
|
|
};
|
|
|
|
|
|
2025-02-01 02:16:29 +01:00
|
|
|
let movement = if !is_shift_pressed {
|
2024-10-23 21:07:45 +02:00
|
|
|
Vector::new(x, y)
|
|
|
|
|
} else {
|
|
|
|
|
Vector::new(y, x)
|
|
|
|
|
};
|
2024-09-18 21:45:25 +02:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
// TODO: Configurable speed/friction (?)
|
|
|
|
|
-movement * 60.0
|
|
|
|
|
}
|
|
|
|
|
mouse::ScrollDelta::Pixels { x, y } => {
|
2024-10-18 16:19:36 -04:00
|
|
|
Vector::new(x, y)
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
};
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
state.scroll(
|
|
|
|
|
self.direction.align(delta),
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let has_scrolled = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let in_transaction = state.last_scrolled.is_some();
|
|
|
|
|
|
|
|
|
|
if has_scrolled || in_transaction {
|
2024-10-25 19:28:18 +02:00
|
|
|
shell.capture_event();
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
2025-05-30 17:03:58 +00:00
|
|
|
Event::Mouse(mouse::Event::ButtonPressed(
|
|
|
|
|
mouse::Button::Middle,
|
2025-11-28 06:08:20 +01:00
|
|
|
)) if self.auto_scroll
|
|
|
|
|
&& matches!(state.interaction, Interaction::None) =>
|
|
|
|
|
{
|
2025-05-30 17:03:58 +00:00
|
|
|
let Some(origin) = cursor_over_scrollable else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
state.interaction = Interaction::AutoScrolling {
|
|
|
|
|
origin,
|
|
|
|
|
current: origin,
|
|
|
|
|
last_frame: None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
shell.capture_event();
|
2025-11-28 08:28:03 +01:00
|
|
|
shell.invalidate_layout();
|
|
|
|
|
shell.request_redraw();
|
2025-05-30 17:03:58 +00:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
Event::Touch(event)
|
2025-05-30 17:03:58 +00:00
|
|
|
if matches!(
|
|
|
|
|
state.interaction,
|
|
|
|
|
Interaction::TouchScrolling(_)
|
|
|
|
|
) || (!mouse_over_y_scrollbar
|
|
|
|
|
&& !mouse_over_x_scrollbar) =>
|
2024-10-23 21:07:45 +02:00
|
|
|
{
|
|
|
|
|
match event {
|
|
|
|
|
touch::Event::FingerPressed { .. } => {
|
2025-05-30 17:03:58 +00:00
|
|
|
let Some(position) = cursor_over_scrollable else {
|
2024-10-25 19:28:18 +02:00
|
|
|
return;
|
2025-05-30 17:03:58 +00:00
|
|
|
};
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
state.interaction =
|
|
|
|
|
Interaction::TouchScrolling(position);
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
touch::Event::FingerMoved { .. } => {
|
2025-05-30 17:03:58 +00:00
|
|
|
let Interaction::TouchScrolling(
|
|
|
|
|
scroll_box_touched_at,
|
|
|
|
|
) = state.interaction
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
2024-10-23 21:07:45 +02:00
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
let Some(cursor_position) = cursor.position()
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let delta = Vector::new(
|
|
|
|
|
scroll_box_touched_at.x - cursor_position.x,
|
|
|
|
|
scroll_box_touched_at.y - cursor_position.y,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
state.scroll(
|
|
|
|
|
self.direction.align(delta),
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
state.interaction =
|
|
|
|
|
Interaction::TouchScrolling(cursor_position);
|
|
|
|
|
|
|
|
|
|
// TODO: bubble up touch movements if not consumed.
|
|
|
|
|
let _ = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
_ => {}
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
shell.capture_event();
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2025-05-30 17:03:58 +00:00
|
|
|
Event::Mouse(mouse::Event::CursorMoved { position }) => {
|
|
|
|
|
if let Interaction::AutoScrolling {
|
|
|
|
|
origin,
|
|
|
|
|
last_frame,
|
|
|
|
|
..
|
|
|
|
|
} = state.interaction
|
|
|
|
|
{
|
|
|
|
|
let delta = *position - origin;
|
|
|
|
|
|
2025-11-28 08:28:03 +01:00
|
|
|
state.interaction = Interaction::AutoScrolling {
|
|
|
|
|
origin,
|
|
|
|
|
current: *position,
|
|
|
|
|
last_frame,
|
|
|
|
|
};
|
2025-05-30 17:03:58 +00:00
|
|
|
|
2025-11-28 08:28:03 +01:00
|
|
|
if (delta.x.abs() >= AUTOSCROLL_DEADZONE
|
|
|
|
|
|| delta.y.abs() >= AUTOSCROLL_DEADZONE)
|
|
|
|
|
&& last_frame.is_none()
|
|
|
|
|
{
|
|
|
|
|
shell.request_redraw();
|
2025-05-30 17:03:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Event::Keyboard(keyboard::Event::ModifiersChanged(
|
|
|
|
|
modifiers,
|
|
|
|
|
)) => {
|
|
|
|
|
state.keyboard_modifiers = *modifiers;
|
|
|
|
|
}
|
|
|
|
|
Event::Window(window::Event::RedrawRequested(now)) => {
|
|
|
|
|
if let Interaction::AutoScrolling {
|
|
|
|
|
origin,
|
|
|
|
|
current,
|
|
|
|
|
last_frame,
|
|
|
|
|
} = state.interaction
|
|
|
|
|
{
|
|
|
|
|
if last_frame == Some(*now) {
|
|
|
|
|
shell.request_redraw();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state.interaction = Interaction::AutoScrolling {
|
|
|
|
|
origin,
|
|
|
|
|
current,
|
|
|
|
|
last_frame: None,
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-28 08:28:03 +01:00
|
|
|
let mut delta = current - origin;
|
2025-05-30 17:03:58 +00:00
|
|
|
|
2025-11-28 08:28:03 +01:00
|
|
|
if delta.x.abs() < AUTOSCROLL_DEADZONE {
|
|
|
|
|
delta.x = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if delta.y.abs() < AUTOSCROLL_DEADZONE {
|
|
|
|
|
delta.y = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if delta.x != 0.0 || delta.y != 0.0 {
|
2025-05-30 17:03:58 +00:00
|
|
|
let time_delta =
|
|
|
|
|
if let Some(last_frame) = last_frame {
|
|
|
|
|
*now - last_frame
|
|
|
|
|
} else {
|
|
|
|
|
Duration::ZERO
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-28 06:29:25 +01:00
|
|
|
let scroll_factor = time_delta.as_secs_f32();
|
2025-05-30 17:03:58 +00:00
|
|
|
|
|
|
|
|
state.scroll(
|
|
|
|
|
self.direction.align(Vector::new(
|
2025-11-28 06:29:25 +01:00
|
|
|
delta.x.signum()
|
|
|
|
|
* delta
|
|
|
|
|
.x
|
|
|
|
|
.abs()
|
|
|
|
|
.powf(AUTOSCROLL_SMOOTHNESS)
|
|
|
|
|
* scroll_factor,
|
|
|
|
|
delta.y.signum()
|
|
|
|
|
* delta
|
|
|
|
|
.y
|
|
|
|
|
.abs()
|
|
|
|
|
.powf(AUTOSCROLL_SMOOTHNESS)
|
|
|
|
|
* scroll_factor,
|
2025-05-30 17:03:58 +00:00
|
|
|
)),
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let has_scrolled = notify_scroll(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if has_scrolled || time_delta.is_zero() {
|
|
|
|
|
state.interaction =
|
|
|
|
|
Interaction::AutoScrolling {
|
|
|
|
|
origin,
|
|
|
|
|
current,
|
|
|
|
|
last_frame: Some(*now),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
shell.request_redraw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
let _ = notify_viewport(
|
|
|
|
|
state,
|
|
|
|
|
&self.on_scroll,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
shell,
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-10-25 19:28:18 +02:00
|
|
|
_ => {}
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
2024-09-10 22:38:30 +02:00
|
|
|
|
2024-10-25 19:28:18 +02:00
|
|
|
update();
|
2024-10-23 21:07:45 +02:00
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
let status = if state.scrollers_grabbed() {
|
2024-10-23 21:07:45 +02:00
|
|
|
Status::Dragged {
|
|
|
|
|
is_horizontal_scrollbar_dragged: state
|
2025-05-30 17:03:58 +00:00
|
|
|
.x_scroller_grabbed_at()
|
2024-10-23 21:07:45 +02:00
|
|
|
.is_some(),
|
|
|
|
|
is_vertical_scrollbar_dragged: state
|
2025-05-30 17:03:58 +00:00
|
|
|
.y_scroller_grabbed_at()
|
2024-10-23 21:07:45 +02:00
|
|
|
.is_some(),
|
2025-01-06 20:25:22 +01:00
|
|
|
is_horizontal_scrollbar_disabled: scrollbars.is_x_disabled(),
|
|
|
|
|
is_vertical_scrollbar_disabled: scrollbars.is_y_disabled(),
|
2024-10-23 21:07:45 +02:00
|
|
|
}
|
|
|
|
|
} else if cursor_over_scrollable.is_some() {
|
|
|
|
|
Status::Hovered {
|
|
|
|
|
is_horizontal_scrollbar_hovered: mouse_over_x_scrollbar,
|
|
|
|
|
is_vertical_scrollbar_hovered: mouse_over_y_scrollbar,
|
2025-01-06 20:25:22 +01:00
|
|
|
is_horizontal_scrollbar_disabled: scrollbars.is_x_disabled(),
|
|
|
|
|
is_vertical_scrollbar_disabled: scrollbars.is_y_disabled(),
|
2024-09-10 22:38:30 +02:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
} else {
|
2024-09-18 22:03:08 -04:00
|
|
|
Status::Active {
|
2025-01-06 20:25:22 +01:00
|
|
|
is_horizontal_scrollbar_disabled: scrollbars.is_x_disabled(),
|
|
|
|
|
is_vertical_scrollbar_disabled: scrollbars.is_y_disabled(),
|
2024-09-18 22:03:08 -04:00
|
|
|
}
|
2024-10-23 21:07:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if let Event::Window(window::Event::RedrawRequested(_now)) = event {
|
|
|
|
|
self.last_status = Some(status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if last_offsets != (state.offset_x, state.offset_y)
|
|
|
|
|
|| self
|
|
|
|
|
.last_status
|
|
|
|
|
.is_some_and(|last_status| last_status != status)
|
|
|
|
|
{
|
2024-10-25 15:40:05 +02:00
|
|
|
shell.request_redraw();
|
2024-03-08 13:34:36 +01:00
|
|
|
}
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
fn draw(
|
|
|
|
|
&self,
|
|
|
|
|
tree: &Tree,
|
|
|
|
|
renderer: &mut Renderer,
|
2024-01-21 17:56:01 +01:00
|
|
|
theme: &Theme,
|
2024-03-24 05:03:09 +01:00
|
|
|
defaults: &renderer::Style,
|
2022-12-24 21:27:44 -08:00
|
|
|
layout: Layout<'_>,
|
2023-06-08 20:11:59 +02:00
|
|
|
cursor: mouse::Cursor,
|
2024-04-03 21:07:54 +02:00
|
|
|
viewport: &Rectangle,
|
2022-12-24 21:27:44 -08:00
|
|
|
) {
|
2024-03-05 04:42:25 +01:00
|
|
|
let state = tree.state.downcast_ref::<State>();
|
|
|
|
|
|
|
|
|
|
let bounds = layout.bounds();
|
|
|
|
|
let content_layout = layout.children().next().unwrap();
|
|
|
|
|
let content_bounds = content_layout.bounds();
|
|
|
|
|
|
2024-04-23 02:29:04 +02:00
|
|
|
let Some(visible_bounds) = bounds.intersection(viewport) else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-05 04:42:25 +01:00
|
|
|
let scrollbars =
|
|
|
|
|
Scrollbars::new(state, self.direction, bounds, content_bounds);
|
|
|
|
|
|
|
|
|
|
let cursor_over_scrollable = cursor.position_over(bounds);
|
|
|
|
|
let (mouse_over_y_scrollbar, mouse_over_x_scrollbar) =
|
|
|
|
|
scrollbars.is_mouse_over(cursor);
|
|
|
|
|
|
|
|
|
|
let translation =
|
|
|
|
|
state.translation(self.direction, bounds, content_bounds);
|
|
|
|
|
|
|
|
|
|
let cursor = match cursor_over_scrollable {
|
|
|
|
|
Some(cursor_position)
|
|
|
|
|
if !(mouse_over_x_scrollbar || mouse_over_y_scrollbar) =>
|
|
|
|
|
{
|
|
|
|
|
mouse::Cursor::Available(cursor_position + translation)
|
|
|
|
|
}
|
|
|
|
|
_ => mouse::Cursor::Unavailable,
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-18 22:03:08 -04:00
|
|
|
let style = theme.style(
|
|
|
|
|
&self.class,
|
|
|
|
|
self.last_status.unwrap_or(Status::Active {
|
|
|
|
|
is_horizontal_scrollbar_disabled: false,
|
|
|
|
|
is_vertical_scrollbar_disabled: false,
|
|
|
|
|
}),
|
|
|
|
|
);
|
2024-03-05 04:42:25 +01:00
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
container::draw_background(renderer, &style.container, layout.bounds());
|
2024-03-05 04:42:25 +01:00
|
|
|
|
|
|
|
|
// Draw inner content
|
|
|
|
|
if scrollbars.active() {
|
2024-04-23 02:29:04 +02:00
|
|
|
renderer.with_layer(visible_bounds, |renderer| {
|
2024-03-05 04:42:25 +01:00
|
|
|
renderer.with_translation(
|
|
|
|
|
Vector::new(-translation.x, -translation.y),
|
|
|
|
|
|renderer| {
|
|
|
|
|
self.content.as_widget().draw(
|
|
|
|
|
&tree.children[0],
|
|
|
|
|
renderer,
|
|
|
|
|
theme,
|
2024-03-24 05:03:09 +01:00
|
|
|
defaults,
|
2024-03-05 04:42:25 +01:00
|
|
|
content_layout,
|
|
|
|
|
cursor,
|
|
|
|
|
&Rectangle {
|
2025-02-01 01:04:36 +01:00
|
|
|
y: visible_bounds.y + translation.y,
|
|
|
|
|
x: visible_bounds.x + translation.x,
|
|
|
|
|
..visible_bounds
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let draw_scrollbar =
|
|
|
|
|
|renderer: &mut Renderer,
|
2024-07-11 07:58:33 +02:00
|
|
|
style: Rail,
|
2024-03-05 04:42:25 +01:00
|
|
|
scrollbar: &internals::Scrollbar| {
|
|
|
|
|
if scrollbar.bounds.width > 0.0
|
|
|
|
|
&& scrollbar.bounds.height > 0.0
|
|
|
|
|
&& (style.background.is_some()
|
|
|
|
|
|| (style.border.color != Color::TRANSPARENT
|
|
|
|
|
&& style.border.width > 0.0))
|
|
|
|
|
{
|
|
|
|
|
renderer.fill_quad(
|
|
|
|
|
renderer::Quad {
|
|
|
|
|
bounds: scrollbar.bounds,
|
|
|
|
|
border: style.border,
|
|
|
|
|
..renderer::Quad::default()
|
|
|
|
|
},
|
|
|
|
|
style.background.unwrap_or(Background::Color(
|
|
|
|
|
Color::TRANSPARENT,
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-07 22:36:02 +02:00
|
|
|
if let Some(scroller) = scrollbar.scroller
|
|
|
|
|
&& scroller.bounds.width > 0.0
|
|
|
|
|
&& scroller.bounds.height > 0.0
|
2025-09-20 19:01:25 +01:00
|
|
|
&& (style.scroller.background
|
|
|
|
|
!= Background::Color(Color::TRANSPARENT)
|
2025-08-07 22:36:02 +02:00
|
|
|
|| (style.scroller.border.color
|
|
|
|
|
!= Color::TRANSPARENT
|
|
|
|
|
&& style.scroller.border.width > 0.0))
|
|
|
|
|
{
|
|
|
|
|
renderer.fill_quad(
|
|
|
|
|
renderer::Quad {
|
|
|
|
|
bounds: scroller.bounds,
|
|
|
|
|
border: style.scroller.border,
|
|
|
|
|
..renderer::Quad::default()
|
|
|
|
|
},
|
2025-09-20 19:01:25 +01:00
|
|
|
style.scroller.background,
|
2025-08-07 22:36:02 +02:00
|
|
|
);
|
2024-03-05 04:42:25 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderer.with_layer(
|
|
|
|
|
Rectangle {
|
2024-04-23 02:29:04 +02:00
|
|
|
width: (visible_bounds.width + 2.0).min(viewport.width),
|
|
|
|
|
height: (visible_bounds.height + 2.0).min(viewport.height),
|
|
|
|
|
..visible_bounds
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
|renderer| {
|
|
|
|
|
if let Some(scrollbar) = scrollbars.y {
|
|
|
|
|
draw_scrollbar(
|
|
|
|
|
renderer,
|
2024-07-11 07:58:33 +02:00
|
|
|
style.vertical_rail,
|
2024-03-05 04:42:25 +01:00
|
|
|
&scrollbar,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let Some(scrollbar) = scrollbars.x {
|
|
|
|
|
draw_scrollbar(
|
|
|
|
|
renderer,
|
2024-07-11 07:58:33 +02:00
|
|
|
style.horizontal_rail,
|
2024-03-05 04:42:25 +01:00
|
|
|
&scrollbar,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let (Some(x), Some(y)) = (scrollbars.x, scrollbars.y) {
|
|
|
|
|
let background =
|
2024-03-24 05:03:09 +01:00
|
|
|
style.gap.or(style.container.background);
|
2024-03-05 04:42:25 +01:00
|
|
|
|
|
|
|
|
if let Some(background) = background {
|
|
|
|
|
renderer.fill_quad(
|
|
|
|
|
renderer::Quad {
|
|
|
|
|
bounds: Rectangle {
|
|
|
|
|
x: y.bounds.x,
|
|
|
|
|
y: x.bounds.y,
|
|
|
|
|
width: y.bounds.width,
|
|
|
|
|
height: x.bounds.height,
|
|
|
|
|
},
|
|
|
|
|
..renderer::Quad::default()
|
|
|
|
|
},
|
|
|
|
|
background,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
self.content.as_widget().draw(
|
|
|
|
|
&tree.children[0],
|
|
|
|
|
renderer,
|
|
|
|
|
theme,
|
2024-03-24 05:03:09 +01:00
|
|
|
defaults,
|
2024-03-05 04:42:25 +01:00
|
|
|
content_layout,
|
|
|
|
|
cursor,
|
|
|
|
|
&Rectangle {
|
2025-02-01 01:04:36 +01:00
|
|
|
x: visible_bounds.x + translation.x,
|
|
|
|
|
y: visible_bounds.y + translation.y,
|
|
|
|
|
..visible_bounds
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
2022-07-27 06:49:20 +02:00
|
|
|
fn mouse_interaction(
|
|
|
|
|
&self,
|
|
|
|
|
tree: &Tree,
|
|
|
|
|
layout: Layout<'_>,
|
2023-06-08 20:11:59 +02:00
|
|
|
cursor: mouse::Cursor,
|
2022-07-27 06:49:20 +02:00
|
|
|
_viewport: &Rectangle,
|
|
|
|
|
renderer: &Renderer,
|
|
|
|
|
) -> mouse::Interaction {
|
2024-03-08 13:34:36 +01:00
|
|
|
let state = tree.state.downcast_ref::<State>();
|
|
|
|
|
let bounds = layout.bounds();
|
|
|
|
|
let cursor_over_scrollable = cursor.position_over(bounds);
|
|
|
|
|
|
|
|
|
|
let content_layout = layout.children().next().unwrap();
|
|
|
|
|
let content_bounds = content_layout.bounds();
|
|
|
|
|
|
|
|
|
|
let scrollbars =
|
|
|
|
|
Scrollbars::new(state, self.direction, bounds, content_bounds);
|
|
|
|
|
|
|
|
|
|
let (mouse_over_y_scrollbar, mouse_over_x_scrollbar) =
|
|
|
|
|
scrollbars.is_mouse_over(cursor);
|
|
|
|
|
|
2025-10-11 07:57:37 +02:00
|
|
|
if state.scrollers_grabbed() {
|
|
|
|
|
return mouse::Interaction::None;
|
|
|
|
|
}
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-10-11 07:57:37 +02:00
|
|
|
let translation =
|
|
|
|
|
state.translation(self.direction, bounds, content_bounds);
|
2024-03-08 13:34:36 +01:00
|
|
|
|
2025-10-11 07:57:37 +02:00
|
|
|
let cursor = match cursor_over_scrollable {
|
|
|
|
|
Some(cursor_position)
|
|
|
|
|
if !(mouse_over_x_scrollbar || mouse_over_y_scrollbar) =>
|
|
|
|
|
{
|
|
|
|
|
mouse::Cursor::Available(cursor_position + translation)
|
|
|
|
|
}
|
2025-10-15 22:17:39 +02:00
|
|
|
_ => cursor.levitate() + translation,
|
2025-10-11 07:57:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
self.content.as_widget().mouse_interaction(
|
|
|
|
|
&tree.children[0],
|
|
|
|
|
content_layout,
|
|
|
|
|
cursor,
|
|
|
|
|
&Rectangle {
|
|
|
|
|
y: bounds.y + translation.y,
|
|
|
|
|
x: bounds.x + translation.x,
|
|
|
|
|
..bounds
|
|
|
|
|
},
|
|
|
|
|
renderer,
|
|
|
|
|
)
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn overlay<'b>(
|
2022-12-24 21:27:44 -08:00
|
|
|
&'b mut self,
|
2022-07-27 06:49:20 +02:00
|
|
|
tree: &'b mut Tree,
|
2025-04-29 22:31:58 +02:00
|
|
|
layout: Layout<'b>,
|
2022-07-27 06:49:20 +02:00
|
|
|
renderer: &Renderer,
|
2025-04-26 02:51:32 +02:00
|
|
|
viewport: &Rectangle,
|
2024-02-01 01:08:21 +01:00
|
|
|
translation: Vector,
|
2024-01-21 17:56:01 +01:00
|
|
|
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
|
2025-11-28 08:28:03 +01:00
|
|
|
let state = tree.state.downcast_ref::<State>();
|
2024-02-01 01:08:21 +01:00
|
|
|
let bounds = layout.bounds();
|
|
|
|
|
let content_layout = layout.children().next().unwrap();
|
|
|
|
|
let content_bounds = content_layout.bounds();
|
2025-04-26 02:51:32 +02:00
|
|
|
let visible_bounds = bounds.intersection(viewport).unwrap_or(*viewport);
|
2025-11-28 08:28:03 +01:00
|
|
|
let offset = state.translation(self.direction, bounds, content_bounds);
|
2024-02-01 01:08:21 +01:00
|
|
|
|
2025-11-28 08:28:03 +01:00
|
|
|
let overlay = self.content.as_widget_mut().overlay(
|
2024-02-01 01:08:21 +01:00
|
|
|
&mut tree.children[0],
|
|
|
|
|
layout.children().next().unwrap(),
|
|
|
|
|
renderer,
|
2025-04-26 02:51:32 +02:00
|
|
|
&visible_bounds,
|
2024-02-01 01:08:21 +01:00
|
|
|
translation - offset,
|
2025-11-28 08:28:03 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let icon = if let Interaction::AutoScrolling { origin, .. } =
|
|
|
|
|
state.interaction
|
|
|
|
|
{
|
|
|
|
|
let scrollbars =
|
|
|
|
|
Scrollbars::new(state, self.direction, bounds, content_bounds);
|
|
|
|
|
|
|
|
|
|
Some(overlay::Element::new(Box::new(AutoScrollIcon {
|
|
|
|
|
origin,
|
|
|
|
|
vertical: scrollbars.y.is_some(),
|
|
|
|
|
horizontal: scrollbars.x.is_some(),
|
2025-11-28 08:56:32 +01:00
|
|
|
class: &self.class,
|
2025-11-28 08:28:03 +01:00
|
|
|
})))
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
match (overlay, icon) {
|
|
|
|
|
(None, None) => None,
|
|
|
|
|
(None, Some(icon)) => Some(icon),
|
|
|
|
|
(Some(overlay), None) => Some(overlay),
|
|
|
|
|
(Some(overlay), Some(icon)) => Some(overlay::Element::new(
|
|
|
|
|
Box::new(overlay::Group::with_children(vec![overlay, icon])),
|
|
|
|
|
)),
|
|
|
|
|
}
|
|
|
|
|
}
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
|
|
|
|
|
#[cfg(feature = "a11y")]
|
|
|
|
|
fn a11y_nodes(
|
|
|
|
|
&self,
|
|
|
|
|
layout: Layout<'_>,
|
|
|
|
|
state: &Tree,
|
|
|
|
|
cursor: mouse::Cursor,
|
|
|
|
|
) -> iced_accessibility::A11yTree {
|
|
|
|
|
use iced_accessibility::{
|
|
|
|
|
A11yId, A11yNode, A11yTree,
|
|
|
|
|
accesskit::{Node, NodeId, Rect, Role},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let child_layout = layout.children().next().unwrap();
|
|
|
|
|
let child_tree = &state.children[0];
|
|
|
|
|
let child_tree = self.content.as_widget().a11y_nodes(
|
|
|
|
|
child_layout,
|
|
|
|
|
&child_tree,
|
|
|
|
|
cursor,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let window = layout.bounds();
|
|
|
|
|
let is_hovered = cursor.is_over(window);
|
|
|
|
|
let Rectangle {
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
} = window;
|
|
|
|
|
let bounds = Rect::new(
|
|
|
|
|
x as f64,
|
|
|
|
|
y as f64,
|
|
|
|
|
(x + width) as f64,
|
|
|
|
|
(y + height) as f64,
|
|
|
|
|
);
|
|
|
|
|
let mut node = Node::new(Role::ScrollView);
|
|
|
|
|
node.set_bounds(bounds);
|
|
|
|
|
if let Some(name) = self.name.as_ref() {
|
|
|
|
|
node.set_label(name.clone());
|
|
|
|
|
}
|
|
|
|
|
match self.description.as_ref() {
|
|
|
|
|
Some(iced_accessibility::Description::Id(id)) => {
|
|
|
|
|
node.set_described_by(
|
|
|
|
|
id.iter()
|
|
|
|
|
.cloned()
|
|
|
|
|
.map(|id| NodeId::from(id))
|
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Some(iced_accessibility::Description::Text(text)) => {
|
|
|
|
|
node.set_description(text.clone());
|
|
|
|
|
}
|
|
|
|
|
None => {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO hover
|
|
|
|
|
// if is_hovered {
|
|
|
|
|
// node.set_hovered();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if let Some(label) = self.label.as_ref() {
|
|
|
|
|
node.set_labelled_by(label.clone());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let content = layout.children().next().unwrap();
|
|
|
|
|
let content_bounds = content.bounds();
|
|
|
|
|
|
|
|
|
|
let mut scrollbar_node = Node::new(Role::ScrollBar);
|
|
|
|
|
if matches!(state.state, tree::State::Some(_)) {
|
|
|
|
|
let state = state.state.downcast_ref::<State>();
|
|
|
|
|
let scrollbars = Scrollbars::new(
|
|
|
|
|
state,
|
|
|
|
|
self.direction,
|
|
|
|
|
content_bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
|
|
|
|
for (window, content, offset, scrollbar) in scrollbars
|
|
|
|
|
.x
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|s| {
|
|
|
|
|
(window.width, content_bounds.width, state.offset_x, s)
|
|
|
|
|
})
|
|
|
|
|
.chain(scrollbars.y.iter().map(|s| {
|
|
|
|
|
(window.height, content_bounds.height, state.offset_y, s)
|
|
|
|
|
}))
|
|
|
|
|
{
|
|
|
|
|
let scrollbar_bounds = scrollbar.total_bounds;
|
|
|
|
|
let is_hovered = cursor.is_over(scrollbar_bounds);
|
|
|
|
|
let Rectangle {
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
} = scrollbar_bounds;
|
|
|
|
|
let bounds = Rect::new(
|
|
|
|
|
x as f64,
|
|
|
|
|
y as f64,
|
|
|
|
|
(x + width) as f64,
|
|
|
|
|
(y + height) as f64,
|
|
|
|
|
);
|
|
|
|
|
scrollbar_node.set_bounds(bounds);
|
|
|
|
|
// TODO: hover
|
|
|
|
|
// if is_hovered {
|
|
|
|
|
// scrollbar_node.set_hovered();
|
|
|
|
|
// }
|
|
|
|
|
scrollbar_node
|
|
|
|
|
.set_controls(vec![A11yId::Widget(self.id.clone()).into()]);
|
|
|
|
|
scrollbar_node.set_numeric_value(
|
|
|
|
|
100.0 * offset.absolute(window, content) as f64
|
|
|
|
|
/ scrollbar_bounds.height as f64,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let child_tree = A11yTree::join(
|
|
|
|
|
[
|
|
|
|
|
child_tree,
|
|
|
|
|
A11yTree::leaf(scrollbar_node, self.scrollbar_id.clone()),
|
|
|
|
|
]
|
|
|
|
|
.into_iter(),
|
|
|
|
|
);
|
|
|
|
|
A11yTree::node_with_child_tree(
|
|
|
|
|
A11yNode::new(node, self.id.clone()),
|
|
|
|
|
child_tree,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn id(&self) -> Option<Id> {
|
|
|
|
|
Some(Id(Internal::Set(vec![
|
|
|
|
|
self.id.0.clone(),
|
|
|
|
|
self.scrollbar_id.0.clone(),
|
|
|
|
|
])))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn set_id(&mut self, id: Id) {
|
|
|
|
|
if let Id(Internal::Set(list)) = id {
|
|
|
|
|
if list.len() == 2 {
|
|
|
|
|
self.id.0 = list[0].clone();
|
|
|
|
|
self.scrollbar_id.0 = list[1].clone();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn drag_destinations(
|
|
|
|
|
&self,
|
|
|
|
|
tree: &Tree,
|
|
|
|
|
layout: Layout<'_>,
|
|
|
|
|
renderer: &Renderer,
|
|
|
|
|
dnd_rectangles: &mut crate::core::clipboard::DndDestinationRectangles,
|
|
|
|
|
) {
|
|
|
|
|
let my_state = tree.state.downcast_ref::<State>();
|
|
|
|
|
if let Some((c_layout, c_state)) =
|
|
|
|
|
layout.children().zip(tree.children.iter()).next()
|
|
|
|
|
{
|
|
|
|
|
let mut my_dnd_rectangles = DndDestinationRectangles::new();
|
|
|
|
|
self.content.as_widget().drag_destinations(
|
|
|
|
|
c_state,
|
|
|
|
|
c_layout,
|
|
|
|
|
renderer,
|
|
|
|
|
&mut my_dnd_rectangles,
|
|
|
|
|
);
|
|
|
|
|
let mut my_dnd_rectangles = my_dnd_rectangles.into_rectangles();
|
|
|
|
|
|
|
|
|
|
let bounds = layout.bounds();
|
|
|
|
|
let content_bounds = c_layout.bounds();
|
|
|
|
|
for r in &mut my_dnd_rectangles {
|
|
|
|
|
let translation = my_state.translation(
|
|
|
|
|
self.direction,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
);
|
|
|
|
|
r.rectangle.x -= translation.x as f64;
|
|
|
|
|
r.rectangle.y -= translation.y as f64;
|
|
|
|
|
}
|
|
|
|
|
dnd_rectangles.append(&mut my_dnd_rectangles);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-28 08:28:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-28 08:56:32 +01:00
|
|
|
struct AutoScrollIcon<'a, Class> {
|
2025-11-28 08:28:03 +01:00
|
|
|
origin: Point,
|
|
|
|
|
vertical: bool,
|
|
|
|
|
horizontal: bool,
|
2025-11-28 08:56:32 +01:00
|
|
|
class: &'a Class,
|
2025-11-28 08:28:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-11-28 08:56:32 +01:00
|
|
|
impl<Class> AutoScrollIcon<'_, Class> {
|
2025-11-28 08:28:03 +01:00
|
|
|
const SIZE: f32 = 40.0;
|
|
|
|
|
const DOT: f32 = Self::SIZE / 10.0;
|
|
|
|
|
const PADDING: f32 = Self::SIZE / 10.0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<Message, Theme, Renderer> core::Overlay<Message, Theme, Renderer>
|
2025-11-28 08:56:32 +01:00
|
|
|
for AutoScrollIcon<'_, Theme::Class<'_>>
|
2025-11-28 08:28:03 +01:00
|
|
|
where
|
|
|
|
|
Renderer: text::Renderer,
|
2025-11-28 08:56:32 +01:00
|
|
|
Theme: Catalog,
|
2025-11-28 08:28:03 +01:00
|
|
|
{
|
|
|
|
|
fn layout(&mut self, _renderer: &Renderer, _bounds: Size) -> layout::Node {
|
|
|
|
|
layout::Node::new(Size::new(Self::SIZE, Self::SIZE))
|
|
|
|
|
.move_to(self.origin - Vector::new(Self::SIZE, Self::SIZE) / 2.0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw(
|
|
|
|
|
&self,
|
|
|
|
|
renderer: &mut Renderer,
|
2025-11-28 08:56:32 +01:00
|
|
|
theme: &Theme,
|
2025-11-28 08:28:03 +01:00
|
|
|
_style: &renderer::Style,
|
|
|
|
|
layout: Layout<'_>,
|
|
|
|
|
_cursor: mouse::Cursor,
|
|
|
|
|
) {
|
|
|
|
|
let bounds = layout.bounds();
|
2025-11-28 08:56:32 +01:00
|
|
|
let style = theme
|
|
|
|
|
.style(
|
|
|
|
|
self.class,
|
|
|
|
|
Status::Active {
|
|
|
|
|
is_horizontal_scrollbar_disabled: false,
|
|
|
|
|
is_vertical_scrollbar_disabled: false,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.auto_scroll;
|
2025-11-28 08:28:03 +01:00
|
|
|
|
|
|
|
|
renderer.with_layer(Rectangle::INFINITE, |renderer| {
|
|
|
|
|
renderer.fill_quad(
|
|
|
|
|
renderer::Quad {
|
|
|
|
|
bounds,
|
2025-11-28 08:56:32 +01:00
|
|
|
border: style.border,
|
2025-11-28 22:02:17 +01:00
|
|
|
shadow: style.shadow,
|
2025-11-28 08:28:03 +01:00
|
|
|
snap: false,
|
|
|
|
|
},
|
2025-11-28 08:56:32 +01:00
|
|
|
style.background,
|
2025-11-28 08:28:03 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
renderer.fill_quad(
|
|
|
|
|
renderer::Quad {
|
|
|
|
|
bounds: Rectangle::new(
|
|
|
|
|
bounds.center()
|
|
|
|
|
- Vector::new(Self::DOT, Self::DOT) / 2.0,
|
|
|
|
|
Size::new(Self::DOT, Self::DOT),
|
|
|
|
|
),
|
|
|
|
|
border: border::rounded(bounds.width),
|
|
|
|
|
snap: false,
|
|
|
|
|
..renderer::Quad::default()
|
|
|
|
|
},
|
2025-11-28 08:56:32 +01:00
|
|
|
style.icon,
|
2025-11-28 08:28:03 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let arrow = core::Text {
|
|
|
|
|
content: String::new(),
|
|
|
|
|
bounds: bounds.size(),
|
|
|
|
|
size: Pixels::from(12),
|
|
|
|
|
line_height: text::LineHeight::Relative(1.0),
|
|
|
|
|
font: Renderer::ICON_FONT,
|
|
|
|
|
align_x: text::Alignment::Center,
|
|
|
|
|
align_y: alignment::Vertical::Center,
|
|
|
|
|
shaping: text::Shaping::Basic,
|
|
|
|
|
wrapping: text::Wrapping::None,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if self.vertical {
|
|
|
|
|
renderer.fill_text(
|
|
|
|
|
core::Text {
|
|
|
|
|
content: Renderer::SCROLL_UP_ICON.to_string(),
|
|
|
|
|
align_y: alignment::Vertical::Top,
|
|
|
|
|
..arrow
|
|
|
|
|
},
|
2025-11-28 22:02:17 +01:00
|
|
|
Point::new(bounds.center_x(), bounds.y + Self::PADDING),
|
2025-11-28 08:56:32 +01:00
|
|
|
style.icon,
|
2025-11-28 08:28:03 +01:00
|
|
|
bounds,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
renderer.fill_text(
|
|
|
|
|
core::Text {
|
|
|
|
|
content: Renderer::SCROLL_DOWN_ICON.to_string(),
|
|
|
|
|
align_y: alignment::Vertical::Bottom,
|
|
|
|
|
..arrow
|
|
|
|
|
},
|
|
|
|
|
Point::new(
|
|
|
|
|
bounds.center_x(),
|
2025-11-28 22:02:17 +01:00
|
|
|
bounds.y + bounds.height - Self::PADDING - 0.5,
|
2025-11-28 08:28:03 +01:00
|
|
|
),
|
2025-11-28 08:56:32 +01:00
|
|
|
style.icon,
|
2025-11-28 08:28:03 +01:00
|
|
|
bounds,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if self.horizontal {
|
|
|
|
|
renderer.fill_text(
|
|
|
|
|
core::Text {
|
|
|
|
|
content: Renderer::SCROLL_LEFT_ICON.to_string(),
|
|
|
|
|
align_x: text::Alignment::Left,
|
|
|
|
|
..arrow
|
|
|
|
|
},
|
|
|
|
|
Point::new(
|
2025-11-28 22:02:17 +01:00
|
|
|
bounds.x + Self::PADDING + 1.0,
|
2025-11-28 08:28:03 +01:00
|
|
|
bounds.center_y() + 1.0,
|
|
|
|
|
),
|
2025-11-28 08:56:32 +01:00
|
|
|
style.icon,
|
2025-11-28 08:28:03 +01:00
|
|
|
bounds,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
renderer.fill_text(
|
|
|
|
|
core::Text {
|
|
|
|
|
content: Renderer::SCROLL_RIGHT_ICON.to_string(),
|
|
|
|
|
align_x: text::Alignment::Right,
|
|
|
|
|
..arrow
|
|
|
|
|
},
|
|
|
|
|
Point::new(
|
2025-11-28 22:02:17 +01:00
|
|
|
bounds.x + bounds.width - Self::PADDING - 1.0,
|
2025-11-28 08:28:03 +01:00
|
|
|
bounds.center_y() + 1.0,
|
|
|
|
|
),
|
2025-11-28 08:56:32 +01:00
|
|
|
style.icon,
|
2025-11-28 08:28:03 +01:00
|
|
|
bounds,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn index(&self) -> f32 {
|
|
|
|
|
f32::MAX
|
2022-07-27 06:49:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-21 17:56:01 +01:00
|
|
|
impl<'a, Message, Theme, Renderer>
|
|
|
|
|
From<Scrollable<'a, Message, Theme, Renderer>>
|
|
|
|
|
for Element<'a, Message, Theme, Renderer>
|
2022-07-27 06:49:20 +02:00
|
|
|
where
|
|
|
|
|
Message: 'a,
|
2024-03-24 05:03:09 +01:00
|
|
|
Theme: 'a + Catalog,
|
2025-11-28 08:28:03 +01:00
|
|
|
Renderer: 'a + text::Renderer,
|
2022-07-27 06:49:20 +02:00
|
|
|
{
|
|
|
|
|
fn from(
|
2024-01-21 17:56:01 +01:00
|
|
|
text_input: Scrollable<'a, Message, Theme, Renderer>,
|
|
|
|
|
) -> Element<'a, Message, Theme, Renderer> {
|
2022-07-27 06:49:20 +02:00
|
|
|
Element::new(text_input)
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
2022-02-12 15:17:44 +07:00
|
|
|
}
|
2021-06-04 20:46:27 +07:00
|
|
|
|
feat: pop-os megasquash
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 f39a5fd8953494fd8e41c05bc053519740d09612)
fix(sctk): destroy drag icon and send event after cancel action
fix: clipboard cleanup
fix(sctk): clipboard dummy impl typo
refactor(sctk): optional clipboard
fix(sctk): broadcast events after update
when broadcasting events for no specific surface, it should be done after update so that the runtime subscription is current
fix(multi_window): enable drag resize
sctk: Map subsurface pointer events to parent surface, with offset
sctk_subsurface: Use two surfaces, handle button presses
Useful for testing pointer input to subsurfaces.
sctk: Add `subsurface_ids` mapping subsurface to parent and offset
sctk_subsurface_gst: NV12 surface suppport; disabled
Whether or not this works seems to depend on driver, or gstreamer
version...
Handle frame callbacks for subsurfaces, and `commit` parent surface
If the main surface is occluded completely by opaque subsurfaces, it may
not receive `frame` events. So we need to request frame events for all
subsurfaces as well.
Additionally, with "synchronized" subsurfaces, we need to `commit` the
parent surface for subsurface changes to take effect.
Fixes issues with subsurfaces updating slowly, or only when mouse moved
under some circumstances.
examples/sctk_subsurface_gst: Cache `BufferSource` in `BufferRef` qdata
Similar to `waylandsink`. Allows us to avoid creating a buffer source
(and ultimately `wl_buffer`) for every buffer swap.
sctk/subsurface: Cache `wl_buffer`s
Creating a new `wl_buffer` each frame seems to perform poorly. We can
instead keep a cache of `wl_buffer`s we have created from a
`BufferSource`.
sctk/subsurface: Avoid unnecessary subsurface commits if unchanged
feat(slider): add breakpoints
fix: autosize surface layout
Autosized surfaces perform the layout step to get the size and then again when building the interface, but sometimes the calculated size is not enough space when used as a bound, so we need to add a tiny amount to the calculated size. This also makes the event loop timeout duration configurable. Viewport physical size is calculated directly from the logical size now as well in iced-sctk to avoid inconsistencies that resulted from recalculating the logical size after using it to calculate the physical size.
fix(sctk): send close event instead of close requested when a window is closed
sctk: add command to set maximize state
Add `show_window_menu` action
Winit currently supports this only on Windows and Wayland.
This requests that a context menu is shown at the cursor position,
like the menu normally triggered by right clicking the title bar. This
is important for implementing client side decorations with Iced widgets.
Remove unnecessary redraw request
This was particularly visible on Redox where there is no vsync, but also
causes unnecessary redraws on Linux
chore: update accesskit
Disable broken rustdoc links
sctk: Add `Subsurface` widget (#79)
This adds a widget that attaches an shm or dma buffer to a subsurface,
scaled with `wp_viewporter`.
By exposing this as a widget, rather than as a type of window, it can be
positioned and scaled like any other iced widget. It provides an API
that's similar to an iced image.
The initial version of this just took a `wl_buffer`. But this makes
buffer re-use problematic. In particular, the docs for `wl_surface::attach`
note that `wl_buffer::release` events become unreliable if a buffer is
attached to multiple surfaces. And indicates that a client should create
multiple `wl_buffer` instances, or use `wp_linux_buffer_release`.
So we store information about the buffer, and create `wl_buffer`s as
needed. `SubsurfaceBuffer::new` also returns a future that's signaled
when all references are destroyed, both `wl_buffer`s and any instance of
the `SubsurfaceBuffer` that might still be used in the `view`.
So this seems like the best solution for now, within the
model-view-update architecture.
This has two examples: `sctk_subsurface`, showing a single-color shm
buffer, and `sctk_subsurface_gst`, which plays an h264 video to a
subsurface with vaapi decoding.
chore: use pop-os fork of winit
chore: unpin cosmic-text
Update wgpu to a commit that fixes use on Nvidia drivers
This can be tested with something like
`VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json cargo run -p tour
--features iced/wgpu`.
On Nvidia I'm seeing a flood of `Suboptimal present of frame` warnings.
So some improvement may still be needed here. But if it doesn't regress
behavior on other hardware, that seems like an improvement over
freezing.
fix(winit): pass text with modifiers in event
chore: update cosmic-text and glyphon
fix: distinguish between the key character and the utf8 of a key event
feat(wgpu): use alpha modes for compositing if available
chore: use updated softbuffer
fix: typo
fix: downgrade resvg
fix: core/serde
chore: remove default features
typo: add rev to glyphon
Update to cosmic-text refactor
Fix docs error
Add function to fill a Raw
Fixes for last commit
fix: broadcast surface events
dnd_listener: Fix behavior when there are multiple listeners (#87)
A `dnd_listener` widget shouldn't handle a DnD event when the dnd drag
isn't within the widget's bounds. So add a few more checks for this.
Enter/leave events generated by `DndOfferEvent::Motion` also don't
behave as one might expect, since the enter may occur before the leave
depending on the order it calls `on_event` on the widget. Not sure how
to address that, but cosmic-workspaces can just ignore the leave events
for now.
Otherwise, this seems to be working fine, after these changes.
chore: fix sctk multi-window dependency
cleanup: formatting and clippy
fix(example): sctk_drag id
fix: translate the wayland event position for content inside a scrollable
fix: set web-sys to =0.3.64
fix: clip mask checks
chore: use advanced text shaping for pick list
fix: dnd widget layout
fix: ambiguous palette import
chore: remove artifacts job
fix: CI tests
fix: add back the window id to the frames subscription
fix: tooltip children and diff
refactor: udpate gradient angles for slider
reexport limits
fix: editor and sctk_todos examples
cleanup: clippy
cleanup git workflows
chore: cleanup iced_widget
refactor
Update mod.rs
chore: update softbuffer
Hack to remove image blur
iced_core: feature for serde serialization of KeyCode
fix(wgpu): handle border_radius property with image raster
feat: add border radius to image rendering
feat: Add side mouse button events
cleanup: clippy fixes and formatting
Part of this is a refactor of the ID
cleanup: clippy and fmt
fix: test workflow
fix: add note in CHANGELOG
fix: clippy
refactor: restore default style of slider
feat: allow setting the width and height of a rule
fix: slider gradient angle
feat: gradient backgground for the slider rail
feat(mouse-area): added on_drag method
fix(widget): container inherited wrong icon color from renderer
fix(button): inherit icon color if set to none
feat(renderer): define default icon color
By default, this is the same as the text color for best visibility.
feat(winit): client-side resize drag support
feat(winit): client-side resize drag support
Make vertical scroll properties optional
fix: quad rendering including border only inside of the bounds
Move `Screenshot` inside `window` module
Added offscreen rendering support for wgpu & tiny-skia exposed with the window::screenshot command.
Provide access to font from each crate
Use nested for lazy widgets
Use layout with children for nesting
Introduce internal `overlay::Nested` for `UserInterface`
fix: reset button state if the cursor leaves
runtime: Handle widget operations in `program::State` helper (#46)
chore: default line height, text size, and shaping for cosmic
feat: sctk shell
fix: quad rendering including border only inside of the bounds
fix: better slider drawing (it allows just the border part of the handle quad outside of the layout bouds, which isn't great, but is ok for our purposes due to being transparent)
cleanup: fix & format
fix: use iced_core::Font
cleanup
fix: allow leaving out winit & iced-sctk
fix: settings
fix: slider draw improvements
fix: websocket example
fix: modal example
fix: scrollable example
fix: toast example
fix: avoid panicking in iced_sctk with lazy widgets in auto-size surfaces
fix: todos panic
fix: only diff auto-sized surfaces in iced_sctk build_user_interface & improve sctk examples
wip (iced-sctk): window resize with icons
feat (iced-sctk): support for setting cursor
refactor: default decorations to client
fix: set window geometry after receiving configure
fix: size limits with no max bound must be cut off
fix: send size update when autosized surface resizes
fix: use ceil size for positioner
cleanup: remove dbg statement
fix: remove a destroyed surface from compositor surfaces
fix errors after rebase and wip scaling support
fix: handling of scale factor in set_logical_size
fix (sctk_drag example): add .into for border radius
fix: fractional scaling
sctk: Fire RedrawRequests
wip: animations via frame event
fix / refactor iced-sctk redraw & frame event handling
cleanup: note about frame request in iced-sctk
fix: send resize when necessary for layer surface and popups too
fix: always request redraw for a new surface
fix: scaling and autosize surface improvements
refactor: sctk_lazy keyboard interactivity
feat(sctk): configurable natural_scroll property
feat: send state and capabilities events when there are changes
fix: redraw when an update is needed and clean up the logic
Update sctk to latest commit
Fix compilation of sctk drag example
fix(sctk): update interface before checking if it has a redraw request
refactor: after autosize surface resize wait to redraw until the resize has been applied
refactor: better handling of autosize surfaces
chore: update sctk
chore: update sctk
fixes sctk_drag example
fix: default to ControlFlow::Wait for applications with no surface
this seems to help CPU usage for app library and launcher
default to 250ms timeout in the event loop
Update sctk
sctk: Implement xdg-activation support
fix: don't require Flags to be clone for settings on wayland
chore: error if neither winit or wayland feature is set
chore: Allow compiling without windowing system (#65)
fix(iced-sctk): handle exit_on_close_request
fix: make sure that each widget operation operates on every interface
This should be ok even for widget actions like focus next because there can only ever be a single focused widget
cargo fmt
cleanup: dbg statement
fix(iced-sctk): replace panic with handling for remaining enum variants
refactor: use iced clipboard for interacting with the selection
refactor: allow passing an activation token when creating a window
sctk: Add support for `ext-session-lock` protocol
fix(sctk): build and use tree for layout of autosize surfaces
Update winit to latest commit used by upstream iced
fix(sctk): send key characters
fix(sctk): check if key is a named key first
refactor(sctk): keep compositor surface in state
feat: accessibility with some widget impls
feat: stable ids
a11y: Don't unconditionally pull winit (#43)
Update conversion.rs
integration fixes
integration
integration
integration
integration
s
integration
some integration work
more integration
Update Cargo.toml
Update mod.rs
Update multi_window.rs
s
more integration
more integration (ryanabx wip #100000)
more integration!!
integration 2
integration
more integration (rbx)
s
integration
integration work
integration
Update Cargo.toml
integration
simple integration things
int
integration to 175
integration(170)
Co-Authored-By: Ashley Wulber <48420062+wash2@users.noreply.github.com>
Co-Authored-By: Victoria Brekenfeld <4404502+Drakulix@users.noreply.github.com>
Co-Authored-By: Eduardo Flores <edfloreshz@gmail.com>
Co-Authored-By: Michael Murphy <michael@mmurphy.dev>
Co-Authored-By: wiiznokes <78230769+wiiznokes@users.noreply.github.com>
Co-Authored-By: Jeremy Soller <jeremy@system76.com>
Co-Authored-By: Ryan Brue <56272643+ryanabx@users.noreply.github.com>
fix(column): handle keys len change
fix: iced-sctk a11y
wip: winit single window updates
tokio feature hangs even without a11y feature
fix: multiwindow a11y fixes
fix: component
update winit
wip: sctk integration to winit shell
refactor: remove accesskit_unix
fix: svg
fix: remove wayland default feature
feat: derive Hash for image Handle
fix: cleanup 0.13 rebase errors
fix: remove path dependencies
conversion for Radius
conversion for Padding
setter for Svg border radius
re-export Limits
fix: connect clipboard if disconnected on layer surface or popup creation
fix: connect clipboard if disconnected on session lock surface creation
fix: update size of layer surface after configure
fix: insert user interfaces for popup and lock surfaces on creation
fix: svg scaling
feat: popups on winit windows
fix: default text shaping to advanced
fix: fallback to renderer icon style if svg is symbolic
fixes
fix: sctk frame handling
feat: autosize handling
fix: better autosize handling
fix: avoid duplicate window events from sctk
fix: better handling of popups
fix: refactor redraw handling for sctk
fix: include id in frames
fix: image
fix: scrollable delta direction
sctk: unregister clipboard when surface is done
set min / max size when size is requested
fix: popups
filter pointer events
feat: add Hide variant to mouse Interaction
dnd fixes
fix: use physical width for DnD surface
fix: tiny-skia svg quality
refactor: peek_dnd try to parse data
cleanup text conversion
cleanup
svg scaling fixes
background color fix
Introduce consecutive_click_distance like other toolkits do such as gtk,qt,imgui.
2023-05-02 15:48:20 -07:00
|
|
|
/// Produces a [`Task`] that snaps the [`Scrollable`] with the given [`Id`]
|
|
|
|
|
/// to the provided [`RelativeOffset`].
|
|
|
|
|
pub fn snap_to<T>(id: Id, offset: RelativeOffset<Option<f32>>) -> Task<T> {
|
|
|
|
|
task::effect(Action::widget(operation::scrollable::snap_to(id, offset)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Produces a [`Task`] that scrolls the [`Scrollable`] with the given [`Id`]
|
|
|
|
|
/// to the provided [`AbsoluteOffset`].
|
|
|
|
|
pub fn scroll_to<T>(id: Id, offset: AbsoluteOffset<Option<f32>>) -> Task<T> {
|
|
|
|
|
task::effect(Action::widget(operation::scrollable::scroll_to(id, offset)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Produces a [`Task`] that scrolls the [`Scrollable`] with the given [`Id`]
|
|
|
|
|
/// by the provided [`AbsoluteOffset`].
|
|
|
|
|
pub fn scroll_by<T>(id: Id, offset: AbsoluteOffset) -> Task<T> {
|
|
|
|
|
task::effect(Action::widget(operation::scrollable::scroll_by(id, offset)))
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-10 22:38:30 +02:00
|
|
|
fn notify_scroll<Message>(
|
|
|
|
|
state: &mut State,
|
|
|
|
|
on_scroll: &Option<Box<dyn Fn(Viewport) -> Message + '_>>,
|
|
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
shell: &mut Shell<'_, Message>,
|
|
|
|
|
) -> bool {
|
|
|
|
|
if notify_viewport(state, on_scroll, bounds, content_bounds, shell) {
|
|
|
|
|
state.last_scrolled = Some(Instant::now());
|
|
|
|
|
|
|
|
|
|
true
|
|
|
|
|
} else {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn notify_viewport<Message>(
|
2023-04-12 10:32:35 -07:00
|
|
|
state: &mut State,
|
2023-04-17 13:55:40 -07:00
|
|
|
on_scroll: &Option<Box<dyn Fn(Viewport) -> Message + '_>>,
|
2022-02-12 15:17:44 +07:00
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
shell: &mut Shell<'_, Message>,
|
2024-04-23 10:45:44 +10:00
|
|
|
) -> bool {
|
|
|
|
|
if content_bounds.width <= bounds.width
|
|
|
|
|
&& content_bounds.height <= bounds.height
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-02-12 15:17:44 +07:00
|
|
|
|
2024-04-23 10:45:44 +10:00
|
|
|
let viewport = Viewport {
|
|
|
|
|
offset_x: state.offset_x,
|
|
|
|
|
offset_y: state.offset_y,
|
|
|
|
|
bounds,
|
|
|
|
|
content_bounds,
|
|
|
|
|
};
|
2021-06-04 19:39:08 +07:00
|
|
|
|
2024-04-23 10:45:44 +10:00
|
|
|
// Don't publish redundant viewports to shell
|
|
|
|
|
if let Some(last_notified) = state.last_notified {
|
|
|
|
|
let last_relative_offset = last_notified.relative_offset();
|
|
|
|
|
let current_relative_offset = viewport.relative_offset();
|
2021-06-04 19:39:08 +07:00
|
|
|
|
2024-04-23 10:45:44 +10:00
|
|
|
let last_absolute_offset = last_notified.absolute_offset();
|
|
|
|
|
let current_absolute_offset = viewport.absolute_offset();
|
2023-04-12 10:32:35 -07:00
|
|
|
|
2024-04-23 10:45:44 +10:00
|
|
|
let unchanged = |a: f32, b: f32| {
|
|
|
|
|
(a - b).abs() <= f32::EPSILON || (a.is_nan() && b.is_nan())
|
|
|
|
|
};
|
2023-04-12 10:32:35 -07:00
|
|
|
|
2024-09-10 22:38:30 +02:00
|
|
|
if last_notified.bounds == bounds
|
|
|
|
|
&& last_notified.content_bounds == content_bounds
|
|
|
|
|
&& unchanged(last_relative_offset.x, current_relative_offset.x)
|
2024-04-23 10:45:44 +10:00
|
|
|
&& unchanged(last_relative_offset.y, current_relative_offset.y)
|
|
|
|
|
&& unchanged(last_absolute_offset.x, current_absolute_offset.x)
|
|
|
|
|
&& unchanged(last_absolute_offset.y, current_absolute_offset.y)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
2023-04-12 10:32:35 -07:00
|
|
|
}
|
2024-04-23 10:45:44 +10:00
|
|
|
}
|
2023-04-12 10:32:35 -07:00
|
|
|
|
2024-04-23 10:45:44 +10:00
|
|
|
state.last_notified = Some(viewport);
|
|
|
|
|
|
2024-09-18 21:45:25 +02:00
|
|
|
if let Some(on_scroll) = on_scroll {
|
|
|
|
|
shell.publish(on_scroll(viewport));
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-23 10:45:44 +10:00
|
|
|
true
|
2022-08-04 03:55:41 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2024-03-08 13:34:36 +01:00
|
|
|
struct State {
|
2022-12-24 21:27:44 -08:00
|
|
|
offset_y: Offset,
|
|
|
|
|
offset_x: Offset,
|
2025-05-30 17:03:58 +00:00
|
|
|
interaction: Interaction,
|
2023-01-08 20:17:11 +01:00
|
|
|
keyboard_modifiers: keyboard::Modifiers,
|
2023-04-17 13:55:40 -07:00
|
|
|
last_notified: Option<Viewport>,
|
2024-09-08 16:00:22 +02:00
|
|
|
last_scrolled: Option<Instant>,
|
2025-05-03 04:15:18 +02:00
|
|
|
is_scrollbar_visible: bool,
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
enum Interaction {
|
|
|
|
|
None,
|
|
|
|
|
YScrollerGrabbed(f32),
|
|
|
|
|
XScrollerGrabbed(f32),
|
|
|
|
|
TouchScrolling(Point),
|
|
|
|
|
AutoScrolling {
|
|
|
|
|
origin: Point,
|
|
|
|
|
current: Point,
|
|
|
|
|
last_frame: Option<Instant>,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
impl Default for State {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
offset_y: Offset::Absolute(0.0),
|
|
|
|
|
offset_x: Offset::Absolute(0.0),
|
2025-05-30 17:03:58 +00:00
|
|
|
interaction: Interaction::None,
|
2023-01-08 20:17:11 +01:00
|
|
|
keyboard_modifiers: keyboard::Modifiers::default(),
|
2023-04-12 10:32:35 -07:00
|
|
|
last_notified: None,
|
2024-09-08 16:00:22 +02:00
|
|
|
last_scrolled: None,
|
2025-05-03 04:24:07 +02:00
|
|
|
is_scrollbar_visible: true,
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-04 19:39:08 +07:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 10:29:37 -08:00
|
|
|
impl operation::Scrollable for State {
|
2025-11-29 06:23:18 +01:00
|
|
|
fn snap_to(&mut self, offset: RelativeOffset<Option<f32>>) {
|
2023-01-08 20:07:11 +01:00
|
|
|
State::snap_to(self, offset);
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
2023-04-14 13:32:44 -07:00
|
|
|
|
2025-11-29 06:23:18 +01:00
|
|
|
fn scroll_to(&mut self, offset: AbsoluteOffset<Option<f32>>) {
|
2023-09-20 04:11:52 +02:00
|
|
|
State::scroll_to(self, offset);
|
2023-04-14 13:32:44 -07:00
|
|
|
}
|
2024-05-10 18:50:10 -03:00
|
|
|
|
|
|
|
|
fn scroll_by(
|
|
|
|
|
&mut self,
|
|
|
|
|
offset: AbsoluteOffset,
|
|
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
) {
|
|
|
|
|
State::scroll_by(self, offset, bounds, content_bounds);
|
|
|
|
|
}
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
2024-10-23 21:07:45 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2022-12-24 21:27:44 -08:00
|
|
|
enum Offset {
|
|
|
|
|
Absolute(f32),
|
|
|
|
|
Relative(f32),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Offset {
|
2023-04-17 13:55:40 -07:00
|
|
|
fn absolute(self, viewport: f32, content: f32) -> f32 {
|
2022-12-24 21:27:44 -08:00
|
|
|
match self {
|
|
|
|
|
Offset::Absolute(absolute) => {
|
2023-04-17 13:55:40 -07:00
|
|
|
absolute.min((content - viewport).max(0.0))
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
Offset::Relative(percentage) => {
|
2023-04-17 13:55:40 -07:00
|
|
|
((content - viewport) * percentage).max(0.0)
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
2021-06-04 19:39:08 +07:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-12 10:04:26 +02:00
|
|
|
|
2023-07-12 10:05:46 +02:00
|
|
|
fn translation(
|
2023-07-12 10:04:26 +02:00
|
|
|
self,
|
|
|
|
|
viewport: f32,
|
|
|
|
|
content: f32,
|
2024-07-12 15:11:30 +02:00
|
|
|
alignment: Anchor,
|
2023-07-12 10:04:26 +02:00
|
|
|
) -> f32 {
|
|
|
|
|
let offset = self.absolute(viewport, content);
|
|
|
|
|
|
|
|
|
|
match alignment {
|
2024-07-12 15:11:30 +02:00
|
|
|
Anchor::Start => offset,
|
|
|
|
|
Anchor::End => ((content - viewport).max(0.0) - offset).max(0.0),
|
2023-07-12 10:04:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2023-04-17 13:55:40 -07:00
|
|
|
/// The current [`Viewport`] of the [`Scrollable`].
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
pub struct Viewport {
|
|
|
|
|
offset_x: Offset,
|
|
|
|
|
offset_y: Offset,
|
2023-07-12 09:26:13 +02:00
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
2023-04-17 13:55:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Viewport {
|
|
|
|
|
/// Returns the [`AbsoluteOffset`] of the current [`Viewport`].
|
|
|
|
|
pub fn absolute_offset(&self) -> AbsoluteOffset {
|
|
|
|
|
let x = self
|
|
|
|
|
.offset_x
|
|
|
|
|
.absolute(self.bounds.width, self.content_bounds.width);
|
|
|
|
|
let y = self
|
|
|
|
|
.offset_y
|
|
|
|
|
.absolute(self.bounds.height, self.content_bounds.height);
|
|
|
|
|
|
|
|
|
|
AbsoluteOffset { x, y }
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 02:53:45 +02:00
|
|
|
/// Returns the [`AbsoluteOffset`] of the current [`Viewport`], but with its
|
|
|
|
|
/// alignment reversed.
|
|
|
|
|
///
|
|
|
|
|
/// This method can be useful to switch the alignment of a [`Scrollable`]
|
|
|
|
|
/// while maintaining its scrolling position.
|
|
|
|
|
pub fn absolute_offset_reversed(&self) -> AbsoluteOffset {
|
|
|
|
|
let AbsoluteOffset { x, y } = self.absolute_offset();
|
|
|
|
|
|
|
|
|
|
AbsoluteOffset {
|
2023-07-13 03:01:53 +02:00
|
|
|
x: (self.content_bounds.width - self.bounds.width).max(0.0) - x,
|
|
|
|
|
y: (self.content_bounds.height - self.bounds.height).max(0.0) - y,
|
2023-07-13 02:53:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-17 13:55:40 -07:00
|
|
|
/// Returns the [`RelativeOffset`] of the current [`Viewport`].
|
|
|
|
|
pub fn relative_offset(&self) -> RelativeOffset {
|
|
|
|
|
let AbsoluteOffset { x, y } = self.absolute_offset();
|
|
|
|
|
|
|
|
|
|
let x = x / (self.content_bounds.width - self.bounds.width);
|
|
|
|
|
let y = y / (self.content_bounds.height - self.bounds.height);
|
|
|
|
|
|
|
|
|
|
RelativeOffset { x, y }
|
|
|
|
|
}
|
2023-09-06 21:50:59 -04:00
|
|
|
|
|
|
|
|
/// Returns the bounds of the current [`Viewport`].
|
|
|
|
|
pub fn bounds(&self) -> Rectangle {
|
|
|
|
|
self.bounds
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns the content bounds of the current [`Viewport`].
|
|
|
|
|
pub fn content_bounds(&self) -> Rectangle {
|
|
|
|
|
self.content_bounds
|
|
|
|
|
}
|
2023-04-17 13:55:40 -07:00
|
|
|
}
|
|
|
|
|
|
2019-11-21 13:47:20 +01:00
|
|
|
impl State {
|
2025-05-30 17:03:58 +00:00
|
|
|
fn new() -> Self {
|
2019-11-21 13:47:20 +01:00
|
|
|
State::default()
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
fn scroll(
|
2022-12-24 21:27:44 -08:00
|
|
|
&mut self,
|
|
|
|
|
delta: Vector<f32>,
|
|
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
) {
|
|
|
|
|
if bounds.height < content_bounds.height {
|
|
|
|
|
self.offset_y = Offset::Absolute(
|
2023-01-08 20:07:11 +01:00
|
|
|
(self.offset_y.absolute(bounds.height, content_bounds.height)
|
2024-05-10 18:50:10 -03:00
|
|
|
+ delta.y)
|
2022-12-24 21:27:44 -08:00
|
|
|
.clamp(0.0, content_bounds.height - bounds.height),
|
2023-09-20 04:11:52 +02:00
|
|
|
);
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if bounds.width < content_bounds.width {
|
|
|
|
|
self.offset_x = Offset::Absolute(
|
2023-01-08 20:07:11 +01:00
|
|
|
(self.offset_x.absolute(bounds.width, content_bounds.width)
|
2024-05-10 18:50:10 -03:00
|
|
|
+ delta.x)
|
2022-12-24 21:27:44 -08:00
|
|
|
.clamp(0.0, content_bounds.width - bounds.width),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
fn scroll_y_to(
|
2022-12-24 21:27:44 -08:00
|
|
|
&mut self,
|
|
|
|
|
percentage: f32,
|
|
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
) {
|
|
|
|
|
self.offset_y = Offset::Relative(percentage.clamp(0.0, 1.0));
|
|
|
|
|
self.unsnap(bounds, content_bounds);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
fn scroll_x_to(
|
2019-11-21 13:47:20 +01:00
|
|
|
&mut self,
|
2022-12-24 21:27:44 -08:00
|
|
|
percentage: f32,
|
2019-11-21 13:47:20 +01:00
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
) {
|
2022-12-24 21:27:44 -08:00
|
|
|
self.offset_x = Offset::Relative(percentage.clamp(0.0, 1.0));
|
|
|
|
|
self.unsnap(bounds, content_bounds);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-29 06:23:18 +01:00
|
|
|
fn snap_to(&mut self, offset: RelativeOffset<Option<f32>>) {
|
|
|
|
|
if let Some(x) = offset.x {
|
|
|
|
|
self.offset_x = Offset::Relative(x.clamp(0.0, 1.0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let Some(y) = offset.y {
|
|
|
|
|
self.offset_y = Offset::Relative(y.clamp(0.0, 1.0));
|
|
|
|
|
}
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
2025-11-29 06:23:18 +01:00
|
|
|
fn scroll_to(&mut self, offset: AbsoluteOffset<Option<f32>>) {
|
|
|
|
|
if let Some(x) = offset.x {
|
|
|
|
|
self.offset_x = Offset::Absolute(x.max(0.0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let Some(y) = offset.y {
|
|
|
|
|
self.offset_y = Offset::Absolute(y.max(0.0));
|
|
|
|
|
}
|
2023-04-14 13:32:44 -07:00
|
|
|
}
|
|
|
|
|
|
2024-05-10 18:50:10 -03:00
|
|
|
/// Scroll by the provided [`AbsoluteOffset`].
|
2025-11-29 06:23:18 +01:00
|
|
|
fn scroll_by(
|
2024-05-10 18:50:10 -03:00
|
|
|
&mut self,
|
|
|
|
|
offset: AbsoluteOffset,
|
|
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
) {
|
|
|
|
|
self.scroll(Vector::new(offset.x, offset.y), bounds, content_bounds);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
/// Unsnaps the current scroll position, if snapped, given the bounds of the
|
|
|
|
|
/// [`Scrollable`] and its contents.
|
2025-11-29 06:23:18 +01:00
|
|
|
fn unsnap(&mut self, bounds: Rectangle, content_bounds: Rectangle) {
|
2023-01-08 20:07:11 +01:00
|
|
|
self.offset_x = Offset::Absolute(
|
|
|
|
|
self.offset_x.absolute(bounds.width, content_bounds.width),
|
|
|
|
|
);
|
|
|
|
|
self.offset_y = Offset::Absolute(
|
|
|
|
|
self.offset_y.absolute(bounds.height, content_bounds.height),
|
|
|
|
|
);
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 10:04:26 +02:00
|
|
|
/// Returns the scrolling translation of the [`State`], given a [`Direction`],
|
2023-06-27 22:41:16 +02:00
|
|
|
/// the bounds of the [`Scrollable`] and its contents.
|
2023-07-12 10:04:26 +02:00
|
|
|
fn translation(
|
2022-12-24 21:27:44 -08:00
|
|
|
&self,
|
2023-07-12 09:49:14 +02:00
|
|
|
direction: Direction,
|
2022-12-24 21:27:44 -08:00
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
2023-01-08 20:07:11 +01:00
|
|
|
) -> Vector {
|
|
|
|
|
Vector::new(
|
2023-06-12 21:04:43 -07:00
|
|
|
if let Some(horizontal) = direction.horizontal() {
|
2025-05-28 20:51:01 +02:00
|
|
|
self.offset_x
|
|
|
|
|
.translation(
|
|
|
|
|
bounds.width,
|
|
|
|
|
content_bounds.width,
|
|
|
|
|
horizontal.alignment,
|
|
|
|
|
)
|
|
|
|
|
.round()
|
2023-06-27 22:41:16 +02:00
|
|
|
} else {
|
|
|
|
|
0.0
|
|
|
|
|
},
|
2023-06-12 21:04:43 -07:00
|
|
|
if let Some(vertical) = direction.vertical() {
|
2025-05-28 20:51:01 +02:00
|
|
|
self.offset_y
|
|
|
|
|
.translation(
|
|
|
|
|
bounds.height,
|
|
|
|
|
content_bounds.height,
|
|
|
|
|
vertical.alignment,
|
|
|
|
|
)
|
|
|
|
|
.round()
|
2023-06-27 22:41:16 +02:00
|
|
|
} else {
|
|
|
|
|
0.0
|
|
|
|
|
},
|
2022-12-24 21:27:44 -08:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-30 17:03:58 +00:00
|
|
|
fn scrollers_grabbed(&self) -> bool {
|
|
|
|
|
matches!(
|
|
|
|
|
self.interaction,
|
|
|
|
|
Interaction::YScrollerGrabbed(_) | Interaction::XScrollerGrabbed(_),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn y_scroller_grabbed_at(&self) -> Option<f32> {
|
|
|
|
|
let Interaction::YScrollerGrabbed(at) = self.interaction else {
|
|
|
|
|
return None;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Some(at)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn x_scroller_grabbed_at(&self) -> Option<f32> {
|
|
|
|
|
let Interaction::XScrollerGrabbed(at) = self.interaction else {
|
|
|
|
|
return None;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Some(at)
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
/// State of both [`Scrollbar`]s.
|
|
|
|
|
struct Scrollbars {
|
2023-03-04 05:37:11 +01:00
|
|
|
y: Option<internals::Scrollbar>,
|
|
|
|
|
x: Option<internals::Scrollbar>,
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Scrollbars {
|
|
|
|
|
/// Create y and/or x scrollbar(s) if content is overflowing the [`Scrollable`] bounds.
|
|
|
|
|
fn new(
|
|
|
|
|
state: &State,
|
2023-07-12 09:49:14 +02:00
|
|
|
direction: Direction,
|
2022-12-24 21:27:44 -08:00
|
|
|
bounds: Rectangle,
|
|
|
|
|
content_bounds: Rectangle,
|
|
|
|
|
) -> Self {
|
2023-07-12 10:04:26 +02:00
|
|
|
let translation = state.translation(direction, bounds, content_bounds);
|
2022-12-24 21:27:44 -08:00
|
|
|
|
2025-05-03 04:15:18 +02:00
|
|
|
let show_scrollbar_x = direction
|
|
|
|
|
.horizontal()
|
|
|
|
|
.filter(|_scrollbar| content_bounds.width > bounds.width);
|
2023-05-26 20:27:17 -04:00
|
|
|
|
2025-05-03 04:15:18 +02:00
|
|
|
let show_scrollbar_y = direction
|
|
|
|
|
.vertical()
|
|
|
|
|
.filter(|_scrollbar| content_bounds.height > bounds.height);
|
2019-11-21 13:47:20 +01:00
|
|
|
|
2025-01-06 20:23:26 +01:00
|
|
|
let y_scrollbar = if let Some(vertical) = show_scrollbar_y {
|
2024-07-11 07:58:33 +02:00
|
|
|
let Scrollbar {
|
2022-12-24 21:27:44 -08:00
|
|
|
width,
|
|
|
|
|
margin,
|
|
|
|
|
scroller_width,
|
2023-06-12 21:04:43 -07:00
|
|
|
..
|
2022-12-24 21:27:44 -08:00
|
|
|
} = *vertical;
|
2022-11-19 10:29:37 -08:00
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
// Adjust the height of the vertical scrollbar if the horizontal scrollbar
|
2022-11-19 10:29:37 -08:00
|
|
|
// is present
|
2023-02-04 12:24:13 +01:00
|
|
|
let x_scrollbar_height = show_scrollbar_x
|
2025-01-06 20:23:26 +01:00
|
|
|
.map_or(0.0, |h| h.width.max(h.scroller_width) + h.margin);
|
2022-11-19 10:29:37 -08:00
|
|
|
|
2023-02-04 12:24:13 +01:00
|
|
|
let total_scrollbar_width =
|
|
|
|
|
width.max(scroller_width) + 2.0 * margin;
|
2022-11-19 10:29:37 -08:00
|
|
|
|
|
|
|
|
// Total bounds of the scrollbar + margin + scroller width
|
|
|
|
|
let total_scrollbar_bounds = Rectangle {
|
2023-02-04 12:24:13 +01:00
|
|
|
x: bounds.x + bounds.width - total_scrollbar_width,
|
2022-11-19 10:29:37 -08:00
|
|
|
y: bounds.y,
|
2023-02-04 12:24:13 +01:00
|
|
|
width: total_scrollbar_width,
|
2022-12-24 21:27:44 -08:00
|
|
|
height: (bounds.height - x_scrollbar_height).max(0.0),
|
2022-11-19 10:29:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Bounds of just the scrollbar
|
|
|
|
|
let scrollbar_bounds = Rectangle {
|
2023-02-07 19:27:03 +01:00
|
|
|
x: bounds.x + bounds.width
|
|
|
|
|
- total_scrollbar_width / 2.0
|
|
|
|
|
- width / 2.0,
|
2022-11-19 10:29:37 -08:00
|
|
|
y: bounds.y,
|
2023-02-04 12:24:13 +01:00
|
|
|
width,
|
2022-12-24 21:27:44 -08:00
|
|
|
height: (bounds.height - x_scrollbar_height).max(0.0),
|
2022-11-19 10:29:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let ratio = bounds.height / content_bounds.height;
|
|
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
let scroller = if ratio >= 1.0 {
|
|
|
|
|
None
|
|
|
|
|
} else {
|
|
|
|
|
// min height for easier grabbing with super tall content
|
|
|
|
|
let scroller_height =
|
|
|
|
|
(scrollbar_bounds.height * ratio).max(2.0);
|
|
|
|
|
let scroller_offset =
|
|
|
|
|
translation.y * ratio * scrollbar_bounds.height
|
|
|
|
|
/ bounds.height;
|
|
|
|
|
|
|
|
|
|
let scroller_bounds = Rectangle {
|
|
|
|
|
x: bounds.x + bounds.width
|
|
|
|
|
- total_scrollbar_width / 2.0
|
|
|
|
|
- scroller_width / 2.0,
|
|
|
|
|
y: (scrollbar_bounds.y + scroller_offset).max(0.0),
|
|
|
|
|
width: scroller_width,
|
|
|
|
|
height: scroller_height,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Some(internals::Scroller {
|
|
|
|
|
bounds: scroller_bounds,
|
|
|
|
|
})
|
2022-11-19 10:29:37 -08:00
|
|
|
};
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
Some(internals::Scrollbar {
|
2022-11-19 10:29:37 -08:00
|
|
|
total_bounds: total_scrollbar_bounds,
|
|
|
|
|
bounds: scrollbar_bounds,
|
2024-07-11 07:58:33 +02:00
|
|
|
scroller,
|
2023-07-12 09:49:14 +02:00
|
|
|
alignment: vertical.alignment,
|
2025-01-06 20:23:26 +01:00
|
|
|
disabled: content_bounds.height <= bounds.height,
|
2022-11-19 10:29:37 -08:00
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
2019-11-21 13:47:20 +01:00
|
|
|
|
2025-01-06 20:23:26 +01:00
|
|
|
let x_scrollbar = if let Some(horizontal) = show_scrollbar_x {
|
2024-07-11 07:58:33 +02:00
|
|
|
let Scrollbar {
|
2022-12-24 21:27:44 -08:00
|
|
|
width,
|
|
|
|
|
margin,
|
|
|
|
|
scroller_width,
|
2023-06-12 21:04:43 -07:00
|
|
|
..
|
2022-12-24 21:27:44 -08:00
|
|
|
} = *horizontal;
|
2022-11-19 10:29:37 -08:00
|
|
|
|
|
|
|
|
// Need to adjust the width of the horizontal scrollbar if the vertical scrollbar
|
|
|
|
|
// is present
|
2023-09-14 19:35:29 +02:00
|
|
|
let scrollbar_y_width = y_scrollbar
|
|
|
|
|
.map_or(0.0, |scrollbar| scrollbar.total_bounds.width);
|
2022-11-19 10:29:37 -08:00
|
|
|
|
2023-02-04 12:24:13 +01:00
|
|
|
let total_scrollbar_height =
|
|
|
|
|
width.max(scroller_width) + 2.0 * margin;
|
2022-11-19 10:29:37 -08:00
|
|
|
|
|
|
|
|
// Total bounds of the scrollbar + margin + scroller width
|
|
|
|
|
let total_scrollbar_bounds = Rectangle {
|
|
|
|
|
x: bounds.x,
|
2023-02-04 12:24:13 +01:00
|
|
|
y: bounds.y + bounds.height - total_scrollbar_height,
|
2022-11-19 10:29:37 -08:00
|
|
|
width: (bounds.width - scrollbar_y_width).max(0.0),
|
2023-02-04 12:24:13 +01:00
|
|
|
height: total_scrollbar_height,
|
2022-11-19 10:29:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Bounds of just the scrollbar
|
|
|
|
|
let scrollbar_bounds = Rectangle {
|
|
|
|
|
x: bounds.x,
|
2023-02-07 19:27:03 +01:00
|
|
|
y: bounds.y + bounds.height
|
|
|
|
|
- total_scrollbar_height / 2.0
|
|
|
|
|
- width / 2.0,
|
2022-11-19 10:29:37 -08:00
|
|
|
width: (bounds.width - scrollbar_y_width).max(0.0),
|
2023-02-04 12:24:13 +01:00
|
|
|
height: width,
|
2022-11-19 10:29:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let ratio = bounds.width / content_bounds.width;
|
|
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
let scroller = if ratio >= 1.0 {
|
|
|
|
|
None
|
|
|
|
|
} else {
|
|
|
|
|
// min width for easier grabbing with extra wide content
|
|
|
|
|
let scroller_length = (scrollbar_bounds.width * ratio).max(2.0);
|
|
|
|
|
let scroller_offset =
|
|
|
|
|
translation.x * ratio * scrollbar_bounds.width
|
|
|
|
|
/ bounds.width;
|
|
|
|
|
|
|
|
|
|
let scroller_bounds = Rectangle {
|
|
|
|
|
x: (scrollbar_bounds.x + scroller_offset).max(0.0),
|
|
|
|
|
y: bounds.y + bounds.height
|
|
|
|
|
- total_scrollbar_height / 2.0
|
|
|
|
|
- scroller_width / 2.0,
|
|
|
|
|
width: scroller_length,
|
|
|
|
|
height: scroller_width,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Some(internals::Scroller {
|
|
|
|
|
bounds: scroller_bounds,
|
|
|
|
|
})
|
2022-11-19 10:29:37 -08:00
|
|
|
};
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
Some(internals::Scrollbar {
|
2022-11-19 10:29:37 -08:00
|
|
|
total_bounds: total_scrollbar_bounds,
|
|
|
|
|
bounds: scrollbar_bounds,
|
2024-07-11 07:58:33 +02:00
|
|
|
scroller,
|
2023-07-12 09:49:14 +02:00
|
|
|
alignment: horizontal.alignment,
|
2025-01-06 20:23:26 +01:00
|
|
|
disabled: content_bounds.width <= bounds.width,
|
2022-11-19 10:29:37 -08:00
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
};
|
2022-12-24 21:27:44 -08:00
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
y: y_scrollbar,
|
|
|
|
|
x: x_scrollbar,
|
|
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2023-06-08 20:11:59 +02:00
|
|
|
fn is_mouse_over(&self, cursor: mouse::Cursor) -> (bool, bool) {
|
|
|
|
|
if let Some(cursor_position) = cursor.position() {
|
|
|
|
|
(
|
|
|
|
|
self.y
|
|
|
|
|
.as_ref()
|
|
|
|
|
.map(|scrollbar| scrollbar.is_mouse_over(cursor_position))
|
|
|
|
|
.unwrap_or(false),
|
|
|
|
|
self.x
|
|
|
|
|
.as_ref()
|
|
|
|
|
.map(|scrollbar| scrollbar.is_mouse_over(cursor_position))
|
|
|
|
|
.unwrap_or(false),
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
(false, false)
|
|
|
|
|
}
|
2020-11-10 14:23:49 +03:00
|
|
|
}
|
|
|
|
|
|
2025-01-06 20:25:22 +01:00
|
|
|
fn is_y_disabled(&self) -> bool {
|
2024-09-18 22:03:08 -04:00
|
|
|
self.y.map(|y| y.disabled).unwrap_or(false)
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-06 20:25:22 +01:00
|
|
|
fn is_x_disabled(&self) -> bool {
|
2024-09-18 22:03:08 -04:00
|
|
|
self.x.map(|x| x.disabled).unwrap_or(false)
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
fn grab_y_scroller(&self, cursor_position: Point) -> Option<f32> {
|
2024-07-11 07:58:33 +02:00
|
|
|
let scrollbar = self.y?;
|
|
|
|
|
let scroller = scrollbar.scroller?;
|
|
|
|
|
|
|
|
|
|
if scrollbar.total_bounds.contains(cursor_position) {
|
|
|
|
|
Some(if scroller.bounds.contains(cursor_position) {
|
|
|
|
|
(cursor_position.y - scroller.bounds.y) / scroller.bounds.height
|
2022-12-24 21:27:44 -08:00
|
|
|
} else {
|
2024-07-11 07:58:33 +02:00
|
|
|
0.5
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
2022-12-24 21:27:44 -08:00
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
fn grab_x_scroller(&self, cursor_position: Point) -> Option<f32> {
|
2024-07-11 07:58:33 +02:00
|
|
|
let scrollbar = self.x?;
|
|
|
|
|
let scroller = scrollbar.scroller?;
|
|
|
|
|
|
|
|
|
|
if scrollbar.total_bounds.contains(cursor_position) {
|
|
|
|
|
Some(if scroller.bounds.contains(cursor_position) {
|
|
|
|
|
(cursor_position.x - scroller.bounds.x) / scroller.bounds.width
|
2022-12-24 21:27:44 -08:00
|
|
|
} else {
|
2024-07-11 07:58:33 +02:00
|
|
|
0.5
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
2019-11-11 20:29:58 -08:00
|
|
|
|
2022-12-24 21:27:44 -08:00
|
|
|
fn active(&self) -> bool {
|
|
|
|
|
self.y.is_some() || self.x.is_some()
|
2019-11-11 20:29:58 -08:00
|
|
|
}
|
2019-11-21 13:47:20 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
pub(super) mod internals {
|
|
|
|
|
use crate::core::{Point, Rectangle};
|
2020-10-22 16:05:44 -05:00
|
|
|
|
2024-07-12 15:11:30 +02:00
|
|
|
use super::Anchor;
|
2023-06-12 21:04:43 -07:00
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
|
pub struct Scrollbar {
|
|
|
|
|
pub total_bounds: Rectangle,
|
|
|
|
|
pub bounds: Rectangle,
|
2024-07-11 07:58:33 +02:00
|
|
|
pub scroller: Option<Scroller>,
|
2024-07-12 15:11:30 +02:00
|
|
|
pub alignment: Anchor,
|
2024-09-18 22:03:08 -04:00
|
|
|
pub disabled: bool,
|
2019-12-03 06:48:29 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
impl Scrollbar {
|
|
|
|
|
/// Returns whether the mouse is over the scrollbar or not.
|
|
|
|
|
pub fn is_mouse_over(&self, cursor_position: Point) -> bool {
|
|
|
|
|
self.total_bounds.contains(cursor_position)
|
2022-11-19 10:29:37 -08:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
/// Returns the y-axis scrolled percentage from the cursor position.
|
|
|
|
|
pub fn scroll_percentage_y(
|
|
|
|
|
&self,
|
|
|
|
|
grabbed_at: f32,
|
|
|
|
|
cursor_position: Point,
|
|
|
|
|
) -> f32 {
|
2024-07-11 07:58:33 +02:00
|
|
|
if let Some(scroller) = self.scroller {
|
|
|
|
|
let percentage = (cursor_position.y
|
|
|
|
|
- self.bounds.y
|
|
|
|
|
- scroller.bounds.height * grabbed_at)
|
|
|
|
|
/ (self.bounds.height - scroller.bounds.height);
|
|
|
|
|
|
|
|
|
|
match self.alignment {
|
2024-07-12 15:11:30 +02:00
|
|
|
Anchor::Start => percentage,
|
|
|
|
|
Anchor::End => 1.0 - percentage,
|
2024-07-11 07:58:33 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
0.0
|
2023-03-04 05:37:11 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns the x-axis scrolled percentage from the cursor position.
|
|
|
|
|
pub fn scroll_percentage_x(
|
|
|
|
|
&self,
|
|
|
|
|
grabbed_at: f32,
|
|
|
|
|
cursor_position: Point,
|
|
|
|
|
) -> f32 {
|
2024-07-11 07:58:33 +02:00
|
|
|
if let Some(scroller) = self.scroller {
|
|
|
|
|
let percentage = (cursor_position.x
|
|
|
|
|
- self.bounds.x
|
|
|
|
|
- scroller.bounds.width * grabbed_at)
|
|
|
|
|
/ (self.bounds.width - scroller.bounds.width);
|
|
|
|
|
|
|
|
|
|
match self.alignment {
|
2024-07-12 15:11:30 +02:00
|
|
|
Anchor::Start => percentage,
|
|
|
|
|
Anchor::End => 1.0 - percentage,
|
2024-07-11 07:58:33 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
0.0
|
2023-03-04 05:37:11 +01:00
|
|
|
}
|
2022-11-19 10:29:37 -08:00
|
|
|
}
|
2019-12-03 06:48:29 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
/// The handle of a [`Scrollbar`].
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
pub struct Scroller {
|
|
|
|
|
/// The bounds of the [`Scroller`].
|
|
|
|
|
pub bounds: Rectangle,
|
|
|
|
|
}
|
2019-10-25 03:47:34 +02:00
|
|
|
}
|
2024-03-05 04:42:25 +01:00
|
|
|
|
|
|
|
|
/// The possible status of a [`Scrollable`].
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
|
pub enum Status {
|
|
|
|
|
/// The [`Scrollable`] can be interacted with.
|
2024-09-18 22:03:08 -04:00
|
|
|
Active {
|
|
|
|
|
/// Whether or not the horizontal scrollbar is disabled meaning the content isn't overflowing.
|
|
|
|
|
is_horizontal_scrollbar_disabled: bool,
|
|
|
|
|
/// Whether or not the vertical scrollbar is disabled meaning the content isn't overflowing.
|
|
|
|
|
is_vertical_scrollbar_disabled: bool,
|
|
|
|
|
},
|
2024-03-05 04:42:25 +01:00
|
|
|
/// The [`Scrollable`] is being hovered.
|
|
|
|
|
Hovered {
|
|
|
|
|
/// Indicates if the horizontal scrollbar is being hovered.
|
|
|
|
|
is_horizontal_scrollbar_hovered: bool,
|
|
|
|
|
/// Indicates if the vertical scrollbar is being hovered.
|
|
|
|
|
is_vertical_scrollbar_hovered: bool,
|
2024-09-18 22:03:08 -04:00
|
|
|
/// Whether or not the horizontal scrollbar is disabled meaning the content isn't overflowing.
|
|
|
|
|
is_horizontal_scrollbar_disabled: bool,
|
|
|
|
|
/// Whether or not the vertical scrollbar is disabled meaning the content isn't overflowing.
|
|
|
|
|
is_vertical_scrollbar_disabled: bool,
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
/// The [`Scrollable`] is being dragged.
|
|
|
|
|
Dragged {
|
|
|
|
|
/// Indicates if the horizontal scrollbar is being dragged.
|
|
|
|
|
is_horizontal_scrollbar_dragged: bool,
|
|
|
|
|
/// Indicates if the vertical scrollbar is being dragged.
|
|
|
|
|
is_vertical_scrollbar_dragged: bool,
|
2024-09-18 22:03:08 -04:00
|
|
|
/// Whether or not the horizontal scrollbar is disabled meaning the content isn't overflowing.
|
|
|
|
|
is_horizontal_scrollbar_disabled: bool,
|
|
|
|
|
/// Whether or not the vertical scrollbar is disabled meaning the content isn't overflowing.
|
|
|
|
|
is_vertical_scrollbar_disabled: bool,
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
/// The appearance of a scrollable.
|
2024-10-12 19:55:41 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2024-03-24 05:03:09 +01:00
|
|
|
pub struct Style {
|
|
|
|
|
/// The [`container::Style`] of a scrollable.
|
|
|
|
|
pub container: container::Style,
|
2024-07-11 07:58:33 +02:00
|
|
|
/// The vertical [`Rail`] appearance.
|
|
|
|
|
pub vertical_rail: Rail,
|
|
|
|
|
/// The horizontal [`Rail`] appearance.
|
|
|
|
|
pub horizontal_rail: Rail,
|
2024-03-05 04:42:25 +01:00
|
|
|
/// The [`Background`] of the gap between a horizontal and vertical scrollbar.
|
|
|
|
|
pub gap: Option<Background>,
|
2025-11-28 08:56:32 +01:00
|
|
|
/// The appearance of the [`AutoScroll`] overlay.
|
|
|
|
|
pub auto_scroll: AutoScroll,
|
2024-03-05 04:42:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The appearance of the scrollbar of a scrollable.
|
2024-10-12 19:55:41 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2024-07-11 07:58:33 +02:00
|
|
|
pub struct Rail {
|
2024-03-05 04:42:25 +01:00
|
|
|
/// The [`Background`] of a scrollbar.
|
|
|
|
|
pub background: Option<Background>,
|
|
|
|
|
/// The [`Border`] of a scrollbar.
|
|
|
|
|
pub border: Border,
|
|
|
|
|
/// The appearance of the [`Scroller`] of a scrollbar.
|
|
|
|
|
pub scroller: Scroller,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The appearance of the scroller of a scrollable.
|
2024-10-12 19:55:41 -04:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2024-03-05 04:42:25 +01:00
|
|
|
pub struct Scroller {
|
2025-09-20 19:01:25 +01:00
|
|
|
/// The [`Background`] of the scroller.
|
|
|
|
|
pub background: Background,
|
2024-03-05 04:42:25 +01:00
|
|
|
/// The [`Border`] of the scroller.
|
|
|
|
|
pub border: Border,
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-28 08:56:32 +01:00
|
|
|
/// The appearance of the autoscroll overlay of a scrollable.
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
|
pub struct AutoScroll {
|
|
|
|
|
/// The [`Background`] of the [`AutoScroll`] overlay.
|
|
|
|
|
pub background: Background,
|
|
|
|
|
/// The [`Border`] of the [`AutoScroll`] overlay.
|
|
|
|
|
pub border: Border,
|
2025-11-28 22:02:17 +01:00
|
|
|
/// Thje [`Shadow`] of the [`AutoScroll`] overlay.
|
|
|
|
|
pub shadow: Shadow,
|
2025-11-28 08:56:32 +01:00
|
|
|
/// The [`Color`] for the arrow icons of the [`AutoScroll`] overlay.
|
|
|
|
|
pub icon: Color,
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
/// The theme catalog of a [`Scrollable`].
|
|
|
|
|
pub trait Catalog {
|
|
|
|
|
/// The item class of the [`Catalog`].
|
|
|
|
|
type Class<'a>;
|
2024-03-06 20:30:58 +01:00
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
/// The default class produced by the [`Catalog`].
|
|
|
|
|
fn default<'a>() -> Self::Class<'a>;
|
|
|
|
|
|
|
|
|
|
/// The [`Style`] of a class with the given status.
|
|
|
|
|
fn style(&self, class: &Self::Class<'_>, status: Status) -> Style;
|
2024-03-06 20:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
/// A styling function for a [`Scrollable`].
|
|
|
|
|
pub type StyleFn<'a, Theme> = Box<dyn Fn(&Theme, Status) -> Style + 'a>;
|
|
|
|
|
|
|
|
|
|
impl Catalog for Theme {
|
|
|
|
|
type Class<'a> = StyleFn<'a, Self>;
|
|
|
|
|
|
|
|
|
|
fn default<'a>() -> Self::Class<'a> {
|
|
|
|
|
Box::new(default)
|
2024-03-06 20:30:58 +01:00
|
|
|
}
|
2024-03-05 04:42:25 +01:00
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
|
|
|
|
|
class(self, status)
|
2024-03-05 04:42:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-06 17:08:28 +01:00
|
|
|
/// The default style of a [`Scrollable`].
|
2024-03-24 05:03:09 +01:00
|
|
|
pub fn default(theme: &Theme, status: Status) -> Style {
|
2024-03-05 04:42:25 +01:00
|
|
|
let palette = theme.extended_palette();
|
|
|
|
|
|
2024-07-11 07:58:33 +02:00
|
|
|
let scrollbar = Rail {
|
2024-03-05 04:42:25 +01:00
|
|
|
background: Some(palette.background.weak.color.into()),
|
2024-07-12 19:10:52 +02:00
|
|
|
border: border::rounded(2),
|
2024-03-05 04:42:25 +01:00
|
|
|
scroller: Scroller {
|
2025-09-20 19:01:25 +01:00
|
|
|
background: palette.background.strongest.color.into(),
|
2024-07-12 19:10:52 +02:00
|
|
|
border: border::rounded(2),
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-28 08:56:32 +01:00
|
|
|
let auto_scroll = AutoScroll {
|
2025-11-28 22:02:17 +01:00
|
|
|
background: palette.background.base.color.scale_alpha(0.9).into(),
|
2025-11-28 08:56:32 +01:00
|
|
|
border: border::rounded(u32::MAX)
|
|
|
|
|
.width(1)
|
2025-11-28 22:02:17 +01:00
|
|
|
.color(palette.background.base.text.scale_alpha(0.8)),
|
|
|
|
|
shadow: Shadow {
|
|
|
|
|
color: Color::BLACK.scale_alpha(0.7),
|
|
|
|
|
offset: Vector::ZERO,
|
|
|
|
|
blur_radius: 2.0,
|
|
|
|
|
},
|
|
|
|
|
icon: palette.background.base.text.scale_alpha(0.8),
|
2025-11-28 08:56:32 +01:00
|
|
|
};
|
|
|
|
|
|
2024-03-05 04:42:25 +01:00
|
|
|
match status {
|
2024-09-18 22:03:08 -04:00
|
|
|
Status::Active { .. } => Style {
|
2024-03-24 05:03:09 +01:00
|
|
|
container: container::Style::default(),
|
2024-07-11 07:58:33 +02:00
|
|
|
vertical_rail: scrollbar,
|
|
|
|
|
horizontal_rail: scrollbar,
|
2024-03-05 04:42:25 +01:00
|
|
|
gap: None,
|
2025-11-28 08:56:32 +01:00
|
|
|
auto_scroll,
|
2024-03-05 04:42:25 +01:00
|
|
|
},
|
|
|
|
|
Status::Hovered {
|
|
|
|
|
is_horizontal_scrollbar_hovered,
|
|
|
|
|
is_vertical_scrollbar_hovered,
|
2024-09-18 22:03:08 -04:00
|
|
|
..
|
2024-03-05 04:42:25 +01:00
|
|
|
} => {
|
2024-07-11 07:58:33 +02:00
|
|
|
let hovered_scrollbar = Rail {
|
2024-03-05 04:42:25 +01:00
|
|
|
scroller: Scroller {
|
2025-09-20 19:01:25 +01:00
|
|
|
background: palette.primary.strong.color.into(),
|
2024-03-05 04:42:25 +01:00
|
|
|
..scrollbar.scroller
|
|
|
|
|
},
|
|
|
|
|
..scrollbar
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
Style {
|
|
|
|
|
container: container::Style::default(),
|
2024-07-11 07:58:33 +02:00
|
|
|
vertical_rail: if is_vertical_scrollbar_hovered {
|
2024-03-05 04:42:25 +01:00
|
|
|
hovered_scrollbar
|
|
|
|
|
} else {
|
|
|
|
|
scrollbar
|
|
|
|
|
},
|
2024-07-11 07:58:33 +02:00
|
|
|
horizontal_rail: if is_horizontal_scrollbar_hovered {
|
2024-03-05 04:42:25 +01:00
|
|
|
hovered_scrollbar
|
|
|
|
|
} else {
|
|
|
|
|
scrollbar
|
|
|
|
|
},
|
|
|
|
|
gap: None,
|
2025-11-28 08:56:32 +01:00
|
|
|
auto_scroll,
|
2024-03-05 04:42:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Status::Dragged {
|
|
|
|
|
is_horizontal_scrollbar_dragged,
|
|
|
|
|
is_vertical_scrollbar_dragged,
|
2024-09-18 22:03:08 -04:00
|
|
|
..
|
2024-03-05 04:42:25 +01:00
|
|
|
} => {
|
2024-07-11 07:58:33 +02:00
|
|
|
let dragged_scrollbar = Rail {
|
2024-03-05 04:42:25 +01:00
|
|
|
scroller: Scroller {
|
2025-09-20 19:01:25 +01:00
|
|
|
background: palette.primary.base.color.into(),
|
2024-03-05 04:42:25 +01:00
|
|
|
..scrollbar.scroller
|
|
|
|
|
},
|
|
|
|
|
..scrollbar
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-24 05:03:09 +01:00
|
|
|
Style {
|
|
|
|
|
container: container::Style::default(),
|
2024-07-11 07:58:33 +02:00
|
|
|
vertical_rail: if is_vertical_scrollbar_dragged {
|
2024-03-05 04:42:25 +01:00
|
|
|
dragged_scrollbar
|
|
|
|
|
} else {
|
|
|
|
|
scrollbar
|
|
|
|
|
},
|
2024-07-11 07:58:33 +02:00
|
|
|
horizontal_rail: if is_horizontal_scrollbar_dragged {
|
2024-03-05 04:42:25 +01:00
|
|
|
dragged_scrollbar
|
|
|
|
|
} else {
|
|
|
|
|
scrollbar
|
|
|
|
|
},
|
|
|
|
|
gap: None,
|
2025-11-28 08:56:32 +01:00
|
|
|
auto_scroll,
|
2024-03-05 04:42:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|