Struct carbide_core::widget::primitive::image::Image [−][src]
A primitive and basic widget for drawing an Image
.
Fields
image_id: Id
The unique identifier for the image that will be drawn.
src_rect: Option<Rect>
The rectangle area of the original source image that should be used.
style: Style
Unique styling.
Implementations
impl Image
[src]
pub fn old_new(image_id: Id) -> Self
[src]
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 carbide::image::Map
where image::Id
s 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 render).
During rendering, carbide 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 render 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 render or
- use an index type which may be mapped to your various image render.
pub fn new(id: Id) -> Box<Self>
[src]
pub fn source_rectangle(self, rect: Rect) -> Self
[src]
The rectangular area of the image that we wish to display.
If this method is not called, the entire image will be used.
pub fn resizeable(self) -> Box<Self>
[src]
pub fn scaled_to_fit(self) -> Box<Self>
[src]
pub fn scaled_to_fill(self) -> Box<Self>
[src]
pub fn aspect_ratio(self, mode: ScaleMode) -> Box<Self>
[src]
Trait Implementations
impl Clone for Image
[src]
impl<S: GlobalState> CommonWidget<S> for Image
[src]
fn get_id(&self) -> Uuid
[src]
fn get_flag(&self) -> Flags
[src]
fn get_children(&self) -> WidgetIter<'_, S>ⓘNotable traits for WidgetIter<'a, S>
impl<'a, S> Iterator for WidgetIter<'a, S> type Item = &'a Box<dyn Widget<S>>;
[src]
Notable traits for WidgetIter<'a, S>
impl<'a, S> Iterator for WidgetIter<'a, S> type Item = &'a Box<dyn Widget<S>>;
fn get_children_mut(&mut self) -> WidgetIterMut<'_, S>ⓘNotable traits for WidgetIterMut<'a, S>
impl<'a, S> Iterator for WidgetIterMut<'a, S> type Item = &'a mut Box<dyn Widget<S>>;
[src]
Notable traits for WidgetIterMut<'a, S>
impl<'a, S> Iterator for WidgetIterMut<'a, S> type Item = &'a mut Box<dyn Widget<S>>;
fn get_proxied_children(&mut self) -> WidgetIterMut<'_, S>ⓘNotable traits for WidgetIterMut<'a, S>
impl<'a, S> Iterator for WidgetIterMut<'a, S> type Item = &'a mut Box<dyn Widget<S>>;
[src]
Notable traits for WidgetIterMut<'a, S>
impl<'a, S> Iterator for WidgetIterMut<'a, S> type Item = &'a mut Box<dyn Widget<S>>;
fn get_position(&self) -> Point
[src]
fn set_position(&mut self, position: Dimensions)
[src]
fn get_dimension(&self) -> Dimensions
[src]
fn set_dimension(&mut self, dimensions: Dimensions)
[src]
fn get_x(&self) -> Scalar
[src]
fn set_x(&mut self, x: Scalar)
[src]
fn get_y(&self) -> Scalar
[src]
fn set_y(&mut self, y: Scalar)
[src]
fn get_width(&self) -> Scalar
[src]
fn set_width(&mut self, width: Scalar)
[src]
fn get_height(&self) -> Scalar
[src]
fn set_height(&mut self, height: Scalar)
[src]
fn is_inside(&self, point: Point) -> bool
[src]
impl Debug for Image
[src]
impl<GS: GlobalState> Event<GS> for Image
[src]
fn handle_mouse_event(
&mut self,
event: &MouseEvent,
consumed: &bool,
env: &mut Environment<GS>,
global_state: &mut GS
)
[src]
&mut self,
event: &MouseEvent,
consumed: &bool,
env: &mut Environment<GS>,
global_state: &mut GS
)
fn handle_keyboard_event(
&mut self,
event: &KeyboardEvent,
env: &mut Environment<GS>,
global_state: &mut GS
)
[src]
&mut self,
event: &KeyboardEvent,
env: &mut Environment<GS>,
global_state: &mut GS
)
fn handle_other_event(&mut self, event: &WidgetEvent)
[src]
fn process_mouse_event(
&mut self,
event: &MouseEvent,
consumed: &bool,
env: &mut Environment<GS>,
global_state: &mut GS
)
[src]
&mut self,
event: &MouseEvent,
consumed: &bool,
env: &mut Environment<GS>,
global_state: &mut GS
)
fn process_keyboard_event(
&mut self,
event: &KeyboardEvent,
env: &mut Environment<GS>,
global_state: &mut GS
)
[src]
&mut self,
event: &KeyboardEvent,
env: &mut Environment<GS>,
global_state: &mut GS
)
fn process_other_event(
&mut self,
event: &WidgetEvent,
env: &mut Environment<GS>,
global_state: &mut GS
)
[src]
&mut self,
event: &WidgetEvent,
env: &mut Environment<GS>,
global_state: &mut GS
)
fn process_mouse_event_default(
&mut self,
event: &MouseEvent,
consumed: &bool,
env: &mut Environment<S>,
global_state: &mut S
)
[src]
&mut self,
event: &MouseEvent,
consumed: &bool,
env: &mut Environment<S>,
global_state: &mut S
)
fn process_keyboard_event_default(
&mut self,
event: &KeyboardEvent,
env: &mut Environment<S>,
global_state: &mut S
)
[src]
&mut self,
event: &KeyboardEvent,
env: &mut Environment<S>,
global_state: &mut S
)
fn process_other_event_default(
&mut self,
event: &WidgetEvent,
env: &mut Environment<S>,
global_state: &mut S
)
[src]
&mut self,
event: &WidgetEvent,
env: &mut Environment<S>,
global_state: &mut S
)
impl<S: GlobalState> Layout<S> for Image
[src]
fn flexibility(&self) -> u32
[src]
fn calculate_size(
&mut self,
requested_size: Dimensions,
env: &Environment<S>
) -> Dimensions
[src]
&mut self,
requested_size: Dimensions,
env: &Environment<S>
) -> Dimensions
fn position_children(&mut self)
[src]
impl<S: GlobalState> Render<S> for Image
[src]
fn get_primitives(&mut self, _: &Map) -> Vec<Primitive>
[src]
impl<GS: GlobalState> StateSync<GS> for Image
[src]
fn insert_local_state(&self, env: &mut Environment<GS>)
[src]
fn update_all_widget_state(&mut self, env: &Environment<GS>, global_state: &GS)
[src]
fn update_local_widget_state(&mut self, env: &Environment<GS>)
[src]
fn sync_state(&mut self, env: &mut Environment<GS>, global_state: &GS)
[src]
fn default_sync_state(&mut self, env: &mut Environment<S>, global_state: &S)
[src]
impl<GS: GlobalState> Widget<GS> for Image
[src]
impl<GS: GlobalState> WidgetExt<GS> for Image
[src]
fn frame(
self,
width: Box<dyn State<f64, GS>>,
height: Box<dyn State<f64, GS>>
) -> Box<Frame<GS>>
[src]
self,
width: Box<dyn State<f64, GS>>,
height: Box<dyn State<f64, GS>>
) -> Box<Frame<GS>>
fn frame_width(self, width: Box<dyn State<f64, GS>>) -> Box<Frame<GS>>
[src]
fn padding(self, edge_insets: EdgeInsets) -> Box<Padding<GS>>
[src]
fn clip(self) -> Box<Clip<GS>>
[src]
fn hidden(self) -> Box<Hidden<GS>>
[src]
fn offset(
self,
offset_x: CommonState<f64, GS>,
offset_y: CommonState<f64, GS>
) -> Box<Offset<GS>>
[src]
self,
offset_x: CommonState<f64, GS>,
offset_y: CommonState<f64, GS>
) -> Box<Offset<GS>>
fn border(self) -> Box<Border<GS>>
[src]
Auto Trait Implementations
impl RefUnwindSafe for Image
[src]
impl Send for Image
[src]
impl Sync for Image
[src]
impl Unpin for Image
[src]
impl UnwindSafe for Image
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T> GlobalState for T where
T: 'static + Clone + Debug,
[src]
T: 'static + Clone + Debug,
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,