fix split bug on single windows and elide titles
This commit is contained in:
parent
7f71a6556b
commit
c555593ae2
8 changed files with 207 additions and 145 deletions
|
|
@ -937,14 +937,29 @@ impl ContainerNode {
|
|||
.persistent
|
||||
.scale
|
||||
.get();
|
||||
let old_textures: AHashMap<_, _> = self
|
||||
.tab_bar
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.map(|bar| {
|
||||
bar.entries
|
||||
.iter()
|
||||
.map(|entry| (entry.child_id, entry.title_texture.clone()))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let mut bar = TabBar::new(height, render_scale);
|
||||
for child in self.children.iter() {
|
||||
let child_id = child.node.node_id();
|
||||
let title = self.get_child_tab_title(&child, override_id, override_title);
|
||||
let title_texture = old_textures
|
||||
.get(&child_id)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| Rc::new(RefCell::new(None)));
|
||||
bar.entries.push(TabBarEntry {
|
||||
child_id,
|
||||
title,
|
||||
title_texture: Rc::new(RefCell::new(None)),
|
||||
title_texture,
|
||||
active: child_id == active_id,
|
||||
attention_requested: child.attention_requested.get(),
|
||||
x: Cell::new(0),
|
||||
|
|
@ -964,10 +979,27 @@ impl ContainerNode {
|
|||
let Some(focused) = self.focus_history.last() else {
|
||||
return;
|
||||
};
|
||||
if self.num_children.get() <= 1 {
|
||||
let focused_node = focused.node.clone();
|
||||
let focused_active = focused_node.tl_data().active();
|
||||
if self.num_children.get() == 1 {
|
||||
let sub = ContainerNode::new(
|
||||
&self.state,
|
||||
&self.workspace.get(),
|
||||
focused_node.clone(),
|
||||
split,
|
||||
);
|
||||
let sub_id = sub.node_id();
|
||||
if ephemeral {
|
||||
sub.ephemeral.set(Ephemeral::On);
|
||||
}
|
||||
self.clone().cnode_replace_child(&*focused_node, sub);
|
||||
if focused_active
|
||||
&& let Some(group) = self.child_nodes.borrow().get(&sub_id).map(|n| n.to_ref())
|
||||
{
|
||||
self.update_child_active(&group, true, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let focused_node = focused.node.clone();
|
||||
// Record the sibling that comes AFTER the focused child so we can
|
||||
// insert the new group at the same position.
|
||||
let next_sibling: Option<Rc<dyn ToplevelNode>> = {
|
||||
|
|
@ -1774,6 +1806,7 @@ impl ContainerNode {
|
|||
e.title.clone(),
|
||||
TabBar::entry_colors(&self.state, e),
|
||||
e.title_texture.clone(),
|
||||
e.width.get(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
|
@ -1794,12 +1827,24 @@ impl ContainerNode {
|
|||
texture_height = (bar_height as f64 * s).round() as _;
|
||||
}
|
||||
let mut texture_refs = Vec::new();
|
||||
for (title, (_, _, text_color), title_texture) in &entries {
|
||||
let text_padding = self.state.theme.sizes.tab_bar_text_padding.get();
|
||||
let border_width = self.state.theme.sizes.tab_bar_border_width.get();
|
||||
for (title, (_, _, text_color), title_texture, tab_width) in &entries {
|
||||
let max_width = (*tab_width - 2 * (text_padding + border_width)).max(0);
|
||||
let max_width = if let Some(s) = scale {
|
||||
(max_width as f64 * s).round() as i32
|
||||
} else {
|
||||
max_width
|
||||
};
|
||||
if max_width <= 0 {
|
||||
continue;
|
||||
}
|
||||
let mut tex_ref = title_texture.borrow_mut();
|
||||
let tex = tex_ref.get_or_insert_with(|| TextTexture::new(&self.state, &ctx));
|
||||
tex.schedule_render_fitting(
|
||||
tex.schedule_render_fitting_or_ellipsized(
|
||||
on_completed.clone(),
|
||||
Some(texture_height),
|
||||
max_width,
|
||||
&font,
|
||||
title,
|
||||
*text_color,
|
||||
|
|
@ -2465,6 +2510,7 @@ impl ToplevelNodeBase for ContainerNode {
|
|||
let padding = self.state.theme.sizes.tab_bar_padding.get();
|
||||
bar.layout_entries(rect.width(), padding);
|
||||
}
|
||||
self.schedule_update_tab_textures();
|
||||
}
|
||||
// log::info!("tl_change_extents");
|
||||
self.perform_layout();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue