debugger: Make historic snapshot button a dropdown menu (#44307)
This allows users to select any snapshot in the debugger history feature and go back to the active session snapshot. We also change variable names to use hsitoric snapshot instead of history and move the snapshot icon to the back of the debugger top control strip. https://github.com/user-attachments/assets/805de8d0-30c1-4719-8af7-2d47e1df1da4 Release Notes: - N/A Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
co-authored by
Anthony Eid
parent
4577e1bf8f
commit
ef76f07b1e
@@ -4,7 +4,7 @@ use gpui::{
|
||||
};
|
||||
use theme::ActiveTheme;
|
||||
|
||||
use crate::{ElevationIndex, h_flex};
|
||||
use crate::{ElevationIndex, IconButton, h_flex};
|
||||
|
||||
use super::ButtonLike;
|
||||
|
||||
@@ -15,6 +15,23 @@ pub enum SplitButtonStyle {
|
||||
Transparent,
|
||||
}
|
||||
|
||||
pub enum SplitButtonKind {
|
||||
ButtonLike(ButtonLike),
|
||||
IconButton(IconButton),
|
||||
}
|
||||
|
||||
impl From<IconButton> for SplitButtonKind {
|
||||
fn from(icon_button: IconButton) -> Self {
|
||||
Self::IconButton(icon_button)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ButtonLike> for SplitButtonKind {
|
||||
fn from(button_like: ButtonLike) -> Self {
|
||||
Self::ButtonLike(button_like)
|
||||
}
|
||||
}
|
||||
|
||||
/// /// 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
|
||||
@@ -23,15 +40,15 @@ pub enum SplitButtonStyle {
|
||||
/// 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,
|
||||
left: SplitButtonKind,
|
||||
right: AnyElement,
|
||||
style: SplitButtonStyle,
|
||||
}
|
||||
|
||||
impl SplitButton {
|
||||
pub fn new(left: ButtonLike, right: AnyElement) -> Self {
|
||||
pub fn new(left: impl Into<SplitButtonKind>, right: AnyElement) -> Self {
|
||||
Self {
|
||||
left,
|
||||
left: left.into(),
|
||||
right,
|
||||
style: SplitButtonStyle::Filled,
|
||||
}
|
||||
@@ -56,7 +73,10 @@ impl RenderOnce for SplitButton {
|
||||
this.border_1()
|
||||
.border_color(cx.theme().colors().border.opacity(0.8))
|
||||
})
|
||||
.child(div().flex_grow().child(self.left))
|
||||
.child(div().flex_grow().child(match self.left {
|
||||
SplitButtonKind::ButtonLike(button) => button.into_any_element(),
|
||||
SplitButtonKind::IconButton(icon) => icon.into_any_element(),
|
||||
}))
|
||||
.child(
|
||||
div()
|
||||
.h_full()
|
||||
|
||||
Reference in New Issue
Block a user