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

Allow images to be shown in the tab titles #165

Open
LiamPClancy opened this issue Aug 25, 2023 · 4 comments
Open

Allow images to be shown in the tab titles #165

LiamPClancy opened this issue Aug 25, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@LiamPClancy
Copy link

Is your feature request related to a problem? Please describe.
Not a issue just additional functionality.

Describe the solution you'd like
Essentially i'd like to be able to display images in the title section of a tab, i'd like to be able to also control if the image + Title, just image or just title were shown.

i'm considering adding something like

fn title_image(&mut self, _tab: &mut Self::Tab, _ui: &mut Ui) -> Option<Image>:

to the TabViewer trait returning null as default.
if Null - behave as is
if not null - show the image to the left of the text in the title.

Describe alternatives you've considered
Also considered passing in having the proposed title_image method return Option<&RetainedImage> but this would require the egui_extras crate which is unnecessary and would make it a bit opinionated.

Additional context
Happy to make a PR if this is something you're interested in?

@LiamPClancy LiamPClancy added the enhancement New feature or request label Aug 25, 2023
@Adanos020
Copy link
Owner

This would be a very nice addition. I think tabs should support 3 variants:

  • Title text only
  • Image only
  • Image and title text

Images should also be appropriately resized not to exceed the tab height.

@LiamPClancy
Copy link
Author

wondering how you'd prefer this was acheived.

thinking of changing the title trait method to accept an enum

something like

enum TabTitle{
      Title(String), 
      Image(Image, String)
      }

The if the user wanted to have title and string, it'd be provided in the Image variant.
If not provided it could continue with the default title that is currently used?

alternatively, could add the additional method as mentioned in the initial comment, and if both title and image methods return values both will be used?

also happy with a different approach if you have a different preference?

@Adanos020
Copy link
Owner

Adanos020 commented Aug 27, 2023

I'd imagine the enum looking something like

enum TabTitle {
    Text(String),
    Image(Image),
    ImageAndText(Image, String),
}

@RegenJacob
Copy link
Contributor

It might be nice to also allow egui's RichText for tab titles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants