-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use custom container type for path command editors (#260)
- Loading branch information
Showing
3 changed files
with
49 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Allows passing an array of custom horizontal spacings. | ||
class_name CustomSpacedHBoxContainer extends Container | ||
|
||
# Array for the spacing between elements. | ||
var _spacing_array: Array[int] | ||
|
||
func _ready() -> void: | ||
sort_children.connect(_sort_children) | ||
|
||
func set_spacing_array(new_arr: Array[int]) -> void: | ||
_spacing_array = new_arr | ||
queue_sort() | ||
|
||
func _sort_children(): | ||
var current_x: float = 0 | ||
var spacing_arr_size := _spacing_array.size() | ||
|
||
for i in get_child_count(): | ||
var child: Control = get_child(i) | ||
child.position.x = current_x | ||
|
||
current_x += child.size.x | ||
if i < spacing_arr_size: | ||
current_x += _spacing_array[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters