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
impl UIPage
pub fn new(width: u16, height: u16) -> Self
pub fn set_root_widget(&mut self, widget: Box<dyn Widget>)
pub fn set_theme(&mut self, theme_name: &str) -> UIResult<()>
pub fn set_frame_rate(&mut self, fps: u32)
pub fn handle_input_event(&mut self, input_event: InputEvent)
pub fn update(&mut self, dt: f32) -> UIResult<()>
pub fn render(&mut self) -> UIResult<()>
Sourcepub fn render_into(&mut self, target_buffer: &mut Buffer) -> UIResult<()>
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
pub fn layout(&mut self)
pub fn resize(&mut self, width: u16, height: u16)
pub fn quit(&mut self)
pub fn is_running(&self) -> bool
pub fn start(&mut self)
pub fn should_render(&self) -> bool
pub fn frame_complete(&mut self)
Sourcepub fn buffer_mut(&mut self) -> &mut Buffer
pub fn buffer_mut(&mut self) -> &mut Buffer
Get mutable reference to internal buffer (for BufferTransition output)
pub fn event_dispatcher(&mut self) -> &mut EventDispatcher
pub fn theme_manager(&self) -> &ThemeManager
pub fn theme_manager_mut(&mut self) -> &mut ThemeManager
Sourcepub fn run_simple(&mut self) -> UIResult<()>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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