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

Enhance filesystem dock tooltips #63263

Merged
merged 1 commit into from
May 12, 2023
Merged

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jul 20, 2022

Closes godotengine/godot-proposals#175

Added this to the tooltips:

  • file size
  • resource type (if resource)
  • bigger preview (if texture or image)
    godot windows tools 64_BQPpwf9LeL

@KoBeWi KoBeWi added this to the 4.0 milestone Jul 20, 2022
@KoBeWi KoBeWi requested a review from a team as a code owner July 20, 2022 21:48
@YeldhamDev
Copy link
Member

The borders of the tooltips for images seem broken.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 20, 2022

What do you mean?
The bigger tooltip in the GIF just went outside recording area 🙃

@YeldhamDev
Copy link
Member

What do you mean?

The left border has a much smaller gap than the rest when hovering images.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 20, 2022

Borders are managed by the default tooltip container, so it doesn't seem like my fault. I could maybe hack it by adding an empty control.

@YeldhamDev
Copy link
Member

It would be better if we found the root issue rather than implementing a hack. Still, not a stopper for this PR.

@fire-forge
Copy link
Contributor

What do you think about adding previews for more resources there, using the same system the FileSystem uses to get previews in grid mode? That way more resources, like scenes, scripts, gradients, materials, fonts, etc. could have tooltip previews.

image

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 21, 2022

I'd leave it for later. The PR lays a nice foundation for such additions.

editor/filesystem_dock.cpp Outdated Show resolved Hide resolved
editor/filesystem_dock.cpp Outdated Show resolved Hide resolved
@KoBeWi KoBeWi force-pushed the power_tooltips branch 2 times, most recently from 17cf203 to 1121633 Compare July 21, 2022 11:20
@groud
Copy link
Member

groud commented Jul 21, 2022

I am not sure the preview implementation is acceptable as loading a resource can be costly. In that case it's only images, but I think I would have preferred that this PR uses the built in resource preview system.

It should even simplify the implementation, as it's fairly easy to use. You can check for uses of EditorResourcePreview::get_singleton()->queue_resource_preview to check how it works.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 21, 2022

I tried this

TextureRect *tr = memnew(TextureRect);
EditorResourcePreview::get_singleton()->queue_resource_preview(p_path, tr, "set_texture", Variant());

but it doesn't have effect 🤔

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 21, 2022

Ok done. It indeed simplified the code, but I still load the texture to display the dimensions 🙃 (it's not possible otherwise)

My idea for possible solution is to add EditorResourcePreview.get_preview_metadata(path, meta_name). The metadata would be automatically stored somewhere in EditorResourcePreview depending on the resource type (e.g. we could store size of textures).

@groud
Copy link
Member

groud commented Jul 21, 2022

Yeah I agree with the fact that EditorResourcePreview could also generate some metadata to be displayed along with the picture or something like that.
If you don't want to implement that right now and maybe to avoid freezes, maybe you could load the texture in the _tooltip_thumbnail_done callback? With some luck the texture will still be kept loaded and it would avoid the loading freeze.

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 21, 2022

It doesn't work. When the preview is cached it doesn't even load the texture. I can look into implementing preview metadata, but I don't think it really blocks this PR.

@reduz
Copy link
Member

reduz commented Aug 8, 2022

All welcome the new Godot Operating System overlord.

@mhilbrunner
Copy link
Member

Editor PR review meeting: feature is wanted and approved, @KoBeWi wants to improve texture loading first seperately.

@YuriSizov YuriSizov modified the milestones: 4.0, 4.x Feb 10, 2023
@KoBeWi
Copy link
Member Author

KoBeWi commented May 10, 2023

Rebased after #64628. For now this PR still uses the hard-coded approach. I'll look into implementing EditorResourceFileTooltipPlugin.

@KoBeWi KoBeWi requested a review from a team as a code owner May 10, 2023 16:02
@KoBeWi
Copy link
Member Author

KoBeWi commented May 10, 2023

Ok I added an API for creating resource tooltips and added a plugin for textures. We can add more plugins later (I have some fun idea for audio files).

@KoBeWi KoBeWi force-pushed the power_tooltips branch 3 times, most recently from 82f6737 to 8a40dc0 Compare May 10, 2023 17:07
@akien-mga akien-mga merged commit 3be56af into godotengine:master May 12, 2023
@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.

Show images in a tooltip when hovering them in the FileSystem dock
9 participants