feat: add page surfaces and collapsible sidebar
This commit is contained in:
@@ -113,6 +113,18 @@ pub struct RenderDocument {
|
||||
|
||||
impl RenderDocument {
|
||||
pub fn validate(&self) -> Result<()> {
|
||||
let surface = &self.frame.surface;
|
||||
if !surface.zoom.is_finite()
|
||||
|| !(0.1..=4.0).contains(&surface.zoom)
|
||||
|| ![surface.pan.x, surface.pan.y]
|
||||
.iter()
|
||||
.all(|v| v.is_finite() && v.abs() <= 1_000_000.0)
|
||||
|| ![surface.extent.width, surface.extent.height]
|
||||
.iter()
|
||||
.all(|v| v.is_finite() && (0.0..=1_000_000.0).contains(v))
|
||||
{
|
||||
bail!("invalid page camera or extent");
|
||||
}
|
||||
if self.windows.len() > 15 {
|
||||
bail!("too many window projections");
|
||||
}
|
||||
@@ -322,6 +334,8 @@ impl CodeNode {
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Frame {
|
||||
#[serde(default)]
|
||||
pub surface: crate::page::Surface,
|
||||
#[serde(default = "default_window")]
|
||||
pub window: u64,
|
||||
#[serde(default = "default_background")]
|
||||
@@ -347,6 +361,7 @@ pub struct Frame {
|
||||
impl Default for Frame {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
surface: crate::page::Surface::default(),
|
||||
window: crate::window::MAIN_WINDOW,
|
||||
background: default_background(),
|
||||
commands: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user