Struct widgetry::mapspace::World[][src]

pub struct World<ID: ObjectID> {
    objects: HashMap<ID, Object<ID>>,
    quadtree: QuadTree<ID>,
    draw_master_batches: Vec<ToggleZoomed>,
    hovering: Option<ID>,
    dragging_from: Option<(Pt2D, bool)>,
}
Expand description

A World manages objects that exist in “map-space”, the zoomable and pannable canvas. These objects can be drawn, hovered on, clicked, dragged, etc.

Fields

objects: HashMap<ID, Object<ID>>quadtree: QuadTree<ID>draw_master_batches: Vec<ToggleZoomed>hovering: Option<ID>dragging_from: Option<(Pt2D, bool)>

Implementations

Creates an empty World, whose objects can exist anywhere from (0, 0) to the max f64.

Creates an empty World, whose objects can exist in the provided rectangular boundary.

Start adding an object to the World. The caller should specify the object with methods on ObjectBuilder, then call build.

Delete an object. Not idempotent – this will panic if the object doesn’t exist. Will panic if the object is deleted in the middle of being dragged.

Delete an object, with the promise to recreate it with the same ID before the next call to event. This may be called while the object is being hovered on or dragged.

After adding all objects to a World, call this to initially detect if the cursor is hovering on an object.

If a drag event causes the world to be totally rebuilt, call this with the previous world to preserve the ongoing drag.

This should be called after initialize_hover.

Important: the rebuilt world must include the same object ID that’s currently being dragged from the previous world.

Draw something underneath all objects. This is useful for performance, when a large number of objects never change appearance.

Let objects in the world respond to something happening.

Draw objects in the world that’re currently visible.

Begin adding an unnamed object to the World.

Note: You must call build on this object before calling add_unnamed again. Otherwise, the object IDs will collide.

TODO This will break when objects are deleted!

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

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

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.