Merge pull request #462 from storytold/fix/417-viewer-resolution
Viewer: each composition keeps its Resolution in the project, as in After Effects (#417) # Conflicts: # crates/ui-egui/src/control.rs # crates/ui-egui/src/menus.rs # crates/ui-egui/src/panels/viewer_tools.rs
This commit is contained in:
@@ -224,49 +224,9 @@ impl Tool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Viewer resolution (Auto follows the magnification).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Resolution {
|
||||
#[default]
|
||||
Auto,
|
||||
Full,
|
||||
Half,
|
||||
Third,
|
||||
Quarter,
|
||||
/// View ▸ Resolution ▸ Custom: render every n-th pixel (2..=40).
|
||||
Custom(u8),
|
||||
}
|
||||
|
||||
impl Resolution {
|
||||
pub const ALL: [Resolution; 5] = [Resolution::Auto, Resolution::Full, Resolution::Half, Resolution::Third, Resolution::Quarter];
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Resolution::Auto => "Auto",
|
||||
Resolution::Full => "Full",
|
||||
Resolution::Half => "Half",
|
||||
Resolution::Third => "Third",
|
||||
Resolution::Quarter => "Quarter",
|
||||
Resolution::Custom(_) => "Custom",
|
||||
}
|
||||
}
|
||||
/// Render scale for a viewer magnification (and display pixel density).
|
||||
pub fn scale(self, zoom: f32, ppp: f32) -> f64 {
|
||||
match self {
|
||||
// As in After Effects, Auto renders the pixels the magnification needs: the coarsest
|
||||
// whole factor that still gives every screen pixel a rendered one (Full above 50 %,
|
||||
// Half down to 33.3 %, Third down to 25 %, Quarter below), never fewer (#417).
|
||||
Resolution::Auto => {
|
||||
let n = (1.0 / (zoom * ppp) as f64 + 1e-3).floor();
|
||||
if n >= 1.0 { 1.0 / n.min(4.0) } else { 1.0 }
|
||||
}
|
||||
Resolution::Full => 1.0,
|
||||
Resolution::Half => 0.5,
|
||||
Resolution::Third => 1.0 / 3.0,
|
||||
Resolution::Quarter => 0.25,
|
||||
Resolution::Custom(n) => 1.0 / n.max(1) as f64,
|
||||
}
|
||||
}
|
||||
}
|
||||
/// The viewer's Resolution: each composition keeps its own in the project
|
||||
/// ([`effectcraft_engine::project::Comp::resolution`], `EffectcraftApp::viewer_res`).
|
||||
pub use effectcraft_engine::project::Resolution;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
@@ -275,7 +235,6 @@ pub struct ViewerState {
|
||||
pub zoom: Option<f32>,
|
||||
/// Pan offset in points from the centred position.
|
||||
pub pan: [f32; 2],
|
||||
pub res: Resolution,
|
||||
pub transparency_grid: bool,
|
||||
pub show_masks: bool,
|
||||
pub safe_margins: bool,
|
||||
@@ -314,7 +273,6 @@ impl Default for ViewerState {
|
||||
ViewerState {
|
||||
zoom: None,
|
||||
pan: [0.0, 0.0],
|
||||
res: Resolution::Auto,
|
||||
transparency_grid: false,
|
||||
show_masks: true,
|
||||
safe_margins: false,
|
||||
|
||||
Reference in New Issue
Block a user