feat(xiaoyi): show upcoming video outputs
This commit is contained in:
parent
60a5351ec2
commit
314b4fca3a
@ -1873,6 +1873,9 @@ impl Workspace {
|
||||
}
|
||||
}
|
||||
});
|
||||
for (id, text) in super::creation::UPCOMING_OUTPUT_TAGS {
|
||||
super::creation::output_tag(ui, id, text, true);
|
||||
}
|
||||
if variants.len() > 1 || (!variants.is_empty() && !current_color_visible) {
|
||||
let colour_width = 140.0_f32.min((left_width - ui.spacing().item_spacing.x - 1.0).max(0.0));
|
||||
ui.allocate_ui_with_layout(
|
||||
@ -4053,6 +4056,17 @@ mod tests {
|
||||
PhotocraftApp::setup_context(&ctx, crate::theme::ThemeKind::ProMedium);
|
||||
let mut initial=Vec::new();
|
||||
for _ in 0..2 { initial=frame(&mut w,&mut app,&ctx,vec![]); }
|
||||
for (_, label) in super::super::creation::UPCOMING_OUTPUT_TAGS {
|
||||
let pos = initial.iter().find(|(text, _)| text == label).unwrap().1.center();
|
||||
for pressed in [true, false] {
|
||||
frame(&mut w, &mut app, &ctx, vec![
|
||||
egui::Event::PointerMoved(pos),
|
||||
egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE },
|
||||
]);
|
||||
}
|
||||
assert!(requests.try_recv().is_err());
|
||||
assert_eq!(w.canvas_workspace.output, "detail");
|
||||
}
|
||||
let trigger=initial.iter().find(|(text,_)|text=="木纹").unwrap().1.center();
|
||||
for pressed in [true,false] {
|
||||
frame(&mut w,&mut app,&ctx,vec![egui::Event::PointerMoved(trigger),egui::Event::PointerButton {
|
||||
|
||||
@ -1302,6 +1302,18 @@ impl Workspace {
|
||||
brief_section_break(ui);
|
||||
}
|
||||
|
||||
fn output_tags_ui(&mut self, ui: &mut Ui) {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label("输出内容");
|
||||
for (id, text) in READY_OUTPUT_TAGS {
|
||||
self.control_geometry(id, output_tag(ui, id, text, false).rect);
|
||||
}
|
||||
for (id, text) in UPCOMING_OUTPUT_TAGS {
|
||||
self.control_geometry(id, output_tag(ui, id, text, true).rect);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn brief_ui(&mut self, app: &mut PhotocraftApp, ui: &mut Ui) {
|
||||
let editable = form_editable(self.busy.as_deref(), self.unknown && !self.scoped_production_pending());
|
||||
ui.add_enabled_ui(editable, |ui| self.brief_fields_ui(app, ui));
|
||||
@ -1346,6 +1358,8 @@ impl Workspace {
|
||||
};
|
||||
self.control_geometry("entry-hint", hint.rect);
|
||||
ui.add_space(6.0);
|
||||
self.output_tags_ui(ui);
|
||||
ui.add_space(6.0);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
let label = ui.label("制作时限");
|
||||
let response = ui.add_enabled_ui(editable, |ui| {
|
||||
@ -2536,6 +2550,35 @@ impl Workspace {
|
||||
}
|
||||
}
|
||||
|
||||
const READY_OUTPUT_TAGS: [(&str, &str); 3] = [
|
||||
("output-tag-detail", "详情页"),
|
||||
("output-tag-main_images", "主图"),
|
||||
("output-tag-sku_images", "SKU"),
|
||||
];
|
||||
|
||||
pub(super) const UPCOMING_OUTPUT_TAGS: [(&str, &str); 2] = [
|
||||
("output-tag-main_video", "主图视频 · 即将上线"),
|
||||
("output-tag-seeding_video", "买家秀(种草视频)· 即将上线"),
|
||||
];
|
||||
|
||||
pub(super) fn output_tag(ui: &mut Ui, id: &str, text: &str, upcoming: bool) -> egui::Response {
|
||||
let kind = if upcoming { stitch_ui::BadgeKind::Neutral } else { stitch_ui::BadgeKind::Adopted };
|
||||
let tokens = crate::theme::Tokens::get(ui.ctx()).agent();
|
||||
let text_width = ui.painter().layout_no_wrap(
|
||||
text.to_owned(), egui::FontId::proportional(11.76), tokens.text,
|
||||
).size().x;
|
||||
// Allocate the complete pill so the parent wraps it as a single item.
|
||||
let width = text_width + if upcoming { 20.0 } else { 38.0 };
|
||||
let (rect, response) = ui.allocate_exact_size(vec2(width, 24.0), egui::Sense::hover());
|
||||
stitch_ui::paint_badge(ui, ui.make_persistent_id(id), rect, kind, text, true);
|
||||
response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, text));
|
||||
if upcoming {
|
||||
response.on_hover_text("开发中,即将支持")
|
||||
} else {
|
||||
response
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -3637,6 +3680,59 @@ mod tests {
|
||||
assert!(requests.try_recv().is_err(), "painting a fully cached form does not execute a read or model action");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "offscreen GPU visual evidence"]
|
||||
fn output_tags_visual_preview() {
|
||||
let mut h = egui_kittest::Harness::builder()
|
||||
.with_size(vec2(900.0, 160.0))
|
||||
.with_context_setup(|ctx| {
|
||||
PhotocraftApp::setup_context(ctx, crate::theme::ThemeKind::ProMedium);
|
||||
})
|
||||
.wgpu()
|
||||
.build_ui_state(
|
||||
|ui, workspace: &mut Workspace| {
|
||||
stitch_ui::scope(ui, |ui| workspace.output_tags_ui(ui));
|
||||
ui.add_space(24.0);
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(380.0);
|
||||
stitch_ui::scope(ui, |ui| workspace.output_tags_ui(ui));
|
||||
});
|
||||
},
|
||||
brief_fixture().0,
|
||||
);
|
||||
h.run_steps(4);
|
||||
let directory = std::env::temp_dir().join("xiaoyi-output-tags-preview");
|
||||
std::fs::create_dir_all(&directory).unwrap();
|
||||
h.render().unwrap().save(directory.join("output-tags.png")).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_tags_wrap_and_upcoming_tags_do_not_dispatch() {
|
||||
let (mut w, mut app, requests) = brief_fixture();
|
||||
let ctx = egui::Context::default();
|
||||
PhotocraftApp::setup_context(&ctx, crate::theme::ThemeKind::ProMedium);
|
||||
let original = w.creation_brief.clone();
|
||||
w.creation_dirty = false;
|
||||
for width in [900.0, 380.0] {
|
||||
brief_frame(&mut w, &mut app, &ctx, width, vec![]);
|
||||
let bounds = brief_frame(&mut w, &mut app, &ctx, width, vec![]);
|
||||
let mut rects: Vec<egui::Rect> = Vec::new();
|
||||
for (id, _) in READY_OUTPUT_TAGS.into_iter().chain(UPCOMING_OUTPUT_TAGS) {
|
||||
let rect = control_rect(&w, id);
|
||||
assert!(bounds.contains_rect(rect), "{id} at {width}: {rect:?}");
|
||||
assert!(rects.iter().all(|other| !other.intersects(rect)), "{id} overlaps at {width}");
|
||||
rects.push(rect);
|
||||
}
|
||||
for (id, _) in UPCOMING_OUTPUT_TAGS {
|
||||
let pos = control_rect(&w, id).center();
|
||||
brief_frame(&mut w, &mut app, &ctx, width, click_events(pos));
|
||||
assert!(!w.creation_dirty);
|
||||
assert_eq!(w.creation_brief, original);
|
||||
assert!(requests.try_recv().is_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brief_library_search_and_entry_actions_reflow_without_dispatching() {
|
||||
let (mut w, mut app, requests) = brief_fixture();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user