Render diagnostics view and such a bit more
This commit is contained in:
parent
c6d22af416
commit
967ef9d414
9 changed files with 100 additions and 127 deletions
|
@ -14,50 +14,35 @@ impl Render for ToolbarControls {
|
|||
type Element = Div<Self>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div()
|
||||
.h_flex()
|
||||
.child(IconButton::new("toggle-warnings", Icon::Warning).on_click(|view, cx| todo!()))
|
||||
let include_warnings = self
|
||||
.editor
|
||||
.as_ref()
|
||||
.and_then(|editor| editor.upgrade())
|
||||
.map(|editor| editor.read(cx).include_warnings)
|
||||
.unwrap_or(false);
|
||||
|
||||
let tooltip = if include_warnings {
|
||||
"Exclude Warnings"
|
||||
} else {
|
||||
"Include Warnings"
|
||||
};
|
||||
|
||||
div().child(
|
||||
IconButton::new("toggle-warnings", Icon::ExclamationTriangle)
|
||||
.tooltip(tooltip)
|
||||
.on_click(|this: &mut Self, cx| {
|
||||
if let Some(editor) = this.editor.as_ref().and_then(|editor| editor.upgrade()) {
|
||||
editor.update(cx, |editor, cx| {
|
||||
editor.toggle_warnings(&Default::default(), cx);
|
||||
});
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl EventEmitter<ToolbarItemEvent> for ToolbarControls {}
|
||||
|
||||
// impl View for ToolbarControls {
|
||||
// fn ui_name() -> &'static str {
|
||||
// "ToolbarControls"
|
||||
// }
|
||||
|
||||
// fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
// let include_warnings = self
|
||||
// .editor
|
||||
// .as_ref()
|
||||
// .and_then(|editor| editor.upgrade(cx))
|
||||
// .map(|editor| editor.read(cx).include_warnings)
|
||||
// .unwrap_or(false);
|
||||
// let tooltip = if include_warnings {
|
||||
// "Exclude Warnings".into()
|
||||
// } else {
|
||||
// "Include Warnings".into()
|
||||
// };
|
||||
// Flex::row()
|
||||
// .with_child(render_toggle_button(
|
||||
// 0,
|
||||
// "icons/warning.svg",
|
||||
// include_warnings,
|
||||
// (tooltip, Some(Box::new(ToggleWarnings))),
|
||||
// cx,
|
||||
// move |this, cx| {
|
||||
// if let Some(editor) = this.editor.and_then(|editor| editor.upgrade(cx)) {
|
||||
// editor.update(cx, |editor, cx| {
|
||||
// editor.toggle_warnings(&Default::default(), cx)
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// ))
|
||||
// .into_any()
|
||||
// }
|
||||
// }
|
||||
|
||||
impl ToolbarItemView for ToolbarControls {
|
||||
fn set_active_pane_item(
|
||||
&mut self,
|
||||
|
@ -82,42 +67,3 @@ impl ToolbarControls {
|
|||
ToolbarControls { editor: None }
|
||||
}
|
||||
}
|
||||
|
||||
// fn render_toggle_button<
|
||||
// F: 'static + Fn(&mut ToolbarControls, &mut EventContext<ToolbarControls>),
|
||||
// >(
|
||||
// index: usize,
|
||||
// icon: &'static str,
|
||||
// toggled: bool,
|
||||
// tooltip: (String, Option<Box<dyn Action>>),
|
||||
// cx: &mut ViewContext<ToolbarControls>,
|
||||
// on_click: F,
|
||||
// ) -> AnyElement<ToolbarControls> {
|
||||
// enum Button {}
|
||||
|
||||
// let theme = theme::current(cx);
|
||||
// let (tooltip_text, action) = tooltip;
|
||||
|
||||
// MouseEventHandler::new::<Button, _>(index, cx, |mouse_state, _| {
|
||||
// let style = theme
|
||||
// .workspace
|
||||
// .toolbar
|
||||
// .toggleable_tool
|
||||
// .in_state(toggled)
|
||||
// .style_for(mouse_state);
|
||||
// Svg::new(icon)
|
||||
// .with_color(style.color)
|
||||
// .constrained()
|
||||
// .with_width(style.icon_width)
|
||||
// .aligned()
|
||||
// .constrained()
|
||||
// .with_width(style.button_width)
|
||||
// .with_height(style.button_width)
|
||||
// .contained()
|
||||
// .with_style(style.container)
|
||||
// })
|
||||
// .with_cursor_style(CursorStyle::PointingHand)
|
||||
// .on_click(MouseButton::Left, move |_, view, cx| on_click(view, cx))
|
||||
// .with_tooltip::<Button>(index, tooltip_text, action, theme.tooltip.clone(), cx)
|
||||
// .into_any_named("quick action bar button")
|
||||
// }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue