tweak drop target overlay color and make stack fully constraint children by the first child

's size
This commit is contained in:
K Simmons 2022-10-24 23:47:43 -07:00
parent aed085b168
commit 113b7f6f97
3 changed files with 14 additions and 5 deletions

View file

@ -7,6 +7,8 @@ use crate::{
DebugContext, Element, ElementBox, LayoutContext, PaintContext, SizeConstraint, DebugContext, Element, ElementBox, LayoutContext, PaintContext, SizeConstraint,
}; };
/// Element which renders it's children in a stack on top of each other.
/// The first child determines the size of the others.
#[derive(Default)] #[derive(Default)]
pub struct Stack { pub struct Stack {
children: Vec<ElementBox>, children: Vec<ElementBox>,
@ -28,10 +30,16 @@ impl Element for Stack {
cx: &mut LayoutContext, cx: &mut LayoutContext,
) -> (Vector2F, Self::LayoutState) { ) -> (Vector2F, Self::LayoutState) {
let mut size = constraint.min; let mut size = constraint.min;
for child in &mut self.children { let mut children = self.children.iter_mut();
size = size.max(child.layout(constraint, cx)); if let Some(bottom_child) = children.next() {
constraint.min = size; size = bottom_child.layout(constraint, cx);
constraint = SizeConstraint::strict(size);
} }
for child in children {
child.layout(constraint, cx);
}
(size, ()) (size, ())
} }

View file

@ -126,6 +126,7 @@ pub struct OpenSharedScreen {
pub peer_id: PeerId, pub peer_id: PeerId,
} }
#[derive(Clone, PartialEq)]
pub struct SplitWithItem { pub struct SplitWithItem {
from: WeakViewHandle<Pane>, from: WeakViewHandle<Pane>,
pane_to_split: WeakViewHandle<Pane>, pane_to_split: WeakViewHandle<Pane>,

View file

@ -228,8 +228,8 @@ export default function workspace(colorScheme: ColorScheme) {
}, },
}, },
dropTargetOverlayColor: withOpacity( dropTargetOverlayColor: withOpacity(
foreground(layer), foreground(layer, "variant"),
0.6 0.5
), ),
}; };
} }