mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 12:33:14 +00:00
Use a ValueSlider in the window opacity dialog
More ValueSlider replacements coming next.
This commit is contained in:
parent
4c85f5b0ff
commit
8abbe0a1cb
4 changed files with 18 additions and 41 deletions
|
@ -1,7 +1,6 @@
|
|||
extends AcceptDialog
|
||||
|
||||
onready var hslider: HSlider = $VBoxContainer/HBoxContainer/HSlider
|
||||
onready var spinbox: SpinBox = $VBoxContainer/HBoxContainer/SpinBox
|
||||
onready var slider: ValueSlider = $VBoxContainer/ValueSlider
|
||||
onready var fullscreen_warning: Label = $VBoxContainer/FullscreenWarning
|
||||
onready var main_canvas = Global.control.find_node("Main Canvas")
|
||||
|
||||
|
@ -13,34 +12,28 @@ func _ready() -> void:
|
|||
|
||||
func _on_WindowOpacityDialog_about_to_show() -> void:
|
||||
OS.window_per_pixel_transparency_enabled = true
|
||||
hslider.editable = !OS.window_fullscreen
|
||||
spinbox.editable = hslider.editable
|
||||
fullscreen_warning.visible = !spinbox.editable
|
||||
slider.editable = !OS.window_fullscreen
|
||||
fullscreen_warning.visible = !slider.editable
|
||||
|
||||
|
||||
func _recalculate_opacity():
|
||||
set_window_opacity(hslider.value)
|
||||
|
||||
|
||||
func _on_value_changed(value: float) -> void:
|
||||
set_window_opacity(value)
|
||||
func _recalculate_opacity() -> void:
|
||||
set_window_opacity(slider.value)
|
||||
|
||||
|
||||
func set_window_opacity(value: float) -> void:
|
||||
if OS.window_fullscreen:
|
||||
value = 100.0
|
||||
hslider.value = value
|
||||
spinbox.value = value
|
||||
slider.value = value
|
||||
|
||||
value = value / 100.0
|
||||
for container in Global.control.ui._panel_container.get_children():
|
||||
if container.get_class() == "TabContainer":
|
||||
if container is TabContainer:
|
||||
var point = container.get_rect().position + (container.get_rect().size / 2.0)
|
||||
if main_canvas.get_rect().has_point(point):
|
||||
container.self_modulate.a = value
|
||||
else:
|
||||
container.self_modulate.a = 1.0
|
||||
Global.transparent_checker.transparency(value)
|
||||
Global.transparent_checker.update_transparency(value)
|
||||
|
||||
|
||||
func _on_WindowOpacityDialog_popup_hide() -> void:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Dialogs/WindowOpacityDialog.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/UI/Nodes/ValueSlider.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="WindowOpacityDialog" type="AcceptDialog"]
|
||||
margin_right = 204.0
|
||||
|
@ -21,24 +22,9 @@ margin_top = 8.0
|
|||
margin_right = -8.0
|
||||
margin_bottom = -36.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
[node name="ValueSlider" parent="VBoxContainer" instance=ExtResource( 2 )]
|
||||
margin_right = 327.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="HSlider" type="HSlider" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_top = 4.0
|
||||
margin_right = 249.0
|
||||
margin_bottom = 20.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
value = 100.0
|
||||
|
||||
[node name="SpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
|
||||
margin_left = 253.0
|
||||
margin_right = 327.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
value = 100.0
|
||||
|
||||
[node name="FullscreenWarning" type="Label" parent="VBoxContainer"]
|
||||
|
@ -50,5 +36,4 @@ text = "Window opacity does not work on fullscreen mode."
|
|||
|
||||
[connection signal="about_to_show" from="." to="." method="_on_WindowOpacityDialog_about_to_show"]
|
||||
[connection signal="popup_hide" from="." to="." method="_on_WindowOpacityDialog_popup_hide"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/HSlider" to="." method="_on_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpinBox" to="." method="_on_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/ValueSlider" to="." method="set_window_opacity"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Made by MrTriPie
|
||||
# Initial version made by MrTriPie, has been modified
|
||||
tool
|
||||
class_name ValueSlider
|
||||
extends TextureProgress
|
||||
|
|
|
@ -32,15 +32,14 @@ func fit_rect(rect: Rect2) -> void:
|
|||
rect_size = rect.size
|
||||
|
||||
|
||||
func transparency(value: float) -> void:
|
||||
# first make viewport transparent then background and then viewport
|
||||
func update_transparency(value: float) -> void:
|
||||
# Change the transparency status of the parent viewport and the root viewport
|
||||
if value == 1.0:
|
||||
get_parent().transparent_bg = false
|
||||
get_tree().get_root().set_transparent_background(false)
|
||||
get_tree().get_root().transparent_bg = false
|
||||
else:
|
||||
get_parent().transparent_bg = true
|
||||
get_tree().get_root().set_transparent_background(true)
|
||||
get_tree().get_root().transparent_bg = true
|
||||
|
||||
# this controls opacity 0 for transparent, 1 or a greater value than 1 is opaque
|
||||
# i have set a minimum amount for the fade (We would'nt want the canvas to dissapear now would we?)
|
||||
# Set a minimum amount for the fade so the canvas won't disappear
|
||||
material.set("shader_param/alpha", clamp(value, 0.1, 1))
|
||||
|
|
Loading…
Add table
Reference in a new issue