Skip to content
Snippets Groups Projects
Commit 9c66f0f2 authored by MrGVSV's avatar MrGVSV
Browse files

Border radius now uses Corner

parent f4f6c740
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ use bevy::{ ...@@ -4,6 +4,7 @@ use bevy::{
sprite::Rect, sprite::Rect,
}; };
use kayak_core::render_primitive::RenderPrimitive; use kayak_core::render_primitive::RenderPrimitive;
use kayak_core::styles::Corner;
use kayak_font::{Alignment, CoordinateSystem, KayakFont}; use kayak_font::{Alignment, CoordinateSystem, KayakFont};
use crate::{ use crate::{
...@@ -77,7 +78,7 @@ pub fn extract_texts( ...@@ -77,7 +78,7 @@ pub fn extract_texts(
z_index: layout.z_index, z_index: layout.z_index,
quad_type: UIQuadType::Text, quad_type: UIQuadType::Text,
type_index: 0, type_index: 0,
border_radius: (0.0, 0.0, 0.0, 0.0), border_radius: Corner::default(),
image: None, image: None,
uv_max: None, uv_max: None,
uv_min: None, uv_min: None,
......
...@@ -9,7 +9,7 @@ use bevy::{ ...@@ -9,7 +9,7 @@ use bevy::{
sprite::Rect, sprite::Rect,
window::Windows, window::Windows,
}; };
use kayak_core::{render_primitive::RenderPrimitive, Binding, Bound}; use kayak_core::{render_primitive::RenderPrimitive, styles::Corner, Binding, Bound};
use kayak_font::KayakFont; use kayak_font::KayakFont;
use crate::{ use crate::{
...@@ -129,7 +129,7 @@ pub fn extract( ...@@ -129,7 +129,7 @@ pub fn extract(
font_handle: None, font_handle: None,
quad_type: UIQuadType::Clip, quad_type: UIQuadType::Clip,
type_index: 0, type_index: 0,
border_radius: (0.0, 0.0, 0.0, 0.0), border_radius: Corner::default(),
image: None, image: None,
uv_min: None, uv_min: None,
uv_max: None, uv_max: None,
......
...@@ -5,6 +5,7 @@ use bevy::{ ...@@ -5,6 +5,7 @@ use bevy::{
sprite::Rect, sprite::Rect,
}; };
use kayak_core::render_primitive::RenderPrimitive; use kayak_core::render_primitive::RenderPrimitive;
use kayak_core::styles::Corner;
use crate::{ use crate::{
render::unified::pipeline::{ExtractQuadBundle, ExtractedQuad, UIQuadType}, render::unified::pipeline::{ExtractQuadBundle, ExtractedQuad, UIQuadType},
...@@ -60,7 +61,7 @@ pub fn extract_nine_patch( ...@@ -60,7 +61,7 @@ pub fn extract_nine_patch(
font_handle: None, font_handle: None,
quad_type: UIQuadType::Image, quad_type: UIQuadType::Image,
type_index: 0, type_index: 0,
border_radius: (0.0, 0.0, 0.0, 0.0), border_radius: Corner::default(),
image: image_handle, image: image_handle,
uv_max: None, uv_max: None,
uv_min: None, uv_min: None,
......
...@@ -37,6 +37,7 @@ use kayak_font::{ ...@@ -37,6 +37,7 @@ use kayak_font::{
KayakFont, KayakFont,
}; };
use kayak_core::styles::Corner;
use super::{Dpi, UNIFIED_SHADER_HANDLE}; use super::{Dpi, UNIFIED_SHADER_HANDLE};
use crate::{render::ui_pass::TransparentUI, WindowSize}; use crate::{render::ui_pass::TransparentUI, WindowSize};
...@@ -320,7 +321,7 @@ pub struct ExtractedQuad { ...@@ -320,7 +321,7 @@ pub struct ExtractedQuad {
pub font_handle: Option<Handle<KayakFont>>, pub font_handle: Option<Handle<KayakFont>>,
pub quad_type: UIQuadType, pub quad_type: UIQuadType,
pub type_index: u32, pub type_index: u32,
pub border_radius: (f32, f32, f32, f32), pub border_radius: Corner<f32>,
pub image: Option<Handle<Image>>, pub image: Option<Handle<Image>>,
pub uv_min: Option<Vec2>, pub uv_min: Option<Vec2>,
pub uv_max: Option<Vec2>, pub uv_max: Option<Vec2>,
...@@ -413,25 +414,25 @@ pub fn prepare_quads( ...@@ -413,25 +414,25 @@ pub fn prepare_quads(
uv_min.x, uv_min.x,
uv_max.y, uv_max.y,
extracted_sprite.char_id as f32, extracted_sprite.char_id as f32,
extracted_sprite.border_radius.0, extracted_sprite.border_radius.top_left,
); );
let top_left = Vec4::new( let top_left = Vec4::new(
uv_min.x, uv_min.x,
uv_min.y, uv_min.y,
extracted_sprite.char_id as f32, extracted_sprite.char_id as f32,
extracted_sprite.border_radius.1, extracted_sprite.border_radius.bottom_left,
); );
let top_right = Vec4::new( let top_right = Vec4::new(
uv_max.x, uv_max.x,
uv_min.y, uv_min.y,
extracted_sprite.char_id as f32, extracted_sprite.char_id as f32,
extracted_sprite.border_radius.2, extracted_sprite.border_radius.bottom_right,
); );
let bottom_right = Vec4::new( let bottom_right = Vec4::new(
uv_max.x, uv_max.x,
uv_max.y, uv_max.y,
extracted_sprite.char_id as f32, extracted_sprite.char_id as f32,
extracted_sprite.border_radius.3, extracted_sprite.border_radius.top_right,
); );
let uvs: [[f32; 4]; 6] = [ let uvs: [[f32; 4]; 6] = [
......
...@@ -7,7 +7,7 @@ use kayak_core::styles::PositionType; ...@@ -7,7 +7,7 @@ use kayak_core::styles::PositionType;
use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle}; use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, ImageManager, UICameraBundle};
use kayak_ui::core::{ use kayak_ui::core::{
render, render,
styles::{Style, StyleProp, Units}, styles::{Corner, Style, StyleProp, Units},
Index, Index,
}; };
use kayak_ui::widgets::{App, Image}; use kayak_ui::widgets::{App, Image};
...@@ -27,7 +27,7 @@ fn startup( ...@@ -27,7 +27,7 @@ fn startup(
position_type: StyleProp::Value(PositionType::SelfDirected), position_type: StyleProp::Value(PositionType::SelfDirected),
left: StyleProp::Value(Units::Pixels(10.0)), left: StyleProp::Value(Units::Pixels(10.0)),
top: StyleProp::Value(Units::Pixels(10.0)), top: StyleProp::Value(Units::Pixels(10.0)),
border_radius: StyleProp::Value((500.0, 500.0, 500.0, 500.0)), border_radius: StyleProp::Value(Corner::all(500.0)),
width: StyleProp::Value(Units::Pixels(200.0)), width: StyleProp::Value(Units::Pixels(200.0)),
height: StyleProp::Value(Units::Pixels(182.0)), height: StyleProp::Value(Units::Pixels(182.0)),
..Style::default() ..Style::default()
......
...@@ -3,7 +3,7 @@ use kayak_ui::core::{ ...@@ -3,7 +3,7 @@ use kayak_ui::core::{
color::Color, color::Color,
render_command::RenderCommand, render_command::RenderCommand,
rsx, rsx,
styles::{Style, StyleProp, Units}, styles::{Corner, Style, StyleProp, Units},
use_state, widget, EventType, OnEvent, WidgetProps, use_state, widget, EventType, OnEvent, WidgetProps,
}; };
...@@ -30,7 +30,7 @@ pub fn AddButton(props: AddButtonProps) { ...@@ -30,7 +30,7 @@ pub fn AddButton(props: AddButtonProps) {
}); });
let background_styles = Some(Style { let background_styles = Some(Style {
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)), border_radius: StyleProp::Value(Corner::all(5.0)),
background_color: StyleProp::Value(color), background_color: StyleProp::Value(color),
cursor: CursorIcon::Hand.into(), cursor: CursorIcon::Hand.into(),
padding_left: StyleProp::Value(Units::Pixels(9.0)), padding_left: StyleProp::Value(Units::Pixels(9.0)),
......
...@@ -3,7 +3,7 @@ use kayak_ui::core::{ ...@@ -3,7 +3,7 @@ use kayak_ui::core::{
color::Color, color::Color,
render_command::RenderCommand, render_command::RenderCommand,
rsx, rsx,
styles::{Style, StyleProp, Units}, styles::{Corner, Style, StyleProp, Units},
use_state, widget, EventType, OnEvent, WidgetProps, use_state, widget, EventType, OnEvent, WidgetProps,
}; };
...@@ -31,7 +31,7 @@ pub fn DeleteButton(props: DeleteButtonProps) { ...@@ -31,7 +31,7 @@ pub fn DeleteButton(props: DeleteButtonProps) {
}); });
let background_styles = Some(Style { let background_styles = Some(Style {
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)), border_radius: StyleProp::Value(Corner::all(5.0)),
background_color: StyleProp::Value(color), background_color: StyleProp::Value(color),
cursor: CursorIcon::Hand.into(), cursor: CursorIcon::Hand.into(),
padding_left: StyleProp::Value(Units::Pixels(8.0)), padding_left: StyleProp::Value(Units::Pixels(8.0)),
......
...@@ -2,7 +2,7 @@ use crate::{ ...@@ -2,7 +2,7 @@ use crate::{
color::Color, color::Color,
layout_cache::Rect, layout_cache::Rect,
render_command::RenderCommand, render_command::RenderCommand,
styles::{Edge, Style, StyleProp}, styles::{Corner, Edge, Style, StyleProp},
}; };
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
...@@ -16,7 +16,7 @@ pub enum RenderPrimitive { ...@@ -16,7 +16,7 @@ pub enum RenderPrimitive {
background_color: Color, background_color: Color,
border_color: Color, border_color: Color,
border: Edge<f32>, border: Edge<f32>,
border_radius: (f32, f32, f32, f32), border_radius: Corner<f32>,
}, },
Text { Text {
color: Color, color: Color,
...@@ -28,7 +28,7 @@ pub enum RenderPrimitive { ...@@ -28,7 +28,7 @@ pub enum RenderPrimitive {
size: f32, size: f32,
}, },
Image { Image {
border_radius: (f32, f32, f32, f32), border_radius: Corner<f32>,
layout: Rect, layout: Rect,
handle: u16, handle: u16,
}, },
......
...@@ -145,7 +145,7 @@ define_styles! { ...@@ -145,7 +145,7 @@ define_styles! {
pub struct Style { pub struct Style {
pub background_color : StyleProp<Color>, pub background_color : StyleProp<Color>,
pub border_color: StyleProp<Color>, pub border_color: StyleProp<Color>,
pub border_radius: StyleProp<(f32, f32, f32, f32)>, pub border_radius: StyleProp<Corner<f32>>,
pub border: StyleProp<Edge<f32>>, pub border: StyleProp<Edge<f32>>,
pub bottom: StyleProp<Units>, pub bottom: StyleProp<Units>,
pub color: StyleProp<Color>, pub color: StyleProp<Color>,
......
use crate::core::{ use crate::core::{
render_command::RenderCommand, render_command::RenderCommand,
rsx, rsx,
styles::{Style, StyleProp, Units}, styles::{Corner, Style, StyleProp, Units},
widget, Children, Color, Fragment, OnEvent, WidgetProps, widget, Children, Color, Fragment, OnEvent, WidgetProps,
}; };
use kayak_core::CursorIcon; use kayak_core::CursorIcon;
...@@ -48,7 +48,7 @@ pub fn Button(props: ButtonProps) { ...@@ -48,7 +48,7 @@ pub fn Button(props: ButtonProps) {
.with_style(&props.styles) .with_style(&props.styles)
.with_style(Style { .with_style(Style {
background_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)), background_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)),
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)), border_radius: StyleProp::Value(Corner::all(5.0)),
height: StyleProp::Value(Units::Pixels(45.0)), height: StyleProp::Value(Units::Pixels(45.0)),
padding_left: StyleProp::Value(Units::Stretch(1.0)), padding_left: StyleProp::Value(Units::Stretch(1.0)),
padding_right: StyleProp::Value(Units::Stretch(1.0)), padding_right: StyleProp::Value(Units::Stretch(1.0)),
......
use kayak_core::styles::{PositionType, Style, StyleProp, Units}; use kayak_core::styles::{Corner, PositionType, Style, StyleProp, Units};
use kayak_core::{Bound, Color, EventType, OnEvent, VecTracker}; use kayak_core::{Bound, Color, EventType, OnEvent, VecTracker};
use kayak_render_macros::{constructor, use_state}; use kayak_render_macros::{constructor, use_state};
...@@ -24,7 +24,7 @@ pub fn Inspector(props: InspectorProps) { ...@@ -24,7 +24,7 @@ pub fn Inspector(props: InspectorProps) {
let background_styles = Some(Style { let background_styles = Some(Style {
background_color: StyleProp::Value(Color::new(0.125, 0.125, 0.125, 1.0)), background_color: StyleProp::Value(Color::new(0.125, 0.125, 0.125, 1.0)),
border_radius: StyleProp::Value((0.0, 0.0, 0.0, 0.0)), border_radius: StyleProp::Value(Corner::all(0.0)),
position_type: StyleProp::Value(PositionType::SelfDirected), position_type: StyleProp::Value(PositionType::SelfDirected),
left: StyleProp::Value(Units::Stretch(1.0)), left: StyleProp::Value(Units::Stretch(1.0)),
top: StyleProp::Value(Units::Stretch(0.0)), top: StyleProp::Value(Units::Stretch(0.0)),
......
use crate::core::{ use crate::core::{
render_command::RenderCommand, render_command::RenderCommand,
rsx, rsx,
styles::{Style, Units}, styles::{Corner, Style, Units},
widget, Bound, Children, Color, EventType, MutableBound, OnEvent, WidgetProps, widget, Bound, Children, Color, EventType, MutableBound, OnEvent, WidgetProps,
}; };
use kayak_core::CursorIcon; use kayak_core::CursorIcon;
...@@ -102,7 +102,7 @@ pub fn TextBox(props: TextBoxProps) { ...@@ -102,7 +102,7 @@ pub fn TextBox(props: TextBoxProps) {
let background_styles = Style { let background_styles = Style {
background_color: Color::new(0.176, 0.196, 0.215, 1.0).into(), background_color: Color::new(0.176, 0.196, 0.215, 1.0).into(),
border_radius: (5.0, 5.0, 5.0, 5.0).into(), border_radius: Corner::all(5.0).into(),
height: Units::Pixels(26.0).into(), height: Units::Pixels(26.0).into(),
padding_left: Units::Pixels(5.0).into(), padding_left: Units::Pixels(5.0).into(),
padding_right: Units::Pixels(5.0).into(), padding_right: Units::Pixels(5.0).into(),
......
...@@ -2,7 +2,7 @@ use crate::core::{ ...@@ -2,7 +2,7 @@ use crate::core::{
color::Color, color::Color,
render_command::RenderCommand, render_command::RenderCommand,
rsx, rsx,
styles::{Edge, PositionType, Style, StyleProp, Units}, styles::{Corner, Edge, PositionType, Style, StyleProp, Units},
use_state, widget, Children, EventType, OnEvent, WidgetProps, use_state, widget, Children, EventType, OnEvent, WidgetProps,
}; };
use kayak_core::CursorIcon; use kayak_core::CursorIcon;
...@@ -65,7 +65,7 @@ pub fn Window(props: WindowProps) { ...@@ -65,7 +65,7 @@ pub fn Window(props: WindowProps) {
background_color: StyleProp::Value(Color::new(0.125, 0.125, 0.125, 1.0)), background_color: StyleProp::Value(Color::new(0.125, 0.125, 0.125, 1.0)),
border_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)), border_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)),
border: StyleProp::Value(Edge::all(4.0)), border: StyleProp::Value(Edge::all(4.0)),
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)), border_radius: StyleProp::Value(Corner::all(5.0)),
render_command: StyleProp::Value(RenderCommand::Quad), render_command: StyleProp::Value(RenderCommand::Quad),
position_type: StyleProp::Value(PositionType::SelfDirected), position_type: StyleProp::Value(PositionType::SelfDirected),
left: StyleProp::Value(Units::Pixels(pos.0)), left: StyleProp::Value(Units::Pixels(pos.0)),
...@@ -98,7 +98,7 @@ pub fn Window(props: WindowProps) { ...@@ -98,7 +98,7 @@ pub fn Window(props: WindowProps) {
let title_background_styles = Style { let title_background_styles = Style {
background_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)), background_color: StyleProp::Value(Color::new(0.0781, 0.0898, 0.101, 1.0)),
border_radius: StyleProp::Value((5.0, 5.0, 5.0, 5.0)), border_radius: StyleProp::Value(Corner::all(5.0)),
cursor: cursor.into(), cursor: cursor.into(),
height: StyleProp::Value(Units::Pixels(24.0)), height: StyleProp::Value(Units::Pixels(24.0)),
width: StyleProp::Value(Units::Stretch(1.0)), width: StyleProp::Value(Units::Stretch(1.0)),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment