Commit graph

134 commits

Author SHA1 Message Date
a322516f33 segmented_button: fix internal tab reorder end-to-end
Two independent bugs prevented tab drag-and-drop reorder from working
on cosmic-comp (and likely other compositors):

1. allow_reorder required DndAction::Move to be negotiated via
   OfferEvent::SelectedAction, which cosmic-comp does not always emit
   for self-drops (the SelectedAction event either never arrives or
   arrives with DndAction::empty()). Add a fallback: accept self-drops
   whenever state.dragging_tab is set. dragging_tab is only populated
   by start_tab_drag on this same widget, so this is safe; mime match
   and on_reorder presence are checked below.

2. reorder_event_for_drop preferred drop_hint.side over positional
   swap, producing counter-intuitive no-ops: dropping A (pos 0) on the
   left half of B (pos 1) resolved to "Before B" which, after removing
   A, lands at pos 0 again — the tab appeared not to move. Always use
   default_insert_position, which derives direction from dragged vs
   target positions (Konsole/Firefox/Chrome-style swap semantics).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 11:09:46 +02:00
108441ef61 segmented_button: add on_double_click callback
Fires in addition to on_activate when the same entity is left-clicked
twice within 400 ms. Lets applications bind quick actions (e.g. rename
a tab) without blocking the normal single-click activation path.

- New Widget::on_double_click builder mirroring on_activate/on_close.
- last_click field on LocalState for timestamp tracking.
- Detection branch in the mouse handler after on_activate fires, so the
  target entity is already focused when the callback runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 21:26:35 +02:00
1d98eee6de perf(widget): avoid VecDeque clone in segmented_button/table Model::clear
Model::clear() cloned the entire order VecDeque to iterate while
remove() mutated it, producing an O(n) allocation proportional to the
number of items — needless on a clear() which is going to drop all of
them anyway.

Replace the clone with std::mem::take(&mut self.order): we iterate the
taken VecDeque (transferring ownership), and the inner self.order.remove(index)
in each remove() call now finds position()==None and no-ops, since
self.order has been swapped with an empty default.

