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

Draw UI improvements #671

Merged
merged 14 commits into from
May 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Tools/Draw.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ func _on_BrushType_pressed() -> void:
Global.brushes_popup.connect(
"brush_selected", self, "_on_Brush_selected", [], CONNECT_ONESHOT
)
Global.brushes_popup.popup(Rect2($Brush/Type.rect_global_position, Vector2(226, 72)))
# Now we set position and tab allignment considering certain conditions
var pop_size := Vector2(226, 72)
var pop_position: Vector2 = $Brush/Type.rect_global_position
var off_limit: float = Global.shrink * (pop_position.x + pop_size.x) - OS.get_window_size().x
if off_limit <= 72 and off_limit > 0: # Some space left "Leftward"
pop_position -= Vector2(pop_size.x / 2.0 - 48, -32)
Global.brushes_popup.get_node("TabContainer").tab_align = TabContainer.ALIGN_CENTER
elif off_limit >= 72: # No space left "Leftward"
pop_position -= Vector2(pop_size.x / 2.0 + 16, -32)
Global.brushes_popup.get_node("TabContainer").tab_align = TabContainer.ALIGN_RIGHT
else:
pop_position -= Vector2(0, -32) # Plenty of space left "Leftward"
Global.brushes_popup.get_node("TabContainer").tab_align = TabContainer.ALIGN_LEFT
Global.brushes_popup.popup(Rect2(pop_position, pop_size))


func _on_Brush_selected(brush: Brushes.Brush) -> void:
Expand Down Expand Up @@ -92,6 +105,7 @@ func update_config() -> void:


func update_brush() -> void:
$Brush/Size.suffix = "px" # Assume we are using default brushes
match _brush.type:
Brushes.PIXEL:
_brush_texture.create_from_image(load("res://assets/graphics/pixel_image.png"), 0)
Expand All @@ -100,6 +114,7 @@ func update_brush() -> void:
Brushes.FILLED_CIRCLE:
_brush_texture.create_from_image(load("res://assets/graphics/circle_filled_9x9.png"), 0)
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
$Brush/Size.suffix = "00 %" # It's an image so a different size convention is used
if _brush.random.size() <= 1:
_brush_image = _create_blended_brush_image(_brush.image)
else:
Expand Down