Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gradient resource preview generator #60395

Merged

Conversation

Geometror
Copy link
Member

This PR implements a resource preview generator for the Gradient resource, which is quite helpful when working with Gradients separate from GradientTexture1D/2D. Having the resource expanded in the inspector takes up a lot of space and makes it more chaotic when you just wan't to see how the gradient looks like. (Also useful for saved gradient resources)

Examples:
FastNoiseLite
grafik

CPUParticles2D/3D
grafik

Resource preview in FileSystem dock:
grafik

@Geometror Geometror changed the title Add gradient resource preview generator Add Gradient resource preview generator Apr 20, 2022
@Chaosus Chaosus added this to the 4.0 milestone Apr 20, 2022
@Geometror Geometror force-pushed the editor-gradient-preview-plugin branch from 0320c6d to 64b3d2f Compare April 20, 2022 18:49
@clayjohn
Copy link
Member

How does it look when the inspector is narrower?

@fire-forge
Copy link
Contributor

@clayjohn It fills the width of the preview space. GradientTexture1D also does this.

image
image

editor/editor_resource_picker.cpp Outdated Show resolved Hide resolved
@@ -90,7 +90,8 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const
if (p_preview.is_valid()) {
preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button")));

if (Ref<GradientTexture1D>(edited_resource).is_valid()) {
// Ressource-specific stretching.
if (Ref<GradientTexture1D>(edited_resource).is_valid() || Ref<Gradient>(edited_resource).is_valid()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to make stretching be defined by EditorResourcePreviewGenerator instead of hardcoding the resources, so that plugins can add stretching previews for custom resources too. But that can be done in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I thought of this too, but this PR is just for adding the preview. I actually plan to refactor the resource preview system (as there are also some other small issues) sometime in the following weeks, it's already on my to-do list :)

@akien-mga akien-mga merged commit e8cca50 into godotengine:master Apr 26, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants