1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Add a new "CanvasRulers" node group for the canvas rulers

This commit is contained in:
Emmanouil Papadeas 2024-10-11 16:31:18 +03:00
parent d05787d6ef
commit dddcfed3c4
4 changed files with 9 additions and 10 deletions

View file

@ -561,7 +561,10 @@ var draw_grid := false
## If [code]true[/code], the pixel grid is visible. ## If [code]true[/code], the pixel grid is visible.
var draw_pixel_grid := false var draw_pixel_grid := false
## If [code]true[/code], the rulers are visible. ## If [code]true[/code], the rulers are visible.
var show_rulers := true var show_rulers := true:
set(value):
show_rulers = value
get_tree().set_group(&"CanvasRulers", "visible", value)
## If [code]true[/code], the guides are visible. ## If [code]true[/code], the guides are visible.
var show_guides := true var show_guides := true
## If [code]true[/code], the mouse guides are visible. ## If [code]true[/code], the mouse guides are visible.
@ -612,10 +615,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn")
@onready var global_tool_options: PanelContainer = control.find_child("Global Tool Options") @onready var global_tool_options: PanelContainer = control.find_child("Global Tool Options")
## Camera of the main canvas. ## Camera of the main canvas.
@onready var camera: CanvasCamera = main_viewport.find_child("Camera2D") @onready var camera: CanvasCamera = main_viewport.find_child("Camera2D")
## Horizontal ruler of the main canvas. It has the [param HorizontalRuler.gd] script attached.
@onready var horizontal_ruler: BaseButton = control.find_child("HorizontalRuler")
## Vertical ruler of the main canvas. It has the [param VerticalRuler.gd] script attached.
@onready var vertical_ruler: BaseButton = control.find_child("VerticalRuler")
## Transparent checker of the main canvas. It has the [param TransparentChecker.gd] script attached. ## Transparent checker of the main canvas. It has the [param TransparentChecker.gd] script attached.
@onready var transparent_checker: ColorRect = control.find_child("TransparentChecker") @onready var transparent_checker: ColorRect = control.find_child("TransparentChecker")

View file

@ -8,6 +8,8 @@ var minor_subdivision := 4
var first: Vector2 var first: Vector2
var last: Vector2 var last: Vector2
@onready var vertical_ruler := $"../ViewportandVerticalRuler/VerticalRuler" as Button
func _ready() -> void: func _ready() -> void:
Global.project_switched.connect(queue_redraw) Global.project_switched.connect(queue_redraw)
@ -120,7 +122,7 @@ func create_guide() -> void:
return return
var mouse_pos := get_local_mouse_position() var mouse_pos := get_local_mouse_position()
if mouse_pos.x < RULER_WIDTH: # For double guides if mouse_pos.x < RULER_WIDTH: # For double guides
Global.vertical_ruler.create_guide() vertical_ruler.create_guide()
var guide := Guide.new() var guide := Guide.new()
if absf(Global.camera.rotation_degrees) < 45 or absf(Global.camera.rotation_degrees) > 135: if absf(Global.camera.rotation_degrees) < 45 or absf(Global.camera.rotation_degrees) > 135:
guide.type = guide.Types.HORIZONTAL guide.type = guide.Types.HORIZONTAL

View file

@ -735,8 +735,6 @@ func _toggle_show_pixel_grid() -> void:
func _toggle_show_rulers() -> void: func _toggle_show_rulers() -> void:
Global.show_rulers = !Global.show_rulers Global.show_rulers = !Global.show_rulers
view_menu.set_item_checked(Global.ViewMenu.SHOW_RULERS, Global.show_rulers) view_menu.set_item_checked(Global.ViewMenu.SHOW_RULERS, Global.show_rulers)
Global.horizontal_ruler.visible = Global.show_rulers
Global.vertical_ruler.visible = Global.show_rulers
func _toggle_show_guides() -> void: func _toggle_show_guides() -> void:

View file

@ -275,7 +275,7 @@ tab_close_display_policy = 2
drag_to_rearrange_enabled = true drag_to_rearrange_enabled = true
script = ExtResource("3") script = ExtResource("3")
[node name="HorizontalRuler" type="Button" parent="DockableContainer/Main Canvas"] [node name="HorizontalRuler" type="Button" parent="DockableContainer/Main Canvas" groups=["CanvasRulers"]]
clip_contents = true clip_contents = true
custom_minimum_size = Vector2(0, 16) custom_minimum_size = Vector2(0, 16)
layout_mode = 2 layout_mode = 2
@ -291,7 +291,7 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/separation = 0 theme_override_constants/separation = 0
[node name="VerticalRuler" type="Button" parent="DockableContainer/Main Canvas/ViewportandVerticalRuler"] [node name="VerticalRuler" type="Button" parent="DockableContainer/Main Canvas/ViewportandVerticalRuler" groups=["CanvasRulers"]]
clip_contents = true clip_contents = true
custom_minimum_size = Vector2(16, 0) custom_minimum_size = Vector2(16, 0)
layout_mode = 2 layout_mode = 2