Struct conrod::UiCell
[−]
[src]
pub struct UiCell<'a> { /* fields omitted */ }
A wrapper around the Ui
that restricts the user from mutating the Ui
in certain ways while
in the scope of the Ui::set_widgets
function and within Widget
s' update
methods. Using
the UiCell
, users may access the Ui
immutably (via Deref
) however they wish, however they
may only mutate the Ui
via the &mut self
methods provided by the UiCell
.
The name came from its likening to a "jail cell for the Ui
", as it restricts a user's access
to it. However, we realise that the name may also cause ambiguity with the std Cell
and
RefCell
types (which UiCell
has nothing to do with). Thus, if you have a better name for
this type in mind, please let us know at the github repo via an issue or PR sometime before we
hit 1.0.0!
Methods
impl<'a> UiCell<'a>
[src]
fn theme(&self) -> &Theme
A reference to the Theme
that is currently active within the Ui
.
fn font(&self, id: Id) -> Option<&Font>
A convenience method for borrowing the Font
for the given Id
if it exists.
fn window_dim(&self) -> Dimensions
Returns the dimensions of the window
fn global_input(&self) -> &Global
Returns an immutable reference to the input::Global
of the Ui
.
All coordinates here will be relative to the center of the window.
fn widget_input(&self, id: Id) -> Widget
Returns a input::Widget
with input events for the widget.
All coordinates in the input::Widget
will be relative to the widget at the given index.
fn widget_id_generator(&mut self) -> Generator
Produces a type that may be used to generate new unique widget::Id
s.
See the widget::id::Generator docs for details on how to use this correctly.
fn kids_bounding_box(&self, id: Id) -> Option<Rect>
The Rect that bounds the kids of the widget with the given index.
Returns None
if the widget has no children or if there's is no widget for the given index.
fn scroll_widget(&mut self, id: Id, offset: [Scalar; 2])
Scroll the widget at the given index by the given offset amount.
The produced Scroll
event will be pushed to the pending_scroll_events
and will be
applied to the widget during the next call to Ui::set_widgets
.
Methods from Deref<Target=Ui>
fn widget_input(&self, widget: Id) -> Widget
Returns a input::Widget
for the given widget
fn rect_of(&self, id: Id) -> Option<Rect>
The Rect for the widget at the given index.
Returns None
if there is no widget for the given index.
fn w_of(&self, id: Id) -> Option<Scalar>
The absolute width of the widget at the given index.
Returns None
if there is no widget for the given index.
fn h_of(&self, id: Id) -> Option<Scalar>
The absolute height of the widget at the given index.
Returns None
if there is no widget for the given index.
fn wh_of(&self, id: Id) -> Option<Dimensions>
The absolute dimensions for the widget at the given index.
Returns None
if there is no widget for the given index.
fn xy_of(&self, id: Id) -> Option<Point>
The coordinates for the widget at the given index.
Returns None
if there is no widget for the given index.
fn kid_area_of(&self, id: Id) -> Option<Rect>
The kid_area
of the widget at the given index.
Returns None
if there is no widget for the given index.
fn maybe_prev_widget(&self) -> Option<Id>
An index to the previously updated widget if there is one.
fn widget_graph(&self) -> &Graph
Borrow the Ui's widget_graph
.
fn updated_widgets(&self) -> &HashSet<Id>
Borrow the Ui's set of updated widgets.
This set indicates which widgets have been instantiated since the beginning of the most
recent Ui::set_widgets
call.
fn prev_updated_widgets(&self) -> &HashSet<Id>
Borrow the Ui's set of updated widgets.
This set indicates which widgets have were instantiated during the previous call to
Ui::set_widgets
.
fn calc_xy(&self,
maybe_id: Option<Id>,
x_position: Position,
y_position: Position,
dim: Dimensions,
place_on_kid_area: bool)
-> Point
maybe_id: Option<Id>,
x_position: Position,
y_position: Position,
dim: Dimensions,
place_on_kid_area: bool)
-> Point
Get the centred xy coords for some given Dimension
s, Position
and alignment.
If getting the xy for a specific widget, its widget::Id
should be specified so that we
can also consider the scroll offset of the scrollable parent widgets.
The place_on_kid_area
argument specifies whether or not Place Position variants
should target a Widget's kid_area
, or simply the Widget's total area.
fn kids_bounding_box(&self, id: Id) -> Option<Rect>
The Rect that bounds the kids of the widget with the given index.
fn visible_area(&self, id: Id) -> Option<Rect>
The Rect that represents the maximum fully visible area for the widget with the given index, including consideration of cropped scroll area.
Otherwise, return None if the widget is not visible.
Trait Implementations
impl<'a> Drop for UiCell<'a>
[src]
impl<'a> Deref for UiCell<'a>
[src]
type Target = Ui
The resulting type after dereferencing
fn deref(&self) -> &Ui
The method called to dereference a value