mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 11:15:01 +03:00
fix(desktop): Float the sidebar and isolate journal split clicks
This commit is contained in:
1 parent
207e250fdc
commit
a80af5370e
7 files changed
+352
-67
No files matched your search
@@ -60,14 +60,10 @@ pub(super) fn workspace_header(
|
||||
.h(px(38.0))
|
||||
.flex_shrink(0.0)
|
||||
.child(trigger)
|
||||
.child(
|
||||
button("desktop.sidebar.switch", SIDEBAR_TOGGLE_SVG, 28.0, palette).on_click(
|
||||
cx.listener(|this, _, _, cx| {
|
||||
this.state.sidebar.toggle_open();
|
||||
cx.notify();
|
||||
}),
|
||||
),
|
||||
)
|
||||
.children((!sidebar.hover_floating).then(|| {
|
||||
button("desktop.sidebar.switch", SIDEBAR_TOGGLE_SVG, 28.0, palette)
|
||||
.on_click(cx.listener(|this, _, _, cx| this.toggle_sidebar(cx)))
|
||||
}))
|
||||
}
|
||||
|
||||
fn workspace_card(
|
||||
|
||||
@@ -41,6 +41,7 @@ pub enum SidebarSection {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SidebarState {
|
||||
pub open: bool,
|
||||
pub(crate) hover_floating: bool,
|
||||
pub width: f32,
|
||||
pub scroll_y: f32,
|
||||
pub expanded_sections: BTreeSet<SidebarSection>,
|
||||
@@ -55,6 +56,7 @@ impl Default for SidebarState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
open: true,
|
||||
hover_floating: false,
|
||||
width: 248.0,
|
||||
scroll_y: 0.0,
|
||||
expanded_sections: BTreeSet::from([
|
||||
@@ -83,6 +85,7 @@ impl SidebarState {
|
||||
|
||||
pub fn toggle_open(&mut self) {
|
||||
self.open = !self.open;
|
||||
self.hover_floating = false;
|
||||
self.dismiss_popups();
|
||||
}
|
||||
|
||||
@@ -112,6 +115,7 @@ pub(crate) fn close_drawer(sidebar: &mut SidebarState, window: &Window) {
|
||||
if f32::from(window.viewport_size().width) < DRAWER_BREAKPOINT {
|
||||
sidebar.open = false;
|
||||
}
|
||||
sidebar.hover_floating = false;
|
||||
sidebar.dismiss_popups();
|
||||
}
|
||||
|
||||
@@ -228,9 +232,11 @@ pub(crate) fn render_sidebar(
|
||||
.snapshot("desktop.sidebar", Some("desktop.shell.root"))
|
||||
.h_full()
|
||||
.flex_shrink(0.0)
|
||||
.bg(palette.bg_canvas)
|
||||
.border_r_1()
|
||||
.border_color(palette.border)
|
||||
.when(!sidebar.hover_floating, |el| {
|
||||
el.bg(palette.bg_canvas)
|
||||
.border_r_1()
|
||||
.border_color(palette.border)
|
||||
})
|
||||
.font_family(FONT_SANS)
|
||||
.flex()
|
||||
.flex_col()
|
||||
|
||||
@@ -92,9 +92,13 @@ impl TestShell {
|
||||
}
|
||||
|
||||
fn hover(&self, id: &str) {
|
||||
self.move_pointer(self.center(id));
|
||||
}
|
||||
|
||||
fn move_pointer(&self, position: Point<Pixels>) {
|
||||
self.window
|
||||
.dispatch_input(PlatformInput::MouseMove(MouseMoveEvent {
|
||||
position: self.center(id),
|
||||
position,
|
||||
pressed_button: None,
|
||||
modifiers: Default::default(),
|
||||
}));
|
||||
@@ -305,3 +309,105 @@ fn sidebar_menus_anchor_below_their_triggers_and_dismiss_in_each_layout() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collapsed_sidebar_floats_without_moving_the_pane_and_closes_after_navigation() {
|
||||
for (web, top, collapse) in [
|
||||
(true, 52.0, "desktop.sidebar.switch"),
|
||||
(false, 92.0, "desktop.sidebar.collapse"),
|
||||
] {
|
||||
let app = TestShell::at_width(1280, web);
|
||||
let bounds = |id: &str| {
|
||||
app.shell(|_, window, _| window.frame_snapshot().elements.get(id).map(|el| el.bounds))
|
||||
};
|
||||
let floating = "desktop.sidebar.floating";
|
||||
let toggle = "desktop.topbar.sidebar_toggle";
|
||||
app.click(collapse);
|
||||
let pane = bounds("desktop.pane.0");
|
||||
app.hover(toggle);
|
||||
assert!(bounds(floating).is_none(), "the collapse suppresses hover");
|
||||
app.move_pointer(point(px(100.0), px(20.0)));
|
||||
app.hover(toggle);
|
||||
let panel = bounds(floating).expect("floating sidebar");
|
||||
assert_eq!(
|
||||
(panel.x, panel.y, panel.width, panel.height),
|
||||
(4.0, top, 248.0, 792.0 - top)
|
||||
);
|
||||
assert_eq!(bounds("desktop.pane.0"), pane);
|
||||
assert!(bounds("desktop.sidebar.switch").is_none());
|
||||
|
||||
app.move_pointer(point(px(268.0), px(200.0)));
|
||||
assert!(
|
||||
bounds(floating).is_some(),
|
||||
"the 20px margin keeps the panel open"
|
||||
);
|
||||
app.move_pointer(point(px(269.0), px(200.0)));
|
||||
assert!(bounds(floating).is_none());
|
||||
app.move_pointer(point(px(6.0), px(140.0)));
|
||||
assert!(bounds(floating).is_some(), "the left edge opens the panel");
|
||||
let doc = app.shell(|view, _, _| view.state().store.favorite_docs()[0].id.clone());
|
||||
app.click(&format!("desktop.sidebar.fav.{doc}"));
|
||||
assert!(bounds(floating).is_none());
|
||||
app.shell(|view, _, _| {
|
||||
assert_eq!(
|
||||
view.state.split.active().active_route().doc_id(),
|
||||
Some(doc.as_str())
|
||||
);
|
||||
});
|
||||
|
||||
app.hover(toggle);
|
||||
assert!(bounds(floating).is_some());
|
||||
app.click("desktop.sidebar.all_docs");
|
||||
assert!(bounds(floating).is_none());
|
||||
app.shell(|view, _, _| {
|
||||
assert_eq!(
|
||||
view.state.split.active().active_route(),
|
||||
&crate::split_view::DesktopRoute::AllDocs
|
||||
);
|
||||
});
|
||||
|
||||
app.hover(toggle);
|
||||
app.click(toggle);
|
||||
assert!(bounds(floating).is_none());
|
||||
app.shell(|view, _, _| assert!(view.state.sidebar.open));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn floating_sidebar_keeps_popups_open_and_yields_to_modals_and_narrow_windows() {
|
||||
let app = TestShell::at_width(1280, true);
|
||||
let has =
|
||||
|id: &str| app.shell(|_, window, _| window.frame_snapshot().elements.contains_key(id));
|
||||
let floating = "desktop.sidebar.floating";
|
||||
let toggle = "desktop.topbar.sidebar_toggle";
|
||||
let switcher = "desktop.sidebar.workspace_switcher";
|
||||
app.click("desktop.sidebar.switch");
|
||||
app.move_pointer(point(px(100.0), px(20.0)));
|
||||
app.hover(toggle);
|
||||
app.click(switcher);
|
||||
app.move_pointer(point(px(500.0), px(200.0)));
|
||||
assert!(has(floating) && has("desktop.sidebar.workspace_menu"));
|
||||
app.click(switcher);
|
||||
app.move_pointer(point(px(500.0), px(200.0)));
|
||||
assert!(!has(floating));
|
||||
|
||||
for (trigger, modal) in [
|
||||
("desktop.sidebar.quick_search", "desktop.qs.modal"),
|
||||
("desktop.sidebar.settings", "desktop.settings.modal"),
|
||||
] {
|
||||
app.hover(toggle);
|
||||
app.click(trigger);
|
||||
assert!(has(modal) && !has(floating));
|
||||
app.key("escape");
|
||||
}
|
||||
|
||||
app.hover(toggle);
|
||||
assert!(has(floating));
|
||||
let mut window = app.window.clone();
|
||||
window.resize(size(px(767.0), px(800.0)));
|
||||
app.frame();
|
||||
assert!(!has(floating));
|
||||
app.hover(toggle);
|
||||
app.move_pointer(point(px(6.0), px(140.0)));
|
||||
assert!(!has(floating));
|
||||
}
|
||||
@@ -230,11 +230,14 @@ impl DesktopShellView {
|
||||
pane_idx: usize,
|
||||
width: f32,
|
||||
show_doc_today: bool,
|
||||
split_visible: bool,
|
||||
palette: DesktopPalette,
|
||||
cx: &Context<Self>,
|
||||
) -> impl IntoElement + use<> {
|
||||
// Keep one pixel between the split indicator and the calendar after layout snapping.
|
||||
div()
|
||||
.min_w_0()
|
||||
.pt(px(if split_visible { 2.0 } else { 0.0 }))
|
||||
.overflow_hidden()
|
||||
.child(ui::ViewElement::new(CalendarView {
|
||||
kind: CalendarKind::Week {
|
||||
@@ -844,6 +847,47 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn readonly_journal_split_indicator_focuses_the_right_pane_without_navigation() {
|
||||
let mut state = seeded(false);
|
||||
let yesterday =
|
||||
state
|
||||
.store
|
||||
.create_doc("Yesterday", DocMode::Page, Some(YESTERDAY.into()), 1_000);
|
||||
mark_readonly(&mut state);
|
||||
state.navigate_active_pane(DesktopRoute::Doc(yesterday.clone()));
|
||||
let shell = TestShell::open(state, 1280);
|
||||
shell.state(|state| state.web_chrome = false);
|
||||
shell.split_journal();
|
||||
shell.resize(768, 800);
|
||||
let frame = shell.frame();
|
||||
let pane = frame.elements["desktop.pane.1"].bounds;
|
||||
let dot = frame.elements["desktop.pane.1.topbar.split_indicator"].bounds;
|
||||
assert_eq!((pane.x, pane.width), (508.0, 260.0));
|
||||
let x = dot.x + dot.width / 2.0;
|
||||
assert_eq!((x, dot.y), (638.0, 40.0));
|
||||
|
||||
for start in [0, 1] {
|
||||
for y in [dot.y + dot.height / 2.0, 46.0] {
|
||||
let history = shell.state(|state| {
|
||||
state.split.focus_pane(start);
|
||||
state.split.panes[1].history.clone()
|
||||
});
|
||||
shell.frame();
|
||||
shell.window.simulate_click(point(px(x), px(y)));
|
||||
shell.frame();
|
||||
shell.state(|state| {
|
||||
assert_eq!(state.split.active_pane, 1, "start={start}, y={y}");
|
||||
assert_eq!(
|
||||
state.split.active().active_route().doc_id(),
|
||||
Some(yesterday.as_str())
|
||||
);
|
||||
assert_eq!(state.split.panes[1].history, history);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn journal_header_controls_fit_the_pane_and_keep_actions_available() {
|
||||
for readonly in [false, true] {
|
||||
@@ -947,14 +991,34 @@ mod tests {
|
||||
readonly,
|
||||
&case,
|
||||
);
|
||||
if split_open && folded && pane.width < 400.0 {
|
||||
if split_open {
|
||||
let indicator =
|
||||
frame.elements[&format!("{prefix}.split_indicator")].bounds;
|
||||
let week = frame.elements[&format!("{prefix}.journal_week")].bounds;
|
||||
assert!(
|
||||
indicator.bottom() <= week.y,
|
||||
"split indicator overlaps the week: {case}"
|
||||
);
|
||||
assert_eq!(indicator.height, 6.0, "{case}");
|
||||
let scope = format!("{prefix}.");
|
||||
for (id, element) in &frame.elements {
|
||||
let Some(name) = id.strip_prefix(scope.as_str()) else {
|
||||
continue;
|
||||
};
|
||||
if name.starts_with("day.")
|
||||
|| matches!(
|
||||
name,
|
||||
"journal_week"
|
||||
| "journal_previous"
|
||||
| "journal_next"
|
||||
| "today"
|
||||
)
|
||||
{
|
||||
let bounds = element.bounds;
|
||||
assert!(
|
||||
indicator.right() <= bounds.x
|
||||
|| bounds.right() <= indicator.x
|
||||
|| indicator.bottom() <= bounds.y
|
||||
|| bounds.bottom() <= indicator.y,
|
||||
"{id} overlaps the split indicator: {case}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,104 @@ use crate::{
|
||||
|
||||
use super::DesktopShellView;
|
||||
|
||||
const SIDEBAR_HOVER_MIN_WIDTH: f32 = 768.0;
|
||||
|
||||
impl DesktopShellView {
|
||||
pub(crate) fn toggle_sidebar(&mut self, cx: &mut Context<Self>) {
|
||||
self.state.sidebar.toggle_open();
|
||||
self.sidebar_prevent_hover = !self.state.sidebar.open;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn sidebar_can_float(&self, width: f32) -> bool {
|
||||
width >= SIDEBAR_HOVER_MIN_WIDTH
|
||||
&& !self.state.sidebar.open
|
||||
&& !self.state.quick_search.open
|
||||
&& !matches!(self.state.modal, Some(DesktopModal::Settings))
|
||||
&& !self.state.peek_view.is_open()
|
||||
}
|
||||
|
||||
pub(super) fn update_sidebar_hover_availability(&mut self, width: f32) {
|
||||
if self.state.sidebar.hover_floating && !self.sidebar_can_float(width) {
|
||||
self.state.sidebar.hover_floating = false;
|
||||
self.state.sidebar.dismiss_popups();
|
||||
}
|
||||
if width < SIDEBAR_HOVER_MIN_WIDTH || self.state.sidebar.open {
|
||||
self.sidebar_prevent_hover = false;
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn hover_sidebar(
|
||||
&mut self,
|
||||
event: &MouseMoveEvent,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if event.pressed_button.is_none()
|
||||
&& !window.last_input_was_touch()
|
||||
&& !self.sidebar_prevent_hover
|
||||
&& !self.state.sidebar.hover_floating
|
||||
&& self.sidebar_can_float(window.viewport_size().width.into())
|
||||
{
|
||||
self.state.sidebar.hover_floating = true;
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
fn move_sidebar_pointer(
|
||||
&mut self,
|
||||
event: &MouseMoveEvent,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let position = event.position;
|
||||
if position.x > px(52.0) {
|
||||
self.sidebar_prevent_hover = false;
|
||||
}
|
||||
let sidebar = &mut self.state.sidebar;
|
||||
if sidebar.hover_floating
|
||||
&& !sidebar.workspace_menu_open
|
||||
&& sidebar.popup.is_none()
|
||||
&& position.x > px(sidebar.width + 20.0)
|
||||
{
|
||||
sidebar.hover_floating = false;
|
||||
cx.notify();
|
||||
} else if position.x <= px(6.0) && position.y >= px(52.0) {
|
||||
self.hover_sidebar(event, window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn render_floating_sidebar(
|
||||
&mut self,
|
||||
route: &crate::split_view::DesktopRoute,
|
||||
top: f32,
|
||||
viewport_height: f32,
|
||||
palette: DesktopPalette,
|
||||
cx: &mut Context<Self>,
|
||||
) -> impl IntoElement + use<> {
|
||||
let width = self.state.sidebar.width;
|
||||
let height = (viewport_height - top - 8.0).max(120.0);
|
||||
let panel = self.render_sidebar_panel(route, width, height, palette, cx);
|
||||
div()
|
||||
.id("desktop.sidebar.floating")
|
||||
.snapshot("desktop.sidebar.floating", Some("desktop.shell.root"))
|
||||
.absolute()
|
||||
.left(px(4.0))
|
||||
.top(px(top))
|
||||
.w(px(width))
|
||||
.h(px(height))
|
||||
.rounded(px(6.0))
|
||||
.bg(palette.bg_elevated)
|
||||
.border(px(0.5))
|
||||
.border_color(palette.border)
|
||||
.shadow(crate::theme_shadow(
|
||||
self.state.theme,
|
||||
"--affine-popover-shadow",
|
||||
))
|
||||
.occlude()
|
||||
.child(panel)
|
||||
}
|
||||
|
||||
fn focus_modal(&mut self, focus: &FocusHandle, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.modal_return_focus.is_none() {
|
||||
self.modal_return_focus = window
|
||||
@@ -166,7 +263,7 @@ impl DesktopShellView {
|
||||
self.state
|
||||
.create_new_doc(crate::settings_modal::new_doc_default_mode(&self.state));
|
||||
}
|
||||
("/", false) => self.state.sidebar.toggle_open(),
|
||||
("/", false) => self.toggle_sidebar(cx),
|
||||
("k", false) => {
|
||||
self.open_search(window, cx);
|
||||
window.prevent_default();
|
||||
@@ -326,11 +423,11 @@ pub(super) fn resize_handle(
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn resize_capture(
|
||||
pub(super) fn pointer_capture(
|
||||
active: bool,
|
||||
cx: &Context<DesktopShellView>,
|
||||
) -> impl IntoElement + use<> {
|
||||
let on_move = cx.listener(|this, event: &MouseMoveEvent, _, cx| {
|
||||
let on_move = cx.listener(|this, event: &MouseMoveEvent, window, cx| {
|
||||
if let Some(drag) = this.resize {
|
||||
if event.pressed_button == Some(MouseButton::Left) {
|
||||
drag.apply(event.position.x.into(), this);
|
||||
@@ -339,6 +436,8 @@ pub(super) fn resize_capture(
|
||||
}
|
||||
cx.stop_propagation();
|
||||
cx.notify();
|
||||
} else {
|
||||
this.move_sidebar_pointer(event, window, cx);
|
||||
}
|
||||
});
|
||||
let on_up = cx.listener(|this, event: &MouseUpEvent, _, cx| {
|
||||
|
||||
@@ -17,7 +17,7 @@ pub use local_workspace::{LocalDocStore, LocalWorkspaces, StoredDocs, StoredWork
|
||||
|
||||
use blocksuite_editor::inline_input::Utf16ImeBuffer;
|
||||
pub(crate) use interaction::backdrop;
|
||||
use interaction::{ResizeDrag, ResizeTarget, resize_capture, resize_handle};
|
||||
use interaction::{ResizeDrag, ResizeTarget, pointer_capture, resize_handle};
|
||||
pub(crate) use search_input::search_input_handler;
|
||||
use topbar::{
|
||||
APP_TABS_HEIGHT, HEADER_HEIGHT, HeaderOverlay, HeaderPosition, SPLIT_BREAKPOINT, ThreePaneDrag,
|
||||
@@ -67,6 +67,7 @@ pub struct DesktopShellView {
|
||||
search_input: Utf16ImeBuffer,
|
||||
resize: Option<ResizeDrag>,
|
||||
docked_sidebar_open: Option<bool>,
|
||||
sidebar_prevent_hover: bool,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
connection: Option<connected_workspace::ConnectedWorkspace>,
|
||||
local: Option<local_workspace::LocalBinding>,
|
||||
@@ -98,6 +99,7 @@ impl DesktopShellView {
|
||||
search_input: Utf16ImeBuffer::default(),
|
||||
resize: None,
|
||||
docked_sidebar_open: None,
|
||||
sidebar_prevent_hover: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,6 +382,7 @@ impl Render for DesktopShellView {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
self.update_sidebar_hover_availability(vp_w);
|
||||
let drawer_open = compact && self.state.sidebar.open;
|
||||
let sidebar_w = if self.state.sidebar.open && !compact {
|
||||
self.state.sidebar.width.min(vp_w - 390.0)
|
||||
@@ -591,7 +594,7 @@ impl Render for DesktopShellView {
|
||||
cx,
|
||||
));
|
||||
}
|
||||
root = root.child(resize_capture(self.resize.is_some(), cx));
|
||||
root = root.child(pointer_capture(self.resize.is_some(), cx));
|
||||
|
||||
if inspector_floating && let Some(tab) = self.state.inspector_tab {
|
||||
root = root.child(
|
||||
@@ -628,6 +631,16 @@ impl Render for DesktopShellView {
|
||||
);
|
||||
}
|
||||
|
||||
if self.state.sidebar.hover_floating {
|
||||
root = root.child(self.render_floating_sidebar(
|
||||
&active_route,
|
||||
native_tabs_h + HEADER_HEIGHT,
|
||||
vp_h,
|
||||
palette,
|
||||
cx,
|
||||
));
|
||||
}
|
||||
|
||||
if drawer_open {
|
||||
let sidebar = self.render_sidebar_panel(
|
||||
&active_route,
|
||||
|
||||
@@ -148,11 +148,9 @@ pub(super) fn sidebar_switch(
|
||||
SIDEBAR_TOGGLE_SVG,
|
||||
false,
|
||||
palette,
|
||||
cx.listener(|this, _, _, cx| {
|
||||
this.state.sidebar.toggle_open();
|
||||
cx.notify();
|
||||
}),
|
||||
cx.listener(|this, _, _, cx| this.toggle_sidebar(cx)),
|
||||
)
|
||||
.on_mouse_move(cx.listener(DesktopShellView::hover_sidebar))
|
||||
}
|
||||
|
||||
pub(super) struct HeaderPosition {
|
||||
@@ -248,8 +246,8 @@ pub(super) fn render_detail_header(
|
||||
header = header
|
||||
.child(sidebar_switch("desktop.topbar.sidebar_toggle", palette, cx).w(px(icon_width)));
|
||||
}
|
||||
let close_split = if split_visible {
|
||||
let pane_id = pane.id;
|
||||
let pane_id = pane.id;
|
||||
let split_indicator = split_visible.then(|| {
|
||||
let active = shell.state.split.active_pane == index;
|
||||
let indicator = button(
|
||||
id("split_indicator"),
|
||||
@@ -269,11 +267,12 @@ pub(super) fn render_detail_header(
|
||||
}),
|
||||
)
|
||||
.w(px(36.0))
|
||||
.h(px(if tight_split_journal && first && last {
|
||||
.h(px(if journal || route == &DesktopRoute::Journals {
|
||||
6.0
|
||||
} else {
|
||||
12.0
|
||||
}))
|
||||
.occlude()
|
||||
.gap(px(3.0))
|
||||
.children((0..3).map(|_| {
|
||||
div().w(px(3.0)).h(px(3.0)).rounded(px(1.5)).bg(if active {
|
||||
@@ -282,42 +281,38 @@ pub(super) fn render_detail_header(
|
||||
palette.border_strong
|
||||
})
|
||||
}));
|
||||
header = header.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.right(px(0.0))
|
||||
.flex()
|
||||
.justify_center()
|
||||
.child(indicator),
|
||||
);
|
||||
Some(
|
||||
icon_button(
|
||||
id("close_split"),
|
||||
CLOSE_ICON_SVG,
|
||||
false,
|
||||
palette,
|
||||
cx.listener(move |this, _, window, cx| {
|
||||
if let Some(index) = this
|
||||
.state
|
||||
.split
|
||||
.panes
|
||||
.iter()
|
||||
.position(|pane| pane.id == pane_id)
|
||||
{
|
||||
this.sync_editors(cx);
|
||||
this.state.split.close_pane(index);
|
||||
window.focus(&this.focus_handle, cx);
|
||||
cx.notify();
|
||||
}
|
||||
}),
|
||||
)
|
||||
.w(px(icon_width)),
|
||||
div()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.right(px(0.0))
|
||||
.flex()
|
||||
.justify_center()
|
||||
.child(indicator)
|
||||
});
|
||||
let close_split = split_visible.then(|| {
|
||||
icon_button(
|
||||
id("close_split"),
|
||||
CLOSE_ICON_SVG,
|
||||
false,
|
||||
palette,
|
||||
cx.listener(move |this, _, window, cx| {
|
||||
if let Some(index) = this
|
||||
.state
|
||||
.split
|
||||
.panes
|
||||
.iter()
|
||||
.position(|pane| pane.id == pane_id)
|
||||
{
|
||||
this.sync_editors(cx);
|
||||
this.state.split.close_pane(index);
|
||||
window.focus(&this.focus_handle, cx);
|
||||
cx.notify();
|
||||
}
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.w(px(icon_width))
|
||||
});
|
||||
let title_label = |name: String| {
|
||||
div()
|
||||
.truncate()
|
||||
@@ -367,6 +362,7 @@ pub(super) fn render_detail_header(
|
||||
index,
|
||||
remaining - badge_width,
|
||||
false,
|
||||
split_visible,
|
||||
palette,
|
||||
cx,
|
||||
),
|
||||
@@ -380,7 +376,8 @@ pub(super) fn render_detail_header(
|
||||
return header
|
||||
.child(content)
|
||||
.children(inspector_toggle)
|
||||
.children(close_split);
|
||||
.children(close_split)
|
||||
.children(split_indicator);
|
||||
};
|
||||
let share_width = 72.0;
|
||||
let mode_button_width = if tight_split_journal {
|
||||
@@ -491,6 +488,7 @@ pub(super) fn render_detail_header(
|
||||
index,
|
||||
calendar_width,
|
||||
!hide_doc_actions,
|
||||
split_visible,
|
||||
palette,
|
||||
cx,
|
||||
),
|
||||
@@ -569,7 +567,10 @@ pub(super) fn render_detail_header(
|
||||
}),
|
||||
));
|
||||
}
|
||||
header.children(inspector_toggle).children(close_split)
|
||||
header
|
||||
.children(inspector_toggle)
|
||||
.children(close_split)
|
||||
.children(split_indicator)
|
||||
}
|
||||
|
||||
fn share_button(
|
||||
|
||||
Reference in new issue
Block a user