From 6f70032aab25779ef31476bb08f0d1ce0b5486d1 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Sat, 6 Sep 2025 12:30:48 +0300 Subject: [PATCH] fix flex size, fix hover --- dns/frontend/register.html | 2 +- flumi/Scenes/main.tscn | 2 +- flumi/Scripts/AutoSizingFlexContainer.gd | 15 ++++++++++++--- flumi/Scripts/CertificateManager.gd | 8 ++++---- flumi/Scripts/StyleManager.gd | 24 ++++++++++++++++++++---- flumi/Scripts/main.gd | 11 +++++++++++ 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/dns/frontend/register.html b/dns/frontend/register.html index 9402319..1a42ccf 100644 --- a/dns/frontend/register.html +++ b/dns/frontend/register.html @@ -121,7 +121,7 @@
-

Redeem Invite

+

Redeem Invite

diff --git a/flumi/Scenes/main.tscn b/flumi/Scenes/main.tscn index a61661d..448f2ee 100644 --- a/flumi/Scenes/main.tscn +++ b/flumi/Scenes/main.tscn @@ -9,7 +9,7 @@ [ext_resource type="PackedScene" uid="uid://sqhcxhcre081" path="res://Scenes/Tab.tscn" id="4_344ge"] [ext_resource type="Texture2D" uid="uid://cu4hjoba6etf" path="res://Assets/Icons/rotate-cw.svg" id="5_344ge"] [ext_resource type="Texture2D" uid="uid://cehbtwq6gq0cn" path="res://Assets/Icons/plus.svg" id="5_ynf5e"] -[ext_resource type="Script" uid="uid://nve723radqih" path="res://Scripts/SearchBar.gd" id="9_gt3je"] +[ext_resource type="Script" path="res://Scripts/SearchBar.gd" id="9_gt3je"] [ext_resource type="Texture2D" uid="uid://cklatjc4m38dy" path="res://Assets/Icons/ellipsis-vertical.svg" id="10_6iyac"] [ext_resource type="Theme" uid="uid://bn6rbmdy60lhr" path="res://Scenes/Styles/BrowserText.tres" id="11_ee4r6"] [ext_resource type="Script" uid="uid://vjjhljlftlbk" path="res://Scripts/OptionButton.gd" id="11_gt3je"] diff --git a/flumi/Scripts/AutoSizingFlexContainer.gd b/flumi/Scripts/AutoSizingFlexContainer.gd index 75b629b..493a32d 100644 --- a/flumi/Scripts/AutoSizingFlexContainer.gd +++ b/flumi/Scripts/AutoSizingFlexContainer.gd @@ -159,11 +159,20 @@ func _resort() -> void: _draw_debug_rect(Rect2(offset, rect_size), Color(1, 0, 0, 0.8)) - # Update background panel if needed - BackgroundUtils.update_background_panel(self) + if not _is_inside_background_container(): + BackgroundUtils.update_background_panel(self) emit_signal("flex_resized") +func _is_inside_background_container() -> bool: + var current_parent = get_parent() + while current_parent: + if current_parent is PanelContainer: + if current_parent.has_meta("hover_stylebox") or current_parent.has_meta("normal_stylebox"): + return true + current_parent = current_parent.get_parent() + return false + func calculate_available_dimension(is_width: bool) -> float: var percentage_key = "custom_css_width_percentage" if is_width else "custom_css_height_percentage" var fill_key = "should_fill_horizontal" if is_width else "should_fill_vertical" @@ -196,7 +205,7 @@ func calculate_custom_dimension(is_width: bool) -> float: else: return 0.0 elif has_meta(fill_key): - return get_parent_or_fallback_size(is_width) + return 0.0 else: return 0.0 diff --git a/flumi/Scripts/CertificateManager.gd b/flumi/Scripts/CertificateManager.gd index 4787a00..5696eb3 100644 --- a/flumi/Scripts/CertificateManager.gd +++ b/flumi/Scripts/CertificateManager.gd @@ -32,7 +32,7 @@ static func fetch_cert_via_http(url: String) -> String: static func initialize(): load_builtin_ca() - print("📋 Certificate Manager initialized with ", trusted_ca_certificates.size(), " trusted CAs") + print("Certificate Manager initialized with ", trusted_ca_certificates.size(), " trusted CAs") static func load_builtin_ca(): var ca_file = FileAccess.open("res://Assets/gurted-ca.crt", FileAccess.READ) @@ -42,8 +42,8 @@ static func load_builtin_ca(): if not ca_cert_pem.is_empty(): trusted_ca_certificates.append(ca_cert_pem) - print("✅ Loaded built-in GURT CA certificate") + print("Loaded built-in GURT CA certificate") else: - print("⚠️ Built-in CA certificate not yet configured") + print("Built-in CA certificate not yet configured") else: - print("❌ Could not load built-in CA certificate") + print("Could not load built-in CA certificate") diff --git a/flumi/Scripts/StyleManager.gd b/flumi/Scripts/StyleManager.gd index d43ec6c..7cad2c0 100644 --- a/flumi/Scripts/StyleManager.gd +++ b/flumi/Scripts/StyleManager.gd @@ -325,15 +325,31 @@ static func apply_margin_wrapper(node: Control, styles: Dictionary) -> Control: margin_container.name = "MarginWrapper_" + node.name margin_container.set_meta("is_margin_wrapper", true) + var needs_fill = false + + if node.has_meta("should_fill_horizontal"): + needs_fill = true + + if node.get_child_count() > 0: + var vbox = node.get_child(0) + if vbox is VBoxContainer and vbox.get_child_count() > 0: + var flex_child = vbox.get_child(0) + if flex_child and flex_child.has_meta("should_fill_horizontal"): + needs_fill = true + + if needs_fill: + margin_container.size_flags_horizontal = Control.SIZE_EXPAND_FILL + + var has_explicit_width = styles.has("width") var has_explicit_height = styles.has("height") - if has_explicit_width: - margin_container.size_flags_horizontal = node.size_flags_horizontal - else: + if has_explicit_width and not needs_fill: + margin_container.size_flags_horizontal = node.size_flags_horizontal + elif not needs_fill: margin_container.size_flags_horizontal = node.size_flags_horizontal node.size_flags_horizontal = Control.SIZE_EXPAND_FILL - + if has_explicit_height: margin_container.size_flags_vertical = node.size_flags_vertical else: diff --git a/flumi/Scripts/main.gd b/flumi/Scripts/main.gd index 652d795..7ab96d4 100644 --- a/flumi/Scripts/main.gd +++ b/flumi/Scripts/main.gd @@ -366,6 +366,7 @@ func render_content(html_bytes: PackedByteArray) -> void: # ul/ol handle their own adding if element.tag_name != "ul" and element.tag_name != "ol": safe_add_child(target_container, element_node) + if contains_hyperlink(element): if element_node is RichTextLabel: @@ -456,16 +457,21 @@ func create_element_node(element: HTMLParser.HTMLElement, parser: HTMLParser, co if element.tag_name == "div": if BackgroundUtils.needs_background_wrapper(styles) or BackgroundUtils.needs_background_wrapper(hover_styles): final_node = BackgroundUtils.create_panel_container_with_background(styles, hover_styles) + var flex_container = AUTO_SIZING_FLEX_CONTAINER.new() flex_container.name = "Flex_" + element.tag_name var vbox = final_node.get_child(0) as VBoxContainer vbox.add_child(flex_container) container_for_children = flex_container FlexUtils.apply_flex_container_properties(flex_container, styles) + + if flex_container.has_meta("should_fill_horizontal"): + final_node.set_meta("needs_size_expand_fill", true) else: final_node = AUTO_SIZING_FLEX_CONTAINER.new() final_node.name = "Flex_" + element.tag_name container_for_children = final_node + FlexUtils.apply_flex_container_properties(final_node, styles) else: final_node = AUTO_SIZING_FLEX_CONTAINER.new() @@ -512,6 +518,11 @@ func create_element_node(element: HTMLParser.HTMLElement, parser: HTMLParser, co # Applies background, size, etc. to the FlexContainer (top-level node) final_node = StyleManager.apply_element_styles(final_node, element, parser) + if final_node and final_node.has_meta("needs_size_expand_fill"): + final_node.size_flags_horizontal = Control.SIZE_EXPAND_FILL + if final_node.get_child_count() > 0: + var vbox = final_node.get_child(0) + vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL if is_grid_container: var grid_container_node = final_node