Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Undo #708: the dock looks and grows as in 1.0.6

gelenmedyad3f7b48c4c9f
diff --git a/crates/rf-app/src/dock/middle.rs b/crates/rf-app/src/dock/middle.rs
index 39667a43..94a8bdbc 100644
--- a/crates/rf-app/src/dock/middle.rs
+++ b/crates/rf-app/src/dock/middle.rs
@@ -156,8 +156,8 @@ pub struct MiddleIsland {
/// Counts the showings of a level: the timer that ends one ends only its own.
vol_serial: u64,
rest_items: Vec<(f32, f32)>,
- /// What the minimize targets were last told for: the glass's place, the unit and whether the dock is compact.
- min_told: Option<(i32, i32, i32, u32, bool)>,
+ /// What the minimize targets were last told for (see `tell_min_targets`): the glass's place and the unit; `None` asks for a telling.
+ min_told: Option<(i32, i32, i32, u32)>,
/// The glass and the icons' boxes as they were drawn last (dock units, the window's coordinates): what a right click is told
/// "empty glass" or "an icon" by.
last_glass: [f32; 4],
@@ -654,31 +654,18 @@ impl MiddleIsland {
/// Tells the shell hook where each window of this island's apps goes when it is minimized: its app's icon at rest, on the screen
/// (`rf_win::shellhost::shellhook::set_min_targets`: with no Explorer, Windows asks the shell for that place and animates the
/// window to it). Called on every frame, it does work only when the windows, the layout at rest or the glass's place changed.
- fn tell_min_targets(&mut self, rest_width: f32, sq: &rf_win::dock::thin::Squeeze, cx: &App) {
- // Update the shell at the endpoints, not on every animation frame.
- if sq.grow > 0.0 && !sq.is_full() && self.min_told.is_some() {
- return;
- }
+ fn tell_min_targets(&mut self, cx: &App) {
let Some(mut glass) = host::visible_glass_rect_on(self.mon, Kind::Middle, cx) else { return };
let edge = host::dock_edge(cx);
glass = rf_win::dock::layout::edge_axes(glass, edge);
let unit = host::env_on(self.mon, cx).unit();
- let thin = sq.grow == 0.0;
- let now = (glass.left, glass.top, glass.bottom, unit.to_bits(), thin);
+ let now = (glass.left, glass.top, glass.bottom, unit.to_bits());
if self.min_told == Some(now) {
return;
}
self.min_told = Some(now);
- let compact;
- let spans = if thin {
- compact = sq.compact_frame(&Frame::at_rest(&self.rest_items, rest_width), &self.slots);
- glass.top = glass.bottom - rf_win::dock::layout::px(rf_win::dock::thin::THIN_HEIGHT, unit);
- &compact.spans
- } else {
- &self.rest_items
- };
let mut targets = Vec::new();
- for (item, &(x, w)) in self.items.iter().zip(spans) {
+ for (item, &(x, w)) in self.items.iter().zip(&self.rest_items) {
let DockItem::App(a) = item else { continue };
let (left, right) = min_target_span(glass.left, x, w, unit);
let r = rf_win::dock::layout::edge_axes(rf_win::dock::layout::Rect::new(left, glass.top, right, glass.bottom), edge);
@@ -1272,8 +1259,6 @@ impl Render for MiddleIsland {
let real = vw - ml - mr;
let rest_width = if real > 0.0 { real.min(self.width()) } else { self.width() };
let rest = plan::rest_layout(&self.slots, rest_width);
- let thin_width = rest_width - rf_win::dock::thin::Squeeze::at(0.0).removed_width(&self.slots, &rest);
- super::thin::set_entry_width(mon, thin_width * env.unit(), cx);
// (a pressed button holds the sizes it went down with)
let (pointer, height) = match self.frozen {
Some((x, h)) => (Some(x), h),
@@ -1284,7 +1269,6 @@ impl Render for MiddleIsland {
let height = sq.bell(height);
let frame = match pointer {
Some(x) if height > 0.0 && strength != magnify::Strength::Off => {
- let x = sq.rest_pointer_x(x, rest_width, &self.slots, &rest);
magnify::frame(&self.slots, &rest, rest_width, x, height, strength, rest_width + 2.0 * inset.growth)
}
_ => Frame::at_rest(&rest, rest_width),
@@ -1297,7 +1281,7 @@ impl Render for MiddleIsland {
self.min_told = None;
}
self.rest_items.clone_from(&rest);
- self.tell_min_targets(rest_width, &sq, cx);
+ self.tell_min_targets(cx);
// (what a drag measures the pointer against)
self.last_slots.clone_from(&pic.items);
// what a right click is judged by: the glass and the icons as they are drawn in this frame
@@ -1490,7 +1474,7 @@ impl Render for MiddleIsland {
// the app's name under it, at the icon's resting size (the name does not grow with the icon)
.when(labels && !held, |d| {
// (as wide as an icon and a little of the gap: two names never touch)
- let lw = rest[ix].1 * sq.icon + 2.0;
+ let lw = ICON_REST + 2.0;
d.child(
div()
.absolute()
diff --git a/crates/rf-app/src/dock/right.rs b/crates/rf-app/src/dock/right.rs
index aaac18e1..01680e25 100644
--- a/crates/rf-app/src/dock/right.rs
+++ b/crates/rf-app/src/dock/right.rs
@@ -79,7 +79,7 @@ struct StatusPress {
/// How often the pointer is looked at while one of the island's own buttons is held (the tray strip's rate).
/// The right island's symbols (network, volume, the bell…), logical px.
-const STATUS_GLYPH: f32 = 24.0;
+const STATUS_GLYPH: f32 = 18.0;
const STATUS_POLL: Duration = Duration::from_millis(16);
@@ -548,7 +548,7 @@ fn icon_button(id: &'static str, icon: L, pal: Palette, k: f32) -> impl IntoElem
.cursor_pointer()
.hover(move |s| s.bg(hover))
.active(move |s| s.bg(pressed))
- // Larger status symbols within the existing 32-unit button.
+ // (18, not 16: the island's symbols looked small for its height, issue 455)
.child(Icon::new(icon).size(px(STATUS_GLYPH * k)).text_color(pal.text().hsla()))
}
@@ -682,7 +682,7 @@ fn bell_button(pal: Palette, dot: Option<Hsla>, k: f32, on_click: impl Fn(&mut A
.hover(move |s| s.bg(hover))
.active(move |s| s.bg(pressed))
.child(Icon::new(L::Bell).size(px(STATUS_GLYPH * k)).text_color(pal.text().hsla()))
- .when_some(dot, |d, color| d.child(div().absolute().top(px(4. * k)).right(px(5. * k)).size(px(8. * k)).rounded_full().bg(color)))
+ .when_some(dot, |d, color| d.child(div().absolute().top(px(7. * k)).right(px(8. * k)).size(px(8. * k)).rounded_full().bg(color)))
.on_click(move |_, _, cx| on_click(cx))
}
diff --git a/crates/rf-app/src/dock/thin.rs b/crates/rf-app/src/dock/thin.rs
index f38601f3..9c80da04 100644
--- a/crates/rf-app/src/dock/thin.rs
+++ b/crates/rf-app/src/dock/thin.rs
@@ -28,8 +28,8 @@
//!
//! WHAT IT DOES. The island's window never changes (it was always big enough for the full glass and the icons that grow out of it); only
//! the glass inside it and the icons do, in the frames the magnification already draws (`host::set_middle_frame` sends the glass and the
-//! pointer region), so the growth costs what a pointer move over the dock costs. The icons reflow around the island's centre and the
-//! glass keeps its bottom edge while its width follows the row. The band follows the setting alone
+//! pointer region), so the growth costs what a pointer move over the dock costs and nothing moves under the user's hand: the icons keep
+//! their centres, the glass keeps its bottom edge and its width. The band is another matter: it follows the setting alone
//! (`rf_win::dock::thin::BandRule`).
use std::sync::Mutex;
@@ -40,6 +40,7 @@ use futures::StreamExt;
use futures::channel::mpsc::{UnboundedSender, unbounded};
use gpui_kit::*;
use rf_win::dock::hover::Slot;
+use rf_win::dock::layout::MIDDLE_HEIGHT;
use rf_win::dock::magnify::{Frame, Presence};
use rf_win::dock::thin::{Model, Squeeze, Zone};
use rf_win::dock::zoomwatch::{self, ZoomWatch};
@@ -154,31 +155,30 @@ pub fn band_is_thin_on(_mon: MonId, cx: &App) -> bool {
}
}
-/// The glass and icons contract together around the centre using the same squeeze as the height animation.
+/// The picture of a frame of the middle island at this squeeze: the glass lowers its top edge and keeps its bottom edge, the icons
+/// shrink around their own centres (so the island is as wide as it was and nothing beside it moves), the rest is
+/// `plan::picture`'s. At the full squeeze it IS `plan::picture`.
pub fn picture(frame: &Frame, slots: &[Slot], margins: [f32; 4], baseline: f32, sq: &Squeeze) -> DockPicture {
+ let full = plan::picture(frame, slots, margins, baseline);
if sq.is_full() {
- return plan::picture(frame, slots, margins, baseline);
- }
- let compact = sq.compact_frame(frame, slots);
- let mut pic = plan::picture(&compact, slots, margins, baseline);
- let bottom = pic.glass[1] + pic.glass[3];
- pic.glass[1] = bottom - sq.glass_h;
- pic.glass[3] = sq.glass_h;
- let foot = bottom - baseline;
- pic.out_of_glass = slots.iter().zip(&pic.items).filter(|(s, _)| **s == Slot::Icon).map(|(_, &(x, w))| [x, foot - w, w, w]).filter(|b| b[1] < pic.glass[1]).collect();
- pic
-}
-
-/// Keep the hover-entry area in step with the compact row. The expanded hover area stays wide to prevent flicker during growth.
-pub fn set_entry_width(mon: MonId, width_px: f32, cx: &mut App) {
- if !ENABLED.load(Ordering::Relaxed) {
- return;
- }
- let Some(full) = host::visible_glass_rect_on(mon, Kind::Middle, cx) else { return };
- let full = rf_win::dock::layout::edge_axes(full, host::dock_edge(cx));
- if let Some(zone) = me(cx).and_then(|h| h.mon_mut(mon)).and_then(|m| m.zone.as_mut()) {
- zone.set_entry_width(full, width_px.round() as i32);
- }
+ return full;
+ }
+ let mt = margins[1];
+ let glass = [full.glass[0], mt + MIDDLE_HEIGHT - sq.glass_h, full.glass[2], sq.glass_h];
+ let items: Vec<(f32, f32)> = slots
+ .iter()
+ .zip(&full.items)
+ .map(|(s, &(x, w))| match s {
+ Slot::Icon => {
+ let w2 = w * sq.icon;
+ (x + (w - w2) / 2.0, w2)
+ }
+ Slot::Separator => (x, w),
+ })
+ .collect();
+ let bottom = mt + MIDDLE_HEIGHT - baseline;
+ let out_of_glass = slots.iter().zip(&items).filter(|(s, _)| **s == Slot::Icon).map(|(_, &(x, w))| [x, bottom - w, w, w]).filter(|b| b[1] < glass[1]).collect();
+ DockPicture { glass, items, out_of_glass }
}
/// The glass rectangle in device px for a squeeze that is not full: the bottom edge stays (`bottom_px`), the height is the thin one at
@@ -570,83 +570,100 @@ mod tests {
}
#[test]
- fn the_thin_picture_keeps_the_bottom_edge_and_centre_and_closes_the_gaps() {
+ fn the_thin_picture_keeps_the_bottom_edge_the_width_and_every_icons_centre() {
let (slots, rest, width) = row();
let margins = [44.0, 12.0, 44.0, 4.0];
let frame = Frame::at_rest(&rest, width);
- let full = picture(&frame, &slots, margins, BASELINE, &Squeeze::FULL);
+ let full = plan::picture(&frame, &slots, margins, BASELINE);
let thin = picture(&frame, &slots, margins, BASELINE, &Squeeze::at(0.0));
- let removed = 4.0 * (ICON_REST - rf_win::dock::thin::THIN_ICON);
- assert!((thin.glass[0] - full.glass[0] - removed / 2.0).abs() < 1e-4);
- assert!((thin.glass[2] - (full.glass[2] - removed)).abs() < 1e-4);
+ // the glass: the same bottom edge, the same left edge and width, 48 high instead of 72
+ assert_eq!(thin.glass[0], full.glass[0]);
+ assert_eq!(thin.glass[2], full.glass[2]);
assert_eq!(thin.glass[1] + thin.glass[3], full.glass[1] + full.glass[3]);
assert_eq!(thin.glass[3], 48.0);
- for (slot, &(_, w)) in slots.iter().zip(&thin.items) {
- let expected = if *slot == Slot::Icon { rf_win::dock::thin::THIN_ICON } else { layout::SEPARATOR_WIDTH };
- assert!((w - expected).abs() < 1e-4);
- }
- for pair in thin.items.windows(2) {
- assert!((pair[1].0 - (pair[0].0 + pair[0].1) - layout::ICON_GAP).abs() < 1e-4);
+ for ((s, a), b) in slots.iter().zip(&full.items).zip(&thin.items) {
+ match s {
+ Slot::Icon => {
+ assert!((a.0 + a.1 / 2.0 - (b.0 + b.1 / 2.0)).abs() < 1e-4, "the centre moved: {a:?} {b:?}");
+ assert!((b.1 - rf_win::dock::thin::THIN_ICON).abs() < 1e-4, "an icon is THIN_ICON units thin");
+ }
+ Slot::Separator => assert_eq!(a, b),
+ }
}
- assert!((thin.items[0].0 - thin.glass[0] - layout::DOCK_PADDING).abs() < 1e-4);
- let (last_x, last_w) = *thin.items.last().unwrap();
- assert!((thin.glass[0] + thin.glass[2] - last_x - last_w - layout::DOCK_PADDING).abs() < 1e-4);
+ // nothing sticks out of the thin glass, and the icons stand inside it
assert!(thin.out_of_glass.is_empty());
+ let foot = thin.glass[1] + thin.glass[3] - BASELINE;
+ for (s, &(_, w)) in slots.iter().zip(&thin.items) {
+ if *s == Slot::Icon {
+ assert!(foot - w >= thin.glass[1], "the icon's top is inside the glass");
+ }
+ }
}
#[test]
- fn the_compact_row_expands_smoothly_with_the_height_at_every_step() {
+ fn a_point_on_a_thin_icon_stays_on_that_icon_all_through_the_growth() {
+ // "the icon the user aims at stays under the pointer": the icons grow about their own centres and up from the same foot, so
+ // every point of a thin icon is a point of the same icon at every moment of the growth, and at the end
let (slots, rest, width) = row();
let margins = [44.0, 12.0, 44.0, 4.0];
let frame = Frame::at_rest(&rest, width);
- let mut last_width = 0.0;
- for step in 0..=100 {
- let sq = Squeeze::at(step as f32 / 100.0);
- let p = picture(&frame, &slots, margins, BASELINE, &sq);
- assert!(p.glass[2] >= last_width - 1e-4);
- assert!((p.glass[0] + p.glass[2] / 2.0 - (margins[0] + width / 2.0)).abs() < 1e-4);
- assert!((p.glass[1] + p.glass[3] - (margins[1] + layout::MIDDLE_HEIGHT)).abs() < 1e-4);
- for pair in p.items.windows(2) {
- assert!((pair[1].0 - pair[0].0 - pair[0].1 - layout::ICON_GAP).abs() < 1e-3);
+ let rect = |sq: &Squeeze, ix: usize| {
+ let p = picture(&frame, &slots, margins, BASELINE, sq);
+ let (x, w) = p.items[ix];
+ let foot = margins[1] + layout::MIDDLE_HEIGHT - BASELINE;
+ (x, foot - w, x + w, foot)
+ };
+ for ix in [0usize, 1, 3, 4] {
+ let (l0, t0, r0, b0) = rect(&Squeeze::at(0.0), ix);
+ for k in 1..=20 {
+ let (l, t, r, b) = rect(&Squeeze::at(k as f32 / 20.0), ix);
+ assert!(l <= l0 + 1e-3 && t <= t0 + 1e-3 && r >= r0 - 1e-3 && (b - b0).abs() < 1e-3, "icon {ix} at step {k}: ({l},{t},{r},{b}) does not cover ({l0},{t0},{r0},{b0})");
}
- last_width = p.glass[2];
}
- assert_eq!(last_width, width);
}
#[test]
- fn compaction_preserves_fitted_gaps_and_padding_with_magnification() {
- let (slots, _, natural_width) = row();
+ fn the_icon_under_the_pointer_does_not_move_sideways_while_the_dock_grows() {
+ // the pointer is over the third icon: its centre has the same x from the thin dock to the full one (the bell aside)
+ let (slots, rest, width) = row();
let margins = [44.0, 12.0, 44.0, 4.0];
- for width in [natural_width, 160.0, 110.0] {
- let rest = plan::rest_layout(&slots, width);
- for step in 0..=20 {
- let sq = Squeeze::at(step as f32 / 20.0);
- let x = sq.rest_pointer_x(width * 0.7, width, &slots, &rest);
- let frame = magnify::frame(&slots, &rest, width, x, sq.bell(1.0), magnify::Strength::Full, width + 40.0);
- let full = plan::picture(&frame, &slots, margins, BASELINE);
- let actual = picture(&frame, &slots, margins, BASELINE, &sq);
- assert!((actual.glass[0] + actual.glass[2] / 2.0 - full.glass[0] - full.glass[2] / 2.0).abs() < 1e-3);
- for (before, after) in full.items.windows(2).zip(actual.items.windows(2)) {
- let old_gap = before[1].0 - before[0].0 - before[0].1;
- let new_gap = after[1].0 - after[0].0 - after[0].1;
- assert!((old_gap - new_gap).abs() < 1e-3);
- }
- assert!(actual.glass[2] <= full.glass[2] + 1e-3);
- }
+ let frame = Frame::at_rest(&rest, width);
+ let centre = |sq: &Squeeze| {
+ let p = picture(&frame, &slots, margins, BASELINE, sq);
+ p.items[3].0 + p.items[3].1 / 2.0
+ };
+ let at_thin = centre(&Squeeze::at(0.0));
+ for k in 0..=20 {
+ assert!((centre(&Squeeze::at(k as f32 / 20.0)) - at_thin).abs() < 1e-3, "step {k}");
}
}
#[test]
- fn compact_zone_enters_only_under_the_visible_row_and_holds_the_full_row() {
- let full = layout::Rect::new(100, 200, 600, 272);
- let monitor = layout::Rect::new(0, 0, 800, 276);
- let mut zone = rf_win::dock::thin::zone(full, layout::Rect::default(), layout::Rect::default(), monitor, 1.0);
- zone.set_entry_width(full, 338);
- assert_eq!((zone.enter.left, zone.enter.right), (181, 519));
- assert!(zone.enters(350, 270));
- assert!(!zone.enters(110, 270));
- assert!(zone.contains(110, 270));
+ fn the_icon_the_pointer_aims_at_is_still_under_it_at_every_step_with_the_bell_coming_in() {
+ // The real growth: the squeeze AND the magnification's bell (`Squeeze::bell`) come in together, the glass widens around the
+ // island's centre and the icons beside the pointer swell. Whatever icon the pointer is over when the dock is thin is under it
+ // at every step to the full dock, wherever on the icon it is (the pointer's x is in the frame's coordinates).
+ let (slots, rest, width) = row();
+ let margins = [44.0, 12.0, 44.0, 4.0];
+ for ix in [0usize, 1, 3, 4] {
+ let (rx, rw) = rest[ix];
+ for frac in [0.1f32, 0.3, 0.5, 0.7, 0.9] {
+ let pointer = rx + rw * frac;
+ // (thin, the icon is 30/36 of its rest size around the same centre: the pointer is over it for frac within that)
+ let thin_w = rw * Squeeze::at(0.0).icon;
+ let thin_l = rx + (rw - thin_w) / 2.0;
+ if pointer < thin_l || pointer > thin_l + thin_w {
+ continue;
+ }
+ for k in 0..=20 {
+ let sq = Squeeze::at(k as f32 / 20.0);
+ let frame = magnify::frame(&slots, &rest, width, pointer, sq.bell(1.0), magnify::Strength::Full, width + 80.0);
+ let p = picture(&frame, &slots, margins, BASELINE, &sq);
+ let (l, w) = (p.items[ix].0 - margins[0], p.items[ix].1);
+ assert!(pointer >= l - 1e-3 && pointer <= l + w + 1e-3, "icon {ix}, pointer at {frac} of it, step {k}: the icon spans {l}..{} and the pointer is at {pointer}", l + w);
+ }
+ }
+ }
}
#[test]
diff --git a/crates/rf-app/src/dock/tray_strip.rs b/crates/rf-app/src/dock/tray_strip.rs
index 21d0dba5..89331fe7 100644
--- a/crates/rf-app/src/dock/tray_strip.rs
+++ b/crates/rf-app/src/dock/tray_strip.rs
@@ -660,7 +660,7 @@ pub fn strip_element(pal: Palette, cx: &App) -> Option<AnyElement> {
.cursor_pointer()
.when(chevron_hot, |d| d.bg(if target == Some(DropTarget::Chevron) { drop_bg } else { hover_bg }))
.when(pressed == Some(Source::Chevron), |d| d.bg(press_bg))
- .child(Icon::new(L::ChevronUp).size(px(18. * k)).text_color(pal.text_secondary().hsla()));
+ .child(Icon::new(L::ChevronUp).size(px(14. * k)).text_color(pal.text_secondary().hsla()));
row = row.child(wire(chevron, Source::Chevron));
Some(
div()
diff --git a/crates/rf-win/src/dock/thin.rs b/crates/rf-win/src/dock/thin.rs
index fea731d2..11448785 100644
--- a/crates/rf-win/src/dock/thin.rs
+++ b/crates/rf-win/src/dock/thin.rs
@@ -3,9 +3,10 @@
//! clock of their own: the app feeds them facts and the time, and every rule has a test.
//!
//! WHAT IS THIN. The middle island's GLASS is `SIDE_HEIGHT` high (the same line as the other two: all three bottoms are the same
-//! `MARGIN_BOTTOM` above the work area's bottom) and its icons are `THIN_ICON` instead of `ICON_REST`. The row contracts around its
-//! centre as the icons shrink, keeping the gaps and edge padding from the full layout. Its neighbours stay in place and the icons
-//! grow up from the same baseline the magnification uses.
+//! `MARGIN_BOTTOM` above the work area's bottom) and its icons are `THIN_ICON` instead of `ICON_REST`. The icons keep their CENTRES,
+//! so the island is exactly as wide as it was and nothing beside it moves; only the glass lowers its top and the icons shrink in place.
+//! That is also what keeps "the icon the user aims at stays under the pointer" true while the dock grows: horizontally nothing moves, and
+//! the icons grow up from the same baseline the magnification uses.
//!
//! THE FIVE RULES (each is a type below):
//! 1. [`Follower`]: thin or full from (setting, a maximised window seen, pointer near, something open). It goes back to thin the
@@ -18,8 +19,6 @@
//! dock: [`docked_under`]).
//! 5. [`Squeeze`]: the numbers of every moment between thin and full, and [`glass_height_px`] for the device pixels.
-use super::hover::Slot;
-use super::magnify::Frame;
use super::layout::{ICON_REST, MARGIN_BOTTOM, MIDDLE_HEIGHT, MIDDLE_RESERVE, Rect, SIDE_HEIGHT, px};
/// The thin dock's glass height: the side islands', so the three stand on one line and are one height.
@@ -73,7 +72,7 @@ pub struct Squeeze {
pub grow: f32,
/// The glass's height, dock units.
pub glass_h: f32,
- /// What an icon's rest size is multiplied by.
+ /// What an icon's rest size is multiplied by (the icon keeps its centre).
pub icon: f32,
}
@@ -93,36 +92,6 @@ impl Squeeze {
Squeeze { grow: g, glass_h: lerp(THIN_HEIGHT, MIDDLE_HEIGHT, g), icon: lerp(THIN_ICON / ICON_REST, 1.0, g) }
}
- /// How much width the icons give back at this squeeze. Separators and gaps keep their existing widths.
- pub fn removed_width(&self, slots: &[Slot], spans: &[(f32, f32)]) -> f32 {
- slots.iter().zip(spans).filter(|(slot, _)| **slot == Slot::Icon).map(|(_, &(_, w))| w * (1.0 - self.icon)).sum()
- }
-
- /// Contract the row around its centre, preserving its gaps and edge padding even on a narrow display.
- pub fn compact_frame(&self, frame: &Frame, slots: &[Slot]) -> Frame {
- if self.is_full() {
- return frame.clone();
- }
- let removed = self.removed_width(slots, &frame.spans);
- let mut shift = removed / 2.0;
- let spans = frame.spans.iter().zip(slots).map(|(&(x, w), slot)| {
- let next_w = if *slot == Slot::Icon { w * self.icon } else { w };
- let next_x = x + shift;
- shift -= w - next_w;
- (next_x, next_w)
- }).collect();
- Frame { spans, left: frame.left + removed / 2.0, width: frame.width - removed }
- }
-
- /// Map a cursor in the compact row back into the full resting row for the existing magnification bell.
- pub fn rest_pointer_x(&self, x: f32, width: f32, slots: &[Slot], rest: &[(f32, f32)]) -> f32 {
- if self.is_full() {
- return x;
- }
- let compact = width - self.removed_width(slots, rest);
- if compact > 0.0 { width / 2.0 + (x - width / 2.0) * width / compact } else { x }
- }
-
pub fn is_full(&self) -> bool {
self.grow >= 1.0
}
@@ -143,7 +112,7 @@ pub fn glass_height_px(sq: &Squeeze, unit: f32, full_px: f32) -> f32 {
lerp(px(THIN_HEIGHT, unit) as f32, full_px, sq.grow)
}
-/// The full horizontal extent at the thin dock's height. The view narrows the actual glass to its compact row.
+/// The glass rectangle of the thin dock: the full one's bottom edge, the side islands' height.
pub fn thin_glass(full: Rect, unit: f32) -> Rect {
Rect { top: full.bottom - px(THIN_HEIGHT, unit), ..full }
}
@@ -167,14 +136,6 @@ pub struct Zone {
}
impl Zone {
- /// Restrict entry to the actual compact row while retaining the full-width region for a grown dock.
- pub fn set_entry_width(&mut self, full: Rect, width: i32) {
- let width = width.clamp(0, full.width().max(0));
- let left = full.left + (full.width() - width) / 2;
- self.enter.left = left;
- self.enter.right = left + width;
- }
-
/// The pointer is in the area that keeps a grown dock grown.
pub fn contains(&self, x: i32, y: i32) -> bool {
self.near.contains(x, y) && !self.left.contains(x, y) && !self.right.contains(x, y)
@@ -860,7 +821,7 @@ mod tests {
assert_eq!(thin.top, i.left.top, "the same height as the left island at unit {unit}");
assert_eq!(thin.top, i.right.top);
assert_eq!(thin.height(), i.left.height());
- assert_eq!((thin.left, thin.right), (i.middle.left, i.middle.right), "the full horizontal extent is kept for the near zone");
+ assert_eq!((thin.left, thin.right), (i.middle.left, i.middle.right), "as wide as it was: nothing beside it moves");
// and the device height the view draws is the same number of pixels
let sq = Squeeze::at(0.0);
assert_eq!(glass_height_px(&sq, unit, i.middle.height() as f32), i.left.height() as f32);