mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 04:04:25 +00:00
Header parts measure inside a layout-memory boundary: the faces a container measures for its header parts are no content of the body around, so no transcript keeps or checks them; DockGroup's menu button takes its side from the header slot
This commit is contained in:
@@ -518,7 +518,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
) -> Option<std::rc::Rc<dyn Any>> {
|
||||
let props = Arc::clone(&self.props);
|
||||
let header = props.header?;
|
||||
let parts = comp.header_parts(cx);
|
||||
let parts = layout_memory::boundary(cx.ui.ctx(), true, || comp.header_parts(cx));
|
||||
if parts == crate::contract::HeaderParts::NONE {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -250,10 +250,12 @@ impl<'b> BodyHooks<'b> {
|
||||
bcx.close_requested()
|
||||
}
|
||||
|
||||
/// The room the container's own header parts take this pass (`Container::header_parts`).
|
||||
/// The room the container's own header parts take this pass (`Container::header_parts`). The faces it measures
|
||||
/// are a question about the parts, not content of the body around: no transcript keeps or checks them.
|
||||
pub(super) fn header_parts<C: Container>(comp: &C, ui: &Ui, env: &Env, cx: &crate::contract::Cx<'_, C>) -> HeaderParts {
|
||||
let input = crate::contract::steps::MeasureIn { ui, env, proposal: craft_behavior::Proposal::Ideal, room: None };
|
||||
comp.header_parts(&crate::contract::steps::measure_cx::<C>(&input, cx.style, cx.core.resolved, cx.shown.as_deref()))
|
||||
let measure = crate::contract::steps::measure_cx::<C>(&input, cx.style, cx.core.resolved, cx.shown.as_deref());
|
||||
crate::runtime::layout_memory::boundary(ui.ctx(), true, || comp.header_parts(&measure))
|
||||
}
|
||||
|
||||
/// The header's line inside its inset, less the slots of the container's own header parts at its two edges: the
|
||||
|
||||
@@ -312,9 +312,10 @@ impl<P: Clone + Hash + Send + Sync + 'static> Component for DockGroup<'_, P> {
|
||||
let sense = if self.movable { Sense::CLICK | Sense::DRAG | Sense::FOCUS } else { Sense::CLICK | Sense::FOCUS };
|
||||
let _ = cx.header_part(HeaderEdge::End, GRIP, band).sense(sense).focusable();
|
||||
if self.menu_button() {
|
||||
let size = cx.face(Self::menu_face(words.panel_menu.clone()));
|
||||
let end = rest.take_end(size.x).0;
|
||||
let button = Rect::from_min_size(egui::Pos2::new(end.left(), slot.top()), Vec2::new(end.width(), size.y.min(slot.height())));
|
||||
// An icon button is square: its side is the slot's room past the band and the gap.
|
||||
let side = (slot.width() - cx.tokens.size.handle.band_outer - cx.tokens.space.gap.item).max(0.0);
|
||||
let end = rest.take_end(side).0;
|
||||
let button = Rect::from_min_size(egui::Pos2::new(end.left(), slot.top()), Vec2::new(end.width(), side.min(slot.height())));
|
||||
let _ = cx
|
||||
.header_part(HeaderEdge::End, MENU, button)
|
||||
.sense(Sense::CLICK | Sense::FOCUS)
|
||||
|
||||
Reference in New Issue
Block a user