* Wireup the `Pixels` change
https://github.com/zed-industries/zed/pull/39367.
This commit is contained in:
Floyd Wang 2025-10-03 14:32:29 +08:00 committed by GitHub
parent 4d459ea160
commit 1358b2906e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 123 additions and 97 deletions

74
Cargo.lock generated
View file

@ -605,7 +605,7 @@ dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.11.0",
"itertools 0.12.1",
"lazy_static",
"lazycell",
"log",
@ -628,7 +628,7 @@ dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.11.0",
"itertools 0.13.0",
"log",
"prettyplease",
"proc-macro2",
@ -692,14 +692,15 @@ dependencies = [
[[package]]
name = "blade-graphics"
version = "0.6.0"
source = "git+https://github.com/kvark/blade?rev=bfa594ea697d4b6326ea29f747525c85ecf933b9#bfa594ea697d4b6326ea29f747525c85ecf933b9"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4deb8f595ce7f00dee3543ebf6fd9a20ea86fc421ab79600dac30876250bdae"
dependencies = [
"ash",
"ash-window",
"bitflags 2.9.1",
"bytemuck",
"codespan-reporting 0.11.1",
"codespan-reporting",
"glow",
"gpu-alloc",
"gpu-alloc-ash",
@ -717,6 +718,7 @@ dependencies = [
"objc2-metal",
"objc2-quartz-core",
"objc2-ui-kit",
"once_cell",
"raw-window-handle",
"slab",
"wasm-bindgen",
@ -726,7 +728,8 @@ dependencies = [
[[package]]
name = "blade-macros"
version = "0.3.0"
source = "git+https://github.com/kvark/blade?rev=bfa594ea697d4b6326ea29f747525c85ecf933b9#bfa594ea697d4b6326ea29f747525c85ecf933b9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27142319e2f4c264581067eaccb9f80acccdde60d8b4bf57cc50cd3152f109ca"
dependencies = [
"proc-macro2",
"quote",
@ -735,8 +738,9 @@ dependencies = [
[[package]]
name = "blade-util"
version = "0.2.0"
source = "git+https://github.com/kvark/blade?rev=bfa594ea697d4b6326ea29f747525c85ecf933b9#bfa594ea697d4b6326ea29f747525c85ecf933b9"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a6be3a82c001ba7a17b6f8e413ede5d1004e6047213f8efaf0ffc15b5c4904c"
dependencies = [
"blade-graphics",
"bytemuck",
@ -1134,16 +1138,6 @@ dependencies = [
"objc",
]
[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
"termcolor",
"unicode-width 0.1.14",
]
[[package]]
name = "codespan-reporting"
version = "0.12.0"
@ -1152,13 +1146,13 @@ checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81"
dependencies = [
"serde",
"termcolor",
"unicode-width 0.2.1",
"unicode-width",
]
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"indexmap",
"rustc-hash 2.1.1",
@ -1586,7 +1580,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"proc-macro2",
"quote",
@ -2660,9 +2654,9 @@ dependencies = [
[[package]]
name = "glow"
version = "0.14.2"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483"
checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08"
dependencies = [
"js-sys",
"slotmap",
@ -2714,7 +2708,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"anyhow",
"as-raw-xcb-connection",
@ -2885,7 +2879,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@ -3152,7 +3146,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"anyhow",
"bytes",
@ -3172,7 +3166,7 @@ dependencies = [
[[package]]
name = "http_client_tls"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"rustls",
"rustls-platform-verifier",
@ -4058,7 +4052,7 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"anyhow",
"bindgen 0.71.1",
@ -4170,7 +4164,7 @@ dependencies = [
"bit-set",
"bitflags 2.9.1",
"cfg_aliases",
"codespan-reporting 0.12.0",
"codespan-reporting",
"half",
"hashbrown 0.15.5",
"hexf-parse",
@ -4818,7 +4812,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "perf"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"collections",
"serde",
@ -5637,7 +5631,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"derive_refineable",
"workspace-hack",
@ -5748,7 +5742,7 @@ dependencies = [
[[package]]
name = "reqwest_client"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"anyhow",
"bytes",
@ -6306,7 +6300,7 @@ checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749"
[[package]]
name = "semantic_version"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"anyhow",
"serde",
@ -6492,7 +6486,7 @@ version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
dependencies = [
"dirs 4.0.0",
"dirs 6.0.0",
]
[[package]]
@ -6868,7 +6862,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"arrayvec",
"log",
@ -8024,12 +8018,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
[[package]]
name = "unicode-width"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
[[package]]
name = "unicode-width"
version = "0.2.1"
@ -8108,7 +8096,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "util"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"anyhow",
"async-fs 2.1.3",
@ -8143,7 +8131,7 @@ dependencies = [
[[package]]
name = "util_macros"
version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#6af385235d2dbd145391861556704edb1523ebf3"
source = "git+https://github.com/zed-industries/zed.git#e4f90b5da2b8a6d2b267edc02b333b7d7908d4d9"
dependencies = [
"perf",
"quote",

View file

@ -11,8 +11,8 @@ use gpui_component::{
locale,
popup_menu::PopupMenuExt as _,
scroll::ScrollbarShow,
set_locale, ActiveTheme as _, ContextModal as _, IconName, Sizable as _, Theme, ThemeMode,
TitleBar,
set_locale, ActiveTheme as _, ContextModal as _, IconName, PixelsExt, Sizable as _, Theme,
ThemeMode, TitleBar,
};
use crate::{themes::ThemeSwitcher, SelectFont, SelectLocale, SelectRadius, SelectScrollbarShow};
@ -219,8 +219,8 @@ impl FontSizeSelector {
impl Render for FontSizeSelector {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let focus_handle = self.focus_handle.clone();
let font_size = cx.theme().font_size.0 as i32;
let radius = cx.theme().radius.0 as i32;
let font_size = cx.theme().font_size.as_f32() as i32;
let radius = cx.theme().radius.as_f32() as i32;
let scroll_show = cx.theme().scrollbar_show;
div()

View file

@ -10,7 +10,7 @@ use crate::{
shape::Area,
Axis, AxisText, Grid, Plot, StrokeStyle, AXIS_GAP,
},
ActiveTheme,
ActiveTheme, PixelsExt,
};
#[derive(IntoPlot)]
@ -94,8 +94,8 @@ where
return;
}
let width = bounds.size.width.0;
let height = bounds.size.height.0 - AXIS_GAP;
let width = bounds.size.width.as_f32();
let height = bounds.size.height.as_f32() - AXIS_GAP;
// X scale
let x = ScalePoint::new(self.data.iter().map(|v| x_fn(v)).collect(), vec![0., width]);

View file

@ -11,7 +11,7 @@ use crate::{
shape::Bar,
Axis, AxisText, Grid, Plot, AXIS_GAP,
},
ActiveTheme,
ActiveTheme, PixelsExt,
};
#[derive(IntoPlot)]
@ -90,8 +90,8 @@ where
return;
};
let width = bounds.size.width.0;
let height = bounds.size.height.0 - AXIS_GAP;
let width = bounds.size.width.as_f32();
let height = bounds.size.height.as_f32() - AXIS_GAP;
// X scale
let x = ScaleBand::new(self.data.iter().map(|v| x_fn(v)).collect(), vec![0., width])

View file

@ -10,7 +10,7 @@ use crate::{
shape::Line,
Axis, AxisText, Grid, Plot, StrokeStyle, AXIS_GAP,
},
ActiveTheme,
ActiveTheme, PixelsExt,
};
#[derive(IntoPlot)]
@ -85,8 +85,8 @@ where
return;
};
let width = bounds.size.width.0;
let height = bounds.size.height.0 - AXIS_GAP;
let width = bounds.size.width.as_f32();
let height = bounds.size.height.as_f32() - AXIS_GAP;
// X scale
let x = ScalePoint::new(self.data.iter().map(|v| x_fn(v)).collect(), vec![0., width]);

View file

@ -9,7 +9,7 @@ use crate::{
shape::{Arc, Pie},
Plot,
},
ActiveTheme,
ActiveTheme, PixelsExt,
};
#[derive(IntoPlot)]
@ -73,7 +73,7 @@ impl<T> Plot for PieChart<T> {
};
let outer_radius = if self.outer_radius.is_zero() {
bounds.size.height.0 * 0.4
bounds.size.height.as_f32() * 0.4
} else {
self.outer_radius
};

View file

@ -312,8 +312,8 @@ impl Dock {
.expect("DockArea is missing")
.read(cx);
let area_bounds = dock_area.bounds;
let mut left_dock_size = Pixels(0.0);
let mut right_dock_size = Pixels(0.0);
let mut left_dock_size = px(0.0);
let mut right_dock_size = px(0.0);
// Get the size of the left dock if it's open and not the current dock
if let Some(left_dock) = &dock_area.left_dock {

View file

@ -15,7 +15,7 @@ use crate::{
text_wrapper::{LineLayout, TextWrapper},
RopeExt as _,
},
ActiveTheme as _, Colorize, Root,
ActiveTheme as _, Colorize, PixelsExt, Root,
};
use super::{mode::InputMode, InputState, LastLayout};
@ -692,21 +692,25 @@ fn print_points_as_svg_path(
for corners in line_corners {
println!(
"tl: ({}, {}), tr: ({}, {}), bl: ({}, {}), br: ({}, {})",
corners.top_left.x.0 as i32,
corners.top_left.y.0 as i32,
corners.top_right.x.0 as i32,
corners.top_right.y.0 as i32,
corners.bottom_left.x.0 as i32,
corners.bottom_left.y.0 as i32,
corners.bottom_right.x.0 as i32,
corners.bottom_right.y.0 as i32,
corners.top_left.x.as_f32() as i32,
corners.top_left.y.as_f32() as i32,
corners.top_right.x.as_f32() as i32,
corners.top_right.y.as_f32() as i32,
corners.bottom_left.x.as_f32() as i32,
corners.bottom_left.y.as_f32() as i32,
corners.bottom_right.x.as_f32() as i32,
corners.bottom_right.y.as_f32() as i32,
);
}
if points.len() > 0 {
println!("M{},{}", points[0].x.0 as i32, points[0].y.0 as i32);
println!(
"M{},{}",
points[0].x.as_f32() as i32,
points[0].y.as_f32() as i32
);
for p in points.iter().skip(1) {
println!("L{},{}", p.x.0 as i32, p.y.0 as i32);
println!("L{},{}", p.x.as_f32() as i32, p.y.as_f32() as i32);
}
}
}

View file

@ -617,7 +617,7 @@ impl InputState {
for (line_index, line) in last_layout.lines.iter().enumerate() {
let local_offset = offset.saturating_sub(prev_lines_offset);
if let Some(pos) = line.position_for_index(local_offset, line_height) {
let sub_line_index = (pos.y.0 / line_height.0) as usize;
let sub_line_index = (pos.y / line_height) as usize;
let adjusted_pos = point(pos.x + last_layout.line_number_width, pos.y + y_offset);
return (line_index, sub_line_index, Some(adjusted_pos));
}

View file

@ -11,6 +11,8 @@ use std::{fmt::Debug, ops::Add};
use gpui::{point, px, App, Bounds, IntoElement, Path, PathBuilder, Pixels, Point, Window};
use crate::PixelsExt;
pub use axis::{Axis, AxisText, AXIS_GAP};
pub use grid::Grid;
pub use label::Label;
@ -42,8 +44,8 @@ where
.iter()
.map(|p| {
point(
px(p.x.into() + bounds.origin.x.0),
px(p.y.into() + bounds.origin.y.0),
px(p.x.into() + bounds.origin.x.as_f32()),
px(p.y.into() + bounds.origin.y.as_f32()),
)
})
.collect::<Vec<_>>();

View file

@ -4,6 +4,8 @@ use std::{f32::consts::PI, fmt::Debug};
use gpui::{point, px, Bounds, Hsla, Path, PathBuilder, Pixels, Point, Window};
use crate::PixelsExt;
const EPSILON: f32 = 1e-12;
const HALF_PI: f32 = PI / 2.;
@ -82,8 +84,8 @@ impl Arc {
let r1 = self.outer_radius.max(0.);
// Calculate the center point.
let center_x = bounds.origin.x.0 + bounds.size.width.0 / 2.;
let center_y = bounds.origin.y.0 + bounds.size.height.0 / 2.;
let center_x = bounds.origin.x.as_f32() + bounds.size.width.as_f32() / 2.;
let center_y = bounds.origin.y.as_f32() + bounds.size.height.as_f32() / 2.;
// Angle difference.
if r1 < EPSILON || da.abs() < EPSILON {

View file

@ -5,7 +5,10 @@ use gpui::{
Point, Window,
};
use crate::plot::{origin_point, StrokeStyle};
use crate::{
plot::{origin_point, StrokeStyle},
PixelsExt,
};
#[allow(clippy::type_complexity)]
pub struct Line<T> {
@ -138,7 +141,7 @@ impl<T> Line<T> {
let pos = origin_point(px(x), px(y), origin);
if self.dot {
let dot_radius = self.dot_size.0 / 2.;
let dot_radius = self.dot_size.as_f32() / 2.;
let dot_pos = origin_point(px(x - dot_radius), px(y - dot_radius), origin);
paint_dots.push(self.paint_dot(dot_pos));
}

View file

@ -5,6 +5,8 @@ use gpui::{
Window,
};
use crate::PixelsExt;
mod panel;
mod resize_handle;
pub use panel::*;
@ -130,7 +132,7 @@ impl ResizableState {
}
pub(crate) fn total_size(&self) -> Pixels {
self.sizes.iter().map(|s| s.0).sum::<f32>().into()
self.sizes.iter().map(|s| s.as_f32()).sum::<f32>().into()
}
pub(crate) fn done_resizing(&mut self, cx: &mut Context<Self>) {
@ -206,7 +208,7 @@ impl ResizableState {
}
// If total size exceeds container size, adjust the main panel
let total_size: Pixels = new_sizes.iter().map(|s| s.0).sum::<f32>().into();
let total_size: Pixels = new_sizes.iter().map(|s| s.as_f32()).sum::<f32>().into();
if total_size > container_size {
let overflow = total_size - container_size;
new_sizes[main_ix] = (new_sizes[main_ix] - overflow).max(size_range.start);

View file

@ -39,12 +39,12 @@ pub(crate) const WIDTH: Pixels = px(2. * 2. + 8.);
const MIN_THUMB_SIZE: f32 = 48.;
const THUMB_WIDTH: Pixels = px(6.);
const THUMB_RADIUS: Pixels = Pixels(6. / 2.);
const THUMB_INSET: Pixels = Pixels(2.);
const THUMB_RADIUS: Pixels = px(6. / 2.);
const THUMB_INSET: Pixels = px(2.);
const THUMB_ACTIVE_WIDTH: Pixels = px(8.);
const THUMB_ACTIVE_RADIUS: Pixels = Pixels(8. / 2.);
const THUMB_ACTIVE_INSET: Pixels = Pixels(2.);
const THUMB_ACTIVE_RADIUS: Pixels = px(8. / 2.);
const THUMB_ACTIVE_INSET: Pixels = px(2.);
const FADE_OUT_DURATION: f32 = 3.0;
const FADE_OUT_DELAY: f32 = 2.0;

View file

@ -224,7 +224,7 @@ pub enum Size {
impl Size {
fn as_f32(&self) -> f32 {
match self {
Size::Size(val) => val.0,
Size::Size(val) => val.as_f32(),
Size::XSmall => 0.,
Size::Small => 1.,
Size::Medium => 2.,
@ -301,7 +301,7 @@ impl Size {
/// e.g. `Size::XSmall.max(Size::Small)` will return `Size::XSmall`.
pub fn max(&self, other: Self) -> Self {
match (self, other) {
(Size::Size(a), Size::Size(b)) => Size::Size(px(a.0.min(b.0))),
(Size::Size(a), Size::Size(b)) => Size::Size(px(a.as_f32().min(b.as_f32()))),
(Size::Size(a), _) => Size::Size(*a),
(_, Size::Size(b)) => Size::Size(b),
(a, b) if a.as_f32() < b.as_f32() => *a,
@ -314,7 +314,7 @@ impl Size {
/// e.g. `Size::XSmall.min(Size::Small)` will return `Size::Small`.
pub fn min(&self, other: Self) -> Self {
match (self, other) {
(Size::Size(a), Size::Size(b)) => Size::Size(px(a.0.max(b.0))),
(Size::Size(a), Size::Size(b)) => Size::Size(px(a.as_f32().max(b.as_f32()))),
(Size::Size(a), _) => Size::Size(*a),
(_, Size::Size(b)) => Size::Size(b),
(a, b) if a.as_f32() > b.as_f32() => *a,
@ -694,6 +694,21 @@ pub trait Collapsible {
fn is_collapsed(&self) -> bool;
}
/// A trait for converting `Pixels` to `f32` and `f64`.
pub trait PixelsExt {
fn as_f32(&self) -> f32;
fn as_f64(self) -> f64;
}
impl PixelsExt for Pixels {
fn as_f32(&self) -> f32 {
f32::from(self)
}
fn as_f64(self) -> f64 {
f64::from(self)
}
}
#[cfg(test)]
mod tests {
use gpui::px;

View file

@ -26,7 +26,7 @@ use gpui::{
};
use smallvec::SmallVec;
use crate::{scroll::ScrollHandleOffsetable, AxisExt};
use crate::{scroll::ScrollHandleOffsetable, AxisExt, PixelsExt};
struct VirtualListScrollHandleState {
axis: Axis,
@ -383,7 +383,11 @@ impl Element for VirtualList {
state.content_size = if self.axis.is_horizontal() {
Size {
width: px(state.sizes.iter().map(|size| size.0).sum::<f32>()),
width: px(state
.sizes
.iter()
.map(|size| size.as_f32())
.sum::<f32>()),
height: state
.items_sizes
.get(0)
@ -395,7 +399,11 @@ impl Element for VirtualList {
.items_sizes
.get(0)
.map_or(px(0.), |size| size.width),
height: px(state.sizes.iter().map(|size| size.0).sum::<f32>()),
height: px(state
.sizes
.iter()
.map(|size| size.as_f32())
.sum::<f32>()),
}
};
}
@ -564,7 +572,7 @@ impl Element for VirtualList {
- layout.size_layout.content_size.along(self.axis);
// Do not trigger scrolling if the content is smaller than the container.
if min_scroll_offset.0 >= 0. {
if min_scroll_offset.as_f32() >= 0. {
scroll_offset.x = px(0.);
scroll_offset.y = px(0.);
}

View file

@ -11,6 +11,8 @@ use gpui::{
MouseDownEvent, ParentElement as _, Pixels, Render, Size, Style, Styled as _, Window,
};
use crate::PixelsExt;
pub struct WebView {
focus_handle: FocusHandle,
webview: Rc<wry::WebView>,
@ -176,8 +178,8 @@ impl Element for WebViewElement {
self.view
.set_bounds(Rect {
size: dpi::Size::Logical(LogicalSize {
width: (bounds.size.width.0).into(),
height: (bounds.size.height.0).into(),
width: (bounds.size.width.as_f32()).into(),
height: (bounds.size.height.as_f32()).into(),
}),
position: dpi::Position::Logical(dpi::LogicalPosition::new(
bounds.origin.x.into(),

View file

@ -9,11 +9,11 @@ use gpui::{
use crate::ActiveTheme;
#[cfg(not(target_os = "linux"))]
const SHADOW_SIZE: Pixels = Pixels(0.0);
const SHADOW_SIZE: Pixels = px(0.0);
#[cfg(target_os = "linux")]
const SHADOW_SIZE: Pixels = Pixels(12.0);
const BORDER_SIZE: Pixels = Pixels(1.0);
pub(crate) const BORDER_RADIUS: Pixels = Pixels(0.0);
const SHADOW_SIZE: Pixels = px(12.0);
const BORDER_SIZE: Pixels = px(1.0);
pub(crate) const BORDER_RADIUS: Pixels = px(0.0);
/// Create a new window border.
pub fn window_border() -> WindowBorder {