Skip to content

Commit

Permalink
Add check button for sec/min
Browse files Browse the repository at this point in the history
  • Loading branch information
Răzvan C. Rădulescu committed May 22, 2021
1 parent b20e8c7 commit 79c75ef
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 44 deletions.
6 changes: 5 additions & 1 deletion project/PexelsQD/Main/SpinBoxTimeInput.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends SpinBox

const PATTERN := "^(\\d{1,3}) s$"
const PATTERN := "^(\\d{1,3})$"

var regex := RegEx.new()
var old_text := ""
Expand All @@ -16,6 +16,10 @@ func _ready() -> void:
old_text = le.text


func _on_CheckBoxTime_toggled(is_button_pressed: bool) -> void:
min_value = 1 if is_button_pressed else 5


func _on_LineEdit_text_changed(new_text: String) -> void:
var old_caret_position := le.caret_position
var regex_match := regex.search(new_text)
Expand Down
11 changes: 7 additions & 4 deletions project/PexelsQD/PexelsQD.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ onready var tb_next: TextureButton = $PanelContainerIntro/CenterContainer/VBoxCo
onready var vbc_main: VBoxContainer = $VBoxContainerMain
onready var le_search: LineEdit = $VBoxContainerMain/HBoxContainerControls/LineEditSearch
onready var sb_time_input: SpinBox = $VBoxContainerMain/HBoxContainerControls/SpinBoxTimeInput
onready var cb_time: CheckButton = $VBoxContainerMain/HBoxContainerControls/CheckButtonTime
onready var tb_back: TextureButton = $VBoxContainerMain/HBoxContainerControls/TextureButtonBack
onready var tb_skip_back: TextureButton = $VBoxContainerMain/HBoxContainerControls/TextureButtonSkipBack
onready var tb_rewind: TextureButton = $VBoxContainerMain/HBoxContainerControls/TextureButtonRewind
Expand Down Expand Up @@ -65,6 +66,7 @@ func _ready() -> void:
tb_back.connect("pressed", tb_play_pause, "set_pressed", [false])
le_search.connect("text_entered", self, "_on_LineEditSearch_text_entered")
le_search.connect("text_validated", self, "_on_LineEditSearch_text_validated")
cb_time.connect("toggled", sb_time_input, "_on_CheckBoxTime_toggled")
tb_skip_back.connect("pressed", self, "_seek", [0, false])
tb_rewind.connect("pressed", self, "_seek", [-Constants.DELTA])
tb_fast_forward.connect("pressed", self, "_seek", [Constants.DELTA])
Expand Down Expand Up @@ -147,13 +149,14 @@ func _search() -> void:
var photo = yield(_session.search(le_search.text), "completed")
match [photo, tb_play_pause.pressed]:
[{"texture": var texture, ..}, true]:
var time: float = sb_time_input.value * (60 if cb_time.pressed else 1)
tween.remove_all()
pc_info.refresh(photo)
tr_image.texture = texture
pb.max_value = sb_time_input.value
tween.interpolate_property(pb, "value", pb.min_value, pb.max_value, sb_time_input.value)
tween.interpolate_property(pb, "modulate", PB_COLORS.begin, PB_COLORS.end, sb_time_input.value - LAST, Tween.TRANS_SINE, Tween.EASE_IN)
tween.interpolate_property(pb, "modulate", PB_COLORS.end, PB_COLORS.last, LAST, Tween.TRANS_LINEAR, Tween.EASE_IN, sb_time_input.value - LAST)
pb.max_value = time
tween.interpolate_property(pb, "value", pb.min_value, pb.max_value, time)
tween.interpolate_property(pb, "modulate", PB_COLORS.begin, PB_COLORS.end, time - LAST, Tween.TRANS_SINE, Tween.EASE_IN)
tween.interpolate_property(pb, "modulate", PB_COLORS.end, PB_COLORS.last, LAST, Tween.TRANS_LINEAR, Tween.EASE_IN, time - LAST)
tween.start()
[{"error": var error}, _]:
_notify(error)
Expand Down
58 changes: 35 additions & 23 deletions project/PexelsQD/PexelsQD.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=64 format=2]
[gd_scene load_steps=68 format=2]

[ext_resource path="res://PexelsQD/Main/SpinBoxTimeInput.gd" type="Script" id=1]
[ext_resource path="res://assets/nord.tres" type="Theme" id=2]
Expand Down Expand Up @@ -42,6 +42,10 @@
[ext_resource path="res://PexelsQD/Main/TextureButtonPlayPause.gd" type="Script" id=40]
[ext_resource path="res://assets/icons/help-circle-hover.svg" type="Texture" id=41]
[ext_resource path="res://assets/icons/help-circle.svg" type="Texture" id=42]
[ext_resource path="res://assets/icons/check-button-time/on.png" type="Texture" id=43]
[ext_resource path="res://assets/icons/check-button-time/off.png" type="Texture" id=44]
[ext_resource path="res://assets/icons/check-button-time/off-disabled.png" type="Texture" id=45]
[ext_resource path="res://assets/icons/check-button-time/on-disabled.png" type="Texture" id=46]

