Fix the size of the timeline layer/frame buttons.

This commit is contained in:
Relintai 2020-11-29 18:37:00 +01:00
parent 68f877879f
commit 7cb04b92ac
4 changed files with 33 additions and 23 deletions

View File

@ -408,7 +408,7 @@ func layers_changed(value : Array) -> void:
var cel_button = load("res://addons/draw_gd/src/UI/Timeline/CelButton.tscn").instance()
cel_button.frame = j
cel_button.layer = i
cel_button.get_child(0).texture = frames[j].cels[i].image_texture
cel_button.texture = frames[j].cels[i].image_texture
layers[i].frame_container.add_child(cel_button)

View File

@ -4,6 +4,8 @@ extends Button
var frame := 0
var layer := 0
var texture : TextureRect = null
var DrawGD : Node = null
var popup_menu : PopupMenu = null
@ -17,6 +19,7 @@ func _enter_tree() -> void:
n = n.get_parent()
popup_menu = get_node("PopupMenu")
texture = get_node("MC/CelTexture")
hint_tooltip = tr("Frame: %s, Layer: %s") % [frame + 1, layer]
if DrawGD.current_project.frames[frame] in DrawGD.current_project.layers[layer].linked_cels:
@ -28,10 +31,6 @@ func _enter_tree() -> void:
popup_menu.set_item_text(4, "Link Cel")
popup_menu.set_item_metadata(4, "Link Cel")
# Reset the checkers size because it assumes you want the same size as the canvas
var checker = $CelTexture/TransparentChecker
checker.rect_size = checker.get_parent().rect_size
func _on_CelButton_pressed() -> void:
if Input.is_action_just_released("left_mouse"):

View File

@ -3,15 +3,13 @@
[ext_resource path="res://addons/draw_gd/src/UI/Timeline/CelButton.gd" type="Script" id=1]
[ext_resource path="res://addons/draw_gd/src/UI/TransparentChecker.tscn" type="PackedScene" id=2]
[node name="CelButton" type="Button"]
margin_top = 18.0
margin_right = 36.0
margin_bottom = 54.0
rect_min_size = Vector2( 36, 36 )
hint_tooltip = "Frame: 1, Layer: 0"
mouse_default_cursor_shape = 2
size_flags_horizontal = 0
size_flags_vertical = 0
toggle_mode = true
button_mask = 7
script = ExtResource( 1 )
@ -19,27 +17,40 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="CelTexture" type="TextureRect" parent="."]
margin_left = 2.0
margin_top = 1.78536
margin_right = 34.0
margin_bottom = 33.7854
[node name="MC2" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TransparentChecker" parent="MC2" instance=ExtResource( 2 )]
margin_right = 36.0
margin_bottom = 36.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="MC" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CelTexture" type="TextureRect" parent="MC"]
margin_right = 36.0
margin_bottom = 36.0
rect_min_size = Vector2( 32, 32 )
size_flags_horizontal = 0
size_flags_vertical = 0
size_flags_horizontal = 3
size_flags_vertical = 3
expand = true
stretch_mode = 6
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TransparentChecker" parent="CelTexture" instance=ExtResource( 2 )]
show_behind_parent = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 0.0
margin_bottom = 0.0
[node name="PopupMenu" type="PopupMenu" parent="."]
margin_right = 20.0
margin_bottom = 20.0
@ -52,5 +63,6 @@ color = Color( 0.0627451, 0.741176, 0.215686, 1 )
invert_enable = true
invert_border = 1.0
polygon = PoolVector2Array( 0, 0, 36, 0, 36, 36, 0, 36 )
[connection signal="pressed" from="." to="." method="_on_CelButton_pressed"]
[connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"]

View File

@ -3,7 +3,6 @@
[ext_resource path="res://addons/draw_gd/assets/graphics/dark_themes/timeline/new_frame.png" type="Texture" id=1]
[ext_resource path="res://addons/draw_gd/src/UI/Timeline/FrameTagDialog.gd" type="Script" id=2]
[node name="FrameTagDialog" type="AcceptDialog"]
margin_right = 83.0
margin_bottom = 58.0