Skip to content
Snippets Groups Projects
Commit 3591320f authored by StarArawn's avatar StarArawn
Browse files

DPI should be fixed.

parent 61bde544
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,7 @@ pub fn extract(
extracted_quads.extend(image_quads);
}
RenderPrimitive::Quad { .. } => {
let quad_quads = quad::extract_quads(&render_primitive, dpi);
let quad_quads = quad::extract_quads(&render_primitive, 1.0);
extracted_quads.extend(quad_quads);
}
RenderPrimitive::NinePatch { .. } => {
......
......@@ -7,23 +7,33 @@ use crate::{
};
pub fn extract_quads(render_primitive: &RenderPrimitive, dpi: f32) -> Vec<ExtractQuadBundle> {
let (background_color, layout, border_radius, border) = match render_primitive {
let (background_color, layout, border_radius, mut border) = match render_primitive {
RenderPrimitive::Quad {
background_color,
layout,
border_radius,
border,
} => (background_color, layout, border_radius, border),
} => (*background_color, *layout, *border_radius, *border),
_ => panic!(""),
};
border = (
border.0 * dpi,
border.1 * dpi,
border.2 * dpi,
border.3 * dpi,
);
vec![
// Border
ExtractQuadBundle {
extracted_quad: ExtractedQuad {
rect: Rect {
min: Vec2::new(layout.posx, layout.posy),
max: Vec2::new(layout.posx + layout.width, layout.posy + layout.height) * dpi,
max: Vec2::new(
layout.posx + (layout.width * dpi),
layout.posy + (layout.height * dpi),
),
},
color: bevy::prelude::Color::rgba(0.0781, 0.0898, 0.101, 1.0),
vertex_index: 0,
......@@ -32,7 +42,7 @@ pub fn extract_quads(render_primitive: &RenderPrimitive, dpi: f32) -> Vec<Extrac
font_handle: None,
quad_type: UIQuadType::Quad,
type_index: 0,
border_radius: *border_radius,
border_radius,
image: None,
uv_max: None,
uv_min: None,
......@@ -43,18 +53,18 @@ pub fn extract_quads(render_primitive: &RenderPrimitive, dpi: f32) -> Vec<Extrac
rect: Rect {
min: Vec2::new(layout.posx + border.3, layout.posy + border.0),
max: Vec2::new(
(layout.posx + layout.width) - border.1,
(layout.posy + layout.height) - border.2,
) * dpi,
(layout.posx + (layout.width * dpi)) - border.1,
(layout.posy + (layout.height * dpi)) - border.2,
),
},
color: to_bevy_color(background_color),
color: to_bevy_color(&background_color),
vertex_index: 0,
char_id: 0,
z_index: layout.z_index,
font_handle: None,
quad_type: UIQuadType::Quad,
type_index: 0,
border_radius: *border_radius,
border_radius,
image: None,
uv_max: None,
uv_min: None,
......
......@@ -5,11 +5,15 @@ use bevy::{
};
use kayak_ui::bevy::{BevyContext, BevyKayakUIPlugin, FontMapping, UICameraBundle};
use kayak_ui::core::Index;
use kayak_ui::core::WidgetProps;
use kayak_ui::core::{render, rsx, widget};
use kayak_ui::widgets::{App, Inspector, Window};
#[derive(WidgetProps, Default, Debug, PartialEq, Clone)]
pub struct Props {}
#[widget]
fn CustomWidget() {
fn CustomWidget(props: Props) {
rsx! {
<>
<Window draggable={true} position={(50.0, 50.0)} size={(300.0, 300.0)} title={"Window 1".to_string()}>
......
......@@ -3,7 +3,6 @@ extern crate proc_macro;
mod function_component;
mod tags;
mod widget_builder;
mod attribute;
mod child;
mod children;
......@@ -11,6 +10,7 @@ mod partial_eq;
mod use_effect;
mod widget;
mod widget_attributes;
mod widget_builder;
mod widget_props;
use function_component::WidgetArguments;
......@@ -23,7 +23,7 @@ use use_effect::UseEffect;
use widget::ConstructedWidget;
use crate::widget::Widget;
use crate::widget_props::{add_widget_props, impl_widget_props};
use crate::widget_props::impl_widget_props;
#[proc_macro]
#[proc_macro_error]
......@@ -235,4 +235,4 @@ fn get_core_crate() -> proc_macro2::TokenStream {
} else {
quote!(kayak_ui::core)
}
}
\ No newline at end of file
}
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