Skip to content

Commit

Permalink
chore: slight naming improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Oct 20, 2024
1 parent 6bb5561 commit fdeca4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 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::{Alignment, 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_medium, spacing_small, Background, SizeExt,
StyleExt, WidgetSize,
},
unit::Unit,
Scope, Widget, WidgetCollection,
Expand Down Expand Up @@ -273,13 +273,13 @@ pub fn col<W: WidgetCollection>(widgets: W) -> List<W> {
List::new(widgets).with_direction(Direction::Vertical)
}

pub fn centered<W>(widget: W) -> Stack<W> {
pub fn centered<W: Widget>(widget: W) -> Stack<W> {
Stack::new(widget)
.with_horizontal_alignment(Alignment::Center)
.with_vertical_alignment(Alignment::Center)
}

pub fn card<W>(widget: W) -> Stack<W> {
pub fn card<W: Widget>(widget: W) -> Stack<W> {
Stack::new(widget)
// TODO: semantic color and sizing increment
.with_background(Background::new(secondary_surface()))
Expand Down
12 changes: 7 additions & 5 deletions violet-wgpu/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<W: Widget> Widget for Canvas<W> {
col(self.root)
.contain_margins(true)
.with_maximize(Vec2::ONE)
.with_background(Background::new(primary_surface()))
// .with_background(Background::new(primary_surface()))
.with_name("CanvasColumn"),
);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ pub struct AppInstance {
pub input_state: InputState,
text_system: Arc<Mutex<TextSystem>>,
layout_changes_rx: flume::Receiver<(Entity, LayoutUpdateEvent)>,
pub has_resized: bool,
pub needs_update: bool,
}

impl AppInstance {
Expand Down Expand Up @@ -227,7 +227,7 @@ impl AppInstance {
input_state,
text_system,
layout_changes_rx,
has_resized: false,
needs_update: false,
}
}

Expand All @@ -237,7 +237,7 @@ impl AppInstance {

pub fn on_resize(&mut self, physical_size: PhysicalSize<u32>) {
self.window_size = physical_size;
self.has_resized = true;
self.needs_update = true;

tracing::info!(?physical_size, self.scale_factor, "Resizing window");

Expand All @@ -264,6 +264,8 @@ impl AppInstance {
return;
}

self.needs_update = false;

let new_time = Instant::now();

self.current_time = new_time;
Expand Down Expand Up @@ -323,7 +325,7 @@ struct WindowEventHandler {
impl WindowEventHandler {
pub fn draw(&mut self) -> anyhow::Result<()> {
puffin::profile_function!();
if mem::take(&mut self.instance.has_resized) {
if mem::take(&mut self.instance.needs_update) {
self.instance.update();
}

Expand Down

0 comments on commit fdeca4f

Please sign in to comment.