复用展开输入区的草稿高度测量

This commit is contained in:
WuYongJie 2026-11-29 02:01:25 +08:00
parent e6d12ddae0
commit 2be3fbbd09

View File

@ -2598,9 +2598,21 @@ impl Workspace {
}
fn composer_surface_height(&self, app: &PhotocraftApp, ui: &Ui, width: f32, progress: f32) -> f32 {
let attachment = if self.composer_text_send_allowed_for(app) { 0.0 } else { self.composer_attachments_extra_height() };
let references = reference_shelf_height(self.composer_reference_list(app).len(), (width - 28.0).max(1.0));
let text_height = composer_galley(ui, &self.composer, (width - 32.0).max(1.0)).size().y.max(24.0);
if progress == 0.0 {
return 56.0 + references;
}
let attachment = if self.composer_text_send_allowed_for(app) { 0.0 } else { self.composer_attachments_extra_height() };
let wrap_width = (width - 32.0).max(1.0);
let layout_key = (wrap_width, ui.pixels_per_point(), Tokens::get(ui.ctx()).kind);
let height_id = ui.scope_id().with("composer-draft-height");
type DraftHeight = ((f32, f32, crate::theme::ThemeKind), String, f32);
let cached = ui.data_mut(|data| data.remove_temp::<Option<DraftHeight>>(height_id)).flatten();
let (key, draft, text_height) = cached
.filter(|(key, draft, _)| *key == layout_key && draft == &self.composer)
.unwrap_or_else(|| (layout_key, self.composer.clone(),
composer_galley(ui, &self.composer, wrap_width).size().y.max(24.0)));
ui.data_mut(|data| data.insert_temp(height_id, Some((key, draft, text_height))));
let expanded = (text_height + 74.0 + attachment).max(168.0)
.min((ui.ctx().content_rect().height() * 0.5 - references).max(168.0));
56.0 + references + (expanded - 56.0) * progress