mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
Removed the "eye" buttons, clicking on the outputs will show the preview
This commit is contained in:
parent
3f679cc348
commit
212e004ad4
@ -385,9 +385,18 @@ func _on_GraphEdit_gui_input(event) -> void:
|
||||
call_deferred("check_last_selected")
|
||||
|
||||
func request_popup(from, from_slot, release_position) -> void:
|
||||
node_popup.rect_global_position = get_global_mouse_position()
|
||||
node_popup.show()
|
||||
node_popup.set_quick_connect(from, from_slot)
|
||||
# Check if the connector was actually dragged
|
||||
var node : GraphNode = get_node(from)
|
||||
var node_transform : Transform2D = node.get_global_transform()
|
||||
var output_position = node_transform.xform(node.get_connection_output_position(from_slot)/node_transform.get_scale())
|
||||
if (get_global_mouse_position()-output_position).length() < 20:
|
||||
# Tell the node its connector was clicked
|
||||
node.on_clicked_output(from_slot)
|
||||
else:
|
||||
# Request the popup
|
||||
node_popup.rect_global_position = get_global_mouse_position()
|
||||
node_popup.show()
|
||||
node_popup.set_quick_connect(from, from_slot)
|
||||
|
||||
func check_last_selected() -> void:
|
||||
if last_selected != null and !(is_instance_valid(last_selected) and last_selected.selected):
|
||||
|
@ -55,9 +55,9 @@
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="10.114758"
|
||||
inkscape:cx="100.19195"
|
||||
inkscape:cy="20.027892"
|
||||
inkscape:zoom="40.459032"
|
||||
inkscape:cx="12.31719"
|
||||
inkscape:cy="41.781829"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
@ -593,5 +593,17 @@
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.15158939px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 114.33714,336.4547 v 5.90037 z m 8.55274,0 v 5.90037 z m -17.10352,0.12943 v 5.90037 z"
|
||||
id="path920" />
|
||||
<path
|
||||
style="opacity:1;fill:none;fill-opacity:1;stroke:#f6f6f6;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
|
||||
id="path4602"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="7.9966879"
|
||||
sodipodi:cy="304.06088"
|
||||
sodipodi:rx="7.4148879"
|
||||
sodipodi:ry="7.4346347"
|
||||
sodipodi:start="0.0057686972"
|
||||
sodipodi:end="0.0018129957"
|
||||
sodipodi:open="true"
|
||||
d="m 15.411452,304.10377 a 7.4148879,7.4346347 0 0 1 -7.4502054,7.39166 7.4148879,7.4346347 0 0 1 -7.37939334,-7.46273 7.4148879,7.4346347 0 0 1 7.43561054,-7.40642 7.4148879,7.4346347 0 0 1 7.3941002,7.44808" />
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
8
material_maker/icons/output_preview.tres
Normal file
8
material_maker/icons/output_preview.tres
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 80, 16, 16 )
|
@ -11,6 +11,17 @@ var preview_position : int
|
||||
var preview_size : int
|
||||
var preview_timer : Timer = null
|
||||
|
||||
func _draw() -> void:
|
||||
._draw()
|
||||
if preview_index >= 0:
|
||||
var conn_pos = get_connection_output_position(preview_index)
|
||||
if preview_index > 0:
|
||||
conn_pos.y += 1
|
||||
print(conn_pos)
|
||||
conn_pos /= get_global_transform().get_scale()
|
||||
print(conn_pos)
|
||||
draw_texture(preload("res://material_maker/icons/output_preview.tres"), conn_pos-Vector2(8, 8))
|
||||
|
||||
func set_generator(g) -> void:
|
||||
.set_generator(g)
|
||||
generator.connect("parameter_changed", self, "on_parameter_changed")
|
||||
@ -262,23 +273,8 @@ func update_node() -> void:
|
||||
hsizer.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL
|
||||
add_child(hsizer)
|
||||
hsizer = get_child(i)
|
||||
var has_filler = false
|
||||
for c in hsizer.get_children():
|
||||
if c.size_flags_horizontal & SIZE_EXPAND != 0:
|
||||
has_filler = true
|
||||
break
|
||||
if !has_filler:
|
||||
var empty_control : Control = Control.new()
|
||||
empty_control.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL
|
||||
hsizer.add_child(empty_control)
|
||||
var button = preload("res://material_maker/widgets/preview_button.tscn").instance()
|
||||
button.size_flags_horizontal = SIZE_SHRINK_END
|
||||
button.size_flags_vertical = SIZE_SHRINK_CENTER
|
||||
if i == preview_index:
|
||||
button.pressed = true
|
||||
hsizer.add_child(button)
|
||||
button.connect("toggled", self, "on_preview_button", [ i ])
|
||||
button_width = button.rect_size.x
|
||||
if hsizer.get_child_count() == 0:
|
||||
hsizer.rect_min_size.y = 16
|
||||
if !outputs.empty():
|
||||
for i in range(output_count, get_child_count()):
|
||||
var hsizer : HBoxContainer = get_child(i)
|
||||
@ -352,34 +348,22 @@ func do_save_generator(file_name : String) -> void:
|
||||
file.close()
|
||||
mm_loader.update_predefined_generators()
|
||||
|
||||
func update_preview_buttons(index : int) -> void:
|
||||
for i in range(output_count):
|
||||
if i != index:
|
||||
var line = get_child(i)
|
||||
line.get_child(line.get_child_count()-1).pressed = false
|
||||
|
||||
var processing_button = false
|
||||
|
||||
func on_preview_button(pressed : bool, index : int) -> void:
|
||||
if processing_button:
|
||||
return
|
||||
processing_button = true
|
||||
if pressed:
|
||||
func on_clicked_output(index : int) -> void:
|
||||
if preview_index == index:
|
||||
preview_index = -1
|
||||
preview.visible = false
|
||||
remove_child(preview)
|
||||
rect_size = Vector2(0, 0)
|
||||
else:
|
||||
preview_index = index
|
||||
var width
|
||||
if preview.visible:
|
||||
update_preview_buttons(index)
|
||||
update_preview()
|
||||
else:
|
||||
var status = update_preview(get_child(0).rect_size.x)
|
||||
while status is GDScriptFunctionState:
|
||||
status = yield(status, "completed")
|
||||
else:
|
||||
preview_index = -1
|
||||
preview.visible = false
|
||||
remove_child(preview)
|
||||
rect_size = Vector2(0, 0)
|
||||
processing_button = false
|
||||
update()
|
||||
|
||||
func update_preview(size : int = 0) -> void:
|
||||
if preview_index == -1:
|
||||
|
Loading…
Reference in New Issue
Block a user