Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Dec 7, 2024
1 parent 495b227 commit 1b6c318
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
10 changes: 5 additions & 5 deletions examples/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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::<Vec<_>>(),
)
.with_cross_align(Alignment::Center)
.with_cross_align(Align::Center)
.mount(scope)
}
}
4 changes: 2 additions & 2 deletions examples/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}
Expand Down
12 changes: 7 additions & 5 deletions examples/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -57,10 +57,12 @@ impl Widget for MainApp {
row((0..4)
.map(|_| Box::new(Stack::new(Item)) as Box<dyn Widget>)
.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<dyn Widget>])
.collect_vec())
Expand Down
2 changes: 1 addition & 1 deletion violet-core/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions violet-core/src/widget/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -276,7 +276,7 @@ pub fn col<W: WidgetCollection>(widgets: W) -> List<W> {
List::new(widgets).with_direction(Direction::Vertical)
}

pub fn centered<W: Widget>(widget: W) -> Stack<W> {
pub fn centered<W: WidgetCollection>(widget: W) -> Stack<W> {
Stack::new(widget)
.with_horizontal_alignment(Align::Center)
.with_vertical_alignment(Align::Center)
Expand Down
8 changes: 4 additions & 4 deletions violet-demo/src/palettes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()))
Expand Down Expand Up @@ -354,8 +354,8 @@ fn palette_color_view(color: Mutable<PaletteColor>) -> 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<u8>);
Expand Down

0 comments on commit 1b6c318

Please sign in to comment.