mirror of
https://github.com/Relintai/gdfxr.git
synced 2024-11-18 09:07:23 +01:00
Slider improvements
- Sliders now display current value when hovered. - While dragging sliders, hold CTRL to snap the value to 0.01 increments.
This commit is contained in:
parent
3afc110a58
commit
2a73615082
@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Display current Slider value when hovered.
|
||||
- Hold Ctrl to snap Slider value to 0.01 increments.
|
||||
|
||||
## [1.1.1] - 2022-07-30
|
||||
### Fixed
|
||||
|
@ -8,6 +8,21 @@ export var label: String setget set_label
|
||||
export var parameter: String
|
||||
export var bipolar := false setget set_bipolar
|
||||
|
||||
var is_dragging_slider := false
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
match what:
|
||||
NOTIFICATION_ENTER_TREE, NOTIFICATION_THEME_CHANGED:
|
||||
var display: Label = $HSlider/Anchor/ValueDisplay
|
||||
var bg := StyleBoxFlat.new()
|
||||
bg.bg_color = get_color("dark_color_3", "Editor")
|
||||
bg.content_margin_bottom = 2
|
||||
bg.content_margin_top = 2
|
||||
bg.content_margin_left = 4
|
||||
bg.content_margin_right = 4
|
||||
display.add_stylebox_override("normal", bg)
|
||||
|
||||
|
||||
func set_label(v: String) -> void:
|
||||
label = v
|
||||
@ -34,9 +49,45 @@ func set_resetable(v: bool) -> void:
|
||||
$Reset.disabled = not v
|
||||
|
||||
|
||||
func _update_slider_step():
|
||||
$HSlider.step = 0.01 if is_dragging_slider and Input.is_key_pressed(KEY_CONTROL) else 0
|
||||
|
||||
|
||||
func _update_value_display():
|
||||
var anchor: Control = $HSlider/Anchor
|
||||
var display: Label = $HSlider/Anchor/ValueDisplay
|
||||
var slider: Slider = $HSlider
|
||||
var grabber_size := slider.get_icon("Grabber").get_size()
|
||||
|
||||
display.text = str(slider.value)
|
||||
anchor.rect_position.x = slider.ratio * (slider.rect_size.x - grabber_size.x) + grabber_size.x * 0.5
|
||||
|
||||
|
||||
func _on_HSlider_value_changed(value: float):
|
||||
_update_value_display()
|
||||
emit_signal("param_changed", parameter, value)
|
||||
|
||||
|
||||
func _on_HSlider_mouse_entered():
|
||||
$HSlider/Anchor.show()
|
||||
_update_value_display()
|
||||
|
||||
|
||||
func _on_HSlider_mouse_exited():
|
||||
$HSlider/Anchor.hide()
|
||||
|
||||
|
||||
func _on_HSlider_gui_input(event: InputEvent):
|
||||
var mb := event as InputEventMouseButton
|
||||
if mb and mb.button_index == BUTTON_LEFT:
|
||||
is_dragging_slider = mb.pressed
|
||||
_update_slider_step()
|
||||
|
||||
var ek := event as InputEventKey
|
||||
if ek and is_dragging_slider and ek.scancode == KEY_CONTROL:
|
||||
_update_slider_step()
|
||||
|
||||
|
||||
func _on_Reset_pressed():
|
||||
emit_signal("param_reset", parameter)
|
||||
|
||||
|
@ -1,8 +1,15 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/gdfxr/editor/ParamSlider.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/gdfxr/editor/EditorIconButton.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
content_margin_left = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="ParamSlider" type="HBoxContainer"]
|
||||
margin_right = 253.0
|
||||
margin_bottom = 40.0
|
||||
@ -23,10 +30,22 @@ margin_top = 12.0
|
||||
margin_right = 237.0
|
||||
margin_bottom = 28.0
|
||||
rect_min_size = Vector2( 90, 0 )
|
||||
hint_tooltip = "Hold Ctrl to snap to 0.01 increments."
|
||||
size_flags_vertical = 4
|
||||
max_value = 1.0
|
||||
step = 0.0
|
||||
|
||||
[node name="Anchor" type="Control" parent="HSlider"]
|
||||
visible = false
|
||||
|
||||
[node name="ValueDisplay" type="Label" parent="HSlider/Anchor"]
|
||||
margin_bottom = -2.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
custom_styles/normal = SubResource( 1 )
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Reset" type="ToolButton" parent="."]
|
||||
margin_left = 241.0
|
||||
margin_top = 9.0
|
||||
@ -36,5 +55,8 @@ size_flags_vertical = 4
|
||||
script = ExtResource( 2 )
|
||||
icon_name = "ReloadSmall"
|
||||
|
||||
[connection signal="gui_input" from="HSlider" to="." method="_on_HSlider_gui_input"]
|
||||
[connection signal="mouse_entered" from="HSlider" to="." method="_on_HSlider_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="HSlider" to="." method="_on_HSlider_mouse_exited"]
|
||||
[connection signal="value_changed" from="HSlider" to="." method="_on_HSlider_value_changed"]
|
||||
[connection signal="pressed" from="Reset" to="." method="_on_Reset_pressed"]
|
||||
|
@ -48,6 +48,9 @@ func _translate_node(node: Node):
|
||||
|
||||
if node is Label:
|
||||
node.text = tr(node.text)
|
||||
|
||||
if node is Slider:
|
||||
node.hint_tooltip = tr(node.hint_tooltip)
|
||||
|
||||
for child in node.get_children():
|
||||
_translate_node(child)
|
||||
|
@ -8,14 +8,14 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gdfxr 1.0\n"
|
||||
"Report-Msgid-Bugs-To: timothyqiu32@gmail.com\n"
|
||||
"POT-Creation-Date: 2022-03-10 17:02+0800\n"
|
||||
"POT-Creation-Date: 2022-09-20 14:01+0800\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.9.1\n"
|
||||
"Generated-By: Babel 2.10.3\n"
|
||||
|
||||
#: addons/gdfxr/editor/Editor.gd
|
||||
msgid "Save As..."
|
||||
@ -68,7 +68,7 @@ msgid ""
|
||||
"Open '%s' anyway?"
|
||||
msgstr ""
|
||||
|
||||
#: addons/gdfxr/editor/Editor.gd addons/gdfxr/editor/Editor.gd
|
||||
#: addons/gdfxr/editor/Editor.gd
|
||||
msgid "SFXR Editor"
|
||||
msgstr ""
|
||||
|
||||
@ -129,7 +129,7 @@ msgstr ""
|
||||
msgid "Play"
|
||||
msgstr ""
|
||||
|
||||
#: addons/gdfxr/editor/Editor.tscn addons/gdfxr/editor/Editor.tscn
|
||||
#: addons/gdfxr/editor/Editor.tscn
|
||||
msgid "Restore"
|
||||
msgstr ""
|
||||
|
||||
@ -245,3 +245,7 @@ msgstr ""
|
||||
msgid "Waveform"
|
||||
msgstr ""
|
||||
|
||||
#: addons/gdfxr/editor/ParamSlider.tscn
|
||||
msgid "Hold Ctrl to snap to 0.01 increments."
|
||||
msgstr ""
|
||||
|
||||
|
@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gdfxr 1.0\n"
|
||||
"Report-Msgid-Bugs-To: timothyqiu32@gmail.com\n"
|
||||
"POT-Creation-Date: 2022-03-10 17:02+0800\n"
|
||||
"PO-Revision-Date: 2022-03-10 17:02+0800\n"
|
||||
"POT-Creation-Date: 2022-09-20 14:01+0800\n"
|
||||
"PO-Revision-Date: 2022-09-20 14:01+0800\n"
|
||||
"Last-Translator: Haoyu Qiu <timothyqiu32@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: zh_CN\n"
|
||||
@ -17,7 +17,7 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"Generated-By: Babel 2.9.1\n"
|
||||
"X-Generator: Poedit 3.0.1\n"
|
||||
"X-Generator: Poedit 3.1\n"
|
||||
|
||||
#: addons/gdfxr/editor/Editor.gd
|
||||
msgid "Save As..."
|
||||
@ -252,3 +252,7 @@ msgstr "高通变频"
|
||||
#: addons/gdfxr/editor/ParamOption.tscn
|
||||
msgid "Waveform"
|
||||
msgstr "波形"
|
||||
|
||||
#: addons/gdfxr/editor/ParamSlider.tscn
|
||||
msgid "Hold Ctrl to snap to 0.01 increments."
|
||||
msgstr "按住 Ctrl 吸附到 0.01 增量。"
|
||||
|
@ -3,5 +3,5 @@
|
||||
name="gdfxr"
|
||||
description="A Godot plugin that ports sfxr, the popular program of choice to make retro sound effects for games."
|
||||
author="Haoyu Qiu"
|
||||
version="1.1.1"
|
||||
version="1.2"
|
||||
script="plugin.gd"
|
||||
|
Loading…
Reference in New Issue
Block a user