[−][src]Struct penrose::core::data_types::Region
An X window / screen position: top left corner + extent
Fields
x: u32
The x-coordinate of the top left corner of this region
y: u32
The y-coordinate of the top left corner of this region
w: u32
The width of this region
h: u32
The height of this region
Implementations
impl Region
[src]
pub fn new(x: u32, y: u32, w: u32, h: u32) -> Region
[src]
Create a new Region.
pub fn values(&self) -> (u32, u32, u32, u32)
[src]
Destructure this Region into its component values (x, y, w, h).
Examples
use penrose::core::data_types::Region; // In practice, this will be a region your code is receiving: not one you create let r = Region::new(10, 20, 30, 40); assert_eq!(r.values(), (10, 20, 30, 40));
pub fn scale_w(&self, factor: f64) -> Self
[src]
Create a new Region with width equal to factor
x self.w
Examples
use penrose::core::data_types::Region; let r = Region::new(10, 20, 30, 40); assert_eq!(r.scale_w(1.5), Region::new(10, 20, 45, 40)); assert_eq!(r.scale_w(0.5), Region::new(10, 20, 15, 40));
pub fn scale_h(&self, factor: f64) -> Self
[src]
Create a new Region with height equal to factor
x self.h
Examples
use penrose::core::data_types::Region; let r = Region::new(10, 20, 30, 40); assert_eq!(r.scale_h(1.5), Region::new(10, 20, 30, 60)); assert_eq!(r.scale_h(0.5), Region::new(10, 20, 30, 20));
pub fn contains(&self, other: &Region) -> bool
[src]
Check whether this Region contains other
as a sub-Region
Examples
use penrose::core::data_types::Region; let r1 = Region::new(10, 10, 50, 50); let r2 = Region::new(0, 0, 100, 100); assert!(r2.contains(&r1)); assert!(!r1.contains(&r2));
pub fn contains_point(&self, p: &Point) -> bool
[src]
Check whether this Region contains other
as a sub-Region
Examples
use penrose::core::data_types::{Point, Region}; let r1 = Region::new(10, 10, 50, 50); assert!(r1.contains_point(&Point::new(30, 20))); assert!(!r1.contains_point(&Point::new(0, 0)));
pub fn centered_in(&self, enclosing: &Region) -> Result<Self>
[src]
Center this region inside of enclosing
.
Errors
Fails if this Region can not fit inside of enclosing
Examples
use penrose::core::data_types::Region; let r1 = Region::new(10, 10, 50, 60); let r2 = Region::new(0, 0, 100, 100); let centered = r1.centered_in(&r2); assert!(centered.is_ok()); assert_eq!(centered.unwrap(), Region::new(25, 20, 50, 60)); let too_big = r2.centered_in(&r1); assert!(too_big.is_err());
pub fn as_rows(&self, n_rows: u32) -> Vec<Region>
[src]
Split this Region
into evenly sized rows.
Examples
use penrose::core::data_types::Region; let r = Region::new(0, 0, 100, 100); let regions = r.as_rows(2); assert_eq!(regions.len(), 2); assert_eq!(regions[0], Region::new(0, 0, 100, 50)); assert_eq!(regions[1], Region::new(0, 50, 100, 50));
pub fn as_columns(&self, n_columns: u32) -> Vec<Region>
[src]
Split this Region
into evenly sized columns.
Examples
use penrose::core::data_types::Region; let r = Region::new(0, 0, 100, 100); let regions = r.as_columns(2); assert_eq!(regions.len(), 2); assert_eq!(regions[0], Region::new(0, 0, 50, 100)); assert_eq!(regions[1], Region::new(50, 0, 50, 100));
pub fn split_at_width(&self, new_width: u32) -> Result<(Self, Self)>
[src]
Divides this region into two columns where the first has the given width.
Errors
Fails if the requested split point is not contained within self
Examples
use penrose::core::data_types::Region; let r = Region::new(10, 10, 50, 60); let (r1, r2) = r.split_at_width(30).unwrap(); assert_eq!(r1, Region::new(10, 10, 30, 60)); assert_eq!(r2, Region::new(40, 10, 20, 60)); assert!(r.split_at_width(100).is_err());
pub fn split_at_height(&self, new_height: u32) -> Result<(Self, Self)>
[src]
Divides this region into two rows where the first has the given height.
Errors
Fails if the requested split point is not contained within self
Examples
use penrose::core::data_types::Region; let r = Region::new(10, 10, 50, 60); let (r1, r2) = r.split_at_height(40).unwrap(); assert_eq!(r1, Region::new(10, 10, 50, 40)); assert_eq!(r2, Region::new(10, 50, 50, 20)); assert!(r.split_at_height(100).is_err());
Trait Implementations
impl Clone for Region
[src]
impl Copy for Region
[src]
impl Debug for Region
[src]
impl Eq for Region
[src]
impl Hash for Region
[src]
pub fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Region> for Region
[src]
impl StructuralEq for Region
[src]
impl StructuralPartialEq for Region
[src]
Auto Trait Implementations
impl RefUnwindSafe for Region
[src]
impl Send for Region
[src]
impl Sync for Region
[src]
impl Unpin for Region
[src]
impl UnwindSafe for Region
[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> From<T> for T
[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>,