Align feedback button styles with other sidebar buttons

Make feedback button reflect whether you're in a feedback buffer
This commit is contained in:
Mikayla Maki 2023-03-10 16:19:33 -08:00
parent e45104a1c0
commit c8de738972
4 changed files with 41 additions and 19 deletions

View file

@ -2,39 +2,58 @@ use gpui::{elements::*, CursorStyle, Entity, MouseButton, RenderContext, View, V
use settings::Settings; use settings::Settings;
use workspace::{item::ItemHandle, StatusItemView}; use workspace::{item::ItemHandle, StatusItemView};
use crate::feedback_editor::GiveFeedback; use crate::feedback_editor::{FeedbackEditor, GiveFeedback};
pub struct DeployFeedbackButton; pub struct DeployFeedbackButton {
active: bool,
}
impl Entity for DeployFeedbackButton { impl Entity for DeployFeedbackButton {
type Event = (); type Event = ();
} }
impl DeployFeedbackButton {
pub fn new() -> Self {
DeployFeedbackButton { active: false }
}
}
impl View for DeployFeedbackButton { impl View for DeployFeedbackButton {
fn ui_name() -> &'static str { fn ui_name() -> &'static str {
"DeployFeedbackButton" "DeployFeedbackButton"
} }
fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> ElementBox { fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> ElementBox {
let active = self.active;
Stack::new() Stack::new()
.with_child( .with_child(
MouseEventHandler::<Self>::new(0, cx, |state, cx| { MouseEventHandler::<Self>::new(0, cx, |state, cx| {
let theme = &cx.global::<Settings>().theme; let theme = &cx.global::<Settings>().theme;
let style = &theme.workspace.status_bar.feedback.style_for(state, false); let style = &theme
.workspace
.status_bar
.sidebar_buttons
.item
.style_for(state, active);
Svg::new("icons/speech_bubble_12.svg") Svg::new("icons/speech_bubble_12.svg")
.with_color(style.color) .with_color(style.icon_color)
.constrained() .constrained()
.with_width(style.icon_width) .with_width(style.icon_size)
.aligned() .aligned()
.constrained() .constrained()
.with_width(style.button_width) .with_width(style.icon_size)
.with_height(style.button_width) .with_height(style.icon_size)
.contained() .contained()
.with_style(style.container) .with_style(style.container)
.boxed() .boxed()
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, |_, cx| cx.dispatch_action(GiveFeedback)) .on_click(MouseButton::Left, move |_, cx| {
if !active {
cx.dispatch_action(GiveFeedback)
}
})
.boxed(), .boxed(),
) )
.boxed() .boxed()
@ -42,5 +61,15 @@ impl View for DeployFeedbackButton {
} }
impl StatusItemView for DeployFeedbackButton { impl StatusItemView for DeployFeedbackButton {
fn set_active_pane_item(&mut self, _: Option<&dyn ItemHandle>, _: &mut ViewContext<Self>) {} fn set_active_pane_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext<Self>) {
if let Some(item) = item {
if let Some(_) = item.downcast::<FeedbackEditor>() {
self.active = true;
cx.notify();
return;
}
}
self.active = false;
cx.notify();
}
} }

View file

@ -281,7 +281,6 @@ pub struct StatusBar {
pub auto_update_progress_message: TextStyle, pub auto_update_progress_message: TextStyle,
pub auto_update_done_message: TextStyle, pub auto_update_done_message: TextStyle,
pub lsp_status: Interactive<StatusBarLspStatus>, pub lsp_status: Interactive<StatusBarLspStatus>,
pub feedback: Interactive<IconButton>,
pub sidebar_buttons: StatusBarSidebarButtons, pub sidebar_buttons: StatusBarSidebarButtons,
pub diagnostic_summary: Interactive<StatusBarDiagnosticSummary>, pub diagnostic_summary: Interactive<StatusBarDiagnosticSummary>,
pub diagnostic_message: Interactive<ContainedText>, pub diagnostic_message: Interactive<ContainedText>,

View file

@ -339,10 +339,13 @@ pub fn initialize_workspace(
let activity_indicator = let activity_indicator =
activity_indicator::ActivityIndicator::new(workspace, app_state.languages.clone(), cx); activity_indicator::ActivityIndicator::new(workspace, app_state.languages.clone(), cx);
let active_buffer_language = cx.add_view(|_| language_selector::ActiveBufferLanguage::new()); let active_buffer_language = cx.add_view(|_| language_selector::ActiveBufferLanguage::new());
let feedback_button =
cx.add_view(|_| feedback::deploy_feedback_button::DeployFeedbackButton::new());
let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new()); let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
workspace.status_bar().update(cx, |status_bar, cx| { workspace.status_bar().update(cx, |status_bar, cx| {
status_bar.add_left_item(diagnostic_summary, cx); status_bar.add_left_item(diagnostic_summary, cx);
status_bar.add_left_item(activity_indicator, cx); status_bar.add_left_item(activity_indicator, cx);
status_bar.add_right_item(feedback_button, cx);
status_bar.add_right_item(active_buffer_language, cx); status_bar.add_right_item(active_buffer_language, cx);
status_bar.add_right_item(cursor_position, cx); status_bar.add_right_item(cursor_position, cx);
}); });

View file

@ -51,15 +51,6 @@ export default function statusBar(colorScheme: ColorScheme) {
...text(layer, "sans"), ...text(layer, "sans"),
hover: text(layer, "sans", "hovered"), hover: text(layer, "sans", "hovered"),
}, },
feedback: {
margin: { left: 2 },
color: foreground(layer, "variant"),
iconWidth: 14,
buttonWidth: 14,
hover: {
color: foreground(layer, "on"),
},
},
diagnosticSummary: { diagnosticSummary: {
height: 20, height: 20,
iconWidth: 16, iconWidth: 16,