Struct conrod::widget::primitive::image::Image
[−]
[src]
pub struct Image { pub common: CommonBuilder, pub src_rect: Option<Rect>, pub style: Style, }
A primitive and basic widget for drawing an Image
.
Fields
common: CommonBuilder
Data necessary and common for all widget builder types.
src_rect: Option<Rect>
The rectangle area of the original source image that should be used.
style: Style
Unique styling.
Methods
impl Image
[src]
fn new() -> Self
Construct a new Image
.
Note that the Image
widget does not require borrowing or owning any image data directly.
Instead, image data is stored within a conrod::image::Map
where widget indices are mapped
to their associated data.
This is done for a few reasons:
- To avoid requiring that the widget graph owns an instance of each image
- To avoid requiring that the user passes the image data to the
Image
every update unnecessarily - To make it easier for users to borrow and mutate their images without needing to index
into the
Ui
's widget graph (which also requires casting types).
During rendering, conrod will take the image::Map
, retrieve the data associated with each
image and yield it via the render::Primitive::Image
variant.
Note: this implies that the type must be the same for all Image
widgets instantiated via
the same Ui
. In the case that you require multiple different types of images, we
recommend that you either:
- use an enum with a variant for each type
- use a trait object, where the trait is implemented for each of your image types or
- use an index type which may be mapped to your various image types.
fn source_rectangle(self, rect: Rect) -> Self
The rectangular area of the image that we wish to display.
If this method is not called, the entire image will be used.
fn color(self, color: Option<Color>) -> Self
Build the type's self.$($assignee).+ with the given $Type.
Trait Implementations
impl Copy for Image
[src]
impl Clone for Image
[src]
fn clone(&self) -> Image
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Widget for Image
[src]
type State = State
State to be stored within the Ui
s widget cache. Read more
type Style = Style
Every widget is required to have its own associated Style
type. This type is intended to contain high-level styling information for the widget that can be optionally specified by a user of the widget. Read more
type Event = ()
The type of event yielded by the widget, returned via the Widget::set
function. Read more
fn common(&self) -> &CommonBuilder
Return a reference to a CommonBuilder struct owned by the Widget. This method allows us to do a blanket impl of Positionable and Sizeable for T: Widget. Read more
fn common_mut(&mut self) -> &mut CommonBuilder
Return a mutable reference to a CommonBuilder struct owned by the Widget. This method allows us to do a blanket impl of Positionable and Sizeable for T: Widget. Read more
fn init_state(&self, _: Generator) -> Self::State
Return the initial State of the Widget. Read more
fn style(&self) -> Self::Style
Return the styling of the widget. Read more
fn default_x_dimension(&self, ui: &Ui) -> Dimension
The default width for the Widget. Read more
fn default_y_dimension(&self, ui: &Ui) -> Dimension
The default height of the widget. Read more
fn update(self, args: UpdateArgs<Self>) -> Self::Event
Update our Widget's unique Widget::State via the State wrapper type (the state
field within the UpdateArgs). Read more
fn default_x_position(&self, ui: &Ui) -> Position
The default Position for the widget along the x axis. Read more
fn default_y_position(&self, ui: &Ui) -> Position
The default Position for the widget along the y axis. Read more
fn drag_area(&self,
_dim: Dimensions,
_style: &Self::Style,
_theme: &Theme)
-> Option<Rect>
_dim: Dimensions,
_style: &Self::Style,
_theme: &Theme)
-> Option<Rect>
If the widget is draggable, implement this method and return the position and dimensions of the draggable space. The position should be relative to the center of the widget. Read more
fn kid_area(&self, args: KidAreaArgs<Self>) -> KidArea
The area on which child widgets will be placed when using the Place
Position
methods.
fn parent(self, parent_id: Id) -> Self
Set the parent widget for this Widget by passing the WidgetId of the parent. Read more
fn no_parent(self) -> Self
Specify that this widget has no parent widgets.
fn place_on_kid_area(self, b: bool) -> Self
Set whether or not the Widget should be placed on the kid_area. Read more
fn graphics_for(self, id: Id) -> Self
Indicates that the Widget is used as a non-interactive graphical element for some other widget. Read more
fn floating(self, is_floating: bool) -> Self
Set whether or not the widget is floating (the default is false
). A typical example of a floating widget would be a pop-up or alert window. Read more
fn crop_kids(self) -> Self
Indicates that all widgets who are children of this widget should be cropped to the kid_area
of this widget. Read more
fn scroll_kids(self) -> Self
Makes the widget's KidArea
scrollable. Read more
fn scroll_kids_vertically(self) -> Self
Makes the widget's KidArea
scrollable. Read more
fn scroll_kids_horizontally(self) -> Self
Set whether or not the widget's KidArea
is scrollable (the default is false). Read more
fn and<F>(self, build: F) -> Self where F: FnOnce(Self) -> Self
A builder method that "lifts" the Widget through the given build
function. Read more
fn and_mut<F>(self, mutate: F) -> Self where F: FnOnce(&mut Self)
A builder method that mutates the Widget with the given mutate
function. Read more
fn and_if<F>(self, cond: bool, build: F) -> Self where F: FnOnce(Self) -> Self
A method that conditionally builds the Widget with the given build
function. Read more
fn and_then<T, F>(self, maybe: Option<T>, build: F) -> Self where F: FnOnce(Self, T) -> Self
A method that optionally builds the the Widget with the given build
function. Read more
fn set<'a, 'b>(self, id: Id, ui_cell: &'a mut UiCell<'b>) -> Self::Event
Note: There should be no need to override this method. Read more