mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 04:04:25 +00:00
Content inside a label shows before the label scope opens
The size samples in LayersOptionsDialog registered as a second control of their radio's label scope, so the label named the group and left the radio without a name.
This commit is contained in:
@@ -751,7 +751,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
claims: false,
|
||||
trailing: Vec2::ZERO,
|
||||
};
|
||||
body_rect = label::run(ui, env, &input).control;
|
||||
body_rect = label::run(ui, env, &input, None).control;
|
||||
label_input = Some(input);
|
||||
}
|
||||
let label_extra = label_extra_of(regions.body, body_rect);
|
||||
|
||||
@@ -95,7 +95,7 @@ impl LeafPlaced {
|
||||
}
|
||||
}
|
||||
|
||||
/// The label step for one leaf child: measures the child's narrowest width, runs the step in `row`, shows the
|
||||
/// The label step for one leaf child: measures the child's narrowest width, runs the step in `row` with the
|
||||
/// `trailing` content inside the label and returns the rect left for the child. The caller shows the child there and
|
||||
/// then calls `LeafPlaced::finish`.
|
||||
pub(crate) fn leaf<C: Show>(ui: &mut Ui, env: &Env, at: &LeafLabel<'_>, child: &mut C, trailing: Option<Trailing<'_>>) -> LeafPlaced {
|
||||
@@ -120,17 +120,14 @@ pub(crate) fn leaf<C: Show>(ui: &mut Ui, env: &Env, at: &LeafLabel<'_>, child: &
|
||||
claims: C::LABELLED_AFTER,
|
||||
trailing: trailing.as_ref().map_or(Vec2::ZERO, |trailing| trailing.size),
|
||||
};
|
||||
let placed = run(ui, env, &input);
|
||||
// The content shows before the control, so a control that claims the label lies over it and takes its presses.
|
||||
if let Some(trailing) = trailing {
|
||||
(trailing.show)(ui, placed.trailing);
|
||||
}
|
||||
let placed = run(ui, env, &input, trailing);
|
||||
LeafPlaced { control: placed.control, label: placed.label, scope }
|
||||
}
|
||||
|
||||
/// Runs the label step in `ui`: shows the label, opens the label scope and returns where the label and the control
|
||||
/// sit. The caller closes the scope with `scope::finish` after the control ran.
|
||||
pub(crate) fn run(ui: &mut Ui, env: &Env, input: &LabelIn<'_>) -> Placed {
|
||||
/// Runs the label step in `ui`: shows the label and the `trailing` content inside it (`input.trailing` is its size),
|
||||
/// opens the label scope and returns where the label and the control sit. The caller closes the scope with
|
||||
/// `scope::finish` after the control ran.
|
||||
pub(crate) fn run(ui: &mut Ui, env: &Env, input: &LabelIn<'_>, trailing: Option<Trailing<'_>>) -> Placed {
|
||||
let ctx = ui.ctx().clone();
|
||||
let rtl = env.direction.is_rtl();
|
||||
let tokens = &env.tokens;
|
||||
@@ -185,6 +182,11 @@ pub(crate) fn run(ui: &mut Ui, env: &Env, input: &LabelIn<'_>) -> Placed {
|
||||
if let Some(fact) = reset.filter(|_| shown.double_click || shown.dot_click) {
|
||||
keys::route_whole_reset(&ctx, fact.control);
|
||||
}
|
||||
// The content belongs to the label, not to the controls it names, so it shows before the scope opens. It also
|
||||
// shows before the control, so a control that claims the label lies over it and takes its presses.
|
||||
if let Some(trailing) = trailing {
|
||||
(trailing.show)(ui, placed.trailing);
|
||||
}
|
||||
let label =
|
||||
field_label(env, input, label_id_for_scope, placed.label).with_press(shown.press).with_hover(shown.hovered).activated(shown.activated);
|
||||
scope::begin(&ctx, input.scope, input.owner, scope::Kind::Label(label));
|
||||
|
||||
Reference in New Issue
Block a user