gpui_widgets defect fixes: menu checkmarks, dock ratios, meter orientation, CPU frames, drop-frame timecode
- menu: add runtime set-checked path (MenuItem::set_checked/clear_checked, Menu::set_item_checked recursive, MenuBar::set_item_checked) - dock: Split now stores per-child ratios (sum 1.0) so 3+ panels on one axis keep distinct sizes; resize_split_child adjusts a single boundary, resize_split keeps its two-arg whole-share semantics; one handle per boundary; DockLayoutState VERSION bumped to 2 for the new ratios field - audio_meter: MeterOrientation::Vertical for the 26px transport strip, segments lit bottom to top - viewer: ViewerFrameSource::CpuFrame + set_cpu_frame (BGRA8 RenderImage via the sprite atlas) for platforms without CVPixelBuffer - timeline: TimeDisplay::TimecodeDropFrame (SMPTE drop-frame for NTSC rates, non-drop fallback otherwise) - gpui_widgets: regression test pinning the fractional spacing helpers (py_0p5/py_1p5/py_2p5/py_3p5 already exist; no _0_5 aliases added)
This commit is contained in:
@@ -33,3 +33,48 @@ pub mod spinbox;
|
||||
pub mod theme;
|
||||
pub mod value;
|
||||
pub mod viewer;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gpui::prelude::*;
|
||||
use gpui::{AbsoluteLength, DefiniteLength, div, rems};
|
||||
|
||||
/// Fractional spacing helpers exist on the [`Styled`](gpui::Styled) trait
|
||||
/// (via `gpui_macros::padding_style_methods!` / `margin_style_methods!`),
|
||||
/// named after Tailwind's fractional scale: `0p5`, `1p5`, `2p5`, `3p5`
|
||||
/// (i.e. 0.5/1.5/2.5/3.5 units of 4px = 2/6/10/14px).
|
||||
///
|
||||
/// We deliberately do **not** add `_0_5`-style aliases (`py_0_5`,
|
||||
/// `px_1_5`, ...): every fractional value they would name already exists
|
||||
/// under the established `0p5`/`1p5`/`2p5`/`3p5` convention used
|
||||
/// throughout gpui and gpui_widgets, and a second naming scheme for the
|
||||
/// same helpers would only fragment the API surface. This test pins the
|
||||
/// helpers (and their values) so a future refactor of the style macros
|
||||
/// cannot silently drop them.
|
||||
#[test]
|
||||
fn fractional_spacing_helpers_exist() {
|
||||
let mut padding = div().py_0p5().px_1p5();
|
||||
assert_eq!(
|
||||
padding.style().padding.top,
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Rems(rems(0.125))))
|
||||
);
|
||||
assert_eq!(
|
||||
padding.style().padding.left,
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Rems(rems(0.375))))
|
||||
);
|
||||
assert_eq!(
|
||||
padding.style().padding.right,
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Rems(rems(0.375))))
|
||||
);
|
||||
|
||||
let mut margin = div().my_2p5().pt_3p5();
|
||||
assert_eq!(
|
||||
margin.style().margin.top,
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Rems(rems(0.625))).into())
|
||||
);
|
||||
assert_eq!(
|
||||
margin.style().padding.top,
|
||||
Some(DefiniteLength::Absolute(AbsoluteLength::Rems(rems(0.875))).into())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user