mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Add a custom ValueSlider node made by @mrtripie
And bump version to v0.11-dev
This commit is contained in:
parent
af2b1feb1f
commit
8148d03c1f
BIN
assets/graphics/misc/value_slider.png
Normal file
BIN
assets/graphics/misc/value_slider.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 B |
35
assets/graphics/misc/value_slider.png.import
Normal file
35
assets/graphics/misc/value_slider.png.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/value_slider.png-1923f0534fe53aef508cb99231851c39.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/misc/value_slider.png"
|
||||
dest_files=[ "res://.import/value_slider.png-1923f0534fe53aef508cb99231851c39.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -1380,14 +1380,14 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.4, 0.4225, 0.4825, 1 )
|
||||
bg_color = Color( 0.4, 0.423529, 0.482353, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=162]
|
||||
content_margin_left = 2.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.1, 0.115, 0.155, 1 )
|
||||
bg_color = Color( 0.101961, 0.113725, 0.156863, 1 )
|
||||
|
||||
[sub_resource type="Image" id=218]
|
||||
data = {
|
||||
|
@ -1781,6 +1781,8 @@ VSlider/styles/slider = SubResource( 162 )
|
|||
VSplitContainer/constants/separation = 8
|
||||
VSplitContainer/icons/grabber = SubResource( 164 )
|
||||
VSplitContainer/styles/bg = SubResource( 167 )
|
||||
ValueSlider/colors/progress_color = Color( 0.4, 0.423529, 0.482353, 1 )
|
||||
ValueSlider/colors/under_color = Color( 0.101961, 0.113725, 0.156863, 1 )
|
||||
WindowDialog/colors/title_color = Color( 0.8, 0.8075, 0.8275, 1 )
|
||||
WindowDialog/constants/close_h_ofs = 22
|
||||
WindowDialog/constants/close_v_ofs = 20
|
||||
|
|
|
@ -1405,14 +1405,14 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.711914, 0.579886, 0.42548, 1 )
|
||||
bg_color = Color( 0.713726, 0.580392, 0.423529, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=165]
|
||||
content_margin_left = 2.0
|
||||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.474609, 0.386591, 0.283653, 1 )
|
||||
bg_color = Color( 0.47451, 0.388235, 0.282353, 1 )
|
||||
|
||||
[sub_resource type="Image" id=221]
|
||||
data = {
|
||||
|
@ -1874,6 +1874,8 @@ VSplitContainer/constants/autohide = 1
|
|||
VSplitContainer/constants/separation = 8
|
||||
VSplitContainer/icons/grabber = SubResource( 167 )
|
||||
VSplitContainer/styles/bg = SubResource( 170 )
|
||||
ValueSlider/colors/progress_color = Color( 0.713726, 0.580392, 0.423529, 1 )
|
||||
ValueSlider/colors/under_color = Color( 0.47451, 0.388235, 0.282353, 1 )
|
||||
WindowDialog/colors/title_color = Color( 0.237305, 0.193295, 0.141827, 1 )
|
||||
WindowDialog/constants/close_h_ofs = 22
|
||||
WindowDialog/constants/close_v_ofs = 20
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Theme" load_steps=179 format=2]
|
||||
[gd_resource type="Theme" load_steps=178 format=2]
|
||||
|
||||
[ext_resource path="res://assets/fonts/Roboto-Regular.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://assets/fonts/Roboto-Big.tres" type="DynamicFont" id=2]
|
||||
|
@ -750,21 +750,21 @@ content_margin_left = 0.0
|
|||
content_margin_right = 0.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color( 0.334961, 0.334961, 0.334961, 1 )
|
||||
bg_color = Color( 0.333333, 0.333333, 0.333333, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=87]
|
||||
content_margin_left = 0.0
|
||||
content_margin_right = 0.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color( 0.334961, 0.334961, 0.334961, 1 )
|
||||
bg_color = Color( 0.333333, 0.333333, 0.333333, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=88]
|
||||
content_margin_left = 0.0
|
||||
content_margin_right = 0.0
|
||||
content_margin_top = 2.0
|
||||
content_margin_bottom = 2.0
|
||||
bg_color = Color( 0.0679686, 0.0679686, 0.0679686, 1 )
|
||||
bg_color = Color( 0.0666667, 0.0666667, 0.0666667, 1 )
|
||||
|
||||
[sub_resource type="Image" id=205]
|
||||
data = {
|
||||
|
@ -1031,21 +1031,6 @@ margin_right = 6.0
|
|||
margin_top = 6.0
|
||||
margin_bottom = 6.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=122]
|
||||
content_margin_left = 8.0
|
||||
content_margin_right = 8.0
|
||||
content_margin_top = 8.0
|
||||
content_margin_bottom = 8.0
|
||||
bg_color = Color( 0.0792967, 0.0792967, 0.0792967, 1 )
|
||||
border_width_left = 1
|
||||
border_width_top = 24
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
border_color = Color( 0.0792967, 0.0792967, 0.0792967, 1 )
|
||||
expand_margin_top = 24.0
|
||||
shadow_color = Color( 0, 0, 0, 0.3 )
|
||||
shadow_size = 4
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=123]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
|
@ -1761,7 +1746,6 @@ PopupPanel/styles/panel = SubResource( 105 )
|
|||
ProgressBar/colors/font_color = Color( 0.77832, 0.77832, 0.77832, 1 )
|
||||
ProgressBar/styles/bg = SubResource( 118 )
|
||||
ProgressBar/styles/fg = SubResource( 121 )
|
||||
ProjectSettingsEditor/styles/panel = SubResource( 122 )
|
||||
RichTextLabel/colors/default_color = Color( 0.77832, 0.77832, 0.77832, 1 )
|
||||
RichTextLabel/colors/font_color_shadow = Color( 0, 0, 0, 0 )
|
||||
RichTextLabel/constants/shadow_as_outline = 0
|
||||
|
@ -1926,6 +1910,8 @@ VSplitContainer/constants/autohide = 1
|
|||
VSplitContainer/constants/separation = 8
|
||||
VSplitContainer/icons/grabber = SubResource( 172 )
|
||||
VSplitContainer/styles/bg = SubResource( 175 )
|
||||
ValueSlider/colors/progress_color = Color( 0.333333, 0.333333, 0.333333, 1 )
|
||||
ValueSlider/colors/under_color = Color( 0.0666667, 0.0666667, 0.0666667, 1 )
|
||||
WindowDialog/colors/title_color = Color( 0.77832, 0.77832, 0.77832, 1 )
|
||||
WindowDialog/constants/close_h_ofs = 22
|
||||
WindowDialog/constants/close_v_ofs = 20
|
||||
|
|
|
@ -1437,7 +1437,7 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.544118, 0.544118, 0.544118, 1 )
|
||||
bg_color = Color( 0.545098, 0.545098, 0.545098, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=168]
|
||||
content_margin_left = 2.0
|
||||
|
@ -1918,6 +1918,8 @@ VSplitContainer/constants/autohide = 1
|
|||
VSplitContainer/constants/separation = 8
|
||||
VSplitContainer/icons/grabber = SubResource( 171 )
|
||||
VSplitContainer/styles/bg = SubResource( 174 )
|
||||
ValueSlider/colors/progress_color = Color( 0.545098, 0.545098, 0.545098, 1 )
|
||||
ValueSlider/colors/under_color = Color( 0.235294, 0.235294, 0.235294, 1 )
|
||||
WindowDialog/colors/title_color = Color( 0.848039, 0.848039, 0.848039, 1 )
|
||||
WindowDialog/constants/close_h_ofs = 22
|
||||
WindowDialog/constants/close_v_ofs = 20
|
||||
|
|
|
@ -1437,7 +1437,7 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.75, 0.75, 0.75, 1 )
|
||||
bg_color = Color( 0.74902, 0.74902, 0.74902, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=168]
|
||||
content_margin_left = 2.0
|
||||
|
@ -1451,7 +1451,7 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.84, 0.84, 0.84, 1 )
|
||||
bg_color = Color( 0.839216, 0.839216, 0.839216, 1 )
|
||||
|
||||
[sub_resource type="Image" id=225]
|
||||
data = {
|
||||
|
@ -1921,6 +1921,8 @@ VSplitContainer/constants/autohide = 1
|
|||
VSplitContainer/constants/separation = 8
|
||||
VSplitContainer/icons/grabber = SubResource( 171 )
|
||||
VSplitContainer/styles/bg = SubResource( 174 )
|
||||
ValueSlider/colors/progress_color = Color( 0.74902, 0.74902, 0.74902, 1 )
|
||||
ValueSlider/colors/under_color = Color( 0.839216, 0.839216, 0.839216, 1 )
|
||||
WindowDialog/colors/title_color = Color( 0.25, 0.25, 0.25, 1 )
|
||||
WindowDialog/constants/close_h_ofs = 22
|
||||
WindowDialog/constants/close_v_ofs = 20
|
||||
|
|
|
@ -1390,7 +1390,7 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.397059, 0.341176, 0.461765, 1 )
|
||||
bg_color = Color( 0.396078, 0.341176, 0.462745, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=163]
|
||||
content_margin_left = 2.0
|
||||
|
@ -1404,7 +1404,7 @@ content_margin_left = 2.0
|
|||
content_margin_right = 2.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color( 0.0980392, 0.0607843, 0.141176, 1 )
|
||||
bg_color = Color( 0.0980392, 0.0588235, 0.141176, 1 )
|
||||
|
||||
[sub_resource type="Image" id=220]
|
||||
data = {
|
||||
|
@ -1785,6 +1785,8 @@ VSlider/styles/slider = SubResource( 164 )
|
|||
VSplitContainer/constants/separation = 8
|
||||
VSplitContainer/icons/grabber = SubResource( 166 )
|
||||
VSplitContainer/styles/bg = SubResource( 169 )
|
||||
ValueSlider/colors/progress_color = Color( 0.396078, 0.341176, 0.462745, 1 )
|
||||
ValueSlider/colors/under_color = Color( 0.0980392, 0.0588235, 0.141176, 1 )
|
||||
WindowDialog/colors/title_color = Color( 0.79902, 0.780392, 0.820588, 1 )
|
||||
WindowDialog/constants/close_h_ofs = 22
|
||||
WindowDialog/constants/close_v_ofs = 20
|
||||
|
|
|
@ -153,6 +153,11 @@ _global_script_classes=[ {
|
|||
"class": "Tiles",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/Classes/Tiles.gd"
|
||||
}, {
|
||||
"base": "TextureProgress",
|
||||
"class": "ValueSlider",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/UI/Nodes/ValueSlider.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"AnimationTag": "",
|
||||
|
@ -183,7 +188,8 @@ _global_script_class_icons={
|
|||
"ShaderImageEffect": "",
|
||||
"ShortcutProfile": "",
|
||||
"SymmetryGuide": "",
|
||||
"Tiles": ""
|
||||
"Tiles": "",
|
||||
"ValueSlider": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
@ -199,7 +205,7 @@ config/icon="res://assets/graphics/icons/icon.png"
|
|||
config/macos_native_icon="res://assets/graphics/icons/icon.icns"
|
||||
config/windows_native_icon="res://assets/graphics/icons/icon.ico"
|
||||
config/custom_user_dir_name.X11="pixelorama"
|
||||
config/Version="v0.10.3-stable"
|
||||
config/Version="v0.11-dev"
|
||||
config/ExtensionsAPI_Version=2
|
||||
|
||||
[audio]
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
extends Node
|
||||
|
||||
signal theme_changed
|
||||
|
||||
var theme_index := 0
|
||||
var theme_button_group := ButtonGroup.new()
|
||||
|
||||
|
@ -98,6 +100,7 @@ func change_theme(id: int) -> void:
|
|||
|
||||
# Sets disabled theme color on palette swatches
|
||||
Global.palette_panel.reset_empty_palette_swatches_color()
|
||||
emit_signal("theme_changed")
|
||||
|
||||
|
||||
func change_clear_color() -> void:
|
||||
|
|
135
src/UI/Nodes/ValueSlider.gd
Normal file
135
src/UI/Nodes/ValueSlider.gd
Normal file
|
@ -0,0 +1,135 @@
|
|||
# Made by MrTriPie
|
||||
class_name ValueSlider
|
||||
extends TextureProgress
|
||||
|
||||
enum { NORMAL, HELD, SLIDING, TYPING }
|
||||
|
||||
export var prefix: String
|
||||
export var suffix: String
|
||||
# Size of additional snapping (applied in addition to Range's step).
|
||||
# This should always be larger than step.
|
||||
export var snap_step := 1.0
|
||||
# If snap_by_default is true, snapping is enabled when Control is NOT held (used for sliding in
|
||||
# larger steps by default, and smaller steps when holding Control).
|
||||
# If false, snapping is enabled when Control IS held (used for sliding in smaller steps by
|
||||
# default, and larger steps when holding Control).
|
||||
export var snap_by_default := false
|
||||
# If show_progress is true it will show the colored progress bar, good for values with a specific
|
||||
# range. False will hide it, which is good for values that can be any number.
|
||||
export var show_progress := true
|
||||
|
||||
var state := NORMAL
|
||||
onready var line_edit: LineEdit = $LineEdit
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
reset_display()
|
||||
yield(get_tree(), "idle_frame")
|
||||
Global.preferences_dialog.themes.connect("theme_changed", self, "reset_display")
|
||||
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if state == NORMAL:
|
||||
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and event.pressed:
|
||||
state = HELD
|
||||
set_meta("mouse_start_position", get_local_mouse_position())
|
||||
elif state == HELD:
|
||||
if (
|
||||
event is InputEventMouseButton
|
||||
and event.button_index == BUTTON_LEFT
|
||||
and not event.pressed
|
||||
):
|
||||
state = TYPING
|
||||
line_edit.text = str(value)
|
||||
line_edit.editable = true
|
||||
line_edit.grab_focus()
|
||||
line_edit.selecting_enabled = true
|
||||
line_edit.select_all()
|
||||
line_edit.caret_position = line_edit.text.length()
|
||||
tint_progress = Color.transparent
|
||||
elif event is InputEventMouseMotion:
|
||||
if get_meta("mouse_start_position").distance_to(get_local_mouse_position()) > 2:
|
||||
state = SLIDING
|
||||
set_meta("shift_pressed", event.shift)
|
||||
set_meta("start_ratio", ratio)
|
||||
set_meta("start_value", value)
|
||||
elif state == SLIDING:
|
||||
if (
|
||||
event is InputEventMouseButton
|
||||
and event.button_index == BUTTON_LEFT
|
||||
and not event.pressed
|
||||
):
|
||||
state = NORMAL
|
||||
remove_meta("mouse_start_position")
|
||||
remove_meta("start_ratio")
|
||||
remove_meta("start_value")
|
||||
remove_meta("shift_pressed")
|
||||
if event is InputEventMouseMotion:
|
||||
# When pressing/releasing Shift, reset starting values to prevent slider jumping around
|
||||
if get_meta("shift_pressed") != event.shift:
|
||||
set_meta("mouse_start_position", get_local_mouse_position())
|
||||
set_meta("start_ratio", ratio)
|
||||
set_meta("start_value", value)
|
||||
set_meta("shift_pressed", event.shift)
|
||||
var x_delta: float = get_local_mouse_position().x - get_meta("mouse_start_position").x
|
||||
# Slow down to allow for more precision
|
||||
if event.shift:
|
||||
x_delta *= 0.1
|
||||
if show_progress:
|
||||
ratio = get_meta("start_ratio") + x_delta / rect_size.x
|
||||
else:
|
||||
value = get_meta("start_value") + x_delta * step
|
||||
# Snap when snap_by_default is true, do the opposite when Control is pressed
|
||||
if snap_by_default:
|
||||
if not event.control:
|
||||
value = round(value / snap_step) * snap_step
|
||||
else:
|
||||
if event.control:
|
||||
value = round(value / snap_step) * snap_step
|
||||
|
||||
|
||||
func _on_LineEdit_gui_input(event: InputEvent) -> void:
|
||||
if state == TYPING:
|
||||
if event is InputEventKey and event.scancode == KEY_ESCAPE:
|
||||
_confirm_text(false) # Cancel
|
||||
line_edit.release_focus()
|
||||
|
||||
|
||||
func _on_value_changed(_value: float) -> void:
|
||||
reset_display()
|
||||
|
||||
|
||||
func _on_LineEdit_text_entered(_new_text) -> void:
|
||||
# When pressing enter, release focus, which will call _confirm_text on focus_exited signal
|
||||
line_edit.release_focus()
|
||||
|
||||
|
||||
# Called on LineEdit's focus_exited signal
|
||||
# If confirm is false it will cancel setting value
|
||||
func _confirm_text(confirm := true) -> void:
|
||||
if state != TYPING:
|
||||
return
|
||||
state = NORMAL
|
||||
if confirm:
|
||||
var expression := Expression.new()
|
||||
var error := expression.parse(line_edit.text, [])
|
||||
if error != OK:
|
||||
reset_display()
|
||||
return
|
||||
var result = expression.execute([], null, true)
|
||||
if expression.has_execute_failed() or not (result is int or result is float):
|
||||
reset_display()
|
||||
return
|
||||
value = result
|
||||
reset_display()
|
||||
|
||||
|
||||
func reset_display() -> void:
|
||||
line_edit.selecting_enabled = false # Remove the selection
|
||||
line_edit.editable = false
|
||||
tint_under = get_color("under_color", "ValueSlider")
|
||||
if show_progress:
|
||||
tint_progress = get_color("progress_color", "ValueSlider")
|
||||
else:
|
||||
tint_progress = Color.transparent
|
||||
line_edit.text = str(prefix, " ", value, " ", suffix).strip_edges()
|
37
src/UI/Nodes/ValueSlider.tscn
Normal file
37
src/UI/Nodes/ValueSlider.tscn
Normal file
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Nodes/ValueSlider.gd" type="Script" id=1]
|
||||
[ext_resource path="res://assets/graphics/misc/value_slider.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id=1]
|
||||
|
||||
[node name="ValueSlider" type="TextureProgress"]
|
||||
margin_right = 6.0
|
||||
margin_bottom = 6.0
|
||||
rect_min_size = Vector2( 32, 32 )
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_type_variation = "ValueSlider"
|
||||
texture_under = ExtResource( 2 )
|
||||
texture_progress = ExtResource( 2 )
|
||||
nine_patch_stretch = true
|
||||
stretch_margin_left = 3
|
||||
stretch_margin_top = 3
|
||||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
custom_styles/read_only = SubResource( 1 )
|
||||
custom_styles/normal = SubResource( 1 )
|
||||
align = 1
|
||||
editable = false
|
||||
|
||||
[connection signal="value_changed" from="." to="." method="_on_value_changed"]
|
||||
[connection signal="focus_exited" from="LineEdit" to="." method="_confirm_text"]
|
||||
[connection signal="gui_input" from="LineEdit" to="." method="_on_LineEdit_gui_input"]
|
||||
[connection signal="text_entered" from="LineEdit" to="." method="_on_LineEdit_text_entered"]
|
Loading…
Reference in a new issue