From 1b6c3188cf54d6b11aeae499332810239bc8378f Mon Sep 17 00:00:00 2001 From: Freja Roberts Date: Sat, 7 Dec 2024 16:47:22 +0100 Subject: [PATCH] chore: cleanup --- examples/buttons.rs | 10 +++++----- examples/counter.rs | 4 ++-- examples/row.rs | 12 +++++++----- violet-core/src/scope.rs | 2 +- violet-core/src/widget/container.rs | 6 +++--- violet-demo/src/palettes/mod.rs | 8 ++++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/examples/buttons.rs b/examples/buttons.rs index 518dc91..5946216 100644 --- a/examples/buttons.rs +++ b/examples/buttons.rs @@ -6,7 +6,7 @@ use tracing_subscriber::{layer::SubscriberExt, registry, util::SubscriberInitExt use tracing_tree::HierarchicalLayer; use violet::core::{ - layout::Alignment, + layout::Align, style::StyleExt, unit::Unit, widget::{List, Rectangle, SignalWidget, Stack, Text}, @@ -165,15 +165,15 @@ impl Widget for ItemList { )))) .with_padding(spacing_small()) .with_margin(spacing_small()) - // .with_cross_align(Alignment::Center) - .with_vertical_alignment(Alignment::Center) - .with_horizontal_alignment(Alignment::Center) + // .with_cross_align(Align::Center) + .with_vertical_alignment(Align::Center) + .with_horizontal_alignment(Align::Center) .with_size(Unit::px2(size, size)) .with_max_size(Unit::px2(size, size)) }) .collect::>(), ) - .with_cross_align(Alignment::Center) + .with_cross_align(Align::Center) .mount(scope) } } diff --git a/examples/counter.rs b/examples/counter.rs index 6bdec70..419e289 100644 --- a/examples/counter.rs +++ b/examples/counter.rs @@ -6,7 +6,7 @@ use tracing_subscriber::{prelude::*, registry, util::SubscriberInitExt, EnvFilte use tracing_tree::HierarchicalLayer; use violet::core::{ components::size, - layout::Alignment, + layout::Align, unit::Unit, widget::{Button, List, SignalWidget, Stack, Text}, Scope, Widget, @@ -61,7 +61,7 @@ impl Widget for MainApp { )), )) .with_background(Background::new(accent_element())) - .with_cross_align(Alignment::Center) + .with_cross_align(Align::Center) .mount(scope); } } diff --git a/examples/row.rs b/examples/row.rs index 37c68ff..ca2c409 100644 --- a/examples/row.rs +++ b/examples/row.rs @@ -6,7 +6,7 @@ use tracing_tree::HierarchicalLayer; use violet::core::{style::Background, unit::Unit, widget::Rectangle, Scope, Widget}; use violet_core::{ style::{accent_element, primary_surface, spacing_small, SizeExt}, - widget::{centered, col, row, Image, Stack}, + widget::{centered, col, image::Image, row, Stack}, }; use violet_wgpu::renderer::MainRendererConfig; @@ -57,10 +57,12 @@ impl Widget for MainApp { row((0..4) .map(|_| Box::new(Stack::new(Item)) as Box) .chain([Box::new( - centered((Rectangle::new(accent_element()) - .with_maximize(vec2(1.0, 0.0)) - .with_size(Unit::px2(0.0, 50.0)) - .with_max_size(Unit::px2(1000.0, 100.0)),)) + centered( + Rectangle::new(accent_element()) + .with_maximize(vec2(1.0, 0.0)) + .with_size(Unit::px2(0.0, 50.0)) + .with_max_size(Unit::px2(1000.0, 100.0)), + ) .with_maximize(Vec2::ONE), ) as Box]) .collect_vec()) diff --git a/violet-core/src/scope.rs b/violet-core/src/scope.rs index 9a4db03..bfa1404 100644 --- a/violet-core/src/scope.rs +++ b/violet-core/src/scope.rs @@ -33,7 +33,7 @@ pub struct Scope<'a> { data: EntityBuilder, } -impl<'a> std::fmt::Debug for Scope<'a> { +impl std::fmt::Debug for Scope<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Scope") .field("id", &self.id) diff --git a/violet-core/src/widget/container.rs b/violet-core/src/widget/container.rs index 4987cde..7423948 100644 --- a/violet-core/src/widget/container.rs +++ b/violet-core/src/widget/container.rs @@ -8,8 +8,8 @@ use crate::{ layout::{Align, Direction, FloatLayout, FlowLayout, Layout, StackLayout}, scope::ScopeRef, style::{ - primary_surface, secondary_surface, spacing_medium, spacing_small, Background, SizeExt, - StyleExt, WidgetSize, + primary_surface, secondary_surface, spacing_small, Background, SizeExt, StyleExt, + WidgetSize, }, unit::Unit, Scope, Widget, WidgetCollection, @@ -276,7 +276,7 @@ pub fn col(widgets: W) -> List { List::new(widgets).with_direction(Direction::Vertical) } -pub fn centered(widget: W) -> Stack { +pub fn centered(widget: W) -> Stack { Stack::new(widget) .with_horizontal_alignment(Align::Center) .with_vertical_alignment(Align::Center) diff --git a/violet-demo/src/palettes/mod.rs b/violet-demo/src/palettes/mod.rs index 9a1bcfb..f0604b6 100644 --- a/violet-demo/src/palettes/mod.rs +++ b/violet-demo/src/palettes/mod.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use violet::{ core::{ declare_atom, - layout::Alignment, + layout::Align, state::{State, StateMut, StateStream, StateStreamRef}, style::{ danger_element, primary_surface, success_element, warning_element, Background, SizeExt, @@ -60,7 +60,7 @@ impl Widget for App { items: notify_rx.into_stream(), }) .with_maximize(Vec2::ONE) - .with_horizontal_alignment(Alignment::End), + .with_horizontal_alignment(Align::End), )) .with_size(Unit::rel2(1.0, 1.0)) .with_background(Background::new(primary_surface())) @@ -354,8 +354,8 @@ fn palette_color_view(color: Mutable) -> impl Widget { let label = TextInput::new(label); Stack::new((row((tints(color),)), label)) - .with_vertical_alignment(Alignment::End) - .with_horizontal_alignment(Alignment::Center) + .with_vertical_alignment(Align::End) + .with_horizontal_alignment(Align::Center) } pub struct HexColor(Srgb);