Skip to main content

WindowDesc

Struct WindowDesc 

Source
pub struct WindowDesc {
    pub id: &'static str,
    pub title: &'static str,
    pub icon: &'static str,
    pub order: i32,
    pub size: [f32; 2],
    pub min_size: [f32; 2],
    pub maximized: bool,
    pub always: bool,
}
Expand description

一个模块窗的自描述(纯数据,零 egui)。

字段与 ek-ui::mount::ModDesc 一一对应;界面层拿到本类型后直接映射, 不做二次推断(避免“两处各有一套默认值“的老病)。

ⓘ
fn window(&self) -> Option<WindowDesc> {
    Some(WindowDesc {
        id: "strategy",
        title: "策略交易",
        icon: "🎯",
        order: 50,
        size: [1180.0, 620.0],
        min_size: [820.0, 420.0],
        maximized: false,
        always: false,
    })
}

Fields§

§id: &'static str

模块名(必须等于 Plugin::kind)。

界面层用它做去重键:同一 kind 出现多份描述时以静态表为准 (静态表是“复核过的老模块“,自报是“新插件“),并记一次诊断。

§title: &'static str

菜单项标题。

§icon: &'static str

菜单项图标(单个 emoji 或短字形;空串 = 无图标)。

§order: i32

菜单排序位(小的在前;与静态表共用同一坐标系)。

§size: [f32; 2]

首次打开的建议尺寸(像素)。

§min_size: [f32; 2]

最小尺寸(像素)。

§maximized: bool

打开即最大化。

§always: bool

未装配也常驻菜单。

true 只适用于“没有实例也能配置/仍有意义“的模块(全局面、连接档案等); 依赖实例内容才有意义的模块必须给 false —— 因为 Self::always 为真时, 界面层要在没有任何插件实例的场合建窗,那时没有对象可供自报描述, 只能靠静态兜底表。两者是互斥的,别同时指望。

Implementations§

Source§

impl WindowDesc

Source

pub fn sizes_ok(&self) -> bool

尺寸合法性(宽高为正且 min ≤ size);不合法时界面层按静态表兜底。

放在契约侧而不是渲染侧,是为了让插件在单测里就能撞见自己的笔误。

Trait Implementations§

Source§

impl Clone for WindowDesc

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 WindowDesc

Source§

impl Debug for WindowDesc

Source§

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

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

impl PartialEq for WindowDesc

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 WindowDesc

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.