mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 14:48:42 -06:00
rename FrameRect
to RectFrame
This commit is contained in:
parent
44b8beaa94
commit
d82eb2eeb1
|
@ -32,7 +32,7 @@
|
|||
.with_align(Alignment::Center)
|
||||
.with_padding(5.)
|
||||
.with_gap(10.)
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0.5, 0.5, 0.5, 1.),
|
||||
corner_radius: 10.,
|
||||
})
|
||||
|
@ -44,7 +44,7 @@
|
|||
.add_child(ui);
|
||||
Container::default()
|
||||
.with_padding((10., 20.))
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: color::DARK_RED,
|
||||
corner_radius: (2.5, 30., 2.5, 2.5),
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@ use winit::{
|
|||
use hui::{
|
||||
element::{
|
||||
container::Container, frame_view::FrameView, progress_bar::ProgressBar, ElementList, UiElement
|
||||
}, frame::FrameRect, layout::{Alignment, Direction, Size}, rect::{Corners, Sides}, UiInstance
|
||||
}, frame::RectFrame, layout::{Alignment, Direction, Size}, rect::{Corners, Sides}, UiInstance
|
||||
};
|
||||
use hui_glium::GliumUiRenderer;
|
||||
|
||||
|
@ -92,7 +92,7 @@ fn main() {
|
|||
Box::new(Container {
|
||||
gap: 5.,
|
||||
padding: Sides::all(5.),
|
||||
background_frame: Box::new(FrameRect::color(vec4(0., 0., 0., 0.5))),
|
||||
background_frame: Box::new(RectFrame::color(vec4(0., 0., 0., 0.5))),
|
||||
direction: Direction::Horizontal,
|
||||
children: {
|
||||
let mut x: Vec<Box<dyn UiElement>> = vec![];
|
||||
|
@ -111,7 +111,7 @@ fn main() {
|
|||
..Default::default()
|
||||
}),
|
||||
Box::new(Container {
|
||||
background_frame: Box::new(FrameRect::color((1., 0., 0.)).with_corner_radius(Corners {
|
||||
background_frame: Box::new(RectFrame::color((1., 0., 0.)).with_corner_radius(Corners {
|
||||
top_left: 0.,
|
||||
top_right: 30.,
|
||||
bottom_left: 0.,
|
||||
|
|
|
@ -5,7 +5,7 @@ use hui::{
|
|||
progress_bar::ProgressBar,
|
||||
text::Text,
|
||||
UiElementExt,
|
||||
}, frame::FrameRect, frame_rect, layout::{Alignment, Direction}, size
|
||||
}, frame::RectFrame, rect_frame, layout::{Alignment, Direction}, size
|
||||
};
|
||||
|
||||
#[path = "../boilerplate.rs"]
|
||||
|
@ -31,7 +31,7 @@ ui_main!{
|
|||
.with_gap(5.)
|
||||
.with_padding(10.)
|
||||
.with_size(size!(450, auto))
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0.2, 0.2, 0.5),
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
@ -43,11 +43,11 @@ ui_main!{
|
|||
.add_child(ui);
|
||||
ProgressBar::default()
|
||||
.with_value(mom_ratio)
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: color::BLACK,
|
||||
corner_radius: 0.125 * ProgressBar::DEFAULT_HEIGHT
|
||||
})
|
||||
.with_foreground(frame_rect! {
|
||||
.with_foreground(rect_frame! {
|
||||
color: color::BLUE,
|
||||
corner_radius: 0.125 * ProgressBar::DEFAULT_HEIGHT
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@ use winit::{
|
|||
use hui::{
|
||||
element::{
|
||||
container::Container, frame_view::FrameView, spacer::Spacer, text::Text, ElementList
|
||||
}, frame::FrameRect, layout::Size, UiInstance
|
||||
}, frame::RectFrame, layout::Size, UiInstance
|
||||
};
|
||||
use hui_glium::GliumUiRenderer;
|
||||
|
||||
|
@ -49,7 +49,7 @@ fn main() {
|
|||
|
||||
hui.add(Container {
|
||||
size: (Size::Relative(1.), Size::Relative(1.)).into(),
|
||||
background_frame: Box::new(FrameRect::color((0.1, 0.1, 0.1, 1.))),
|
||||
background_frame: Box::new(RectFrame::color((0.1, 0.1, 0.1, 1.))),
|
||||
children: elements(|elem| {
|
||||
elem.push(Box::new(Text {
|
||||
text: "THIS LINE SHOULD BE SHARP!".into(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use hui::{
|
||||
color, size, frame_rect,
|
||||
color, size, rect_frame,
|
||||
element::{container::Container, text::Text, UiElementExt},
|
||||
frame::FrameRect,
|
||||
frame::RectFrame,
|
||||
layout::Alignment,
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@ ui_main!(|ui, size, _| {
|
|||
.with_align(Alignment::Center)
|
||||
.with_padding(5.)
|
||||
.with_gap(10.)
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0.5, 0.5, 0.5, 1.),
|
||||
corner_radius: 10.,
|
||||
})
|
||||
|
@ -27,7 +27,7 @@ ui_main!(|ui, size, _| {
|
|||
.add_child(ui);
|
||||
Container::default()
|
||||
.with_padding((10., 20.))
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: color::DARK_RED,
|
||||
corner_radius: (2.5, 30., 2.5, 2.5),
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use glam::vec4;
|
||||
use hui::{
|
||||
size, frame_rect,
|
||||
size, rect_frame,
|
||||
color,
|
||||
element::{
|
||||
container::Container,
|
||||
|
@ -8,7 +8,7 @@ use hui::{
|
|||
text::Text,
|
||||
UiElementExt
|
||||
},
|
||||
frame::FrameRect,
|
||||
frame::RectFrame,
|
||||
layout::Alignment,
|
||||
rect::Corners,
|
||||
text::FontHandle
|
||||
|
@ -45,7 +45,7 @@ ui_main!(
|
|||
.with_children(|ui| {
|
||||
Container::default()
|
||||
.with_padding((10., 15.))
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0., 0., 0., 0.5),
|
||||
corner_radius: 8.,
|
||||
})
|
||||
|
@ -70,7 +70,7 @@ ui_main!(
|
|||
.with_align((Alignment::Center, Alignment::Begin))
|
||||
.with_padding(15.)
|
||||
.with_gap(10.)
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0., 0., 0., 0.5),
|
||||
corner_radius: 8.,
|
||||
})
|
||||
|
@ -111,7 +111,7 @@ ui_main!(
|
|||
.with_children(|ui| {
|
||||
Container::default()
|
||||
.with_padding(10.)
|
||||
.with_background(frame_rect!{
|
||||
.with_background(rect_frame!{
|
||||
color: (0., 0., 0., 0.5),
|
||||
corner_radius: 8.,
|
||||
})
|
||||
|
|
|
@ -7,7 +7,7 @@ use hui::{
|
|||
text::Text,
|
||||
transformer::ElementTransformExt,
|
||||
UiElementExt
|
||||
}, frame::FrameRect, frame_rect, layout::Alignment, rect::Corners, size, text::FontHandle
|
||||
}, frame::RectFrame, rect_frame, layout::Alignment, rect::Corners, size, text::FontHandle
|
||||
};
|
||||
|
||||
#[path = "../boilerplate.rs"]
|
||||
|
@ -37,7 +37,7 @@ ui_main!(
|
|||
.with_align((Alignment::Center, Alignment::Begin))
|
||||
.with_padding(15.)
|
||||
.with_gap(10.)
|
||||
.with_background(frame_rect! {
|
||||
.with_background(rect_frame! {
|
||||
color: (0., 0., 0., 0.5),
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ use hui::{
|
|||
container::Container,
|
||||
frame_view::FrameView,
|
||||
UiElementExt
|
||||
}, frame_rect, layout::{Alignment, Direction}, size
|
||||
}, rect_frame, layout::{Alignment, Direction}, size
|
||||
};
|
||||
|
||||
#[path = "../boilerplate.rs"]
|
||||
|
@ -30,7 +30,7 @@ ui_main!(
|
|||
for i in 0..10 {
|
||||
FrameView::default()
|
||||
.with_size(size!((40 + i * 10)))
|
||||
.with_frame(frame_rect! {
|
||||
.with_frame(rect_frame! {
|
||||
color: color::DARK_RED,
|
||||
corner_radius: 8.
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ use derive_setters::Setters;
|
|||
use glam::{Vec2, vec2};
|
||||
use crate::{
|
||||
element::{ElementList, MeasureContext, ProcessContext, UiElement},
|
||||
frame::{Frame, FrameRect},
|
||||
frame::{Frame, RectFrame},
|
||||
layout::{compute_size, Alignment, Alignment2d, Direction, LayoutInfo, Size, Size2d, WrapBehavior},
|
||||
measure::{Hints, Response},
|
||||
rect::Sides,
|
||||
|
@ -82,7 +82,7 @@ impl Default for Container {
|
|||
gap: 0.,
|
||||
padding: Sides::all(0.),
|
||||
align: Alignment2d::default(),
|
||||
background_frame: Box::<FrameRect>::default(),
|
||||
background_frame: Box::<RectFrame>::default(),
|
||||
wrap: WrapBehavior::Allow,
|
||||
children: ElementList(Vec::new()),
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use derive_setters::Setters;
|
||||
use crate::{
|
||||
element::{MeasureContext, ProcessContext, UiElement},
|
||||
frame::{Frame, FrameRect},
|
||||
frame::{Frame, RectFrame},
|
||||
layout::{compute_size, Size2d},
|
||||
measure::Response,
|
||||
size
|
||||
|
@ -41,7 +41,7 @@ impl Default for FrameView {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
size: size!(10, 10),
|
||||
frame: Box::new(FrameRect::color((0., 0., 0., 0.5))),
|
||||
frame: Box::new(RectFrame::color((0., 0., 0., 0.5))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use derive_setters::Setters;
|
|||
use glam::vec2;
|
||||
use crate::{
|
||||
element::{MeasureContext, ProcessContext, UiElement},
|
||||
frame::{Frame, FrameRect},
|
||||
frame::{Frame, RectFrame},
|
||||
layout::{compute_size, Size, Size2d},
|
||||
measure::Response,
|
||||
};
|
||||
|
@ -47,8 +47,8 @@ impl Default for ProgressBar {
|
|||
Self {
|
||||
value: 0.,
|
||||
size: Size::Auto.into(),
|
||||
foreground: Box::new(FrameRect::color((0.0, 0.0, 1.0, 1.0))),
|
||||
background: Box::new(FrameRect::color((0.0, 0.0, 0.0, 1.0))),
|
||||
foreground: Box::new(RectFrame::color((0.0, 0.0, 1.0, 1.0))),
|
||||
background: Box::new(RectFrame::color((0.0, 0.0, 0.0, 1.0))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use derive_setters::Setters;
|
|||
use glam::{Vec2, vec2};
|
||||
|
||||
use crate::{
|
||||
draw::UiDrawCommand, element::{MeasureContext, ProcessContext, UiElement}, frame::{Frame, FrameRect}, layout::{compute_size, Size2d}, measure::Response, rect::FillColor, signal::{trigger::SignalTriggerArg, Signal}
|
||||
draw::UiDrawCommand, element::{MeasureContext, ProcessContext, UiElement}, frame::{Frame, RectFrame}, layout::{compute_size, Size2d}, measure::Response, rect::FillColor, signal::{trigger::SignalTriggerArg, Signal}
|
||||
};
|
||||
|
||||
|
||||
|
@ -79,9 +79,9 @@ impl Default for Slider {
|
|||
Self {
|
||||
value: 0.0,
|
||||
size: Size2d::default(),
|
||||
handle: Box::new(FrameRect::color((0.0, 0.0, 1.))),
|
||||
track: Box::new(FrameRect::color((0.5, 0.5, 0.5))),
|
||||
track_active: Box::new(FrameRect::color((0.0, 0.0, 0.75))),
|
||||
handle: Box::new(RectFrame::color((0.0, 0.0, 1.))),
|
||||
track: Box::new(RectFrame::color((0.5, 0.5, 0.5))),
|
||||
track_active: Box::new(RectFrame::color((0.0, 0.0, 0.75))),
|
||||
track_height: 0.25,
|
||||
handle_size: (15.0, 1.),
|
||||
follow_mode: SliderFollowMode::default(),
|
||||
|
|
|
@ -9,7 +9,7 @@ pub mod stack;
|
|||
pub mod nine_patch;
|
||||
mod impls;
|
||||
|
||||
pub use rect::FrameRect;
|
||||
pub use rect::RectFrame;
|
||||
|
||||
/// Trait for a drawable frame
|
||||
pub trait Frame {
|
||||
|
|
|
@ -10,7 +10,7 @@ use super::{Frame, point::FramePoint2d};
|
|||
///
|
||||
/// Can optionally be tinted, textured, and have rounded corners
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct FrameRect {
|
||||
pub struct RectFrame {
|
||||
/// Background color of the frame\
|
||||
///
|
||||
/// If the container has a background texture, it will be multiplied by this color
|
||||
|
@ -35,26 +35,26 @@ pub struct FrameRect {
|
|||
pub corner_radius: Corners<f32>,
|
||||
}
|
||||
|
||||
// impl<T: Into<FillColor>> From<T> for FrameRect {
|
||||
// impl<T: Into<FillColor>> From<T> for RectFrame {
|
||||
// fn from(color: T) -> Self {
|
||||
// Self::from_color(color)
|
||||
// }
|
||||
// }
|
||||
|
||||
impl From<FillColor> for FrameRect {
|
||||
impl From<FillColor> for RectFrame {
|
||||
fn from(color: FillColor) -> Self {
|
||||
Self::color(color)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ImageHandle> for FrameRect {
|
||||
impl From<ImageHandle> for RectFrame {
|
||||
fn from(image: ImageHandle) -> Self {
|
||||
Self::image(image)
|
||||
}
|
||||
}
|
||||
|
||||
impl FrameRect {
|
||||
/// Create a new [`FrameRect`] with the given color
|
||||
impl RectFrame {
|
||||
/// Create a new [`RectFrame`] with the given color
|
||||
pub fn color(color: impl Into<FillColor>) -> Self {
|
||||
Self {
|
||||
color: color.into(),
|
||||
|
@ -62,7 +62,7 @@ impl FrameRect {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new [`FrameRect`] with the given image\
|
||||
/// Create a new [`RectFrame`] with the given image\
|
||||
///
|
||||
/// Color will be set to [`WHITE`](crate::color::WHITE) to ensure the image is visible
|
||||
pub fn image(image: ImageHandle) -> Self {
|
||||
|
@ -73,7 +73,7 @@ impl FrameRect {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a new [`FrameRect`] with the given color and image
|
||||
/// Create a new [`RectFrame`] with the given color and image
|
||||
pub fn color_image(color: impl Into<FillColor>, image: ImageHandle) -> Self {
|
||||
Self {
|
||||
color: color.into(),
|
||||
|
@ -82,7 +82,7 @@ impl FrameRect {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the corner radius of the [`FrameRect`]
|
||||
/// Set the corner radius of the [`RectFrame`]
|
||||
pub fn with_corner_radius(self, radius: impl Into<Corners<f32>>) -> Self {
|
||||
Self {
|
||||
corner_radius: radius.into(),
|
||||
|
@ -102,7 +102,7 @@ impl FrameRect {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for FrameRect {
|
||||
impl Default for RectFrame {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
color: FillColor::transparent(),
|
||||
|
@ -114,7 +114,7 @@ impl Default for FrameRect {
|
|||
}
|
||||
}
|
||||
|
||||
impl Frame for FrameRect {
|
||||
impl Frame for RectFrame {
|
||||
fn draw(&self, draw: &mut UiDrawCommandList, position: Vec2, parent_size: Vec2) {
|
||||
//TODO: handle bottom_right < top_left
|
||||
let top_left = self.top_left.resolve(parent_size);
|
||||
|
@ -132,14 +132,14 @@ impl Frame for FrameRect {
|
|||
}
|
||||
|
||||
fn covers_opaque(&self) -> bool {
|
||||
self.top_left.x.absolute <= 0. &&
|
||||
self.top_left.x.relative <= 0. &&
|
||||
self.top_left.y.absolute <= 0. &&
|
||||
self.top_left.x.absolute <= 0. &&
|
||||
self.top_left.y.relative <= 0. &&
|
||||
self.bottom_right.x.absolute >= 0. &&
|
||||
self.top_left.y.absolute <= 0. &&
|
||||
self.bottom_right.x.relative >= 1. &&
|
||||
self.bottom_right.y.absolute >= 0. &&
|
||||
self.bottom_right.x.absolute >= 0. &&
|
||||
self.bottom_right.y.relative >= 1. &&
|
||||
self.bottom_right.y.absolute >= 0. &&
|
||||
self.color.is_opaque() &&
|
||||
self.image.is_none() &&
|
||||
self.corner_radius.max_f32() == 0.
|
||||
|
|
|
@ -75,7 +75,7 @@ macro_rules! size {
|
|||
};
|
||||
}
|
||||
|
||||
/// Helper macro for constructing a `FrameRect`
|
||||
/// Helper macro for constructing a `RectFrame`
|
||||
///
|
||||
/// # Example:
|
||||
/// ```
|
||||
|
@ -89,24 +89,24 @@ macro_rules! size {
|
|||
/// - If the `image` field is set, but not `color`, the `color` field will default to [`WHITE`](crate::color::WHITE) (to ensure visibility)
|
||||
/// - If both `color` and `image` are not set, the `color` field will default to [`TRANSPARENT`](crate::color::TRANSPARENT)
|
||||
#[macro_export]
|
||||
macro_rules! frame_rect {
|
||||
macro_rules! rect_frame {
|
||||
{} => {
|
||||
$crate::frame::FrameRect::default()
|
||||
$crate::frame::RectFrame::default()
|
||||
};
|
||||
|
||||
// () => {
|
||||
// $crate::frame::FrameRect::default()
|
||||
// $crate::frame::RectFrame::default()
|
||||
// };
|
||||
|
||||
($expr:expr) => {
|
||||
{
|
||||
let _frame_rect: $crate::frame::FrameRect = $crate::frame::FrameRect::from($expr);
|
||||
let _frame_rect: $crate::frame::RectFrame = $crate::frame::RectFrame::from($expr);
|
||||
_frame_rect
|
||||
}
|
||||
};
|
||||
|
||||
($image:expr, $color:expr) => {
|
||||
$crate::frame::FrameRect::color_image($color, $image)
|
||||
$crate::frame::RectFrame::color_image($color, $image)
|
||||
};
|
||||
|
||||
{$($ident:ident : $expr:expr),+$(,)?} => {
|
||||
|
@ -115,9 +115,9 @@ macro_rules! frame_rect {
|
|||
#[allow(non_upper_case_globals)]
|
||||
{$(const $ident: () = ();)+}
|
||||
|
||||
// construct the FrameRect
|
||||
// construct the RectFrame
|
||||
{
|
||||
let mut frame_rect = $crate::frame::FrameRect::default();
|
||||
let mut frame_rect = $crate::frame::RectFrame::default();
|
||||
let mut _color_is_set = false;
|
||||
let mut _image_is_set = false;
|
||||
$(
|
||||
|
@ -148,9 +148,9 @@ macro_rules! frame_rect {
|
|||
// const $ident: () = ();
|
||||
// )+
|
||||
// }
|
||||
// // construct the FrameRect
|
||||
// // construct the RectFrame
|
||||
// {
|
||||
// let mut _frame_rect: $crate::frame::FrameRect = ($from).into();
|
||||
// let mut _frame_rect: $crate::frame::RectFrame = ($from).into();
|
||||
// $(
|
||||
// let $ident = ($expr).into();
|
||||
// _frame_rect.$ident = $ident;
|
||||
|
|
Loading…
Reference in a new issue