| el.cursor_s_resize()),
+ ),
+ (
+ "cursor_w_resize",
+ Box::new(|el: Stateful
| el.cursor_w_resize()),
+ ),
+ ];
+
+ Story::container()
+ .flex()
+ .gap_1()
+ .child(Story::title("cursor"))
+ .children(all_cursors.map(|(name, apply_cursor)| {
+ div().gap_1().flex().text_color(gpui::white()).child(
+ div()
+ .flex()
+ .items_center()
+ .justify_center()
+ .id(name)
+ .map(apply_cursor)
+ .w_64()
+ .h_8()
+ .bg(gpui::red())
+ .hover(|style| style.bg(gpui::blue()))
+ .active(|style| style.bg(gpui::green()))
+ .text_sm()
+ .child(Story::label(name)),
+ )
+ }))
+ }
+}
diff --git a/crates/storybook2/src/stories/text.rs b/crates/storybook2/src/stories/text.rs
index 3cb39aa01a..ccd13cb4d8 100644
--- a/crates/storybook2/src/stories/text.rs
+++ b/crates/storybook2/src/stories/text.rs
@@ -1,6 +1,6 @@
use gpui::{
- blue, div, green, red, white, Div, InteractiveText, ParentElement, Render, Styled, StyledText,
- TextRun, View, VisualContext, WindowContext,
+ blue, div, green, red, white, Div, HighlightStyle, InteractiveText, ParentElement, Render,
+ Styled, StyledText, View, VisualContext, WindowContext,
};
use ui::v_stack;
@@ -59,13 +59,11 @@ impl Render for TextStory {
))).child(
InteractiveText::new(
"interactive",
- StyledText::new("Hello world, how is it going?").with_runs(vec![
- cx.text_style().to_run(6),
- TextRun {
+ StyledText::new("Hello world, how is it going?").with_highlights(&cx.text_style(), [
+ (6..11, HighlightStyle {
background_color: Some(green()),
- ..cx.text_style().to_run(5)
- },
- cx.text_style().to_run(18),
+ ..Default::default()
+ }),
]),
)
.on_click(vec![2..4, 1..3, 7..9], |range_ix, _cx| {
diff --git a/crates/storybook2/src/story_selector.rs b/crates/storybook2/src/story_selector.rs
index 4fe76ce878..216762060d 100644
--- a/crates/storybook2/src/story_selector.rs
+++ b/crates/storybook2/src/story_selector.rs
@@ -17,6 +17,7 @@ pub enum ComponentStory {
Button,
Checkbox,
ContextMenu,
+ Cursor,
Disclosure,
Focus,
Icon,
@@ -40,6 +41,7 @@ impl ComponentStory {
Self::Button => cx.build_view(|_| ui::ButtonStory).into(),
Self::Checkbox => cx.build_view(|_| ui::CheckboxStory).into(),
Self::ContextMenu => cx.build_view(|_| ui::ContextMenuStory).into(),
+ Self::Cursor => cx.build_view(|_| crate::stories::CursorStory).into(),
Self::Disclosure => cx.build_view(|_| ui::DisclosureStory).into(),
Self::Focus => FocusStory::view(cx).into(),
Self::Icon => cx.build_view(|_| ui::IconStory).into(),
diff --git a/crates/theme2/src/one_themes.rs b/crates/theme2/src/one_themes.rs
index 2f663618a6..e1fb5f1bed 100644
--- a/crates/theme2/src/one_themes.rs
+++ b/crates/theme2/src/one_themes.rs
@@ -52,13 +52,13 @@ pub(crate) fn one_dark() -> Theme {
element_hover: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
- element_disabled: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
+ element_disabled: SystemColors::default().transparent,
drop_target_background: hsla(220.0 / 360., 8.3 / 100., 21.4 / 100., 1.0),
ghost_element_background: SystemColors::default().transparent,
ghost_element_hover: hsla(225.0 / 360., 11.8 / 100., 26.7 / 100., 1.0),
ghost_element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),
ghost_element_selected: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
- ghost_element_disabled: hsla(224.0 / 360., 11.3 / 100., 26.1 / 100., 1.0),
+ ghost_element_disabled: SystemColors::default().transparent,
text: hsla(221. / 360., 11. / 100., 86. / 100., 1.0),
text_muted: hsla(218.0 / 360., 7. / 100., 46. / 100., 1.0),
text_placeholder: hsla(220.0 / 360., 6.6 / 100., 44.5 / 100., 1.0),
diff --git a/crates/ui2/src/components.rs b/crates/ui2/src/components.rs
index be95fc1fab..17271de48d 100644
--- a/crates/ui2/src/components.rs
+++ b/crates/ui2/src/components.rs
@@ -9,6 +9,8 @@ mod keybinding;
mod label;
mod list;
mod popover;
+mod popover_menu;
+mod right_click_menu;
mod stack;
mod tooltip;
@@ -26,6 +28,8 @@ pub use keybinding::*;
pub use label::*;
pub use list::*;
pub use popover::*;
+pub use popover_menu::*;
+pub use right_click_menu::*;
pub use stack::*;
pub use tooltip::*;
diff --git a/crates/ui2/src/components/button.rs b/crates/ui2/src/components/button.rs
index 085d5f376b..25e88201f4 100644
--- a/crates/ui2/src/components/button.rs
+++ b/crates/ui2/src/components/button.rs
@@ -1,4 +1,5 @@
mod button;
+pub(self) mod button_icon;
mod button_like;
mod icon_button;
diff --git a/crates/ui2/src/components/button/button.rs b/crates/ui2/src/components/button/button.rs
index ce26ee76a5..c1262321ce 100644
--- a/crates/ui2/src/components/button/button.rs
+++ b/crates/ui2/src/components/button/button.rs
@@ -1,13 +1,22 @@
-use gpui::AnyView;
+use gpui::{AnyView, DefiniteLength};
use crate::prelude::*;
-use crate::{ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Label, LineHeightStyle};
+use crate::{
+ ButtonCommon, ButtonLike, ButtonSize, ButtonStyle, Icon, IconSize, Label, LineHeightStyle,
+};
+
+use super::button_icon::ButtonIcon;
#[derive(IntoElement)]
pub struct Button {
base: ButtonLike,
label: SharedString,
label_color: Option
,
+ selected_label: Option,
+ icon: Option,
+ icon_size: Option,
+ icon_color: Option,
+ selected_icon: Option,
}
impl Button {
@@ -16,6 +25,11 @@ impl Button {
base: ButtonLike::new(id),
label: label.into(),
label_color: None,
+ selected_label: None,
+ icon: None,
+ icon_size: None,
+ icon_color: None,
+ selected_icon: None,
}
}
@@ -23,6 +37,31 @@ impl Button {
self.label_color = label_color.into();
self
}
+
+ pub fn selected_label>(mut self, label: impl Into