mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-24 19:41:51 +01:00
Merge branch 'red/rc-chrome-w5' into area/chrome-fw
This commit is contained in:
commit
718273673e
5 files changed
+16
-6
No files matched your search
@@ -158,7 +158,9 @@ fn a_style_tile_samples_its_parameter_from_the_start_point_outward() {
|
||||
assert!(t(tile, 0.5, 0.5) < t(tile, 0.6, 0.5) && t(tile, 0.6, 0.5) < t(tile, 0.9, 0.5));
|
||||
assert!((t(tile, 0.7, 0.5) - t(tile, 0.5, 0.3)).abs() < 1e-4);
|
||||
}
|
||||
// A corner-ward step along the diagonal is farther in a circle than in a rectangle.
|
||||
assert!(t(circle, 0.7, 0.7) > t(rect, 0.7, 0.7) + 0.05);
|
||||
// Both reach 1 at the farthest corner, so a diagonal step reads the same in both; along an axis the rectangle's
|
||||
// square isoline is nearer the centre than the circle's, so it rises faster there.
|
||||
assert!((t(circle, 0.7, 0.7) - t(rect, 0.7, 0.7)).abs() < 1e-4, "both outlines reach the corner together");
|
||||
assert!(t(rect, 0.9, 0.5) > t(circle, 0.9, 0.5) + 0.05, "along an axis a rectangle rises faster than a circle");
|
||||
assert!((t(rect, 0.7, 0.7) - t(rect, 0.7, 0.5)).abs() < 1e-4, "a rectangle's isoline is square");
|
||||
}
|
||||
@@ -154,7 +154,7 @@ impl EditorHandle {
|
||||
.collect();
|
||||
let text = state.lines.iter().map(|line| line.text).collect::<Vec<_>>().join("\n");
|
||||
let selection = state.selection.or(Some((state.caret_at, state.caret_at)));
|
||||
Some(TextFacts { widget: self.widget, text, masked, editable: !self.read_only, lines, selection })
|
||||
Some(TextFacts { widget: self.widget, text, masked, editable: !self.read_only, disabled: false, lines, selection })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -316,6 +316,7 @@ fn facts<C: Component>(
|
||||
rect: Rect,
|
||||
masked: bool,
|
||||
read_only: bool,
|
||||
enabled: bool,
|
||||
) {
|
||||
if !text_access::exposed(&cx.core.ctx, widget) {
|
||||
state.rows = None;
|
||||
@@ -325,7 +326,7 @@ fn facts<C: Component>(
|
||||
let text = out.layout.full.clone();
|
||||
let selection = adapter::selection(&cx.core.ctx, widget).map(|(caret, anchor)| (rows.pos(&text, anchor), rows.pos(&text, caret)));
|
||||
*cx.core.text_access.borrow_mut() =
|
||||
Some(text_access::TextFacts { widget, text, masked, editable: !read_only, lines: rows.lines.clone(), selection });
|
||||
Some(text_access::TextFacts { widget, text, masked, editable: !read_only, disabled: !enabled, lines: rows.lines.clone(), selection });
|
||||
state.rows = Some(rows);
|
||||
}
|
||||
|
||||
@@ -508,7 +509,7 @@ pub(crate) fn run<C: Component>(
|
||||
if let Some(baseline) = out.baseline {
|
||||
cx.core.paint.borrow_mut().baseline.get_or_insert(baseline);
|
||||
}
|
||||
facts(cx, &mut state, widget, &out, decl.rect, decl.options.mask, read_only);
|
||||
facts(cx, &mut state, widget, &out, decl.rect, decl.options.mask, read_only, enabled);
|
||||
cx.core.text_invalid = state.invalid;
|
||||
cx.core.text_unparsed = decl.options.unparsed.clone().filter(|_| state.invalid);
|
||||
cx.core.escape_to_list = state.completions.open || list_open;
|
||||
|
||||
@@ -43,6 +43,8 @@ pub(crate) struct TextFacts {
|
||||
/// A password: the node carries no value and exposes no runs.
|
||||
pub masked: bool,
|
||||
pub editable: bool,
|
||||
/// The text part is disabled (its component may not be): the owner's node stands for the part and says so.
|
||||
pub disabled: bool,
|
||||
pub lines: Vec<Line>,
|
||||
/// The anchor and focus as a line index and a byte offset in the line.
|
||||
pub selection: Option<(TextPos, TextPos)>,
|
||||
@@ -112,7 +114,7 @@ pub(crate) fn report_text(ctx: &Context, owner: Id, facts: &TextFacts) {
|
||||
Some((anchor_node, anchor_at, focus_node, focus_at))
|
||||
});
|
||||
let value = (!facts.masked).then_some(facts.text.as_str());
|
||||
adapter::write_text(ctx, owner, &TextNode { value, editable: facts.editable, selection });
|
||||
adapter::write_text(ctx, owner, &TextNode { value, editable: facts.editable, disabled: facts.disabled, selection });
|
||||
Service::<Tables>::run(ctx, |tables| tables.0.insert(owner, entries));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ pub(crate) struct TextNode<'a> {
|
||||
/// The text; `None` for a node that exposes none (a masked field).
|
||||
pub value: Option<&'a str>,
|
||||
pub editable: bool,
|
||||
/// The node is disabled.
|
||||
pub disabled: bool,
|
||||
/// The anchor and focus of the selection, `None` while the text has no runs.
|
||||
pub selection: Option<(Id, usize, Id, usize)>,
|
||||
}
|
||||
@@ -113,6 +115,9 @@ pub(crate) fn write_text(ctx: &Context, id: Id, text: &TextNode<'_>) {
|
||||
node.set_value(value.to_owned());
|
||||
}
|
||||
node.add_action(accesskit::Action::SetTextSelection);
|
||||
if text.disabled {
|
||||
node.set_disabled();
|
||||
}
|
||||
if text.editable {
|
||||
node.add_action(accesskit::Action::SetValue);
|
||||
node.add_action(accesskit::Action::ReplaceSelectedText);
|
||||
|
||||
Reference in new issue
Block a user