mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Filtered unwanted mouse events in float editor and updated shader parameter editor
This commit is contained in:
parent
1c4e904a22
commit
e7a70af690
@ -7,6 +7,7 @@ export var min_value : float = 0.0 setget set_min_value
|
||||
export var max_value : float = 1.0 setget set_max_value
|
||||
export var step : float = 0.0 setget set_step
|
||||
|
||||
var sliding : bool = false
|
||||
var start_position : float
|
||||
var start_value : float
|
||||
|
||||
@ -45,9 +46,12 @@ func _on_LineEdit_gui_input(event : InputEvent) -> void:
|
||||
if event.is_pressed():
|
||||
start_position = event.position.x
|
||||
start_value = value
|
||||
elif event is InputEventMouseMotion and event.button_mask == BUTTON_MASK_LEFT:
|
||||
sliding = true
|
||||
else:
|
||||
sliding = false
|
||||
elif sliding and event is InputEventMouseMotion and event.button_mask == BUTTON_MASK_LEFT:
|
||||
var delta : float = event.position.x-start_position
|
||||
var v : float = clamp(start_value+sign(delta)*pow(abs(delta)*0.005, 2)*abs(max_value - min_value), min_value, max_value)
|
||||
var v : float = start_value+sign(delta)*pow(abs(delta)*0.005, 2)*abs(max_value - min_value)
|
||||
if step != 0:
|
||||
v = min_value+floor((v - min_value)/step)*step
|
||||
set_value(v)
|
||||
|
@ -9,18 +9,27 @@ func get_model_data() -> Dictionary:
|
||||
default = $Default.value,
|
||||
}
|
||||
|
||||
if $SpinBox.pressed:
|
||||
data.widget = "spinbox"
|
||||
|
||||
return data
|
||||
|
||||
func set_model_data(data) -> void:
|
||||
if data.has("min"):
|
||||
$Min.value = data.min
|
||||
$Default.min_value = data.min
|
||||
if data.has("max"):
|
||||
$Max.value = data.max
|
||||
$Default.max_value = data.max
|
||||
if data.has("step"):
|
||||
$Step.value = data.step
|
||||
$Default.step = data.step
|
||||
if data.has("default"):
|
||||
$Default.value = data.default
|
||||
$SpinBox.pressed = ( data.has("widget") && data.widget == "spinbox" )
|
||||
|
||||
|
||||
func _on_Min_value_changed(v : float) -> void:
|
||||
$Default.min_value = v
|
||||
|
||||
func _on_Max_value_changed(v : float) -> void:
|
||||
$Default.max_value = v
|
||||
|
||||
func _on_Step_value_changed(v : float) -> void:
|
||||
$Default.step = v
|
||||
|
@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/material_maker/widgets/node_editor/parameter_float.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/material_maker/widgets/float_edit.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="float" type="HBoxContainer"]
|
||||
margin_right = 547.0
|
||||
@ -13,67 +14,73 @@ margin_right = 28.0
|
||||
margin_bottom = 19.0
|
||||
text = "Min:"
|
||||
|
||||
[node name="Min" type="SpinBox" parent="."]
|
||||
[node name="Min" parent="." instance=ExtResource( 2 )]
|
||||
anchor_left = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 32.0
|
||||
margin_right = 106.0
|
||||
margin_right = 90.0
|
||||
margin_bottom = 24.0
|
||||
text = "0"
|
||||
value = 0.0
|
||||
min_value = -65536.0
|
||||
max_value = 65536.0
|
||||
step = 0.005
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
|
||||
[node name="LabelMax" type="Label" parent="."]
|
||||
margin_left = 110.0
|
||||
margin_left = 94.0
|
||||
margin_top = 5.0
|
||||
margin_right = 140.0
|
||||
margin_right = 124.0
|
||||
margin_bottom = 19.0
|
||||
text = "Max:"
|
||||
|
||||
[node name="Max" type="SpinBox" parent="."]
|
||||
margin_left = 144.0
|
||||
margin_right = 218.0
|
||||
[node name="Max" parent="." instance=ExtResource( 2 )]
|
||||
anchor_left = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 128.0
|
||||
margin_right = 186.0
|
||||
margin_bottom = 24.0
|
||||
text = "1"
|
||||
value = 1.0
|
||||
min_value = -65536.0
|
||||
max_value = 65536.0
|
||||
step = 0.005
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
|
||||
[node name="LabelStep" type="Label" parent="."]
|
||||
margin_left = 222.0
|
||||
margin_left = 190.0
|
||||
margin_top = 5.0
|
||||
margin_right = 254.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 19.0
|
||||
text = "Step:"
|
||||
|
||||
[node name="Step" type="SpinBox" parent="."]
|
||||
margin_left = 258.0
|
||||
margin_right = 332.0
|
||||
[node name="Step" parent="." instance=ExtResource( 2 )]
|
||||
anchor_left = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 226.0
|
||||
margin_right = 284.0
|
||||
margin_bottom = 24.0
|
||||
text = "0.1"
|
||||
value = 0.1
|
||||
max_value = 10.0
|
||||
step = 0.005
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
|
||||
[node name="LabelDefault" type="Label" parent="."]
|
||||
margin_left = 336.0
|
||||
margin_left = 288.0
|
||||
margin_top = 5.0
|
||||
margin_right = 386.0
|
||||
margin_right = 338.0
|
||||
margin_bottom = 19.0
|
||||
text = "Default:"
|
||||
|
||||
[node name="Default" type="SpinBox" parent="."]
|
||||
margin_left = 390.0
|
||||
margin_right = 464.0
|
||||
[node name="Default" parent="." instance=ExtResource( 2 )]
|
||||
anchor_left = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 342.0
|
||||
margin_right = 400.0
|
||||
margin_bottom = 24.0
|
||||
min_value = -65536.0
|
||||
max_value = 65536.0
|
||||
step = 0.0
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
|
||||
[node name="SpinBox" type="CheckBox" parent="."]
|
||||
margin_left = 468.0
|
||||
margin_right = 547.0
|
||||
margin_bottom = 24.0
|
||||
text = "SpinBox"
|
||||
step = 0.1
|
||||
[connection signal="value_changed" from="Min" to="." method="_on_Min_value_changed"]
|
||||
[connection signal="value_changed" from="Max" to="." method="_on_Max_value_changed"]
|
||||
[connection signal="value_changed" from="Step" to="." method="_on_Step_value_changed"]
|
||||
|
Loading…
Reference in New Issue
Block a user