container: fix equalization, and crash on resize in groups
This commit is contained in:
parent
cea4187fc0
commit
bd3128c516
1 changed files with 49 additions and 6 deletions
|
|
@ -464,10 +464,10 @@ impl ContainerNode {
|
|||
}
|
||||
|
||||
fn perform_layout(self: &Rc<Self>) {
|
||||
self.layout_scheduled.set(false);
|
||||
if self.num_children.get() == 0 {
|
||||
return;
|
||||
}
|
||||
self.layout_scheduled.set(false);
|
||||
if let Some(child) = self.mono_child.get() {
|
||||
self.perform_mono_layout(&child);
|
||||
} else {
|
||||
|
|
@ -1025,7 +1025,24 @@ impl ContainerNode {
|
|||
}
|
||||
|
||||
/// Reset all children's factors to equal (hy3's `equalize`).
|
||||
/// Traverse up to find the nearest ancestor with more than 1 child,
|
||||
/// then equalize that container's children.
|
||||
pub fn equalize(self: &Rc<Self>) {
|
||||
let mut c = self.clone();
|
||||
while c.num_children.get() <= 1 {
|
||||
let parent = match c.toplevel_data.parent.get() {
|
||||
Some(p) => p,
|
||||
None => break,
|
||||
};
|
||||
c = match parent.node_into_container() {
|
||||
Some(p) => p,
|
||||
None => break,
|
||||
};
|
||||
}
|
||||
c.equalize_here();
|
||||
}
|
||||
|
||||
fn equalize_here(self: &Rc<Self>) {
|
||||
let n = self.num_children.get();
|
||||
if n == 0 {
|
||||
return;
|
||||
|
|
@ -1042,10 +1059,25 @@ impl ContainerNode {
|
|||
|
||||
/// Recursively equalize all descendant containers.
|
||||
pub fn equalize_recursive(self: &Rc<Self>) {
|
||||
self.equalize();
|
||||
let mut c = self.clone();
|
||||
while c.num_children.get() <= 1 {
|
||||
let parent = match c.toplevel_data.parent.get() {
|
||||
Some(p) => p,
|
||||
None => break,
|
||||
};
|
||||
c = match parent.node_into_container() {
|
||||
Some(p) => p,
|
||||
None => break,
|
||||
};
|
||||
}
|
||||
c.equalize_recursive_impl();
|
||||
}
|
||||
|
||||
fn equalize_recursive_impl(self: &Rc<Self>) {
|
||||
self.equalize_here();
|
||||
for child in self.children.iter() {
|
||||
if let Some(cn) = child.node.clone().node_into_container() {
|
||||
cn.equalize_recursive();
|
||||
cn.equalize_recursive_impl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2196,17 +2228,24 @@ impl ContainingNode for ContainerNode {
|
|||
self: Rc<Self>,
|
||||
child: &dyn Node,
|
||||
new_x1: Option<i32>,
|
||||
new_y1: Option<i32>,
|
||||
mut new_y1: Option<i32>,
|
||||
new_x2: Option<i32>,
|
||||
new_y2: Option<i32>,
|
||||
) {
|
||||
let theme = &self.state.theme;
|
||||
let bw = theme.sizes.border_width.get();
|
||||
let gap = theme.sizes.gap.get();
|
||||
let mut left_outside = false;
|
||||
let mut right_outside = false;
|
||||
let mut top_outside = false;
|
||||
let mut bottom_outside = false;
|
||||
if self.mono_child.is_some() {
|
||||
// Adjust y1 for the tab bar offset. The window's y1 is offset
|
||||
// from the container's y1 by the tab bar height, so we must
|
||||
// subtract it before propagating upward.
|
||||
let tbh = theme.sizes.tab_bar_height.get();
|
||||
let tbg = theme.sizes.tab_bar_gap.get();
|
||||
new_y1 = new_y1.map(|v| v - tbh - tbg);
|
||||
top_outside = true;
|
||||
right_outside = true;
|
||||
bottom_outside = true;
|
||||
|
|
@ -2241,8 +2280,12 @@ impl ContainingNode for ContainerNode {
|
|||
ci = 1;
|
||||
}
|
||||
let (new_delta, between) = match split {
|
||||
ContainerSplit::Horizontal => (self.abs_x1.get(), bw),
|
||||
ContainerSplit::Vertical => (self.abs_y1.get(), bw),
|
||||
ContainerSplit::Horizontal => {
|
||||
(self.abs_x1.get(), gap.max(bw))
|
||||
}
|
||||
ContainerSplit::Vertical => {
|
||||
(self.abs_y1.get(), gap.max(bw))
|
||||
}
|
||||
};
|
||||
let new_i1 = new_i1.map(|v| v - new_delta);
|
||||
let new_i2 = new_i2.map(|v| v - new_delta);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue