Skip to content

Commit

Permalink
chore: Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Sep 1, 2024
2 parents 55714e9 + 0fb6661 commit bc11356
Show file tree
Hide file tree
Showing 53 changed files with 2,058 additions and 1,019 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev
sudo apt update && sudo apt install build-essential libssl-dev pkg-config libglib2.0-dev libgtk-3-dev libudev-dev
- name: Check examples
run: cargo check --examples
- name: Lint
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ dioxus-router = { workspace = true }
itertools = "0.13.0"
home = "0.5.9"
dioxus-query = "0.5.1"
gilrs = "0.10.8"
gl = { workspace = true }

[profile.release]
lto = true
Expand Down
1 change: 0 additions & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ torin = { workspace = true }
dioxus-core = { workspace = true }

accesskit = { workspace = true }
accesskit_winit = { workspace = true }
winit = { workspace = true }
freya-engine = { workspace = true }
freya-native-core = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
mod compositor_dirty_nodes;
mod event_messages;
mod layers;
mod layout;
mod paragraphs;

pub use compositor_dirty_nodes::*;
pub use event_messages::*;
pub use layers::*;
pub use layout::*;
pub use paragraphs::*;
91 changes: 50 additions & 41 deletions crates/components/src/dropdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ where
};

let DropdownTheme {
width,
font_theme,
dropdown_background,
background_button,
Expand All @@ -259,48 +260,56 @@ where

rsx!(
rect {
onmouseenter,
onmouseleave,
onclick,
onkeydown,
margin: "4",
focus_id,
background: "{button_background}",
color: "{font_theme.color}",
corner_radius: "8",
padding: "8 16",
border: "1 solid {border_fill}",
shadow: "0 4 5 0 rgb(0, 0, 0, 0.1)",
direction: "horizontal",
main_align: "center",
cross_align: "center",
label {
"{selected}"
}
ArrowIcon {
rotate: "0",
fill: "{arrow_fill}",
theme: theme_with!(IconTheme {
margin : "0 0 0 8".into(),
})
}
}
if *opened.read() {
direction: "vertical",
rect {
height: "0",
width: "{width}",
onmouseenter,
onmouseleave,
onclick,
onkeydown,
margin: "4",
focus_id,
background: "{button_background}",
color: "{font_theme.color}",
corner_radius: "8",
padding: "8 16",
border: "1 solid {border_fill}",
shadow: "0 4 5 0 rgb(0, 0, 0, 0.1)",
direction: "horizontal",
main_align: "center",
cross_align: "center",
label {
"{selected}"
}
ArrowIcon {
rotate: "0",
fill: "{arrow_fill}",
theme: theme_with!(IconTheme {
margin : "0 0 0 8".into(),
})
}
}
if *opened.read() {
rect {
onglobalclick,
onkeydown,
layer: "-99",
margin: "4",
border: "1 solid {border_fill}",
overflow: "clip",
corner_radius: "8",
background: "{dropdown_background}",
shadow: "0 4 5 0 rgb(0, 0, 0, 0.3)",
padding: "6",
content: "fit",
{props.children}
height: "0",
width: "0",
rect {
width: "100v",
rect {
onglobalclick,
onkeydown,
layer: "-99",
margin: "4",
border: "1 solid {border_fill}",
overflow: "clip",
corner_radius: "8",
background: "{dropdown_background}",
shadow: "0 4 5 0 rgb(0, 0, 0, 0.3)",
padding: "6",
content: "fit",
{props.children}
}
}
}
}
}
Expand Down Expand Up @@ -344,7 +353,7 @@ mod test {

let mut utils = launch_test(dropdown_app);
let root = utils.root();
let label = root.get(0).get(0);
let label = root.get(0).get(0).get(0);
utils.wait_for_update().await;

// Currently closed
Expand Down
188 changes: 93 additions & 95 deletions crates/components/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use freya_hooks::{
};
use freya_node_state::{
CanvasRunner,
CanvasRunnerContext,
Parse,
};
use torin::prelude::Area;

/// Data line for the [`Graph`] component.
#[derive(Debug, PartialEq, Clone)]
Expand Down Expand Up @@ -52,111 +52,109 @@ pub fn Graph(props: GraphProps) -> Element {
let canvas = use_canvas_with_deps(&props, move |props| {
platform.invalidate_drawing_area(size.peek().area);
platform.request_animation_frame();
Box::new(
move |canvas: &Canvas, font_collection: &mut FontCollection, region: Area, _: f32| {
canvas.translate((region.min_x(), region.min_y()));

let mut paragraph_style = ParagraphStyle::default();
paragraph_style.set_text_align(TextAlign::Center);

let mut text_style = TextStyle::new();
text_style.set_color(Color::BLACK);
paragraph_style.set_text_style(&text_style);

let x_labels = &props.labels;
let x_height: f32 = 50.0;

let start_x = region.min_x();
let start_y = region.height() - x_height;
let height = region.height() - x_height;

let space_x = region.width() / x_labels.len() as f32;

// Calculate the smallest and biggest items
let (smallest_y, biggest_y) = {
let mut smallest_y = 0;
let mut biggest_y = 0;
for line in props.data.iter() {
let max = line.points.iter().max().unwrap();
let min = line.points.iter().min().unwrap();

if let Some(max) = *max {
if max > biggest_y {
biggest_y = max;
}
Box::new(move |ctx: &mut CanvasRunnerContext| {
ctx.canvas.translate((ctx.area.min_x(), ctx.area.min_y()));

let mut paragraph_style = ParagraphStyle::default();
paragraph_style.set_text_align(TextAlign::Center);

let mut text_style = TextStyle::new();
text_style.set_color(Color::BLACK);
paragraph_style.set_text_style(&text_style);

let x_labels = &props.labels;
let x_height: f32 = 50.0;

let start_x = ctx.area.min_x();
let start_y = ctx.area.height() - x_height;
let height = ctx.area.height() - x_height;

let space_x = ctx.area.width() / x_labels.len() as f32;

// Calculate the smallest and biggest items
let (smallest_y, biggest_y) = {
let mut smallest_y = 0;
let mut biggest_y = 0;
for line in props.data.iter() {
let max = line.points.iter().max().unwrap();
let min = line.points.iter().min().unwrap();

if let Some(max) = *max {
if max > biggest_y {
biggest_y = max;
}
if let Some(min) = *min {
if min < smallest_y {
smallest_y = min;
}
}
if let Some(min) = *min {
if min < smallest_y {
smallest_y = min;
}
}
}

(smallest_y, biggest_y)
};

// Difference between the smalles and biggest Y Axis item
let y_axis_len = biggest_y - smallest_y;
// Space between items in the Y axis
let space_y = height / y_axis_len as f32;

// Draw the lines
for line in &props.data {
let mut paint = Paint::default();

paint.set_anti_alias(true);
paint.set_style(PaintStyle::Fill);
paint.set_color(Color::parse(&line.color).unwrap());
paint.set_stroke_width(3.0);

let mut previous_x = None;
let mut previous_y = None;

for (i, y_point) in line.points.iter().enumerate() {
let line_x = (space_x * i as f32) + start_x + (space_x / 2.0);
// Save the position where the last point drawed
let new_previous_x = previous_x.unwrap_or(line_x);

if let Some(y_point) = y_point {
let line_y = start_y - (space_y * ((y_point - smallest_y) as f32));
let new_previous_y = previous_y.unwrap_or(line_y);

// Draw the line and circle
canvas.draw_circle((line_x, line_y), 5.0, &paint);
canvas.draw_line(
(new_previous_x, new_previous_y),
(line_x, line_y),
&paint,
);

previous_y = Some(line_y);
previous_x = Some(line_x);
} else {
previous_y = None;
previous_x = None;
}
(smallest_y, biggest_y)
};

// Difference between the smalles and biggest Y Axis item
let y_axis_len = biggest_y - smallest_y;
// Space between items in the Y axis
let space_y = height / y_axis_len as f32;

// Draw the lines
for line in &props.data {
let mut paint = Paint::default();

paint.set_anti_alias(true);
paint.set_style(PaintStyle::Fill);
paint.set_color(Color::parse(&line.color).unwrap());
paint.set_stroke_width(3.0);

let mut previous_x = None;
let mut previous_y = None;

for (i, y_point) in line.points.iter().enumerate() {
let line_x = (space_x * i as f32) + start_x + (space_x / 2.0);
// Save the position where the last point drawed
let new_previous_x = previous_x.unwrap_or(line_x);

if let Some(y_point) = y_point {
let line_y = start_y - (space_y * ((y_point - smallest_y) as f32));
let new_previous_y = previous_y.unwrap_or(line_y);

// Draw the line and circle
ctx.canvas.draw_circle((line_x, line_y), 5.0, &paint);
ctx.canvas.draw_line(
(new_previous_x, new_previous_y),
(line_x, line_y),
&paint,
);

previous_y = Some(line_y);
previous_x = Some(line_x);
} else {
previous_y = None;
previous_x = None;
}
}
}

// Space between labels
let space_x = region.width() / x_labels.len() as f32;
// Space between labels
let space_x = ctx.area.width() / x_labels.len() as f32;

// Draw the labels
for (i, point) in x_labels.iter().enumerate() {
let x = (space_x * i as f32) + start_x;
// Draw the labels
for (i, point) in x_labels.iter().enumerate() {
let x = (space_x * i as f32) + start_x;

let mut paragrap_builder =
ParagraphBuilder::new(&paragraph_style, font_collection.clone());
paragrap_builder.add_text(point);
let mut text = paragrap_builder.build();
let mut paragrap_builder =
ParagraphBuilder::new(&paragraph_style, ctx.font_collection.clone());
paragrap_builder.add_text(point);
let mut text = paragrap_builder.build();

text.layout(space_x);
text.paint(canvas, (x, start_y + x_height - 30.0));
}
text.layout(space_x);
text.paint(ctx.canvas, (x, start_y + x_height - 30.0));
}

canvas.restore();
},
) as Box<CanvasRunner>
ctx.canvas.restore();
}) as Box<CanvasRunner>
});

rsx!(
Expand Down
Loading

0 comments on commit bc11356

Please sign in to comment.