[sub_resource type="InputEventAction" id=1]
action = "ui_left"
Expand Down Expand Up @@ -132,11 +136,11 @@ __meta__ = {

[node name="HBoxContainerControls" type="HBoxContainer" parent="VBoxContainerMain"]
margin_right = 1008.0
margin_bottom = 34.0
margin_bottom = 36.0

[node name="TextureButtonBack" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_right = 24.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
shortcut_in_tooltip = false
Expand All @@ -149,28 +153,36 @@ stretch_mode = 5

[node name="LineEditSearch" type="LineEdit" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 28.0
margin_right = 576.0
margin_bottom = 34.0
margin_right = 484.0
margin_bottom = 36.0
size_flags_horizontal = 3
max_length = 60
script = ExtResource( 5 )

[node name="SpinBoxTimeInput" type="SpinBox" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 580.0
margin_right = 680.0
margin_bottom = 34.0
margin_left = 488.0
margin_right = 588.0
margin_bottom = 36.0
min_value = 5.0
max_value = 999.0
value = 60.0
rounded = true
align = 2
suffix = "s"
script = ExtResource( 1 )

[node name="CheckButtonTime" type="CheckButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 592.0
margin_right = 680.0
margin_bottom = 36.0
custom_icons/off = ExtResource( 44 )
custom_icons/on_disabled = ExtResource( 46 )
custom_icons/on = ExtResource( 43 )
custom_icons/off_disabled = ExtResource( 45 )

[node name="TextureButtonSkipBack" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 684.0
margin_right = 708.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
shortcut_in_tooltip = false
Expand All @@ -184,7 +196,7 @@ stretch_mode = 5
[node name="TextureButtonRewind" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 712.0
margin_right = 736.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
shortcut_in_tooltip = false
Expand All @@ -198,7 +210,7 @@ stretch_mode = 5
[node name="TextureButtonPlayPause" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 740.0
margin_right = 764.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
disabled = true
Expand All @@ -215,7 +227,7 @@ script = ExtResource( 40 )
[node name="TextureButtonStop" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 768.0
margin_right = 792.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
shortcut_in_tooltip = false
Expand All @@ -229,7 +241,7 @@ stretch_mode = 5
[node name="TextureButtonFastForward" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 796.0
margin_right = 820.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
shortcut_in_tooltip = false
Expand All @@ -243,7 +255,7 @@ stretch_mode = 5
[node name="TextureButtonSkipForward" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 824.0
margin_right = 848.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 0 )
focus_mode = 0
shortcut_in_tooltip = false
Expand All @@ -257,7 +269,7 @@ stretch_mode = 5
[node name="TextureButtonInfo" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 852.0
margin_right = 876.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 24 )
focus_mode = 0
toggle_mode = true
Expand All @@ -275,7 +287,7 @@ __meta__ = {
[node name="TextureButtonHelp" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 880.0
margin_right = 904.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 24 )
toggle_mode = true
shortcut_in_tooltip = false
Expand All @@ -292,12 +304,12 @@ __meta__ = {
[node name="VSeparator" type="VSeparator" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 908.0
margin_right = 912.0
margin_bottom = 34.0
margin_bottom = 36.0

[node name="TextureButtonRazcore" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 916.0
margin_right = 940.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 24, 24 )
focus_mode = 0
mouse_default_cursor_shape = 2
Expand All @@ -309,7 +321,7 @@ stretch_mode = 5
[node name="TextureButtonPexels" type="TextureButton" parent="VBoxContainerMain/HBoxContainerControls"]
margin_left = 944.0
margin_right = 1008.0
margin_bottom = 34.0
margin_bottom = 36.0
rect_min_size = Vector2( 64, 8 )
focus_mode = 0
mouse_default_cursor_shape = 2
Expand All @@ -319,14 +331,14 @@ expand = true
stretch_mode = 5

[node name="ProgressBar" type="ProgressBar" parent="VBoxContainerMain"]
margin_top = 44.0
margin_top = 46.0
margin_right = 1008.0
margin_bottom = 49.0
margin_bottom = 51.0
rect_min_size = Vector2( 0, 5 )
percent_visible = false

[node name="TextureRectImage" type="TextureRect" parent="VBoxContainerMain"]
margin_top = 59.0
margin_top = 61.0
margin_right = 1008.0
margin_bottom = 592.0
grow_horizontal = 2
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions project/assets/icons/check-button-time/off-disabled.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/off-disabled.png-f730e2f4761ef8895392e1d4a723e67b.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/check-button-time/off-disabled.png"
dest_files=[ "res://.import/off-disabled.png-f730e2f4761ef8895392e1d4a723e67b.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=true
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added project/assets/icons/check-button-time/off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions project/assets/icons/check-button-time/off.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/off.png-7db6533eb2befcaab3fa4e92e2d2ab9c.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/check-button-time/off.png"
dest_files=[ "res://.import/off.png-7db6533eb2befcaab3fa4e92e2d2ab9c.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=true
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions project/assets/icons/check-button-time/on-disabled.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/on-disabled.png-ebf4910c5512bff3f7e3d7c9c1eb8174.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/check-button-time/on-disabled.png"
dest_files=[ "res://.import/on-disabled.png-ebf4910c5512bff3f7e3d7c9c1eb8174.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=true
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Binary file added project/assets/icons/check-button-time/on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions project/assets/icons/check-button-time/on.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/on.png-4e7c36665425968ae3acc4c568f5ea88.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/check-button-time/on.png"
dest_files=[ "res://.import/on.png-4e7c36665425968ae3acc4c568f5ea88.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=true
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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
16 changes: 0 additions & 16 deletions project/assets/triton-16.hex

This file was deleted.

0 comments on commit 79c75ef

Please sign in to comment.