use crate::{bindings::*, color::Color, Declaration, Dimensions, Vector2};
pub struct BorderBuilder<
'declaration,
'render,
ImageElementData: 'render,
CustomElementData: 'render,
> {
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
}
impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
BorderBuilder<'declaration, 'render, ImageElementData, CustomElementData>
{
#[inline]
pub fn new(
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
) -> Self {
BorderBuilder { parent }
}
#[inline]
pub fn all_directions(&mut self, width: u16) -> &mut Self {
self.parent.inner.border.width.left = width;
self.parent.inner.border.width.right = width;
self.parent.inner.border.width.top = width;
self.parent.inner.border.width.bottom = width;
self
}
#[inline]
pub fn left(&mut self, width: u16) -> &mut Self {
self.parent.inner.border.width.left = width;
self
}
#[inline]
pub fn right(&mut self, width: u16) -> &mut Self {
self.parent.inner.border.width.right = width;
self
}
#[inline]
pub fn top(&mut self, width: u16) -> &mut Self {
self.parent.inner.border.width.top = width;
self
}
#[inline]
pub fn bottom(&mut self, width: u16) -> &mut Self {
self.parent.inner.border.width.bottom = width;
self
}
#[inline]
pub fn between_children(&mut self, width: u16) -> &mut Self {
self.parent.inner.border.width.betweenChildren = width;
self
}
#[inline]
pub fn color(&mut self, color: Color) -> &mut Self {
self.parent.inner.border.color = color.into();
self
}
#[inline]
pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
self.parent
}
}
pub struct ImageBuilder<
'declaration,
'render,
ImageElementData: 'render,
CustomElementData: 'render,
> {
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
}
impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
ImageBuilder<'declaration, 'render, ImageElementData, CustomElementData>
{
#[inline]
pub fn new(
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
) -> Self {
ImageBuilder { parent }
}
#[inline]
pub fn data(&mut self, data: &'render ImageElementData) -> &mut Self {
self.parent.inner.image.imageData = data as *const ImageElementData as _;
self
}
#[inline]
pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
self.parent
}
}
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum FloatingAttachPointType {
LeftTop = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_LEFT_TOP,
LeftCenter = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_LEFT_CENTER,
LeftBottom = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_LEFT_BOTTOM,
CenterTop = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_CENTER_TOP,
CenterCenter = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_CENTER_CENTER,
CenterBottom = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_CENTER_BOTTOM,
RightTop = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_RIGHT_TOP,
RightCenter = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_RIGHT_CENTER,
RightBottom = Clay_FloatingAttachPointType_CLAY_ATTACH_POINT_RIGHT_BOTTOM,
}
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum PointerCaptureMode {
Capture = Clay_PointerCaptureMode_CLAY_POINTER_CAPTURE_MODE_CAPTURE,
Passthrough = Clay_PointerCaptureMode_CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
}
#[derive(Debug, Clone)]
#[repr(u8)]
pub enum FloatingAttachToElement {
None = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_NONE,
Parent = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_PARENT,
ElementWithId = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_ELEMENT_WITH_ID,
Root = Clay_FloatingAttachToElement_CLAY_ATTACH_TO_ROOT,
}
pub struct FloatingBuilder<
'declaration,
'render,
ImageElementData: 'render,
CustomElementData: 'render,
> {
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
}
impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
FloatingBuilder<'declaration, 'render, ImageElementData, CustomElementData>
{
#[inline]
pub fn new(
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
) -> Self {
FloatingBuilder { parent }
}
#[inline]
pub fn offset(&mut self, offset: Vector2) -> &mut Self {
self.parent.inner.floating.offset = offset.into();
self
}
#[inline]
pub fn dimensions(&mut self, dimensions: Dimensions) -> &mut Self {
self.parent.inner.floating.expand = dimensions.into();
self
}
#[inline]
pub fn z_index(&mut self, z_index: i16) -> &mut Self {
self.parent.inner.floating.zIndex = z_index;
self
}
#[inline]
pub fn parent_id(&mut self, id: u32) -> &mut Self {
self.parent.inner.floating.parentId = id;
self
}
#[inline]
pub fn attach_points(
&mut self,
element: FloatingAttachPointType,
parent: FloatingAttachPointType,
) -> &mut Self {
self.parent.inner.floating.attachPoints.element = element as _;
self.parent.inner.floating.attachPoints.parent = parent as _;
self
}
#[inline]
pub fn attach_to(&mut self, attach: FloatingAttachToElement) -> &mut Self {
self.parent.inner.floating.attachTo = attach as _;
self
}
#[inline]
pub fn pointer_capture_mode(&mut self, mode: PointerCaptureMode) -> &mut Self {
self.parent.inner.floating.pointerCaptureMode = mode as _;
self
}
#[inline]
pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
self.parent
}
}
pub struct CornerRadiusBuilder<
'declaration,
'render,
ImageElementData: 'render,
CustomElementData: 'render,
> {
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
}
impl<'declaration, 'render, ImageElementData: 'render, CustomElementData: 'render>
CornerRadiusBuilder<'declaration, 'render, ImageElementData, CustomElementData>
{
#[inline]
pub fn new(
parent: &'declaration mut Declaration<'render, ImageElementData, CustomElementData>,
) -> Self {
CornerRadiusBuilder { parent }
}
#[inline]
pub fn top_left(&mut self, radius: f32) -> &mut Self {
self.parent.inner.cornerRadius.topLeft = radius;
self
}
#[inline]
pub fn top_right(&mut self, radius: f32) -> &mut Self {
self.parent.inner.cornerRadius.topRight = radius;
self
}
#[inline]
pub fn bottom_left(&mut self, radius: f32) -> &mut Self {
self.parent.inner.cornerRadius.bottomLeft = radius;
self
}
#[inline]
pub fn bottom_right(&mut self, radius: f32) -> &mut Self {
self.parent.inner.cornerRadius.bottomRight = radius;
self
}
#[inline]
pub fn all(&mut self, radius: f32) -> &mut Self {
self.parent.inner.cornerRadius.topLeft = radius;
self.parent.inner.cornerRadius.topRight = radius;
self.parent.inner.cornerRadius.bottomLeft = radius;
self.parent.inner.cornerRadius.bottomRight = radius;
self
}
#[inline]
pub fn end(&mut self) -> &mut Declaration<'render, ImageElementData, CustomElementData> {
self.parent
}
}