Skip to content

Commit 247578c

Browse files
committed
debug_ui: Add properties for Bitmap
1 parent cc6f8bc commit 247578c

File tree

1 file changed

+54
-19
lines changed

1 file changed

+54
-19
lines changed

core/src/debug_ui/display_object.rs

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -726,27 +726,62 @@ impl DisplayObjectWindow {
726726
context: &mut UpdateContext<'gc>,
727727
object: Bitmap<'gc>,
728728
) {
729-
let bitmap_data = object.bitmap_data(context.renderer);
730-
let bitmap_data = bitmap_data.read();
729+
Grid::new(ui.id().with("bitmap"))
730+
.num_columns(2)
731+
.show(ui, |ui| {
732+
let bitmap_data = object.bitmap_data(context.renderer);
733+
let bitmap_data = bitmap_data.read();
731734

732-
if bitmap_data.width() == 0 || bitmap_data.height() == 0 {
733-
ui.weak("(no pixels)");
734-
return;
735-
}
735+
ui.label("Width");
736+
ui.label(format!("{} px", bitmap_data.width()));
737+
ui.end_row();
736738

737-
let mut egui_texture = bitmap_data.egui_texture.borrow_mut();
738-
let texture = egui_texture.get_or_insert_with(|| {
739-
let image = egui::ColorImage::from_rgba_premultiplied(
740-
[bitmap_data.width() as usize, bitmap_data.height() as usize],
741-
&bitmap_data.pixels_rgba(),
742-
);
743-
ui.ctx().load_texture(
744-
format!("bitmap-{:?}", object.as_ptr()),
745-
image,
746-
Default::default(),
747-
)
748-
});
749-
ui.image((texture.id(), texture.size_vec2()));
739+
ui.label("Height");
740+
ui.label(format!("{} px", bitmap_data.height()));
741+
ui.end_row();
742+
743+
ui.label("Transparency");
744+
if bitmap_data.transparency() {
745+
ui.label("Yes");
746+
} else {
747+
ui.label("No");
748+
}
749+
ui.end_row();
750+
751+
ui.label("Disposed");
752+
if bitmap_data.disposed() {
753+
ui.label("Yes");
754+
} else {
755+
ui.label("No");
756+
}
757+
ui.end_row();
758+
});
759+
760+
CollapsingHeader::new("Preview")
761+
.id_salt(ui.id().with("bitmap-preview"))
762+
.show(ui, |ui| {
763+
let bitmap_data = object.bitmap_data(context.renderer);
764+
let bitmap_data = bitmap_data.read();
765+
766+
if bitmap_data.width() == 0 || bitmap_data.height() == 0 {
767+
ui.weak("(no pixels)");
768+
return;
769+
}
770+
771+
let mut egui_texture = bitmap_data.egui_texture.borrow_mut();
772+
let texture = egui_texture.get_or_insert_with(|| {
773+
let image = egui::ColorImage::from_rgba_premultiplied(
774+
[bitmap_data.width() as usize, bitmap_data.height() as usize],
775+
&bitmap_data.pixels_rgba(),
776+
);
777+
ui.ctx().load_texture(
778+
format!("bitmap-{:?}", object.as_ptr()),
779+
image,
780+
Default::default(),
781+
)
782+
});
783+
ui.image((texture.id(), texture.size_vec2()));
784+
});
750785
}
751786

752787
pub fn show_movieclip<'gc>(

0 commit comments

Comments
 (0)