forked from 1b-agent/opencadstudio-upstream
review(#1630): one table rebuild loop that also refreshes formulas; one cell layout
- main already rebuilt an edited table's block; the PR added a second loop after it that could never fire. Formula refresh and the block cache bump now live in the one loop. - Formula refresh copies the drawing only for a table that has a field. - A field cell lays its text out once and boxes it from those cells. - A zero text height at one level falls through to the next instead of ending the lookup. - Field box constants and BACKGROUND keep their own doc comments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
95d5eb73d9
commit
62d72b3a8d
3 files changed
+34
-41
No files matched your search
+12
-2
@@ -137,7 +137,17 @@ pub fn update_fields(
|
||||
/// Recompute a table's cell formulas into its block after the table changed;
|
||||
/// returns the cell texts that changed.
|
||||
pub fn refresh_table_formulas(document: &mut CadDocument, table: Handle) -> Vec<Handle> {
|
||||
if document.fields.is_empty() {
|
||||
// Copying the drawing is only worth it for a table with a field.
|
||||
let has_field = matches!(
|
||||
document.get_entity(table),
|
||||
Some(codec::EntityType::Table(t)) if t
|
||||
.rows
|
||||
.iter()
|
||||
.flat_map(|row| &row.cells)
|
||||
.flat_map(|cell| &cell.contents)
|
||||
.any(|content| content.field_handle.is_some())
|
||||
);
|
||||
if !has_field {
|
||||
return Vec::new();
|
||||
}
|
||||
let snapshot = document.clone();
|
||||
@@ -332,13 +342,13 @@ pub fn set_display(on: bool) {
|
||||
FIELD_DISPLAY.store(on, std::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// The gray the reference draws behind a field.
|
||||
/// FIELDDISPLAY box extent around a line of field text, in text heights:
|
||||
/// from a third of the height below the baseline to 1.19 heights above it
|
||||
/// (the reference's box, measured at 2.5 and 10 unit text).
|
||||
pub const BOX_BELOW: f64 = 0.345;
|
||||
pub const BOX_ABOVE: f64 = 1.19;
|
||||
|
||||
/// The gray the reference draws behind a field.
|
||||
pub const BACKGROUND: [f32; 4] = [203.0 / 255.0, 203.0 / 255.0, 203.0 / 255.0, 1.0];
|
||||
|
||||
/// Whether `entity` hosts a field: its extension dictionary has ACAD_FIELD.
|
||||
|
||||
Reference in new issue
Block a user