diff --git a/addons/resources_speadsheet_view/editor_view.gd b/addons/resources_speadsheet_view/editor_view.gd index a9ad8ea..fef9312 100644 --- a/addons/resources_speadsheet_view/editor_view.gd +++ b/addons/resources_speadsheet_view/editor_view.gd @@ -598,6 +598,13 @@ func _on_cell_gui_input(event : InputEvent, cell : Control): if event is InputEventMouseButton: _update_scroll() if event.button_index != BUTTON_LEFT: + if event.button_index == BUTTON_RIGHT && event.is_pressed(): + if !cell in edited_cells: + deselect_all_cells() + select_cell(cell) + + emit_signal("cells_context", edited_cells) + return grab_focus() @@ -621,9 +628,9 @@ func _gui_input(event : InputEvent): if event is InputEventMouseButton: _update_scroll() if event.button_index != BUTTON_LEFT: - if event.button_index == BUTTON_RIGHT: + if event.button_index == BUTTON_RIGHT && event.is_pressed(): emit_signal("cells_context", edited_cells) - + return grab_focus() diff --git a/addons/resources_speadsheet_view/editor_view.tscn b/addons/resources_speadsheet_view/editor_view.tscn index ed3cb67..c316012 100644 --- a/addons/resources_speadsheet_view/editor_view.tscn +++ b/addons/resources_speadsheet_view/editor_view.tscn @@ -660,56 +660,56 @@ scroll_horizontal_enabled = false [node name="RichTextLabel" type="VBoxContainer" parent="Control/Settings/MarginContainer"] margin_right = 404.0 -margin_bottom = 167.0 +margin_bottom = 195.0 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="GridContainer" type="GridContainer" parent="Control/Settings/MarginContainer/RichTextLabel"] -margin_right = 404.0 -margin_bottom = 150.0 +margin_right = 392.0 +margin_bottom = 195.0 columns = 2 script = ExtResource( 14 ) [node name="Label" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] margin_top = 5.0 -margin_right = 326.0 +margin_right = 314.0 margin_bottom = 19.0 size_flags_horizontal = 3 text = "Color-type cells style rows" [node name="ColorRows" type="CheckBox" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] -margin_left = 330.0 -margin_right = 404.0 +margin_left = 318.0 +margin_right = 392.0 margin_bottom = 24.0 pressed = true text = "Enable" [node name="Label2" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] margin_top = 33.0 -margin_right = 326.0 +margin_right = 314.0 margin_bottom = 47.0 size_flags_horizontal = 3 text = "Colored array elements" [node name="ColorArrays" type="CheckBox" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] -margin_left = 330.0 +margin_left = 318.0 margin_top = 28.0 -margin_right = 404.0 +margin_right = 392.0 margin_bottom = 52.0 pressed = true text = "Enable" [node name="Label3" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] margin_top = 61.0 -margin_right = 326.0 +margin_right = 314.0 margin_bottom = 75.0 size_flags_horizontal = 3 text = "Array cell min width" [node name="ArrayMinWidth" type="SpinBox" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] -margin_left = 330.0 +margin_left = 318.0 margin_top = 56.0 -margin_right = 404.0 +margin_right = 392.0 margin_bottom = 80.0 min_value = 32.0 max_value = 512.0 @@ -717,35 +717,50 @@ value = 128.0 [node name="Label4" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] margin_top = 84.0 -margin_right = 326.0 -margin_bottom = 115.0 +margin_right = 314.0 +margin_bottom = 132.0 size_flags_horizontal = 3 text = "Clip header text (more compact view but header text wont be fully visible) (restart when switching)" autowrap = true [node name="ClipHeaders" type="CheckBox" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] -margin_left = 330.0 +margin_left = 318.0 margin_top = 84.0 -margin_right = 404.0 -margin_bottom = 115.0 +margin_right = 392.0 +margin_bottom = 132.0 text = "Enable" [node name="Label5" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] -margin_top = 119.0 -margin_right = 326.0 -margin_bottom = 150.0 +margin_top = 136.0 +margin_right = 314.0 +margin_bottom = 167.0 size_flags_horizontal = 3 text = "Duplicate arrays on edit (slower, but can be undone)" autowrap = true [node name="DupeArrays" type="CheckBox" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] -margin_left = 330.0 -margin_top = 119.0 -margin_right = 404.0 -margin_bottom = 150.0 +margin_left = 318.0 +margin_top = 136.0 +margin_right = 392.0 +margin_bottom = 167.0 pressed = true text = "Enable" +[node name="Label6" type="Label" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] +margin_top = 176.0 +margin_right = 314.0 +margin_bottom = 190.0 +size_flags_horizontal = 3 +text = "Context menu opens on left-click too" +autowrap = true + +[node name="ContextMenuOnLeftclick" type="CheckBox" parent="Control/Settings/MarginContainer/RichTextLabel/GridContainer"] +margin_left = 318.0 +margin_top = 171.0 +margin_right = 392.0 +margin_bottom = 195.0 +text = "Enable" + [node name="SelectionActions" parent="Control" instance=ExtResource( 19 )] visible = false diff --git a/addons/resources_speadsheet_view/selection_actions.gd b/addons/resources_speadsheet_view/selection_actions.gd index b94cd8b..e013db3 100644 --- a/addons/resources_speadsheet_view/selection_actions.gd +++ b/addons/resources_speadsheet_view/selection_actions.gd @@ -29,20 +29,29 @@ func _on_grid_cells_context(cells): func _on_grid_cells_selected(cells): - open(cells) + if ProjectSettings.get_setting(SettingsGrid.SETTING_PREFIX + "context_menu_on_leftclick"): + open(cells, true) + + else: hide() -func open(cells): +func open(cells : Array, pin_to_cell : bool = false): if cells.size() == 0: hide() cell = null return - cell = cells[-1] - rect_global_position = Vector2( - cell.rect_global_position.x + cell.rect_size.x, - cell.rect_global_position.y - ) + if pin_to_cell: + cell = cells[-1] + rect_global_position = Vector2( + cell.rect_global_position.x + cell.rect_size.x, + cell.rect_global_position.y + ) + + else: + cell = null + rect_global_position = get_global_mouse_position() + Vector2.ONE + rect_size = Vector2.ZERO show() $"Control2/Label".text = str(cells.size()) + (" Cells" if cells.size() % 10 != 1 else " Cell") diff --git a/addons/resources_speadsheet_view/selection_actions.tscn b/addons/resources_speadsheet_view/selection_actions.tscn index 55f579e..e9fd204 100644 --- a/addons/resources_speadsheet_view/selection_actions.tscn +++ b/addons/resources_speadsheet_view/selection_actions.tscn @@ -1,9 +1,9 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://addons/resources_speadsheet_view/editor_icon_button.gd" type="Script" id=1] [ext_resource path="res://addons/resources_speadsheet_view/selection_actions.gd" type="Script" id=2] -[sub_resource type="Image" id=3] +[sub_resource type="Image" id=7] data = { "data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), "format": "LumAlpha8", @@ -15,15 +15,42 @@ data = { [sub_resource type="ImageTexture" id=2] flags = 4 flags = 4 -image = SubResource( 3 ) +image = SubResource( 7 ) size = Vector2( 16, 16 ) +[sub_resource type="Image" id=8] +data = { +"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), +"format": "LumAlpha8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id=5] +flags = 4 +flags = 4 +image = SubResource( 8 ) +size = Vector2( 16, 16 ) + +[sub_resource type="StyleBoxTexture" id=6] +texture = SubResource( 5 ) +region_rect = Rect2( 0, 0, 16, 16 ) +margin_left = 2.0 +margin_right = 2.0 +margin_top = 2.0 +margin_bottom = 2.0 + [node name="SelectionActions" type="MarginContainer"] margin_right = 84.0 margin_bottom = 44.0 mouse_filter = 2 size_flags_horizontal = 9 script = ExtResource( 2 ) +__meta__ = { +"_edit_group_": true, +"_edit_lock_": true +} [node name="Control2" type="Control" parent="."] margin_right = 84.0 @@ -35,11 +62,13 @@ show_behind_parent = true margin_left = -2.0 margin_top = -18.0 margin_bottom = 2.0 +mouse_filter = 2 [node name="ColorRect2" type="ColorRect" parent="Control2"] show_behind_parent = true anchor_bottom = 1.0 margin_left = -2.0 +mouse_filter = 2 [node name="Label" type="Label" parent="Control2"] margin_left = 2.0 @@ -137,6 +166,7 @@ margin_right = 14.0 margin_bottom = 14.0 rect_min_size = Vector2( 192, 0 ) mouse_filter = 2 +custom_styles/panel = SubResource( 6 ) [node name="VBoxContainer" type="VBoxContainer" parent="Control/ColorRect/Popup/Panel"] margin_left = 7.0 diff --git a/project.godot b/project.godot index 2700eb6..2e85bc4 100644 --- a/project.godot +++ b/project.godot @@ -99,6 +99,7 @@ resources_spreadsheet_view/color_arrays=true resources_spreadsheet_view/clip_headers=false resources_spreadsheet_view/dupe_arrays=true resources_spreadsheet_view/array_min_width=128.0 +resources_spreadsheet_view/context_menu_on_leftclick=false [application]