MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / begin

Method begin

src/lib.rs:554–868  ·  view source on GitHub ↗

Starts a new frame, returning a [`Ui`] handle for building the element tree.

(
        &mut self,
    )

Source from the content-addressed store, hash-verified

552
553 /// Starts a new frame, returning a [`Ui`] handle for building the element tree.
554 pub fn begin(
555 &mut self,
556 ) -> Ui<'_, CustomElementData> {
557 jobs::poll_completions();
558
559 if !self.headless {
560 self.context.set_layout_dimensions(Dimensions::new(
561 macroquad::prelude::screen_width(),
562 macroquad::prelude::screen_height(),
563 ));
564
565 // Update timing
566 self.context.current_time = macroquad::prelude::get_time();
567 self.context.frame_delta_time = macroquad::prelude::get_frame_time();
568 }
569
570 // Update blink timers for text inputs
571 self.context.update_text_input_blink_timers();
572
573 // Auto-update pointer state from macroquad
574 if !self.headless {
575 let (mx, my) = macroquad::prelude::mouse_position();
576 let is_down = macroquad::prelude::is_mouse_button_down(
577 macroquad::prelude::MouseButton::Left,
578 );
579
580 // Check shift state for text input click-to-cursor
581 // Must happen AFTER set_pointer_state, since that's what creates pending_text_click.
582 self.context.set_pointer_state(Vector2::new(mx, my), is_down);
583
584 {
585 use macroquad::prelude::{is_key_down, KeyCode};
586 let shift = is_key_down(KeyCode::LeftShift) || is_key_down(KeyCode::RightShift);
587 if shift {
588 // If shift is held and there's a pending text click, update it
589 if let Some(ref mut pending) = self.context.pending_text_click {
590 pending.3 = true;
591 }
592 }
593 }
594
595 let (scroll_x, scroll_y) = macroquad::prelude::mouse_wheel();
596 #[cfg(target_arch = "wasm32")]
597 const SCROLL_SPEED: f32 = 1.0;
598 #[cfg(not(target_arch = "wasm32"))]
599 const SCROLL_SPEED: f32 = 20.0;
600 // Shift+scroll wheel swaps vertical to horizontal scrolling
601 let scroll_shift = {
602 use macroquad::prelude::{is_key_down, KeyCode};
603 is_key_down(KeyCode::LeftShift) || is_key_down(KeyCode::RightShift)
604 };
605 let scroll_delta = if scroll_shift {
606 // Shift held: vertical scroll becomes horizontal
607 Vector2::new(
608 (scroll_x + scroll_y) * SCROLL_SPEED,
609 0.0,
610 )
611 } else {

Calls 15

poll_completionsFunction · 0.85
set_pointer_stateMethod · 0.80
is_emptyMethod · 0.80
is_text_input_focusedMethod · 0.80
cycle_focusMethod · 0.80
getMethod · 0.80
selected_text_styledMethod · 0.80