Add a dropdown for resource selection and adopt it in the 'Image' node (#4543)

* Add a dropdown for resource selection and adopt it in the Image node

* Route every image upload through a new ResourceUpload handler with desktop support and migrate wired 'Image' node inputs

* Show each resource's user count in the resource picker dropdown

* Send a picked resource file to the document that requested it, list every non-font resource in the picker, and link sibling message docs
This commit is contained in:
Keavon Chambers
2026-09-18 18:14:24 -07:00
committed by GitHub
parent cb30348215
commit f90bef159c
34 changed files with 774 additions and 180 deletions
+1 -1
View File
@@ -42,6 +42,7 @@ macro_rules! for_each_item_type_default {
$action!(Gradient);
$action!(Artboard);
$action!(String);
$action!(Resource);
};
}
@@ -63,7 +64,6 @@ macro_rules! for_each_list_type_default {
macro_rules! for_each_bare_type_default {
($action:ident) => {
$action!(DocumentNode);
$action!(Resource);
};
}
+8 -4
View File
@@ -251,13 +251,17 @@ pub fn empty_image(_: impl Ctx, transform: Item<DAffine2>, color: Item<Color>) -
}
#[node_macro::node(category(""))]
pub fn image<'a: 'n>(_: impl Ctx, resource: Item<Resource>) -> Item<Raster<CPU>> {
pub fn image<'a: 'n>(
_: impl Ctx,
_primary: (),
/// The image file to display.
#[widget(ParsedWidgetOverride::Custom = "image_file")]
resource: Item<Resource>,
) -> Item<Raster<CPU>> {
let resource = resource.into_element();
let image_data = resource.as_ref();
let Some(image) = ::image::load_from_memory(image_data).ok() else {
return Item::default();
};
let Some(image) = ::image::load_from_memory(image_data).ok() else { return Item::default() };
let image = image.to_rgba32f();
let image = Image {
data: image.chunks(4).map(|pixel| Color::from_gamma_srgb_channels(pixel[0], pixel[1], pixel[2], pixel[3])).collect(),