Button2 – Part1 (#3420)
## TODO - [x] Remove `InteractionState` - [ ] `Selectable` should use `Selection` instead of a boolean - [x] Clean out ui2 prelude - [ ] Build out button2 button types - [ ] Port old buttons Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
co-authored by
Marshall Bowers
parent
5d59108b97
commit
a8bf0834e6
@@ -7,8 +7,8 @@ use gpui::{
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use theme2::ActiveTheme;
|
||||
use ui::{h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Tooltip};
|
||||
use ui::prelude::*;
|
||||
use ui::{h_stack, menu_handle, ContextMenu, IconButton, Tooltip};
|
||||
|
||||
pub enum PanelEvent {
|
||||
ChangePosition,
|
||||
@@ -686,22 +686,26 @@ impl Render for PanelButtons {
|
||||
let name = entry.panel.persistent_name();
|
||||
let panel = entry.panel.clone();
|
||||
|
||||
let mut button: IconButton = if i == active_index && is_open {
|
||||
let is_active_button = i == active_index && is_open;
|
||||
|
||||
let (action, tooltip) = if is_active_button {
|
||||
let action = dock.toggle_action();
|
||||
|
||||
let tooltip: SharedString =
|
||||
format!("Close {} dock", dock.position.to_label()).into();
|
||||
IconButton::new(name, icon)
|
||||
.state(InteractionState::Active)
|
||||
.action(action.boxed_clone())
|
||||
.tooltip(move |cx| Tooltip::for_action(tooltip.clone(), &*action, cx))
|
||||
|
||||
(action, tooltip)
|
||||
} else {
|
||||
let action = entry.panel.toggle_action(cx);
|
||||
|
||||
IconButton::new(name, icon)
|
||||
.action(action.boxed_clone())
|
||||
.tooltip(move |cx| Tooltip::for_action(name, &*action, cx))
|
||||
(action, name.into())
|
||||
};
|
||||
|
||||
let button = IconButton::new(name, icon)
|
||||
.selected(is_active_button)
|
||||
.action(action.boxed_clone())
|
||||
.tooltip(move |cx| Tooltip::for_action(tooltip.clone(), &*action, cx));
|
||||
|
||||
Some(
|
||||
menu_handle(name)
|
||||
.menu(move |cx| {
|
||||
|
||||
@@ -1482,18 +1482,14 @@ impl Pane {
|
||||
.gap_px()
|
||||
.child(
|
||||
div().border().border_color(gpui::red()).child(
|
||||
IconButton::new("navigate_backward", Icon::ArrowLeft).state(
|
||||
InteractionState::Enabled
|
||||
.if_enabled(self.can_navigate_backward()),
|
||||
),
|
||||
IconButton::new("navigate_backward", Icon::ArrowLeft)
|
||||
.disabled(!self.can_navigate_backward()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div().border().border_color(gpui::red()).child(
|
||||
IconButton::new("navigate_forward", Icon::ArrowRight).state(
|
||||
InteractionState::Enabled
|
||||
.if_enabled(self.can_navigate_forward()),
|
||||
),
|
||||
IconButton::new("navigate_forward", Icon::ArrowRight)
|
||||
.disabled(!self.can_navigate_forward()),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -5,7 +5,7 @@ use gpui::{
|
||||
div, AnyView, Div, IntoElement, ParentElement, Render, Styled, Subscription, View, ViewContext,
|
||||
WindowContext,
|
||||
};
|
||||
use theme2::ActiveTheme;
|
||||
use ui::prelude::*;
|
||||
use ui::{h_stack, Button, Icon, IconButton};
|
||||
use util::ResultExt;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use gpui::{
|
||||
div, AnyView, Div, Entity, EntityId, EventEmitter, ParentElement as _, Render, Styled, View,
|
||||
ViewContext, WindowContext,
|
||||
};
|
||||
use theme2::ActiveTheme;
|
||||
use ui::prelude::*;
|
||||
use ui::{h_stack, v_stack, Button, Color, Icon, IconButton, Label};
|
||||
|
||||
pub enum ToolbarItemEvent {
|
||||
|
||||
Reference in New Issue
Block a user