Skip to main content

EguiBridge

Struct EguiBridge 

Source
pub struct EguiBridge {
    pub max_texture_bits: u8,
    /* private fields */
}
Expand description

Primary Egui Interface.

Fields§

§max_texture_bits: u8

Number of bits allowed for texture size.

The texture will be 2^max_texture_size

Implementations§

Source§

impl EguiBridge

Source

pub fn get_max_texture_bits(&self) -> <u8 as GodotConvert>::Via

Source

pub fn set_max_texture_bits( &mut self, max_texture_bits: <u8 as GodotConvert>::Via, )

Source§

impl EguiBridge

APIs for spawning viewports.

Key for every APIs are that any access to egui::Context triggers

Source

pub fn setup_context(&self, setter: impl FnOnce(&Context) + 'static + Send)

Access to egui context at intra-frame. This will be called immediately if we’re already out of frame boundary(e.g. start..end), otherwise, queue it to be called later.

Source

pub fn sync_root_region(&self, target: Option<Gd<Control>>)

Synchronize root viewport’s region with given control. If None is given, it unregisters synchronization.

Source

pub fn current_frame(&self) -> &Context

Start a new frame (if required), and return context which you can draw with.

This is very default way of using EGUI, and anything you draw upon this will be shown below the spawned root canvas; EguiBridge

Use this when you want to draw widget every frame within process() function.

§Caveats
  • Cloning egui::Context and access it directly out of provided lifecycle is not recommneded. Please guarantee that you only access this context within main thread, right after calling current_frame.
§Panics
  • Called from non main gameplay thread.
Source

pub fn viewport_immediate<R>( &self, id: ViewportId, builder: ViewportBuilder, show: impl FnMut(&Context, ViewportClass) -> R, ) -> R

Render viewport for current frame.

This is shortcut to following code.

let id = ViewportId::from_hash("123");
let builder = ViewportBuilder::default();

bridge.current_frame().show_viewport_immediate(
    id, builder, |ctx, viewport_class| {
        // do something ...    
    }
);
§Panics
Source

pub fn viewport_spawn<L>( &self, id: ViewportId, builder: ViewportBuilder, show: impl FnMut(&Context) -> L + 'static, )
where L: Into<WidgetRetain>,

Spawn new viewport, which renders provided callback at the start of next frame. This is thread-safe, however, you should call exactly once per gameplay frame to ensure viewport is persisted correctly.

This is inherently a shortcut to following code.

let id = ViewportId::from_hash("123");
let builder = ViewportBuilder::default();

bridge.egui_start().show_viewport_deferred(
    id, builder, move |ctx, viewport_class| {
        // do something ...    

        // Viewport will be retained as long as you
        true
    }
);
Source

pub fn register_render_callback_first<L>( &self, priority: i32, widget: impl FnEguiDraw<L>, )
where L: Into<WidgetRetain>,

Registers callback for widget rendering at frame start.

See also FnEguiDrawExt decorator for every method with signature impl FnMut(&egui::Context) -> impl Into<WidgetRetain> + 'static

Callbacks registered with lower priority will be called earlier.

Source

pub fn register_render_callback_last<L>( &self, priority: i32, widget: impl FnEguiDraw<L>, )
where L: Into<WidgetRetain>,

Registers callback for widget rendering at frame end.

See also FnEguiDrawExt decorator for every method with signature impl FnMut(&egui::Context) -> impl Into<WidgetRetain> + 'static

Callbacks registered with lower priority will be called earlier.

Source

pub fn viewport_spawn_as_child( &self, _id: ViewportId, _parent: Gd<Control>, _builder: ViewportBuilder, _show: impl FnOnce(&Context) -> WidgetRetain + 'static, )

Spawn new viewport as child of existing node. If specified parent node is behind other node, the input may work naturally as the egui surface always intercepts any GUI input. It is advised to use this method for any node that lays over any other GUI nodes, which makes all egui rendering appear always top of the other GUI nodes.

Source

pub fn attach_node_to_viewport( &self, _id: ViewportId, node: Gd<Node>, ) -> Result<(), Gd<Node>>

Attach given node to given viewport’s window.

TODO: Implement this!

Trait Implementations§

Source§

impl Bounds for EguiBridge

Source§

type Memory = <<EguiBridge as GodotClass>::Base as Bounds>::Memory

Defines the memory strategy of the static type.
Source§

type Declarer = DeclUser

Whether this class is a core Godot class provided by the engine, or declared by the user as a Rust struct.
Source§

impl GodotClass for EguiBridge

Source§

type Base = CanvasLayer

The immediate superclass of T. This is always a Godot engine class.
Source§

fn class_id() -> ClassId

Globally unique class ID, linked to the name under which the class is registered in Godot. Read more
Source§

fn class_name() -> ClassId

👎Deprecated:

Renamed to class_id()

Source§

const INIT_LEVEL: InitLevel = <Self::Base as GodotClass>::INIT_LEVEL

Initialization level, during which this class should be initialized with Godot. Read more
Source§

fn inherits<Base>() -> bool
where Base: GodotClass,

Returns whether Self inherits from Base. Read more
Source§

impl GodotDefault for EguiBridge

Source§

impl ICanvasLayer for EguiBridge

Source§

fn process(&mut self, _dt: f64)

Source§

fn enter_tree(&mut self)

Source§

fn exit_tree(&mut self)

Source§

fn init(base: Base<Self::Base>) -> Self

Godot constructor, accepting an injected base object. Read more
Source§

fn to_string(&self) -> GString

String representation of the Godot instance. Read more
Source§

fn on_notification(&mut self, what: NodeNotification)

Called when the object receives a Godot notification. Read more
Source§

fn get_property(&self, property: StringName) -> Option<Variant>

Called whenever get() is called or Godot gets the value of a property. Read more
Source§

fn set_property(&mut self, property: StringName, value: Variant) -> bool

Called whenever Godot set() is called or Godot sets the value of a property. Read more
Source§

fn get_property_list(&mut self) -> Vec<PropertyInfo>

Called whenever Godot get_property_list() is called, the returned vector here is appended to the existing list of properties. Read more
Source§

fn validate_property(&self, property: &mut PropertyInfo)

Called whenever Godot retrieves value of property. Allows to customize existing properties. Every property info goes through this method, except properties added with get_property_list(). Read more
Source§

fn property_get_revert(&self, property: StringName) -> Option<Variant>

Called by Godot to tell if a property has a custom revert or not. Read more
Source§

fn physics_process(&mut self, delta: f64)

Source§

fn ready(&mut self)

Source§

fn get_configuration_warnings(&self) -> PackedArray<GString>

Source§

fn get_accessibility_configuration_warnings(&self) -> PackedArray<GString>

Source§

fn input(&mut self, event: Gd<InputEvent>)

Source§

fn shortcut_input(&mut self, event: Gd<InputEvent>)

Source§

fn unhandled_input(&mut self, event: Gd<InputEvent>)

Source§

fn unhandled_key_input(&mut self, event: Gd<InputEvent>)

Source§

fn get_focused_accessibility_element(&self) -> Rid

Source§

impl ImplementsGodotApi for EguiBridge

Source§

impl ImplementsGodotExports for EguiBridge

Source§

impl ImplementsGodotVirtual for EguiBridge

Source§

impl Inherits<CanvasLayer> for EguiBridge

Source§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl Inherits<Node> for EguiBridge

Source§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl Inherits<Object> for EguiBridge

Source§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl WithBaseField for EguiBridge

Source§

fn to_gd(&self) -> Gd<EguiBridge>

Returns the Gd pointer containing this object. Read more
Source§

fn base(&self) -> BaseRef<'_, Self>

Returns a shared reference guard, suitable for calling &self engine methods on this object. Read more
Source§

fn base_mut(&mut self) -> BaseMut<'_, Self>

Returns an exclusive reference guard, suitable for calling &self/&mut self engine methods on this object. Read more
Source§

fn run_deferred<F>(&mut self, mut_self_method: F)
where F: FnOnce(&mut Self) + 'static,

Defers the given closure to run during idle time. Read more
Source§

fn run_deferred_gd<F>(&mut self, gd_function: F)
where F: FnOnce(Gd<Self>) + 'static,

Defers the given closure to run during idle time. Read more
Source§

fn apply_deferred<F>(&mut self, rust_function: F)
where F: FnOnce(&mut Self) + 'static,

👎Deprecated:

Split into run_deferred() + run_deferred_gd().

Source§

impl WithSignals for EguiBridge

Source§

type SignalCollection<'c, C: WithSignals> = __godot_Signals_EguiBridge<'c, C>

The associated struct listing all signals of this class. Read more
Source§

impl WithUserSignals for EguiBridge

Source§

fn signals(&mut self) -> Self::SignalCollection<'_, Self>

Access user-defined signals of the current object self. Read more
Source§

impl You_forgot_the_attribute__godot_api for EguiBridge

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Inherits<T> for T
where T: GodotClass,

Source§

const IS_SAME_CLASS: bool = true

True iff Self == Base. Read more
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<T> NewAlloc for T
where T: GodotDefault<Memory = MemManual> + Bounds,

Source§

fn new_alloc() -> Gd<T>

Return a new, manually-managed Gd containing a default-constructed instance. Read more
Source§

impl<C> ObjectToOwned<C> for C
where C: WithBaseField,

Source§

fn object_to_owned(&self) -> Gd<C>

Converts the object reference to an owned Gd<T>.
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
Source§

impl<T> UniformObjectDeref<DeclUser> for T
where T: WithBaseField,

Source§

type TargetRef<'a> = GdRef<'a, T>

Source§

type TargetMut<'a> = GdMut<'a, T>

Source§

fn object_as_ref<'a>( gd: &'a Gd<T>, ) -> <T as UniformObjectDeref<DeclUser>>::TargetRef<'a>

Source§

fn object_as_mut<'a>( gd: &'a mut Gd<T>, ) -> <T as UniformObjectDeref<DeclUser>>::TargetMut<'a>