pub struct DRect {
pub px: PxRect,
pub dp: AbsRect,
pub rel: RelRect,
}
Expand description
Unified Display Rectangle with both per-pixel and display-independent pixels. Can be
constructed by adding together any combination of PxRect
, AbsRect
or RelRect
.
§Examples
use feather_ui::{DRect, AbsRect, PxRect, RelRect};
let foo: DRect = AbsRect::new(1.0,2.0,3.0,4.0).into();
let bar = AbsRect::new(1.0,2.0,3.0,4.0) + PxRect::new(1.0,2.0,3.0,4.0);
let baz = RelRect::new(1.0,2.0,3.0,4.0) + PxRect::new(1.0,2.0,3.0,4.0);
// These can be added together because bar turned into a `DRect` from adding `PxRect`
// and `AbsRect` together
let foobar = foo + bar;
let test = DRect{
px: PxRect::new(1.0,2.0,3.0,4.0),
dp: AbsRect::new(1.0,2.0,3.0,4.0),
rel: RelRect::new(1.0,2.0,3.0,4.0),
};
let baztest = baz + test;
Fields§
§px: PxRect
§dp: AbsRect
§rel: RelRect
Implementations§
Source§impl DRect
impl DRect
Sourcepub fn topleft(&self) -> DPoint
pub fn topleft(&self) -> DPoint
Returns the top-left corner of the unified display rectangle as a unified display point.
Sourcepub fn bottomright(&self) -> DPoint
pub fn bottomright(&self) -> DPoint
Returns the bottom-right corner of the unified display rectangle. This
is not the size of the rectangle! To get the actual size of the
rectangle, you must subtract the top-left corner from the bottom-right
corner, or call DRect::size
which does this for you.
Sourcepub const fn fill() -> Self
pub const fn fill() -> Self
Returns a DRect with a relative component mapped to the entire available area. This is often used for any element that should be the same size as it’s parent container.
Sourcepub const fn auto() -> Self
pub const fn auto() -> Self
Returns a DRect with two UNSIZED_AXIS
, meaning they will be set to the size of the
children of the element, or the element’s intrinsic size (or zero if it doesn’t have
any).
Trait Implementations§
impl Child for DRect
impl Copy for DRect
impl Empty for DRect
impl Padded for DRect
impl Prop for DRect
impl Prop for DRect
impl StructuralPartialEq for DRect
Auto Trait Implementations§
impl Freeze for DRect
impl RefUnwindSafe for DRect
impl Send for DRect
impl Sync for DRect
impl Unpin for DRect
impl UnwindSafe for DRect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromLuaMulti for Twhere
T: FromLua,
impl<T> FromLuaMulti for Twhere
T: FromLua,
Source§fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>
unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>
unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.