mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 22:58:42 -06:00
document some stuff
This commit is contained in:
parent
405963460d
commit
d14f27a428
|
@ -4,6 +4,7 @@ use proc_macro::TokenStream;
|
|||
use quote::quote;
|
||||
use syn::{parse_macro_input, DeriveInput};
|
||||
|
||||
/// Implements `Signal` trait for the given type
|
||||
#[proc_macro_derive(Signal)]
|
||||
pub fn signal(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! modular procedural background system
|
||||
|
||||
use glam::Vec2;
|
||||
use crate::draw::UiDrawCommandList;
|
||||
|
||||
|
@ -9,6 +11,7 @@ mod impls;
|
|||
|
||||
pub use rect::FrameRect;
|
||||
|
||||
/// Trait for a drawable frame
|
||||
pub trait Frame {
|
||||
/// Draw the frame at the given position and size
|
||||
fn draw(&self, draw: &mut UiDrawCommandList, position: Vec2, parent_size: Vec2);
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
use glam::{vec2, UVec2, Vec2, Vec4};
|
||||
//! nine-patch frame implementation
|
||||
//!
|
||||
//! A 9-patch image is an image that can be scaled in a way that preserves the corners and edges of the image while scaling the center.
|
||||
//! This is useful for creating scalable UI elements like buttons, windows, etc.
|
||||
|
||||
use glam::{vec2, UVec2, Vec2};
|
||||
use crate::{color, draw::{ImageHandle, UiDrawCommand}, rect::{Corners, FillColor, Rect}};
|
||||
use super::Frame;
|
||||
|
||||
/// Represents a 9-patch image asset
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct NinePatchAsset {
|
||||
pub image: ImageHandle,
|
||||
//TODO: remove this
|
||||
//TODO: remove this:
|
||||
pub size: (u32, u32),
|
||||
pub scalable_region: Rect,
|
||||
}
|
||||
|
||||
//TODO allow scaling/moving corners
|
||||
|
||||
/// A 9-patch frame
|
||||
///
|
||||
/// Can optionally be tinted with a color (works well with grayscale assets)
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct NinePatchFrame {
|
||||
pub asset: NinePatchAsset,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! frame-relative positioning/size
|
||||
|
||||
use glam::{Vec2, vec2};
|
||||
use derive_more::{Add, AddAssign, Sub, SubAssign};
|
||||
use crate::layout::{Size, Size2d};
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
//! allows stacking two frames on top of each other
|
||||
|
||||
use glam::Vec2;
|
||||
use crate::draw::UiDrawCommandList;
|
||||
use super::Frame;
|
||||
|
||||
/// A frame that draws two frames on top of each other
|
||||
pub struct FrameStack(pub Box<dyn Frame>, pub Box<dyn Frame>);
|
||||
|
||||
impl Frame for FrameStack {
|
||||
|
@ -17,6 +20,7 @@ impl Frame for FrameStack {
|
|||
}
|
||||
|
||||
pub trait FrameStackExt: Frame {
|
||||
/// Stack another frame on top of this one
|
||||
fn stack(self, other: impl Frame + 'static) -> FrameStack;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue