Compare commits
13 Commits
jtran/plus
...
nadro/brok
Author | SHA1 | Date | |
---|---|---|---|
6abc35e2fc | |||
d8ed24f463 | |||
0422a18428 | |||
3a9e73d441 | |||
287d0ef296 | |||
bc136c302c | |||
cd3b850a92 | |||
4267abc22f | |||
21dffcd2de | |||
43dd26ccdb | |||
4b9f1aa180 | |||
310f40883b | |||
8fbdab8a94 |
@ -9,6 +9,7 @@ import {
|
||||
TEST_COLORS,
|
||||
commonPoints,
|
||||
getUtils,
|
||||
enableConsoleLogEverything,
|
||||
} from '@e2e/playwright/test-utils'
|
||||
import { expect, test } from '@e2e/playwright/zoo-test'
|
||||
|
||||
@ -178,7 +179,19 @@ test.describe('Basic sketch', () => {
|
||||
cmdBar,
|
||||
scene,
|
||||
editor,
|
||||
tronApp,
|
||||
}) => {
|
||||
// await tronApp.cleanProjectDir({
|
||||
// app: {
|
||||
// appearance: {
|
||||
// theme: 'light',
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
enableConsoleLogEverything({
|
||||
page,
|
||||
tronApp,
|
||||
})
|
||||
await doBasicSketch(page, ['code'], { cmdBar, scene, homePage, editor })
|
||||
})
|
||||
|
||||
@ -188,6 +201,7 @@ test.describe('Basic sketch', () => {
|
||||
cmdBar,
|
||||
scene,
|
||||
editor,
|
||||
tronApp,
|
||||
}) => {
|
||||
// Load the app with the code panes
|
||||
await page.addInitScript(async (persistModelingContext) => {
|
||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 80 KiB |
@ -8,10 +8,14 @@ export const TEST_SETTINGS_KEY = '/settings.toml'
|
||||
export const TEST_SETTINGS: DeepPartial<Settings> = {
|
||||
app: {
|
||||
appearance: {
|
||||
theme: Themes.Dark,
|
||||
theme: Themes.Light,
|
||||
},
|
||||
onboarding_status: 'dismissed',
|
||||
show_debug_panel: true,
|
||||
// Tests were written before this setting existed.
|
||||
// It's true by default because it's a good user experience, but
|
||||
// these tests require it to be false.
|
||||
fixed_size_grid: false,
|
||||
},
|
||||
modeling: {
|
||||
enable_ssao: false,
|
||||
|
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
@ -323,13 +323,15 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
settings: &crate::ExecutorSettings,
|
||||
source_range: SourceRange,
|
||||
id_generator: &mut IdGenerator,
|
||||
grid_scale_unit: GridScaleBehavior,
|
||||
) -> Result<(), crate::errors::KclError> {
|
||||
// Set the edge visibility.
|
||||
self.set_edge_visibility(settings.highlight_edges, source_range, id_generator)
|
||||
.await?;
|
||||
|
||||
// Send the command to show the grid.
|
||||
self.modify_grid(!settings.show_grid, source_range, id_generator)
|
||||
|
||||
self.modify_grid(!settings.show_grid, grid_scale_unit, source_range, id_generator)
|
||||
.await?;
|
||||
|
||||
// We do not have commands for changing ssao on the fly.
|
||||
@ -760,6 +762,7 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
async fn modify_grid(
|
||||
&self,
|
||||
hidden: bool,
|
||||
grid_scale_behavior: GridScaleBehavior,
|
||||
source_range: SourceRange,
|
||||
id_generator: &mut IdGenerator,
|
||||
) -> Result<(), KclError> {
|
||||
@ -774,6 +777,13 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
)
|
||||
.await?;
|
||||
|
||||
self.batch_modeling_cmd(
|
||||
id_generator.next_uuid(),
|
||||
source_range,
|
||||
&grid_scale_behavior.into_modeling_cmd(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Hide/show the grid scale text.
|
||||
self.batch_modeling_cmd(
|
||||
id_generator.next_uuid(),
|
||||
@ -886,3 +896,22 @@ pub fn new_zoo_client(token: Option<String>, engine_addr: Option<String>) -> any
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum GridScaleBehavior {
|
||||
ScaleWithZoom,
|
||||
Fixed(Option<kcmc::units::UnitLength>),
|
||||
}
|
||||
|
||||
impl GridScaleBehavior {
|
||||
fn into_modeling_cmd(self) -> ModelingCmd {
|
||||
const NUMBER_OF_GRID_COLUMNS: f32 = 10.0;
|
||||
match self {
|
||||
GridScaleBehavior::ScaleWithZoom => ModelingCmd::from(mcmd::SetGridAutoScale {}),
|
||||
GridScaleBehavior::Fixed(unit_length) => ModelingCmd::from(mcmd::SetGridScale {
|
||||
value: NUMBER_OF_GRID_COLUMNS,
|
||||
units: unit_length.unwrap_or(kcmc::units::UnitLength::Millimeters),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ pub use state::{ExecState, MetaSettings};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
engine::EngineManager,
|
||||
engine::{EngineManager, GridScaleBehavior},
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
cache::{CacheInformation, CacheResult},
|
||||
@ -295,6 +295,8 @@ pub struct ExecutorSettings {
|
||||
/// This is the path to the current file being executed.
|
||||
/// We use this for preventing cyclic imports.
|
||||
pub current_file: Option<TypedPath>,
|
||||
/// Whether or not to automatically scale the grid when user zooms.
|
||||
pub fixed_size_grid: bool,
|
||||
}
|
||||
|
||||
impl Default for ExecutorSettings {
|
||||
@ -306,33 +308,34 @@ impl Default for ExecutorSettings {
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
fixed_size_grid: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::settings::types::Configuration> for ExecutorSettings {
|
||||
fn from(config: crate::settings::types::Configuration) -> Self {
|
||||
Self::from(config.settings)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::settings::types::Settings> for ExecutorSettings {
|
||||
fn from(settings: crate::settings::types::Settings) -> Self {
|
||||
Self {
|
||||
highlight_edges: config.settings.modeling.highlight_edges.into(),
|
||||
enable_ssao: config.settings.modeling.enable_ssao.into(),
|
||||
show_grid: config.settings.modeling.show_scale_grid,
|
||||
highlight_edges: settings.modeling.highlight_edges.into(),
|
||||
enable_ssao: settings.modeling.enable_ssao.into(),
|
||||
show_grid: settings.modeling.show_scale_grid,
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
fixed_size_grid: settings.app.fixed_size_grid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::settings::types::project::ProjectConfiguration> for ExecutorSettings {
|
||||
fn from(config: crate::settings::types::project::ProjectConfiguration) -> Self {
|
||||
Self {
|
||||
highlight_edges: config.settings.modeling.highlight_edges.into(),
|
||||
enable_ssao: config.settings.modeling.enable_ssao.into(),
|
||||
show_grid: Default::default(),
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
}
|
||||
Self::from(config.settings.modeling)
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,6 +348,7 @@ impl From<crate::settings::types::ModelingSettings> for ExecutorSettings {
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
fixed_size_grid: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -358,6 +362,7 @@ impl From<crate::settings::types::project::ProjectModelingSettings> for Executor
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
fixed_size_grid: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -497,6 +502,7 @@ impl ExecutorContext {
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
fixed_size_grid: false,
|
||||
},
|
||||
None,
|
||||
engine_addr,
|
||||
@ -592,6 +598,18 @@ impl ExecutorContext {
|
||||
|
||||
pub async fn run_with_caching(&self, program: crate::Program) -> Result<ExecOutcome, KclErrorWithOutputs> {
|
||||
assert!(!self.is_mock());
|
||||
let grid_scale = if self.settings.fixed_size_grid {
|
||||
GridScaleBehavior::Fixed(
|
||||
program
|
||||
.meta_settings()
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|s| s.default_length_units)
|
||||
.map(kcmc::units::UnitLength::from),
|
||||
)
|
||||
} else {
|
||||
GridScaleBehavior::ScaleWithZoom
|
||||
};
|
||||
|
||||
let (program, exec_state, result) = match cache::read_old_ast().await {
|
||||
Some(mut cached_state) => {
|
||||
@ -618,6 +636,7 @@ impl ExecutorContext {
|
||||
&self.settings,
|
||||
Default::default(),
|
||||
&mut cached_state.main.exec_state.id_generator,
|
||||
grid_scale,
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
@ -645,6 +664,7 @@ impl ExecutorContext {
|
||||
&self.settings,
|
||||
Default::default(),
|
||||
&mut cached_state.main.exec_state.id_generator,
|
||||
grid_scale,
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
@ -689,6 +709,7 @@ impl ExecutorContext {
|
||||
&self.settings,
|
||||
Default::default(),
|
||||
&mut cached_state.main.exec_state.id_generator,
|
||||
grid_scale,
|
||||
)
|
||||
.await
|
||||
.is_ok()
|
||||
@ -1077,8 +1098,25 @@ impl ExecutorContext {
|
||||
let _stats = crate::log::LogPerfStats::new("Interpretation");
|
||||
|
||||
// Re-apply the settings, in case the cache was busted.
|
||||
let grid_scale = if self.settings.fixed_size_grid {
|
||||
GridScaleBehavior::Fixed(
|
||||
program
|
||||
.meta_settings()
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|s| s.default_length_units)
|
||||
.map(kcmc::units::UnitLength::from),
|
||||
)
|
||||
} else {
|
||||
GridScaleBehavior::ScaleWithZoom
|
||||
};
|
||||
self.engine
|
||||
.reapply_settings(&self.settings, Default::default(), exec_state.id_generator())
|
||||
.reapply_settings(
|
||||
&self.settings,
|
||||
Default::default(),
|
||||
exec_state.id_generator(),
|
||||
grid_scale,
|
||||
)
|
||||
.await
|
||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||
|
||||
|
@ -67,6 +67,7 @@ pub struct Settings {
|
||||
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, PartialEq, Validate)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct AppSettings {
|
||||
/// The settings for the appearance of the app.
|
||||
#[serde(default, skip_serializing_if = "is_default")]
|
||||
@ -94,6 +95,13 @@ pub struct AppSettings {
|
||||
/// of the app to aid in development.
|
||||
#[serde(default, skip_serializing_if = "is_default")]
|
||||
pub show_debug_panel: bool,
|
||||
/// If true, the grid cells will be fixed-size, where the width is the user's default length unit.
|
||||
/// If false, the grid's size will scale as the user zooms in and out.
|
||||
pub fixed_size_grid: bool,
|
||||
}
|
||||
|
||||
fn make_it_so() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn deserialize_stream_idle_mode<'de, D>(deserializer: D) -> Result<Option<u32>, D::Error>
|
||||
|
@ -141,6 +141,7 @@ pub async fn new_context(with_auth: bool, current_file: Option<PathBuf>) -> Resu
|
||||
replay: None,
|
||||
project_directory: None,
|
||||
current_file: None,
|
||||
fixed_size_grid: true,
|
||||
};
|
||||
if let Some(current_file) = current_file {
|
||||
settings.with_current_file(crate::TypedPath(current_file));
|
||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |