mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-07 10:59:49 +00:00
Draw UI improvements (#671)
* add limit change with brush * Delete Draw.gd * Delete BaseTool.gd * Some improvements 1) A Smarter Placement of "brushes_popup" 2) A Different Convention for image brushes (100 % instead of 1px) * Formatting * some more formatting
This commit is contained in:
parent
b7df8e9fe8
commit
c1759c74eb
|
@ -33,7 +33,20 @@ func _on_BrushType_pressed() -> void:
|
||||||
Global.brushes_popup.connect(
|
Global.brushes_popup.connect(
|
||||||
"brush_selected", self, "_on_Brush_selected", [], CONNECT_ONESHOT
|
"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:
|
func _on_Brush_selected(brush: Brushes.Brush) -> void:
|
||||||
|
@ -92,6 +105,7 @@ func update_config() -> void:
|
||||||
|
|
||||||
|
|
||||||
func update_brush() -> void:
|
func update_brush() -> void:
|
||||||
|
$Brush/Size.suffix = "px" # Assume we are using default brushes
|
||||||
match _brush.type:
|
match _brush.type:
|
||||||
Brushes.PIXEL:
|
Brushes.PIXEL:
|
||||||
_brush_texture.create_from_image(load("res://assets/graphics/pixel_image.png"), 0)
|
_brush_texture.create_from_image(load("res://assets/graphics/pixel_image.png"), 0)
|
||||||
|
@ -100,6 +114,7 @@ func update_brush() -> void:
|
||||||
Brushes.FILLED_CIRCLE:
|
Brushes.FILLED_CIRCLE:
|
||||||
_brush_texture.create_from_image(load("res://assets/graphics/circle_filled_9x9.png"), 0)
|
_brush_texture.create_from_image(load("res://assets/graphics/circle_filled_9x9.png"), 0)
|
||||||
Brushes.FILE, Brushes.RANDOM_FILE, Brushes.CUSTOM:
|
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:
|
if _brush.random.size() <= 1:
|
||||||
_brush_image = _create_blended_brush_image(_brush.image)
|
_brush_image = _create_blended_brush_image(_brush.image)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue