mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
ui-contract: edge step in the body's settle, fit rank forwarded, tooltips off and cursor zoom read
This commit is contained in:
@@ -84,6 +84,10 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
comp.props(Internal::new()).theme.clone()
|
||||
}
|
||||
|
||||
fn fit_rank(&self, comp: &C) -> Option<u8> {
|
||||
comp.props(Internal::new()).fit_rank
|
||||
}
|
||||
|
||||
fn memory_owner(&self, comp: &C) -> Option<Id> {
|
||||
comp.props(Internal::new()).owner
|
||||
}
|
||||
@@ -649,6 +653,12 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
crate::contract::overlay::note_layer_closed(&cx.core.ctx, cx.core.id, why);
|
||||
}
|
||||
self.write_open(comp, cx);
|
||||
// A drag held at the body's edge scrolls it, unless a scroller inside it took the step.
|
||||
if let Some(scroll) = scroll_of(comp.props(Internal::new()))
|
||||
&& let Some(to) = self.edge_step_body(scroll, &cx.core.ctx, self.offset)
|
||||
{
|
||||
self.offset = to;
|
||||
}
|
||||
if self.offset != self.offset_at_read || self.anchor != self.anchor_at_read {
|
||||
match comp.scroll() {
|
||||
Some(mut bind) => {
|
||||
|
||||
@@ -515,7 +515,6 @@ pub(crate) trait Erased {
|
||||
fn theme_scope(&self) -> Option<ThemeScope>;
|
||||
/// The rank by which the component leaves a shrinking row whole.
|
||||
fn fit_rank(&self) -> Option<u8> {
|
||||
// PLAN: `typed.rs` (`Erased for Typed`) and `body/hooks.rs` (`ShapeHooks::fit_rank` reading `ContainerProps::fit_rank`) are not in chrome-w5's Files table; their owner must forward the rank, or no body reports one.
|
||||
None
|
||||
}
|
||||
fn memory_owner(&self) -> Option<Id>;
|
||||
|
||||
@@ -214,6 +214,10 @@ impl<C: Component> Erased for Typed<'_, '_, C> {
|
||||
self.hooks.theme_scope(self.comp.get_ref())
|
||||
}
|
||||
|
||||
fn fit_rank(&self) -> Option<u8> {
|
||||
self.hooks.fit_rank(self.comp.get_ref())
|
||||
}
|
||||
|
||||
fn memory_owner(&self) -> Option<Id> {
|
||||
self.hooks.memory_owner(self.comp.get_ref())
|
||||
}
|
||||
|
||||
@@ -222,6 +222,8 @@ struct TipCall<'a> {
|
||||
|
||||
fn show_tip(call: TipCall<'_>) {
|
||||
let TipCall { ctx, owner, id, env, layer: rect_layer, rect, text, rich, spec, wants_input, pressed, subject } = call;
|
||||
// The host turned tooltips off: none shows, and one that was showing goes as it does when the pointer leaves.
|
||||
let wants_input = wants_input && env.tooltips;
|
||||
let state_id = sub(id, "tip_state");
|
||||
let has_content = text.is_some() || rich.is_some();
|
||||
// A component with no tooltip content and no timer or fading layer left from before has nothing to advance.
|
||||
|
||||
@@ -97,8 +97,15 @@ pub(crate) fn image_target(ctx: &Context) -> Option<ImageTarget> {
|
||||
if !shell.cursor_images(native) {
|
||||
return None;
|
||||
}
|
||||
// A host that keeps its cursors at their size ignores the interface zoom.
|
||||
let follows_zoom = crate::runtime::env::Env::of_root(ctx).cursor_follows_zoom;
|
||||
let scale = match (shell.os == Os::Mac, follows_zoom) {
|
||||
(_, false) => 1.0,
|
||||
(true, true) => zoom,
|
||||
(false, true) => pixels_per_point,
|
||||
};
|
||||
Some(ImageTarget {
|
||||
scale: if shell.os == Os::Mac { zoom } else { pixels_per_point },
|
||||
scale,
|
||||
max_side: if shell.os == Os::Linux { MAX_SIDE_LINUX } else { MAX_SIDE },
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user