- Toolbar: 2 px gaps and 3 px dividers instead of 3 px and 7 px, and the size estimate now matches the measured layout exactly. On a 900 px screen the buttons are back to 30 px despite the new view-only button. - Text tool: a new field starts three letters wide and grows with the longest line up to the wrap width at the page edge. - INK_NOTES_DEBUG_FLING now confirms it is active and logs every finger lift, including touches ignored because the pen is near. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c38bfdd9b1
commit
819bc7d223
3 files changed
+56
-8
No files matched your search
+27
@@ -151,6 +151,20 @@ impl TextBox {
|
||||
glam::Vec2::new(self.wrap_width.max(self.size), self.layout().height())
|
||||
}
|
||||
|
||||
/// Width of the field while it is being edited: as wide as the longest line plus room for
|
||||
/// the next character, at most the wrap width, so a new field starts short (Issue #34).
|
||||
pub fn edit_width(&self) -> f32 {
|
||||
let widest = self
|
||||
.layout()
|
||||
.lines
|
||||
.iter()
|
||||
.map(|line| line.width)
|
||||
.fold(0.0, f32::max);
|
||||
(widest + self.size)
|
||||
.max(3.0 * self.size)
|
||||
.min(self.wrap_width.max(self.size))
|
||||
}
|
||||
|
||||
/// Setzt den Text mit Zeilenumbruch an Leerzeichen; zu lange Wörter werden zeichenweise
|
||||
/// umbrochen, Zeilenumbrüche im Text bleiben erhalten.
|
||||
pub fn layout(&self) -> TextLayout {
|
||||
@@ -409,6 +423,19 @@ mod tests {
|
||||
TextBox::new(content.to_string(), 50.0, TextFont::Sans, wrap_width)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edit_width_grows_with_the_text() {
|
||||
let empty = sample("", 1500.0);
|
||||
assert!((empty.edit_width() - 150.0).abs() < 1e-3);
|
||||
let short = sample("Hallo", 1500.0);
|
||||
let longer = sample("Hallo Welt, wie geht es", 1500.0);
|
||||
assert!(short.edit_width() < longer.edit_width());
|
||||
assert!(longer.edit_width() < 1500.0);
|
||||
// Long text wraps at the page edge and fills the full width
|
||||
let long = sample(&"Wort ".repeat(100), 1500.0);
|
||||
assert!((long.edit_width() - 1500.0).abs() < 1e-3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fonts_load() {
|
||||
for font in [TextFont::Sans, TextFont::Mono] {
|
||||
|
||||
Reference in new issue
Block a user