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 nothing case for theme #3043

Closed
wants to merge 1 commit into from
Closed

Conversation

pepijndevos
Copy link
Contributor

Description

When calling theme(scene, :key) in a recipe, if scene is nothing it seems to look up the default theme.
But theme(scene) has no such fallback.

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@SimonDanisch
Copy link
Member

Hm, the thing is, CURRENT_DEFAULT_THEME shouldn't be directly handed to the user for mutation.
Although, set_theme! also mutates it, but I'm not sure I want more ways to mutate the default_theme.
What exactly do you want to do with theme()?

@pepijndevos
Copy link
Contributor Author

pepijndevos commented Jul 6, 2023

Get an attribute that may or may not exist. Apparently a recipe gets called with a nothing scene sometimes, so if you write get(theme(scene), key, default) instead of theme(scene, key) it'll error

@SimonDanisch
Copy link
Member

Ah maybe we should add theme(scene, key; default) for more signatures then...

@pepijndevos
Copy link
Contributor Author

That would be another option yes. For reference, this is a line of code I currently have:

        xgridcolor = get(something(get(theme(scene), :Axis, nothing), Attributes()), :xgridcolor, RGBAf(0, 0, 0, 0.12)),

@SimonDanisch
Copy link
Member

Do you want to implement theme(scene, key; default) in this PR?

@pepijndevos
Copy link
Contributor Author

Sure after I'm back from holiday :)

@pepijndevos pepijndevos mentioned this pull request Sep 6, 2023
7 tasks
@pepijndevos
Copy link
Contributor Author

Superseded by #3214 since this one is like an one line change that's now out of date

@pepijndevos pepijndevos closed this Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants