Skip to content
Snippets Groups Projects
Commit e6e83b5c authored by MrGVSV's avatar MrGVSV
Browse files

Formatting

parent 9c66f0f2
No related branches found
No related tags found
No related merge requests found
......@@ -37,9 +37,9 @@ use kayak_font::{
KayakFont,
};
use kayak_core::styles::Corner;
use super::{Dpi, UNIFIED_SHADER_HANDLE};
use crate::{render::ui_pass::TransparentUI, WindowSize};
use kayak_core::styles::Corner;
pub struct UnifiedPipeline {
view_layout: BindGroupLayout,
......
......@@ -4,7 +4,10 @@ use std::ops::{Mul, MulAssign};
///
/// This is useful for things like border radii, etc.
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct Corner<T> where T: Copy + Default + PartialEq {
pub struct Corner<T>
where
T: Copy + Default + PartialEq,
{
/// The value of the top-left corner
pub top_left: T,
/// The value of the top-right corner
......@@ -15,7 +18,10 @@ pub struct Corner<T> where T: Copy + Default + PartialEq {
pub bottom_right: T,
}
impl<T> Corner<T> where T: Copy + Default + PartialEq {
impl<T> Corner<T>
where
T: Copy + Default + PartialEq,
{
/// Creates a new `Corner` with values individually specified for each corner
///
/// # Arguments
......@@ -99,31 +105,48 @@ impl<T> Corner<T> where T: Copy + Default + PartialEq {
/// Converts this `Corner` into a tuple matching `(Top Left, Top Right, Bottom Left, Bottom Right)`
pub fn into_tuple(self) -> (T, T, T, T) {
(self.top_left, self.top_right, self.bottom_left, self.bottom_right)
(
self.top_left,
self.top_right,
self.bottom_left,
self.bottom_right,
)
}
}
impl<T> From<Corner<T>> for (T, T, T, T) where T: Copy + Default + PartialEq {
impl<T> From<Corner<T>> for (T, T, T, T)
where
T: Copy + Default + PartialEq,
{
/// Creates a tuple matching the pattern: `(Top Left, Top Right, Bottom Left, Bottom Right)`
fn from(edge: Corner<T>) -> Self {
edge.into_tuple()
}
}
impl<T> From<T> for Corner<T> where T: Copy + Default + PartialEq {
impl<T> From<T> for Corner<T>
where
T: Copy + Default + PartialEq,
{
fn from(value: T) -> Self {
Corner::all(value)
}
}
impl<T> From<(T, T, T, T)> for Corner<T> where T: Copy + Default + PartialEq {
impl<T> From<(T, T, T, T)> for Corner<T>
where
T: Copy + Default + PartialEq,
{
/// Converts the tuple according to the pattern: `(Top Left, Top Right, Bottom Left, Bottom Right)`
fn from(value: (T, T, T, T)) -> Self {
Corner::new(value.0, value.1, value.2, value.3)
}
}
impl<T> Mul<T> for Corner<T> where T: Copy + Default + PartialEq + Mul<Output=T> {
impl<T> Mul<T> for Corner<T>
where
T: Copy + Default + PartialEq + Mul<Output = T>,
{
type Output = Self;
fn mul(self, rhs: T) -> Self::Output {
......@@ -136,7 +159,10 @@ impl<T> Mul<T> for Corner<T> where T: Copy + Default + PartialEq + Mul<Output=T>
}
}
impl<T> Mul<Corner<T>> for Corner<T> where T: Copy + Default + PartialEq + Mul<Output=T> {
impl<T> Mul<Corner<T>> for Corner<T>
where
T: Copy + Default + PartialEq + Mul<Output = T>,
{
type Output = Self;
fn mul(self, rhs: Corner<T>) -> Self::Output {
......@@ -149,7 +175,10 @@ impl<T> Mul<Corner<T>> for Corner<T> where T: Copy + Default + PartialEq + Mul<O
}
}
impl<T> MulAssign<T> for Corner<T> where T: Copy + Default + PartialEq + MulAssign {
impl<T> MulAssign<T> for Corner<T>
where
T: Copy + Default + PartialEq + MulAssign,
{
fn mul_assign(&mut self, rhs: T) {
self.top_left *= rhs;
self.top_right *= rhs;
......@@ -158,7 +187,10 @@ impl<T> MulAssign<T> for Corner<T> where T: Copy + Default + PartialEq + MulAssi
}
}
impl<T> MulAssign<Corner<T>> for Corner<T> where T: Copy + Default + PartialEq + MulAssign {
impl<T> MulAssign<Corner<T>> for Corner<T>
where
T: Copy + Default + PartialEq + MulAssign,
{
fn mul_assign(&mut self, rhs: Corner<T>) {
self.top_left *= rhs.top_left;
self.top_right *= rhs.top_right;
......@@ -189,7 +221,7 @@ mod tests {
#[test]
fn multiplication_should_work_on_corners() {
let expected = (10.0, 20.0, 30.0, 40.0);
let mut corner= Corner::new(1.0, 2.0, 3.0, 4.0);
let mut corner = Corner::new(1.0, 2.0, 3.0, 4.0);
// Basic multiplication
let multiplied = corner * 10.0;
......@@ -199,4 +231,4 @@ mod tests {
corner *= 10.0;
assert_eq!(expected, corner.into_tuple());
}
}
\ No newline at end of file
}
......@@ -4,7 +4,10 @@ use std::ops::{Mul, MulAssign};
///
/// This is useful for things like borders, padding, etc.
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct Edge<T> where T: Copy + Default + PartialEq {
pub struct Edge<T>
where
T: Copy + Default + PartialEq,
{
/// The value of the top edge
pub top: T,
/// The value of the right edge
......@@ -15,7 +18,10 @@ pub struct Edge<T> where T: Copy + Default + PartialEq {
pub left: T,
}
impl<T> Edge<T> where T: Copy + Default + PartialEq {
impl<T> Edge<T>
where
T: Copy + Default + PartialEq,
{
/// Creates a new `Edge` with values individually specified for each edge
///
/// # Arguments
......@@ -71,31 +77,46 @@ impl<T> Edge<T> where T: Copy + Default + PartialEq {
}
}
impl<T> From<Edge<T>> for (T, T, T, T) where T: Copy + Default + PartialEq {
impl<T> From<Edge<T>> for (T, T, T, T)
where
T: Copy + Default + PartialEq,
{
fn from(edge: Edge<T>) -> Self {
edge.into_tuple()
}
}
impl<T> From<T> for Edge<T> where T: Copy + Default + PartialEq {
impl<T> From<T> for Edge<T>
where
T: Copy + Default + PartialEq,
{
fn from(value: T) -> Self {
Edge::all(value)
}
}
impl<T> From<(T, T)> for Edge<T> where T: Copy + Default + PartialEq {
impl<T> From<(T, T)> for Edge<T>
where
T: Copy + Default + PartialEq,
{
fn from(value: (T, T)) -> Self {
Edge::axis(value.0, value.1)
}
}
impl<T> From<(T, T, T, T)> for Edge<T> where T: Copy + Default + PartialEq {
impl<T> From<(T, T, T, T)> for Edge<T>
where
T: Copy + Default + PartialEq,
{
fn from(value: (T, T, T, T)) -> Self {
Edge::new(value.0, value.1, value.2, value.3)
}
}
impl<T> Mul<T> for Edge<T> where T: Copy + Default + PartialEq + Mul<Output=T> {
impl<T> Mul<T> for Edge<T>
where
T: Copy + Default + PartialEq + Mul<Output = T>,
{
type Output = Self;
fn mul(self, rhs: T) -> Self::Output {
......@@ -108,7 +129,10 @@ impl<T> Mul<T> for Edge<T> where T: Copy + Default + PartialEq + Mul<Output=T> {
}
}
impl<T> Mul<Edge<T>> for Edge<T> where T: Copy + Default + PartialEq + Mul<Output=T> {
impl<T> Mul<Edge<T>> for Edge<T>
where
T: Copy + Default + PartialEq + Mul<Output = T>,
{
type Output = Self;
fn mul(self, rhs: Edge<T>) -> Self::Output {
......@@ -121,7 +145,10 @@ impl<T> Mul<Edge<T>> for Edge<T> where T: Copy + Default + PartialEq + Mul<Outpu
}
}
impl<T> MulAssign<T> for Edge<T> where T: Copy + Default + PartialEq + MulAssign {
impl<T> MulAssign<T> for Edge<T>
where
T: Copy + Default + PartialEq + MulAssign,
{
fn mul_assign(&mut self, rhs: T) {
self.top *= rhs;
self.right *= rhs;
......@@ -130,7 +157,10 @@ impl<T> MulAssign<T> for Edge<T> where T: Copy + Default + PartialEq + MulAssign
}
}
impl<T> MulAssign<Edge<T>> for Edge<T> where T: Copy + Default + PartialEq + MulAssign {
impl<T> MulAssign<Edge<T>> for Edge<T>
where
T: Copy + Default + PartialEq + MulAssign,
{
fn mul_assign(&mut self, rhs: Edge<T>) {
self.top *= rhs.top;
self.right *= rhs.right;
......@@ -165,7 +195,7 @@ mod tests {
#[test]
fn multiplication_should_work_on_edges() {
let expected = (10.0, 20.0, 30.0, 40.0);
let mut corner= Edge::new(1.0, 2.0, 3.0, 4.0);
let mut corner = Edge::new(1.0, 2.0, 3.0, 4.0);
// Basic multiplication
let multiplied = corner * 10.0;
......@@ -175,4 +205,4 @@ mod tests {
corner *= 10.0;
assert_eq!(expected, corner.into_tuple());
}
}
\ No newline at end of file
}
mod corner;
mod edge;
mod option_ref;
mod corner;
pub use morphorm::{LayoutType, PositionType, Units};
pub use edge::Edge;
pub use corner::Corner;
pub use edge::Edge;
pub use morphorm::{LayoutType, PositionType, Units};
use crate::cursor::PointerEvents;
use crate::{color::Color, render_command::RenderCommand, CursorIcon};
......@@ -28,8 +28,8 @@ pub enum StyleProp<T: Default + Clone> {
}
impl<T> Default for StyleProp<T>
where
T: Default + Clone,
where
T: Default + Clone,
{
fn default() -> Self {
Self::Unset
......@@ -37,8 +37,8 @@ impl<T> Default for StyleProp<T>
}
impl<T> StyleProp<T>
where
T: Default + Clone,
where
T: Default + Clone,
{
pub fn resolve(&self) -> T {
match self {
......
......@@ -27,4 +27,4 @@ impl AsRefOption<Style> for &Option<Style> {
fn as_ref_option(&self) -> Option<&Style> {
self.as_ref()
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment