dev: Minor fixes to `CircuitLayout`

- Default view height is now the circuit size.
- Cells are now always shaded on top of any drawn regions.
This commit is contained in:
Jack Grigg 2021-07-27 02:25:46 +01:00
parent 7cf58661d8
commit 8d8e76dc82
1 changed files with 9 additions and 7 deletions

View File

@ -123,7 +123,7 @@ impl CircuitLayout {
};
let view_width = self.view_width.unwrap_or(0..total_columns);
let view_height = self.view_height.unwrap_or(0..layout.total_rows);
let view_height = self.view_height.unwrap_or(0..n);
let view_bottom = view_height.end;
// Prepare the grid layout. We render a red background for advice columns, white for
@ -207,10 +207,10 @@ impl CircuitLayout {
// Render the regions!
let mut labels = if self.hide_labels { None } else { Some(vec![]) };
for region in layout.regions {
for region in &layout.regions {
if let Some(offset) = region.offset {
// Sort the region's columns according to the defined ordering.
let mut columns: Vec<_> = region.columns.into_iter().collect();
let mut columns: Vec<_> = region.columns.iter().cloned().collect();
columns.sort_unstable_by_key(|a| column_index(&cs, *a));
// Render contiguous parts of the same region as a single box.
@ -237,13 +237,15 @@ impl CircuitLayout {
labels.push((region.name.clone(), (start, offset)));
}
}
}
}
// Darken the cells of the region that have been assigned to.
for region in layout.regions {
for (column, row) in region.cells {
draw_cell(&root, column_index(&cs, column), row)?;
}
}
}
// Darken any loose cells that have been assigned to.
for (column, row) in layout.loose_cells {