Skip to content

Commit

Permalink
Merge pull request #1245 from hannobraun/window
Browse files Browse the repository at this point in the history
Simplify `fj_window::run` arguments
  • Loading branch information
hannobraun authored Oct 20, 2022
2 parents a7fb5a4 + c7377cc commit 9f263eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 2 additions & 5 deletions crates/fj-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use std::path::PathBuf;

use anyhow::{anyhow, Context as _};
use fj_export::export;
use fj_host::{Model, Parameters, Watcher};
use fj_interop::status_report::StatusReport;
use fj_host::{Model, Parameters};
use fj_operations::shape_processor::ShapeProcessor;
use fj_window::run::run;
use tracing_subscriber::fmt::format;
Expand All @@ -29,7 +28,6 @@ use tracing_subscriber::EnvFilter;
use crate::{args::Args, config::Config};

fn main() -> anyhow::Result<()> {
let status = StatusReport::new();
// Respect `RUST_LOG`. If that's not defined or erroneous, log warnings and
// above.
//
Expand Down Expand Up @@ -90,8 +88,7 @@ fn main() -> anyhow::Result<()> {

let invert_zoom = config.invert_zoom.unwrap_or(false);

let watcher = Watcher::watch_model(model)?;
run(watcher, shape_processor, status, invert_zoom)?;
run(model, shape_processor, invert_zoom)?;

Ok(())
}
12 changes: 9 additions & 3 deletions crates/fj-window/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::error;

use fj_host::{Watcher, WatcherEvent};
use fj_host::{Model, Watcher, WatcherEvent};
use fj_interop::status_report::StatusReport;
use fj_operations::shape_processor::ShapeProcessor;
use fj_viewer::{
Expand All @@ -27,11 +27,13 @@ use crate::window::{self, Window};

/// Initializes a model viewer for a given model and enters its process loop.
pub fn run(
watcher: Watcher,
model: Model,
shape_processor: ShapeProcessor,
mut status: StatusReport,
invert_zoom: bool,
) -> Result<(), Error> {
let mut status = StatusReport::new();
let watcher = Watcher::watch_model(model)?;

let event_loop = EventLoop::new();
let window = Window::new(&event_loop)?;
let mut viewer = block_on(Viewer::new(&window))?;
Expand Down Expand Up @@ -289,6 +291,10 @@ fn input_event<T>(
/// Error in main loop
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Error loading model
#[error("Error loading model")]
Model(#[from] fj_host::Error),

/// Error initializing window
#[error("Error initializing window")]
WindowInit(#[from] window::Error),
Expand Down

0 comments on commit 9f263eb

Please sign in to comment.