Skip to main content

ControlGeometry

Struct ControlGeometry 

Source
pub struct ControlGeometry {
Show 17 fields pub indicator_size: f32, pub border_width: f32, pub label_gap: f32, pub focus_ring_width: f32, pub focus_ring_offset: f32, pub indicator_radius: f32, pub button_height_sm: f32, pub button_height_md: f32, pub button_height_lg: f32, pub button_padding_h: f32, pub button_border_width: f32, pub switch_width: f32, pub switch_height: f32, pub switch_thumb: f32, pub switch_thumb_inset: f32, pub slider_track_height: f32, pub slider_thumb_size: f32,
}
Expand description

表单控件的几何令牌(Checkbox / Radio 的指示器尺寸、描边、焦点环)。

与 ControlStyle(只管颜色)分开,是为了把两种来源写清楚:

  • border_width / focus_ring_* / label_gap 来自 token(--border-width、 --focus-outline-width、--focus-outline-offset、--spacing-2),改 token 就该跟着变;
  • indicator_size 是 Astryx 组件 CSS 里的常量(Checkbox / Radio 指示器实测 24×24), Astryx 自己也没有为它设 token,所以这里是有出处的常量,不伪装成 token。 出处与测量方式见 crates/mgui-core/src/theme/tokens.rs。

Fields§

§indicator_size: f32

Checkbox / Radio 指示器边长,见 MGUI_INDICATOR_SIZE(Astryx 原值 24,mgui 取 18)。

§border_width: f32

指示器描边宽度(--border-width)。

§label_gap: f32

指示器与标签的间距(--spacing-2)。

§focus_ring_width: f32

焦点环线宽(--focus-outline-width)。

§focus_ring_offset: f32

焦点环与控件之间的间隙(--focus-outline-offset)。

§indicator_radius: f32

指示器圆角:Checkbox 用 --radius-inner;Radio 画成正圆(边长一半)。

§button_height_sm: f32

按钮三档高度(token 驱动:--size-element-sm/md/lg,Astryx 实测 Button/IconButton 就是按档取)。

§button_height_md: f32§button_height_lg: f32§button_padding_h: f32

按钮水平内距(--spacing-3,Astryx Button 实测 12px)。

§button_border_width: f32

按钮描边宽度(--border-width;以前组件里写死 1.5)。

§switch_width: f32

Toggle 轨道尺寸与滑块(Astryx 组件 CSS 实测 40×24、滑块 20、内缩 2)。

§switch_height: f32§switch_thumb: f32§switch_thumb_inset: f32§slider_track_height: f32

Slider 轨道粗细与滑块边长(Astryx 实测 4 / 20;滑块色是 --color-icon-primary)。

§slider_thumb_size: f32

Implementations§

Source§

impl ControlGeometry

Source

pub fn button_height_at(&self, which: usize) -> f32

按档取按钮高度:0 = sm、1 = md、2 = lg(越界按 lg 收)。

组件侧的 ButtonSize 只负责把枚举映射成下标,高度本身仍来自 token, 这样 --size-element-md 一改,Button 和 IconButton 会一起动。

Trait Implementations§

Source§

impl Clone for ControlGeometry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ControlGeometry

Source§

impl Debug for ControlGeometry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ControlGeometry

Source§

fn default() -> Self

默认档(token 取基表值,指示器尺寸见 MGUI_INDICATOR_SIZE)

Source§

impl PartialEq for ControlGeometry

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ControlGeometry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.