Struct zaplib::View

source · []
pub struct View {
    pub view_id: Option<usize>,
    /* private fields */
}
Expand description

A group of DrawCalls.

This is really a pointer to a CxView (indexed in Cx::views using View::view_id), so you can find more information there.

A View has a few special features:

  • It has its own Rect, within which everything is clipped (see also [DrawUniforms]). This typically gets set by the return value of Cx::end_typed_box for the [CxLayoutBox] that is associated with the View. TODO(JP): Look into decoupling [CxLayoutBox] from View.
  • It can scroll (but does not have to; again see also [DrawUniforms]).
  • It has its own set of DrawCalls, which are isolated from the DrawCalls of the parent View.

See also ViewArea, which is an Area pointer to a View.

Fields

view_id: Option<usize>

The index of the corresponding CxView in Cx::views.

Implementations

Creates a new, empty View. See View::is_overlay.

Register the View in the draw tree.

This also creates a new [CxLayoutBox] with the LayoutSize that is passed in. Note that you should not create a View just in order to get a new [CxLayoutBox], since creating a View is relatively expensive – no DrawCalls inside this View will get merged with ones outside of it, so adding too many Views will create too many individual calls to the GPU.

TODO(JP): Perhaps we should decouple [CxLayoutBox] and View altogether?

End the View, by ending the [CxLayoutBox]. Returns a ViewArea that you can hold onto.

Should only be called if View::begin_view returned Result::Ok.

TODO(JP): Is the ViewArea redundant, since it basically contains the same information as the View itself?

Get the Rect that the [CxLayoutBox] associated with the View returned.

TODO(JP): Should we return an Option<Rect> instead of just returning a zero-sized Rect when the View has never been drawn yet?

TODO(JP): Doesn’t check if the View::redraw_id is still up to date, so we might be returning an outdated Rect here.

Returns an Area::View for this View, or Area::Empty if the View hasn’t been instantiated yet.

Get the current CxView::unsnapped_scroll if the View has been instantiated.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.