fix(selection): Checkbox / Radio 命中区恒 48×48(复审 P2-2)
- 无标签时行宽只有状态层的 40dp(A1 的 minimumInteractiveComponentSize 是 48) - ControlGeometry::hit_padding() = (48−40)/2 = 4,view 侧左右各留这段透明内边距 - 单测钉住 40 + 2×4 == 48(checkbox 与 radio 各一遍)
This commit is contained in:
1 parent
c5765c57e7
commit
0c9d4049b3
3 files changed
+28
-5
No files matched your search
@@ -11,7 +11,7 @@
|
|||||||
//! 里面套一个 40 的圆容器,再套 20 的方框(见 `shell` 的模块文档)。
|
//! 里面套一个 40 的圆容器,再套 20 的方框(见 `shell` 的模块文档)。
|
||||||
|
|
||||||
use iced::widget::{container, row, text};
|
use iced::widget::{container, row, text};
|
||||||
use iced::{Alignment, Element, Length};
|
use iced::{Alignment, Element, Length, Padding};
|
||||||
|
|
||||||
use unlucky_design::typography::TypeRole;
|
use unlucky_design::typography::TypeRole;
|
||||||
|
|
||||||
@@ -164,10 +164,17 @@ pub fn checkbox<'a, M: Clone + 'a>(ui: &'a Ui, spec: Checkbox<'a, M>) -> Element
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 命中区 48:方框 20 + 状态层 40 都在里面垂直居中
|
// 命中区 48:方框 20 + 状态层 40 都在里面垂直居中;
|
||||||
|
// 左右各留 `hit_padding` 透明内边距,无标签时命中区也是 48×48(复审 P2-2)
|
||||||
|
let pad = geometry.hit_padding();
|
||||||
let body = container(content)
|
let body = container(content)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.align_y(Alignment::Center);
|
.align_y(Alignment::Center)
|
||||||
|
.padding(Padding {
|
||||||
|
left: pad,
|
||||||
|
right: pad,
|
||||||
|
..Padding::default()
|
||||||
|
});
|
||||||
|
|
||||||
shell::shell(
|
shell::shell(
|
||||||
&source,
|
&source,
|
||||||
|
|||||||
@@ -96,6 +96,15 @@ impl ControlGeometry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 命中区比可见状态层宽出来的部分(左右**各一份**):`(48 − 40) / 2 = 4`。
|
||||||
|
///
|
||||||
|
/// 无标签时行宽只有状态层的 40dp,命中区就少 8dp;A1 的
|
||||||
|
/// `minimumInteractiveComponentSize` 是 **48**,所以 view 侧左右各留这段透明内边距
|
||||||
|
/// (复审 P2-2)。有标签时行宽本来 ≥48,这段内边距不改变结论,只是保持两处口径一致。
|
||||||
|
pub fn hit_padding(&self) -> f32 {
|
||||||
|
(self.hit - self.state_layer) / 2.0
|
||||||
|
}
|
||||||
|
|
||||||
/// 勾形横向端点跨度(20 画布内 0.2→0.8):`[源]` `Checkbox.kt:496-514` 的路径比例。
|
/// 勾形横向端点跨度(20 画布内 0.2→0.8):`[源]` `Checkbox.kt:496-514` 的路径比例。
|
||||||
///
|
///
|
||||||
/// 这是 research/15 §25 明确允许的「组件级常量」(路径比例 0.2/0.4/0.5/0.7/0.8 不进令牌层)。
|
/// 这是 research/15 §25 明确允许的「组件级常量」(路径比例 0.2/0.4/0.5/0.7/0.8 不进令牌层)。
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
//! 内点:独立 10×10 圆容器居中在环里(绘制半径 12/2 − 2/2 = 5,即**直径 10**,§19.2)。
|
//! 内点:独立 10×10 圆容器居中在环里(绘制半径 12/2 − 2/2 = 5,即**直径 10**,§19.2)。
|
||||||
|
|
||||||
use iced::widget::{container, row, text};
|
use iced::widget::{container, row, text};
|
||||||
use iced::{Alignment, Element, Length};
|
use iced::{Alignment, Element, Length, Padding};
|
||||||
|
|
||||||
use unlucky_design::typography::TypeRole;
|
use unlucky_design::typography::TypeRole;
|
||||||
|
|
||||||
@@ -134,9 +134,16 @@ pub fn radio<'a, M: Clone + 'a>(ui: &'a Ui, spec: Radio<'a, M>) -> Element<'a, M
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 命中区 48×48:左右各留 `hit_padding` 透明内边距(无标签时行宽才不是 40;复审 P2-2)
|
||||||
|
let pad = geometry.hit_padding();
|
||||||
let body = container(content)
|
let body = container(content)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.align_y(Alignment::Center);
|
.align_y(Alignment::Center)
|
||||||
|
.padding(Padding {
|
||||||
|
left: pad,
|
||||||
|
right: pad,
|
||||||
|
..Padding::default()
|
||||||
|
});
|
||||||
|
|
||||||
shell::shell(
|
shell::shell(
|
||||||
&source,
|
&source,
|
||||||
|
|||||||
Reference in new issue
Block a user