Skip to content

Commit

Permalink
Comment node update (theme stuff, resize icon, cursor change)
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Jan 9, 2025
1 parent 40d26b3 commit eda8349
Show file tree
Hide file tree
Showing 5 changed files with 4,152 additions and 4,093 deletions.
22 changes: 16 additions & 6 deletions material_maker/nodes/comment/comment.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ var generator : MMGenComment:
editor.text = generator.text
position_offset = generator.position
size = generator.size

set_stylebox_color(generator.color)
update_stylebox()

if mm_globals.get_config("auto_size_comment"):
resize_to_selection()
Expand Down Expand Up @@ -87,6 +86,13 @@ func resize_to_selection() -> void:

# Title edit

func _on_gui_input(event):
if event is InputEventMouseMotion:
if event.position.x > size.x-10 and event.position.y > size.y-10:
mouse_default_cursor_shape = Control.CURSOR_FDIAGSIZE
else:
mouse_default_cursor_shape = Control.CURSOR_ARROW

func _on_Title_gui_input(event):
if event is InputEventMouseButton and event.double_click and event.button_index == MOUSE_BUTTON_LEFT:
title_edit.text = title.text
Expand Down Expand Up @@ -142,7 +148,7 @@ func _on_change_color_pressed():

func update_node() -> void:
size = generator.size
set_stylebox_color(generator.color)
update_stylebox()

func set_color(c):
$Popup.hide()
Expand All @@ -152,14 +158,16 @@ func set_color(c):
var redo_action = { type="comment_color_change", node=generator.get_hier_name(), color=c }
get_parent().undoredo.add("Change comment color", [undo_action], [redo_action], true)
generator.color = c
set_stylebox_color(c)
update_stylebox()
get_parent().send_changed_signal()

func set_stylebox_color(c):
func update_stylebox():
var c : Color = generator.color
c.a = 0.5
var stylebox : StyleBoxFlat = StyleBoxFlat.new()
var stylebox : StyleBoxFlat = get_theme_stylebox("selected" if selected else "default", "MM_CommentNode").duplicate()
stylebox.bg_color = c
$PanelContainer.add_theme_stylebox_override("panel", stylebox)
$PanelContainer/ResizerIcon.texture = get_theme_icon("resizer", "MM_CommentNode")

func _on_ColorChooser_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
Expand All @@ -182,9 +190,11 @@ func _on_position_offset_changed():

func _on_node_selected():
_on_raise_request()
update_stylebox()

func _on_node_deselected():
_on_raise_request()
update_stylebox()

func _on_raise_request():
var parent = get_parent()
Expand Down
21 changes: 16 additions & 5 deletions material_maker/nodes/comment/comment.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[gd_scene load_steps=6 format=3 uid="uid://bwi726lmqxcs3"]
[gd_scene load_steps=7 format=3 uid="uid://bwi726lmqxcs3"]

[ext_resource type="Script" uid="uid://6w4xc06fs82p" path="res://material_maker/nodes/comment/comment.gd" id="1"]
[ext_resource type="Script" uid="uid://s0k653ve15pr" path="res://material_maker/nodes/comment/palette_button.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://bntuquclal2jq" path="res://material_maker/icons/color_palette.png" id="2_x7nyr"]
[ext_resource type="Texture2D" uid="uid://carfoptwr44o4" path="res://material_maker/icons/color_picker.png" id="3"]
[ext_resource type="Texture2D" uid="uid://7gf42vko52o1" path="res://material_maker/icons/close.tres" id="3_awsjf"]

[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_awsjf"]

[node name="CommentNode" type="GraphElement"]
offset_left = 1.0
offset_top = 1.0
Expand All @@ -23,10 +25,10 @@ mouse_filter = 2

[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 3
theme_override_constants/margin_top = 3
theme_override_constants/margin_right = 3
theme_override_constants/margin_bottom = 3
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 4

[node name="VBox" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
layout_mode = 2
Expand Down Expand Up @@ -72,6 +74,14 @@ wrap_mode = 1
caret_blink = true
caret_multiple = false

[node name="ResizerIcon" type="TextureRect" parent="PanelContainer"]
custom_minimum_size = Vector2(16, 16)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8
mouse_filter = 2
texture = SubResource("PlaceholderTexture2D_awsjf")

[node name="Popup" type="PopupPanel" parent="."]
size = Vector2i(64, 64)

Expand Down Expand Up @@ -139,6 +149,7 @@ layout_mode = 2
edit_alpha = false

[connection signal="dragged" from="." to="." method="_on_dragged"]
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
[connection signal="node_deselected" from="." to="." method="_on_node_deselected"]
[connection signal="node_selected" from="." to="." method="_on_node_selected"]
[connection signal="position_offset_changed" from="." to="." method="_on_position_offset_changed"]
Expand Down
28 changes: 26 additions & 2 deletions material_maker/theme/default.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_resource type="Theme" load_steps=118 format=3 uid="uid://b628lwfk6ig2c"]
[gd_resource type="Theme" load_steps=121 format=3 uid="uid://b628lwfk6ig2c"]

[ext_resource type="FontFile" uid="uid://dgkwr5jydtk6p" path="res://material_maker/theme/font_rubik/Rubik-VariableFont_wght.ttf" id="1_5tfb1"]
[ext_resource type="Texture2D" uid="uid://c7mq31csbj1fg" path="res://material_maker/theme/default_theme_icons.svg" id="1_s43fy"]
[ext_resource type="Texture2D" uid="uid://1s0c37uoj4rf" path="res://material_maker/theme/default_theme_icons.svg" id="1_s43fy"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_telh7"]
content_margin_left = 6.0
Expand Down Expand Up @@ -270,6 +270,27 @@ border_width_right = 1
border_width_bottom = 1
border_color = Color(0.359069, 0.359069, 0.359069, 1)

[sub_resource type="AtlasTexture" id="AtlasTexture_08mel"]
atlas = ExtResource("1_s43fy")
region = Rect2(32, 176, 16, 16)

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_asgc8"]
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_en6gw"]
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color(0.485703, 0.485704, 0.485703, 1)
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dyhk7"]
content_margin_left = 10.0
content_margin_top = 2.0
Expand Down Expand Up @@ -937,6 +958,9 @@ LineEdit/styles/read_only = SubResource("StyleBoxFlat_k7e83")
MM_AddNodePanel/base_type = &"PanelContainer"
MM_AddNodePanel/styles/panel = SubResource("StyleBoxFlat_f0kci")
MM_AddNodePanelList/base_type = &"ItemList"
MM_CommentNode/icons/resizer = SubResource("AtlasTexture_08mel")
MM_CommentNode/styles/default = SubResource("StyleBoxFlat_asgc8")
MM_CommentNode/styles/selected = SubResource("StyleBoxFlat_en6gw")
MM_FilterLineEdit/base_type = &"LineEdit"
MM_FilterLineEdit/styles/focus = SubResource("StyleBoxFlat_dyhk7")
MM_FilterLineEdit/styles/normal = SubResource("StyleBoxFlat_mv8c7")
Expand Down
11 changes: 8 additions & 3 deletions material_maker/theme/default_theme_icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eda8349

Please sign in to comment.