Skip to main content

UIPage

Struct UIPage 

Source
pub struct UIPage { /* private fields */ }
Expand description

UI 页面结构 (支持多页面转场)

每个 UIPage 包含:

  • 一个 widget 树 (root_widget)
  • 一个内置 Buffer (用于渲染和转场)
  • 事件分发器和主题管理器

§使用方式

// 创建多个页面
let mut page_a = UIPage::new(80, 30);
page_a.set_root_widget(Box::new(slide1_panel));

let mut page_b = UIPage::new(80, 30);
page_b.set_root_widget(Box::new(slide2_panel));

// 渲染到各自的 buffer
page_a.render();
page_b.render();

// 使用转场混合
let transition = WipeTransition::left();
transition.transition(
    page_a.buffer(),
    page_b.buffer(),
    tui_buffer,
    0.5  // 50% 进度
);

Implementations§

Source§

impl UIPage

Source

pub fn new(width: u16, height: u16) -> Self

Source

pub fn set_root_widget(&mut self, widget: Box<dyn Widget>)

Source

pub fn set_theme(&mut self, theme_name: &str) -> UIResult<()>

Source

pub fn set_frame_rate(&mut self, fps: u32)

Source

pub fn handle_input_event(&mut self, input_event: InputEvent)

Source

pub fn update(&mut self, dt: f32) -> UIResult<()>

Source

pub fn render(&mut self) -> UIResult<()>

Source

pub fn render_into(&mut self, target_buffer: &mut Buffer) -> UIResult<()>

Render UI directly into the provided buffer (zero-copy) This is the recommended way to integrate UI rendering with the main game loop

Source

pub fn layout(&mut self)

Source

pub fn resize(&mut self, width: u16, height: u16)

Source

pub fn quit(&mut self)

Source

pub fn is_running(&self) -> bool

Source

pub fn start(&mut self)

Source

pub fn should_render(&self) -> bool

Source

pub fn frame_complete(&mut self)

Source

pub fn buffer(&self) -> &Buffer

Get immutable reference to internal buffer

Source

pub fn buffer_mut(&mut self) -> &mut Buffer

Get mutable reference to internal buffer (for BufferTransition output)

Source

pub fn event_dispatcher(&mut self) -> &mut EventDispatcher

Source

pub fn theme_manager(&self) -> &ThemeManager

Source

pub fn theme_manager_mut(&mut self) -> &mut ThemeManager

Source

pub fn run_simple(&mut self) -> UIResult<()>

Simple main loop for testing (in a real app, you’d integrate with rust_pixel’s main loop)

Auto Trait Implementations§

§

impl Freeze for UIPage

§

impl !RefUnwindSafe for UIPage

§

impl !Send for UIPage

§

impl !Sync for UIPage

§

impl Unpin for UIPage

§

impl UnsafeUnpin for UIPage

§

impl !UnwindSafe for UIPage

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> UnsafeAny for T
where T: Any,