refactor: split every monolithic module into focused submodules

Each source file that had grown beyond a single concern is replaced by an identically-named directory containing focused submodules. `src/event_loop/mod.rs` (878 lines) becomes a directory with clipboard, context_menu, cursor_shape, drag, focus, handlers, invalidation, overlays_reconcile, repeat, run, surface, text_editing, and tooltip. Every widget, input handler, and theme component follows the same split. Public interfaces are unchanged — only the internal file layout moves.
image bumped from 0.25.2 to 0.25.9.
This commit is contained in:
2026-05-15 23:46:56 +02:00
parent 3d237039c6
commit 4aa3480b64
155 changed files with 13832 additions and 13035 deletions
+96
View File
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>
use super::*;
use crate::render::Canvas;
fn make_canvas() -> Canvas { Canvas::new( 800, 600 ) }
#[ test ]
fn new_uses_documented_defaults()
{
let t = Text::new( "hello" );
assert_eq!( t.content, "hello" );
assert_eq!( t.size, 16.0 );
assert_eq!( t.color, Color::WHITE );
assert_eq!( t.align, TextAlign::Left );
}
#[ test ]
fn size_builder_overrides_default()
{
let t = Text::new( "" ).size( 32.0 );
assert_eq!( t.size, 32.0 );
}
#[ test ]
fn color_builder_overrides_default()
{
let t = Text::new( "" ).color( Color::rgb( 1.0, 0.0, 0.0 ) );
assert_eq!( t.color, Color::rgb( 1.0, 0.0, 0.0 ) );
}
#[ test ]
fn align_builder_can_target_each_variant()
{
assert_eq!( Text::new( "" ).align( TextAlign::Left ).align, TextAlign::Left );
assert_eq!( Text::new( "" ).align( TextAlign::Center ).align, TextAlign::Center );
assert_eq!( Text::new( "" ).align( TextAlign::Right ).align, TextAlign::Right );
}
#[ test ]
fn align_center_shorthand_matches_explicit_align()
{
let a = Text::new( "" ).align_center();
let b = Text::new( "" ).align( TextAlign::Center );
assert_eq!( a.align, b.align );
}
#[ test ]
fn preferred_size_returns_non_negative_dimensions()
{
let canvas = make_canvas();
let ( w, h ) = Text::new( "ltk" ).preferred_size( 200.0, &canvas );
assert!( w >= 0.0 );
assert!( h > 0.0, "non-empty text reports a positive line height" );
}
#[ test ]
fn preferred_size_caps_width_at_max_width()
{
// A long string must not exceed the parent-supplied bound — text
// elides at draw time, so the layout pass needs to see at most
// `max_width`.
let canvas = make_canvas();
let long = "the quick brown fox jumps over the lazy dog";
let ( w, _ ) = Text::new( long ).size( 24.0 ).preferred_size( 64.0, &canvas );
assert!( w <= 64.0, "preferred width must be clamped to max_width (got {w})" );
}
#[ test ]
fn preferred_size_height_scales_with_font_size()
{
let canvas = make_canvas();
let ( _, h_small ) = Text::new( "x" ).size( 12.0 ).preferred_size( 200.0, &canvas );
let ( _, h_large ) = Text::new( "x" ).size( 48.0 ).preferred_size( 200.0, &canvas );
assert!( h_large > h_small, "larger font must report taller line height" );
}
#[ test ]
fn empty_content_still_reports_a_line_height()
{
let canvas = make_canvas();
let ( _, h ) = Text::new( "" ).preferred_size( 200.0, &canvas );
// Even an empty string keeps the baseline metrics so a hidden field
// keeps its row height inside a column.
assert!( h > 0.0 );
}
#[ test ]
fn text_align_enum_implements_partial_eq()
{
// Compile-time guard: TextAlign must keep deriving PartialEq so
// downstream theming code can compare alignments.
assert_eq!( TextAlign::Left, TextAlign::Left );
assert_ne!( TextAlign::Left, TextAlign::Right );
}