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