From 87d6967666c57bdf628053c831c691f899e069fc Mon Sep 17 00:00:00 2001 From: Wybe Westra Date: Mon, 31 May 2021 21:56:21 +0200 Subject: [PATCH] ! Fix "narrowing conversion" warnings. resolves #1 * Change `_calculate_layout` to actually not apply when `apply` is false. --- .gdignore | 0 .gitignore | 0 LICENSE | 0 example_scenes/example_1.tscn | 0 example_scenes/resources/.gdignore | 0 example_scenes/resources/default.theme | Bin h_flow_container/h_flow_container.gd | 11 ++++++----- h_flow_container/h_flow_container.svg | 0 h_flow_container/h_flow_container.svg.import | 0 icon.png | Bin icon.png.import | 0 icon.svg | 0 icon.svg.import | 0 project.godot | 0 readme.md | 0 screenshots/.gdignore | 0 screenshots/example_1.png | Bin 17 files changed, 6 insertions(+), 5 deletions(-) mode change 100644 => 100755 .gdignore mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 example_scenes/example_1.tscn mode change 100644 => 100755 example_scenes/resources/.gdignore mode change 100644 => 100755 example_scenes/resources/default.theme mode change 100644 => 100755 h_flow_container/h_flow_container.gd mode change 100644 => 100755 h_flow_container/h_flow_container.svg mode change 100644 => 100755 h_flow_container/h_flow_container.svg.import mode change 100644 => 100755 icon.png mode change 100644 => 100755 icon.png.import mode change 100644 => 100755 icon.svg mode change 100644 => 100755 icon.svg.import mode change 100644 => 100755 project.godot mode change 100644 => 100755 readme.md mode change 100644 => 100755 screenshots/.gdignore mode change 100644 => 100755 screenshots/example_1.png diff --git a/.gdignore b/.gdignore old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/example_scenes/example_1.tscn b/example_scenes/example_1.tscn old mode 100644 new mode 100755 diff --git a/example_scenes/resources/.gdignore b/example_scenes/resources/.gdignore old mode 100644 new mode 100755 diff --git a/example_scenes/resources/default.theme b/example_scenes/resources/default.theme old mode 100644 new mode 100755 diff --git a/h_flow_container/h_flow_container.gd b/h_flow_container/h_flow_container.gd old mode 100644 new mode 100755 index 7dc2a72..bff1d94 --- a/h_flow_container/h_flow_container.gd +++ b/h_flow_container/h_flow_container.gd @@ -18,7 +18,7 @@ export var vertical_margin: float = 5 # Used to make our parent re-evaluate our size when we have to create more or # less rows to fit in all the children. -var _reported_height_at_last_minimum_size_call := 0 +var _reported_height_at_last_minimum_size_call: float = 0 # Called when the node enters the scene tree for the first time. func _ready(): @@ -27,7 +27,7 @@ func _ready(): func _get_minimum_size() -> Vector2: # Our minimum width is the width of the widest child. - var max_requested_width := 0 + var max_requested_width: float = 0 for child in get_children(): # Check if the child is actually a `Control`. @@ -66,9 +66,9 @@ func _notification(what): func _calculate_layout(apply: bool) -> float: # Where to place the next child. var next_location: Vector2 = Vector2(0, 0) - var row_height: int = 0 + var row_height: float = 0 # Used to calculate when to apply the horizontal margin. - var children_in_current_row := 0 + var children_in_current_row: float = 0 for child in get_children(): # Check if the child is actually a `Control`. @@ -92,7 +92,8 @@ func _calculate_layout(apply: bool) -> float: row_height = 0 children_in_current_row = 0 - fit_child_in_rect(child, Rect2(next_location, requested_size)) + if apply: + fit_child_in_rect(child, Rect2(next_location, requested_size)) if requested_size.y > row_height: row_height = requested_size.y diff --git a/h_flow_container/h_flow_container.svg b/h_flow_container/h_flow_container.svg old mode 100644 new mode 100755 diff --git a/h_flow_container/h_flow_container.svg.import b/h_flow_container/h_flow_container.svg.import old mode 100644 new mode 100755 diff --git a/icon.png b/icon.png old mode 100644 new mode 100755 diff --git a/icon.png.import b/icon.png.import old mode 100644 new mode 100755 diff --git a/icon.svg b/icon.svg old mode 100644 new mode 100755 diff --git a/icon.svg.import b/icon.svg.import old mode 100644 new mode 100755 diff --git a/project.godot b/project.godot old mode 100644 new mode 100755 diff --git a/readme.md b/readme.md old mode 100644 new mode 100755 diff --git a/screenshots/.gdignore b/screenshots/.gdignore old mode 100644 new mode 100755 diff --git a/screenshots/example_1.png b/screenshots/example_1.png old mode 100644 new mode 100755