mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-22 15:18:43 -06:00
rename FillRect
to FrameView
This commit is contained in:
parent
7b671d2f3d
commit
45829d5fef
|
@ -9,7 +9,7 @@ use winit::{
|
||||||
};
|
};
|
||||||
use hui::{
|
use hui::{
|
||||||
element::{
|
element::{
|
||||||
container::Container, fill_rect::FillRect, progress_bar::ProgressBar, ElementList, UiElement
|
container::Container, fill_rect::FrameView, progress_bar::ProgressBar, ElementList, UiElement
|
||||||
}, frame::FrameRect, layout::{Alignment, Direction, Size}, rect::{Corners, Sides}, UiInstance
|
}, frame::FrameRect, layout::{Alignment, Direction, Size}, rect::{Corners, Sides}, UiInstance
|
||||||
};
|
};
|
||||||
use hui_glium::GliumUiRenderer;
|
use hui_glium::GliumUiRenderer;
|
||||||
|
@ -71,11 +71,11 @@ fn main() {
|
||||||
padding: Sides::all(5.),
|
padding: Sides::all(5.),
|
||||||
gap: 10.,
|
gap: 10.,
|
||||||
children: ElementList(vec![
|
children: ElementList(vec![
|
||||||
Box::new(FillRect {
|
Box::new(FrameView {
|
||||||
size: (Size::Relative(0.5), Size::Absolute(30.)).into(),
|
size: (Size::Relative(0.5), Size::Absolute(30.)).into(),
|
||||||
frame: Box::new(vec4(0.75, 0., 0., 1.)),
|
frame: Box::new(vec4(0.75, 0., 0., 1.)),
|
||||||
}),
|
}),
|
||||||
Box::new(FillRect {
|
Box::new(FrameView {
|
||||||
size: (Size::Relative(z / 2. + 0.5), Size::Absolute(30.)).into(),
|
size: (Size::Relative(z / 2. + 0.5), Size::Absolute(30.)).into(),
|
||||||
frame: Box::new(Corners::left_right(
|
frame: Box::new(Corners::left_right(
|
||||||
vec4(1., 0., 0., 1.),
|
vec4(1., 0., 0., 1.),
|
||||||
|
@ -85,7 +85,7 @@ fn main() {
|
||||||
]),
|
]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
Box::new(FillRect {
|
Box::new(FrameView {
|
||||||
size: (Size::Relative(z / 2. + 0.5), Size::Absolute(30.)).into(),
|
size: (Size::Relative(z / 2. + 0.5), Size::Absolute(30.)).into(),
|
||||||
frame: Box::new(vec4(0., 0.75, 0., 1.)),
|
frame: Box::new(vec4(0., 0.75, 0., 1.)),
|
||||||
}),
|
}),
|
||||||
|
@ -97,7 +97,7 @@ fn main() {
|
||||||
children: {
|
children: {
|
||||||
let mut x: Vec<Box<dyn UiElement>> = vec![];
|
let mut x: Vec<Box<dyn UiElement>> = vec![];
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
x.push(Box::new(FillRect {
|
x.push(Box::new(FrameView {
|
||||||
size: (Size::Absolute(50.), Size::Absolute(50.)).into(),
|
size: (Size::Absolute(50.), Size::Absolute(50.)).into(),
|
||||||
frame: Box::new(if i == 1 {
|
frame: Box::new(if i == 1 {
|
||||||
vec4(0.75, 0.75, 0.75, 0.75)
|
vec4(0.75, 0.75, 0.75, 0.75)
|
||||||
|
@ -124,7 +124,7 @@ fn main() {
|
||||||
right: 40.,
|
right: 40.,
|
||||||
},
|
},
|
||||||
children: ElementList(vec![
|
children: ElementList(vec![
|
||||||
Box::new(FillRect {
|
Box::new(FrameView {
|
||||||
size: (Size::Absolute(50.), Size::Absolute(50.)).into(),
|
size: (Size::Absolute(50.), Size::Absolute(50.)).into(),
|
||||||
frame: Box::new(vec4(1., 1., 1., 0.75)),
|
frame: Box::new(vec4(1., 1., 1., 0.75)),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -9,7 +9,7 @@ use winit::{
|
||||||
};
|
};
|
||||||
use hui::{
|
use hui::{
|
||||||
element::{
|
element::{
|
||||||
container::Container, fill_rect::FillRect, spacer::Spacer, text::Text, ElementList
|
container::Container, fill_rect::FrameView, spacer::Spacer, text::Text, ElementList
|
||||||
}, frame::FrameRect, layout::Size, UiInstance
|
}, frame::FrameRect, layout::Size, UiInstance
|
||||||
};
|
};
|
||||||
use hui_glium::GliumUiRenderer;
|
use hui_glium::GliumUiRenderer;
|
||||||
|
@ -71,11 +71,11 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
elem.push(Box::new(FillRect {
|
elem.push(Box::new(FrameView {
|
||||||
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
||||||
frame: Box::new(vec4(0., 0., 1., 1.)),
|
frame: Box::new(vec4(0., 0., 1., 1.)),
|
||||||
}));
|
}));
|
||||||
elem.push(Box::new(FillRect {
|
elem.push(Box::new(FrameView {
|
||||||
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
||||||
frame: Box::new(vec4(1., 1., 0., 1.)),
|
frame: Box::new(vec4(1., 1., 0., 1.)),
|
||||||
}));
|
}));
|
||||||
|
@ -86,11 +86,11 @@ fn main() {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}));
|
}));
|
||||||
if instant.elapsed().as_secs() & 1 != 0 {
|
if instant.elapsed().as_secs() & 1 != 0 {
|
||||||
elem.push(Box::new(FillRect {
|
elem.push(Box::new(FrameView {
|
||||||
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
||||||
frame: Box::new(vec4(1., 0., 0., 1.)),
|
frame: Box::new(vec4(1., 0., 0., 1.)),
|
||||||
}));
|
}));
|
||||||
elem.push(Box::new(FillRect {
|
elem.push(Box::new(FrameView {
|
||||||
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
size: (Size::Relative(1.), Size::Absolute(10.)).into(),
|
||||||
frame: Box::new(vec4(0., 0., 0., 1.)),
|
frame: Box::new(vec4(0., 0., 0., 1.)),
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::time::Instant;
|
||||||
use hui::{
|
use hui::{
|
||||||
color, element::{
|
color, element::{
|
||||||
container::Container,
|
container::Container,
|
||||||
fill_rect::FillRect,
|
fill_rect::FrameView,
|
||||||
UiElementExt
|
UiElementExt
|
||||||
}, frame_rect, layout::{Alignment, Direction}, size
|
}, frame_rect, layout::{Alignment, Direction}, size
|
||||||
};
|
};
|
||||||
|
@ -28,7 +28,7 @@ ui_main!(
|
||||||
.with_wrap(true)
|
.with_wrap(true)
|
||||||
.with_children(|ui| {
|
.with_children(|ui| {
|
||||||
for i in 0..10 {
|
for i in 0..10 {
|
||||||
FillRect::default()
|
FrameView::default()
|
||||||
.with_size(size!((40 + i * 10)))
|
.with_size(size!((40 + i * 10)))
|
||||||
.with_frame(frame_rect! {
|
.with_frame(frame_rect! {
|
||||||
color: color::DARK_RED,
|
color: color::DARK_RED,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use hui::{
|
||||||
color,
|
color,
|
||||||
element::{
|
element::{
|
||||||
container::Container,
|
container::Container,
|
||||||
fill_rect::FillRect,
|
fill_rect::FrameView,
|
||||||
slider::Slider,
|
slider::Slider,
|
||||||
text::Text,
|
text::Text,
|
||||||
UiElementExt
|
UiElementExt
|
||||||
|
@ -54,7 +54,7 @@ ui_main!(
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
})
|
})
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
FillRect::default()
|
FrameView::default()
|
||||||
.with_size(size!(600, 75))
|
.with_size(size!(600, 75))
|
||||||
.with_frame(NinePatchFrame::from_asset(*asset).with_color(color::GREEN))
|
.with_frame(NinePatchFrame::from_asset(*asset).with_color(color::GREEN))
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
|
@ -62,7 +62,7 @@ ui_main!(
|
||||||
.with_color(color::BLACK)
|
.with_color(color::BLACK)
|
||||||
.with_text_size(32)
|
.with_text_size(32)
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
FillRect::default()
|
FrameView::default()
|
||||||
.with_size(size!(700, 50))
|
.with_size(size!(700, 50))
|
||||||
.with_frame(NinePatchFrame::from_asset(*asset).with_color((
|
.with_frame(NinePatchFrame::from_asset(*asset).with_color((
|
||||||
(1., 0., 1.),
|
(1., 0., 1.),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use hui::{
|
||||||
layout::{Alignment, Direction},
|
layout::{Alignment, Direction},
|
||||||
element::{
|
element::{
|
||||||
container::Container,
|
container::Container,
|
||||||
fill_rect::FillRect,
|
fill_rect::FrameView,
|
||||||
image::Image,
|
image::Image,
|
||||||
text::Text,
|
text::Text,
|
||||||
UiElementExt
|
UiElementExt
|
||||||
|
@ -62,7 +62,7 @@ ui_main!(
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
})
|
})
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
FillRect::default()
|
FrameView::default()
|
||||||
.with_size(size!(100%, 1))
|
.with_size(size!(100%, 1))
|
||||||
.with_frame(color::rgb_hex(0x2d2d30))
|
.with_frame(color::rgb_hex(0x2d2d30))
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
|
@ -75,7 +75,7 @@ ui_main!(
|
||||||
.with_size(size!(54, 100%))
|
.with_size(size!(54, 100%))
|
||||||
.with_background(color::rgb_hex(0x343334))
|
.with_background(color::rgb_hex(0x343334))
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
FillRect::default()
|
FrameView::default()
|
||||||
.with_size(size!(1, 100%))
|
.with_size(size!(1, 100%))
|
||||||
.with_frame(color::rgb_hex(0x2d2d30))
|
.with_frame(color::rgb_hex(0x2d2d30))
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
//! Simple filled rectangle with the specified size, background and corner radius
|
//! Simple element that displays the specified frame
|
||||||
|
|
||||||
use derive_setters::Setters;
|
use derive_setters::Setters;
|
||||||
use glam::vec2;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
draw::{RoundedCorners, UiDrawCommand},
|
|
||||||
element::{MeasureContext, ProcessContext, UiElement},
|
element::{MeasureContext, ProcessContext, UiElement},
|
||||||
frame::{Frame, FrameRect},
|
frame::{Frame, FrameRect},
|
||||||
layout::{compute_size, Size, Size2d},
|
layout::{compute_size, Size2d},
|
||||||
measure::Response,
|
measure::Response,
|
||||||
size
|
size
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Simple filled rectangle with the specified size, background, and corner radius
|
/// Simple rectangle that displays the specified frame
|
||||||
#[derive(Setters)]
|
#[derive(Setters)]
|
||||||
#[setters(prefix = "with_")]
|
#[setters(prefix = "with_")]
|
||||||
pub struct FillRect {
|
pub struct FrameView {
|
||||||
/// Size of the rectangle
|
/// Size of the rectangle
|
||||||
#[setters(into)]
|
#[setters(into)]
|
||||||
pub size: Size2d,
|
pub size: Size2d,
|
||||||
|
@ -24,14 +22,22 @@ pub struct FillRect {
|
||||||
pub frame: Box<dyn Frame>,
|
pub frame: Box<dyn Frame>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FillRect {
|
impl FrameView {
|
||||||
|
pub fn new(frame: impl Frame + 'static) -> Self {
|
||||||
|
Self {
|
||||||
|
size: size!(10, 10),
|
||||||
|
frame: Box::new(frame),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//setters:
|
||||||
pub fn with_frame(mut self, frame: impl Frame + 'static) -> Self {
|
pub fn with_frame(mut self, frame: impl Frame + 'static) -> Self {
|
||||||
self.frame = Box::new(frame);
|
self.frame = Box::new(frame);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FillRect {
|
impl Default for FrameView {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
size: size!(10, 10),
|
size: size!(10, 10),
|
||||||
|
@ -40,9 +46,9 @@ impl Default for FillRect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UiElement for FillRect {
|
impl UiElement for FrameView {
|
||||||
fn name(&self) -> &'static str {
|
fn name(&self) -> &'static str {
|
||||||
"fill_rect"
|
"frame_view"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> Option<Size2d> {
|
fn size(&self) -> Option<Size2d> {
|
||||||
|
|
Loading…
Reference in a new issue