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

Remove unused argument in Theme method and expose missing methods #37759

Merged

Conversation

YuriSizov
Copy link
Contributor

@YuriSizov YuriSizov commented Apr 10, 2020

Fixed #36880. Breaks compatibility.

Changed signature:

  • Theme.get_type_list(String type) -> Theme.get_type_list()

Renamed:

  • Theme.get_stylebox_types() -> Theme.get_stylebox_type_list()

Added:

  • Theme.get_color_type_list()
  • Theme.get_constant_type_list()
  • Theme.get_font_type_list()
  • Theme.get_icon_type_list()

As the type argument is never used in get_type_list, I've removed it, and fixed the documentation as well. I've also noticed, that there is a separate method to get types of styleboxes, but there are no methods for other entities. I've introduced them and named all of them to match get_type_list, for consistency. New methods are new to the engine as well and can be used internally, if one requires them.

Due to the removed argument and the renamed function this is a breaking change.

Test script
tool
extends EditorScript

func _run():
	var theme = Theme.new()
	theme.set_color("red_color", "FirstType", Color.red)
	theme.set_color("green_color", "FirstType", Color.green)
	theme.set_color("blue_color", "SecondType", Color.blue)
	
	theme.set_constant("what_const", "FirstType", 3)
	theme.set_constant("this_const", "ThirdType", 4)
	
	theme.set_font("some_font", "FontType", null)
	
	theme.set_icon("default_icon", "", null)
	theme.set_icon("custom_icon", "IconsType", null)
	
	theme.set_stylebox("panel_style", "Panels", StyleBoxFlat.new())
	theme.set_stylebox("box_style", "Panels", StyleBoxEmpty.new())
	
	var theme_types = theme.get_type_list()
	print("found theme types: ", theme_types.size())
	for type in theme_types:
		printt("type: ", type)
	
	var color_types = theme.get_color_type_list()
	print("found color types: ", color_types.size())
	for type in color_types:
		printt("type: ", type)
	
	var constant_types = theme.get_constant_type_list()
	print("found constant types: ", constant_types.size())
	for type in constant_types:
		printt("type: ", type)
	
	var font_types = theme.get_font_type_list()
	print("found font types: ", font_types.size())
	for type in font_types:
		printt("type: ", type)
	
	var icon_types = theme.get_icon_type_list()
	print("found icon types: ", icon_types.size())
	for type in icon_types:
		printt("type: ", type)
	
	var stylebox_types = theme.get_stylebox_type_list()
	print("found stylebox types: ", stylebox_types.size())
	for type in stylebox_types:
		printt("type: ", type)
Test output (formatted for readability)

found theme types: 7
type:
type: IconsType
type: FirstType
type: SecondType
type: ThirdType
type: FontType
type: Panels

found color types: 2
type: SecondType
type: FirstType

found constant types: 2
type: ThirdType
type: FirstType

found font types: 1
type: FontType

found icon types: 2
type:
type: IconsType

found stylebox types: 1
type: Panels

@YuriSizov
Copy link
Contributor Author

I've rebased this PR against the current master. It was messy due to intermediate changes between April and today, but I think I've got it working. The test script is producing the expected results still.

@akien-mga akien-mga merged commit 68117f5 into godotengine:master Dec 17, 2020
@akien-mga
Copy link
Member

Thanks!

@YuriSizov YuriSizov deleted the remove-arg-from-get_type_list branch December 19, 2020 14:18
YuriSizov added a commit to YuriSizov/godot that referenced this pull request Jun 10, 2021
Backport of relevant, non-breaking parts of godotengine#37759
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.

Argument "type" in Theme method get_type_list is never used
4 participants