input (date)

This commit is contained in:
Face
2025-07-25 13:43:11 +03:00
parent c1e442bb83
commit 465200cd28
40 changed files with 1554 additions and 67 deletions

View File

@@ -88,6 +88,9 @@ func _exit_tree():
loading_tween = null
remove_from_group("tabs")
func _enter_tree() -> void:
$AnimationPlayer.play("appear")
func _on_button_pressed() -> void:
# Check if click was on close button area
var mouse_pos = get_global_mouse_position()

View File

@@ -81,7 +81,6 @@ func create_tab() -> void:
tab.tab_closed.connect(_tab_closed.bind(index))
h_box_container.add_child(tab)
tab.animation.play("appear")
set_active_tab(index)

View File

@@ -6,9 +6,6 @@ const BROWSER_TEXT: Theme = preload("res://Scenes/Styles/BrowserText.tres")
var custom_hex_input: LineEdit
func init(element: HTMLParser.HTMLElement) -> void:
var line_edit: LineEdit = $LineEdit
var check_box: CheckBox = $CheckBox
var radio_button: CheckBox = $RadioButton
var color_picker_button: ColorPickerButton = $ColorPickerButton
var picker: ColorPicker = color_picker_button.get_picker()
@@ -54,55 +51,66 @@ func init(element: HTMLParser.HTMLElement) -> void:
var maxlength = element.get_attribute("maxlength")
var pattern = element.get_attribute("pattern")
if input_type == "checkbox":
if is_instance_valid(line_edit): line_edit.queue_free()
if is_instance_valid(radio_button): radio_button.queue_free()
if is_instance_valid(color_picker_button): color_picker_button.queue_free()
check_box.visible = true
if value and value == "true": check_box.button_pressed = true
custom_minimum_size = check_box.size
# Define which child should be active for each input type
var active_child_map = {
"checkbox": "CheckBox",
"radio": "RadioButton",
"color": "ColorPickerButton",
"password": "LineEdit",
"date": "DateButton"
}
var active_child_name = active_child_map.get(input_type, "LineEdit")
remove_unused_children(active_child_name)
var active_child = get_node(active_child_name)
active_child.visible = true
custom_minimum_size = active_child.size
elif input_type == "radio":
if is_instance_valid(line_edit): line_edit.queue_free()
if is_instance_valid(check_box): check_box.queue_free()
if is_instance_valid(color_picker_button): color_picker_button.queue_free()
radio_button.visible = true
radio_button.toggle_mode = true
if value and value == "true": radio_button.button_pressed = true
custom_minimum_size = radio_button.size
match input_type:
"checkbox":
var checkbox = active_child as CheckBox
if value and value == "true":
checkbox.button_pressed = true
"radio":
var radio = active_child as CheckBox
radio.toggle_mode = true
if value and value == "true":
radio.button_pressed = true
if group.length() > 0:
if not button_groups.has(group):
button_groups[group] = ButtonGroup.new()
radio.button_group = button_groups[group]
"color":
var color_button = active_child as ColorPickerButton
if value and value.length() > 0:
var color = Color.from_string(value, Color.WHITE)
color_button.color = color
"password":
var line_edit = active_child as LineEdit
line_edit.secret = true
setup_text_input(line_edit, placeholder, value, minlength, maxlength, pattern)
"date":
var date_button = active_child as DateButton
if value and value.length() > 0:
date_button.init_with_date(value)
else:
date_button.init()
_: # Default case (text input)
var line_edit = active_child as LineEdit
line_edit.secret = false
setup_text_input(line_edit, placeholder, value, minlength, maxlength, pattern)
if group.length() > 0:
if not button_groups.has(group):
button_groups[group] = ButtonGroup.new()
radio_button.button_group = button_groups[group]
elif input_type == "color":
if is_instance_valid(line_edit): line_edit.queue_free()
if is_instance_valid(check_box): check_box.queue_free()
if is_instance_valid(radio_button): radio_button.queue_free()
color_picker_button.visible = true
if value and value.length() > 0:
var color = Color.from_string(value, Color.WHITE)
color_picker_button.color = color
custom_minimum_size = color_picker_button.size
elif input_type == "password":
if is_instance_valid(check_box): check_box.queue_free()
if is_instance_valid(radio_button): radio_button.queue_free()
if is_instance_valid(color_picker_button): color_picker_button.queue_free()
line_edit.visible = true
line_edit.secret = true
custom_minimum_size = line_edit.size
setup_text_input(line_edit, placeholder, value, minlength, maxlength, pattern)
else:
if is_instance_valid(check_box): check_box.queue_free()
if is_instance_valid(radio_button): radio_button.queue_free()
if is_instance_valid(color_picker_button): color_picker_button.queue_free()
line_edit.visible = true
line_edit.secret = false
custom_minimum_size = line_edit.size
setup_text_input(line_edit, placeholder, value, minlength, maxlength, pattern)
func remove_unused_children(keep_child_name: String) -> void:
for child in get_children():
if child.name != keep_child_name:
child.queue_free()
func setup_text_input(line_edit: LineEdit, placeholder: String, value: String, minlength: String, maxlength: String, pattern: String) -> void:
if placeholder: line_edit.placeholder_text = placeholder

View File

@@ -92,6 +92,8 @@ line breaks
<h2>Color</h2>
<input type=\"color\" value=\"#ff0000\" />
<h2>Date</h2>
<input type=\"date\" value=\"2018-07-22\" />
<input type=\"password\" placeholder=\"your password...\" />
<button type=\"submit\">Submit</button>
@@ -104,7 +106,6 @@ line breaks
<separator direction=\"vertical\" />
</body>".to_utf8_buffer()
# Create parser and parse
var parser: HTMLParser = HTMLParser.new(html_bytes)
var parse_result = parser.parse()
@@ -113,7 +114,6 @@ line breaks
if parse_result.errors.size() > 0:
print("Parse errors: " + str(parse_result.errors))
# TODO: render the shit on the screen
var tab = tab_container.tabs[tab_container.active_tab]
var title = parser.get_title()