Same semantics, zero allocation. Noticeable on large nav/table models
(>100 items) and on apps that reset state frequently (settings pages,
file lists, context menus).
2026-04-19 16:29:02 +02:00
Adam Cosner
5d1dfc4c54
refactor!: remove cosmic::iced_* re-exports 2026-04-08 03:12:10 +02:00
Ashley Wulber
b963fbfea9
feat(widget): progress bars 2026-04-07 17:02:58 +02:00
Ashley Wulber
9aa87cd66b fix(segmented_button): active font for context menu & prioritize active font over hover 2026-04-06 18:57:27 -04:00
Vukašin Vojinović
fdf3369cea chore: re-export iced row and column
This removes the custom row and column implementations and uses the iced ones directly.
2026-04-03 20:39:31 +02:00
Vukašin Vojinović
a9e0671075 fix(segmented_button): hover text style 2026-04-03 20:36:23 +02:00
Hojjat
c804d3851d fix: don't ever draw glyphs outside of the bounds 2026-03-23 10:21:15 -04:00
Hojjat
dc3ebaa38e feat(segmented_button): add ellipsize support 2026-03-23 10:21:15 -04:00
Ashley Wulber
c7ac9cfd31 fix: if not in bounds, return default mouse interaction 2026-03-17 20:51:22 +01:00
Ashley Wulber
1970499459 fix: capture mouse motion and mouse interactions in overlay 2026-03-05 22:02:40 +01:00
Ashley Wulber
e8d53b14ea chore: various fixes and some cleanup 2026-03-04 12:04:32 -05:00
Ashley Wulber
e10459fb37 wip rebase updates 2026-03-04 12:04:32 -05:00
Alex Marín
384e8f6e21
fix(segmented_button): clear bold button text on context menu close 2026-02-20 12:06:45 +01:00
Hojjat Abdollahi
b9bd773940
feat: ellipsize text (#1132) 2026-02-19 10:06:45 -07:00
mariinkys
c1c09624bd fix: right-clicking any sidebar item makes all sidebar items bold 2026-02-19 16:43:56 +01:00
Ashley Wulber
fdcba7d8ec fix(segmented_button): dnd hover 2026-01-29 00:07:00 +01:00
Ashley Wulber
9fcd449611 fix(segmented_button): hover state handling
when hover state changes, paragraphs also need to be updated. I'll make a not to check this again after the rebase though.
2026-01-27 14:10:04 -05:00
Ashley Wulber
927035809f refactor(segmented button): only clear tab drag after source event cancel or finish 2026-01-24 00:53:30 +01:00
Ashley Wulber
beddbf1770 improv(segmented_button): dnd state handling 2026-01-22 10:26:58 -05:00
Ashley Wulber
d71c42102d fix(segmented button): tab dnd 2026-01-22 02:11:08 +01:00
Michael Aaron Murphy
cdf4eafc9e
fix(segmented_button): set icon to symbolic 2025-12-05 17:18:26 +01:00
Stephan Buys
7f321cb0a3 segmented button: support tab drag + drop 2025-11-20 22:33:13 +01:00
Cheong Lau
bc744bd4e3
fix(segmented_button): use less restrictive FnOnce for builder method over Fn 2025-11-11 17:18:38 +01:00
Cheong Lau
1d6a43486e remove redundant clones, use mul_add on f32s 2025-10-22 04:30:57 +02:00
Cheong Lau
bd438a8581 perf: reduce memory allocations
This also changes `widget::column::with_children` and
`widget::row::with_children` to take an `impl IntoIterator` instead
of a `Vec`, like the `iced` variants of these functions do.

This shouldn't be a breaking change since passing in a `Vec` will still
compile and function exactly as before.

(Using `iced::widget::Column::from_vec` or
`iced::widget::Row::from_vec` isn't possible, since the elements of the
`Vec` aren't checked, so the size of the resulting `Column` or `Row`
won't adapt to the size of its children. Perhaps a new function could
be added to mirror `iced`'s?)
2025-10-22 04:30:57 +02:00
Ashley Wulber
2e87bd7c41 fix(segmented_button): ensure modifier state exact match for tab 2025-10-21 19:29:48 +02:00
Cheong Lau
a27bb5e05d chore: apply clippy suggestions 2025-10-05 04:40:51 +02:00
Michael Aaron Murphy
6e7a634398
fix(segmented_button): draw all indent levels 2025-08-19 16:31:19 +02:00
Michael Aaron Murphy
c10695600b
feat(segmented_button): add FileNav style with related widget improvements 2025-08-19 11:13:28 +02:00
Michael Aaron Murphy
95ebabf149
improv(segmented_button): hide focus state until tabbed 2025-08-13 12:20:22 +02:00
Michael Aaron Murphy
5434dc95d5
feat(segmented_button): pressed state style 2025-08-13 12:13:05 +02:00
Michael Aaron Murphy
4f423349a2
fix(segmented_button): duplicate focus fix 2025-08-13 11:18:58 +02:00
Michael Aaron Murphy
8badf73383
improv(segmented_button): nav bar, tab, and segmented control theme improvements 2025-08-12 17:52:59 +02:00
Ashley Wulber
5be9611c8a fix(segmented-button): context menu state management 2025-06-19 08:02:54 -06:00
Michael Aaron Murphy
3f4a50ee2c
chore: remove eprintln logs 2025-06-11 11:49:32 +02:00
Michael Aaron Murphy
f835afa59c
fix(segmented_button): unfocus when clicking out of bounds 2025-06-11 09:26:18 +02:00
Ashley Wulber
92ec78ba29
feat: menu bar popups 2025-06-10 18:22:07 +02:00
Ashley Wulber
ce56237ab9 fix(dnd): leave event handlers should expect None as the drag Id 2025-05-22 17:18:56 +02:00
Michael Aaron Murphy
c955c8400f
fix(segmented_button): fix widget focus not being applied on click 2025-03-24 04:36:53 +01:00
Michael Aaron Murphy
0aa518984e
chore: format for 2024 edition 2025-03-21 13:33:07 +01:00
Michael Aaron Murphy
8cf372c9b9
perf: inline public getters/setters, and use non-generic inner functions
To reduce compile-times and avoid some overhead to binary size, this will modify some of our
generic functions to use non-generic inner functions where possible. The inner functions are
marked carefully with `#[inline(never)]` to prevent being inlined by LLVM at their callsites

While looking for generic functions to optimize, I have also taken the opportunity to annotate
public non-generic getters and setters with `#[inline]` to ensure that LLVM will inline them
across crate boundaries. By default, only generic functions are automatically inlined, and
only when enabling fat LTO are constant functions reliably inlined across crate boundaries.
2025-03-21 13:31:34 +01:00
Michael Aaron Murphy
2afa192573
fix: Rust 2024 errors 2025-03-21 13:20:45 +01:00
Ashley Wulber
337b80d4ca
feat: Tooltips and Better Surface Management 2025-03-14 16:56:21 +01:00
ellieplayswow
a234a45ea6
fix(segmented_button): ignore button release / finger lifted events when dragged out of target 2025-03-10 16:21:34 +01:00
Tony4dev
0b7e23444a
feat(segmented_button): add len method 2025-02-13 16:22:42 +01:00
Jason Hansen
51ede4bce6
fix(segmented_button): close context menu when clicked outside 2025-01-01 00:37:04 +01:00
Tony4dev
d536341234
fix(segmented_button): model index out of bounds when setting position 2024-12-03 05:14:33 +01:00
Ashley Wulber
0491c4baaa libcosmic updates 2024-10-18 14:04:39 -04:00