Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify fj_window::run arguments #1245

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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