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>
52 lines
1.6 KiB
Rust
52 lines
1.6 KiB
Rust
use gpui::{
|
|
AnyElement, App, BoxShadow, IntoElement, ParentElement, RenderOnce, Styled, Window, div, hsla,
|
|
point, px,
|
|
};
|
|
use theme::ActiveTheme;
|
|
|
|
use crate::{ElevationIndex, h_flex};
|
|
|
|
use super::ButtonLike;
|
|
|
|
/// /// A button with two parts: a primary action on the left and a secondary action on the right.
|
|
///
|
|
/// The left side is a [`ButtonLike`] with the main action, while the right side can contain
|
|
/// any element (typically a dropdown trigger or similar).
|
|
///
|
|
/// The two sections are visually separated by a divider, but presented as a unified control.
|
|
#[derive(IntoElement)]
|
|
pub struct SplitButton {
|
|
pub left: ButtonLike,
|
|
pub right: AnyElement,
|
|
}
|
|
|
|
impl SplitButton {
|
|
pub fn new(left: ButtonLike, right: AnyElement) -> Self {
|
|
Self { left, right }
|
|
}
|
|
}
|
|
|
|
impl RenderOnce for SplitButton {
|
|
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
|
|
h_flex()
|
|
.rounded_sm()
|
|
.border_1()
|
|
.border_color(cx.theme().colors().text_muted.alpha(0.12))
|
|
.child(div().flex_grow().child(self.left))
|
|
.child(
|
|
div()
|
|
.h_full()
|
|
.w_px()
|
|
.bg(cx.theme().colors().text_muted.alpha(0.16)),
|
|
)
|
|
.child(self.right)
|
|
.bg(ElevationIndex::Surface.on_elevation_bg(cx))
|
|
.shadow(vec![BoxShadow {
|
|
color: hsla(0.0, 0.0, 0.0, 0.16),
|
|
offset: point(px(0.), px(1.)),
|
|
blur_radius: px(0.),
|
|
spread_radius: px(0.),
|
|
}])
|
|
}
|
|
}
|