Add initial element inspector for Zed development (#31315)
Open inspector with `dev: toggle inspector` from command palette or `cmd-alt-i` on mac or `ctrl-alt-i` on linux. https://github.com/user-attachments/assets/54c43034-d40b-414e-ba9b-190bed2e6d2f * Picking of elements via the mouse, with scroll wheel to inspect occluded elements. * Temporary manipulation of the selected element. * Layout info and JSON-based style manipulation for `Div`. * Navigation to code that constructed the element. Big thanks to @as-cii and @maxdeviant for sorting out how to implement the core of an inspector. Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Marshall Bowers <git@maxdeviant.com> Co-authored-by: Federico Dionisi <code@fdionisi.me>
This commit is contained in:
co-authored by
Antonio Scandurra
Marshall Bowers
Federico Dionisi
parent
685933b5c8
commit
ab59982bf7
@@ -1,7 +1,6 @@
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
use gpui::{App, BoxShadow, Hsla, hsla, point, px};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use theme::{ActiveTheme, Appearance};
|
||||
|
||||
/// Today, elevation is primarily used to add shadows to elements, and set the correct background for elements like buttons.
|
||||
@@ -40,14 +39,14 @@ impl Display for ElevationIndex {
|
||||
|
||||
impl ElevationIndex {
|
||||
/// Returns an appropriate shadow for the given elevation index.
|
||||
pub fn shadow(self, cx: &App) -> SmallVec<[BoxShadow; 2]> {
|
||||
pub fn shadow(self, cx: &App) -> Vec<BoxShadow> {
|
||||
let is_light = cx.theme().appearance() == Appearance::Light;
|
||||
|
||||
match self {
|
||||
ElevationIndex::Surface => smallvec![],
|
||||
ElevationIndex::EditorSurface => smallvec![],
|
||||
ElevationIndex::Surface => vec![],
|
||||
ElevationIndex::EditorSurface => vec![],
|
||||
|
||||
ElevationIndex::ElevatedSurface => smallvec![
|
||||
ElevationIndex::ElevatedSurface => vec![
|
||||
BoxShadow {
|
||||
color: hsla(0., 0., 0., 0.12),
|
||||
offset: point(px(0.), px(2.)),
|
||||
@@ -59,10 +58,10 @@ impl ElevationIndex {
|
||||
offset: point(px(1.), px(1.)),
|
||||
blur_radius: px(0.),
|
||||
spread_radius: px(0.),
|
||||
}
|
||||
},
|
||||
],
|
||||
|
||||
ElevationIndex::ModalSurface => smallvec![
|
||||
ElevationIndex::ModalSurface => vec![
|
||||
BoxShadow {
|
||||
color: hsla(0., 0., 0., if is_light { 0.06 } else { 0.12 }),
|
||||
offset: point(px(0.), px(2.)),
|
||||
@@ -89,7 +88,7 @@ impl ElevationIndex {
|
||||
},
|
||||
],
|
||||
|
||||
_ => smallvec![],
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user