From 8fbabdd01adae80cfcaa021a17b97aac2685fcc6 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Sat, 2 Aug 2025 14:12:58 +0300 Subject: [PATCH] cursor, z-index, opacity, "disabled" button support --- Scripts/B9/CSSParser.gd | 25 +++++++++++++++++ Scripts/Constants.gd | 55 ++++++++++++++++++++++++++++++++++--- Scripts/StyleManager.gd | 60 +++++++++++++++++++++++++++++++++++++++++ Scripts/Tags/button.gd | 10 +++++++ 4 files changed, 147 insertions(+), 3 deletions(-) diff --git a/Scripts/B9/CSSParser.gd b/Scripts/B9/CSSParser.gd index 49873ca..6261b60 100644 --- a/Scripts/B9/CSSParser.gd +++ b/Scripts/B9/CSSParser.gd @@ -785,6 +785,31 @@ static func parse_utility_class_internal(rule: CSSRule, utility_name: String) -> apply_border.call("", "", color) return + # Handle cursor classes like cursor-pointer, cursor-default, cursor-text, etc. + if utility_name.begins_with("cursor-"): + var cursor_type = utility_name.substr(7) # after 'cursor-' + rule.properties["cursor"] = cursor_type + return + + # Handle z-index classes like z-10, z-50, z-[999] + if utility_name.begins_with("z-"): + var val = utility_name.substr(2) + if val.begins_with("[") and val.ends_with("]"): + val = val.substr(1, val.length() - 2) + rule.properties["z-index"] = val.to_int() + return + + # Handle opacity classes like opacity-50, opacity-75, opacity-[0.5] + if utility_name.begins_with("opacity-"): + var val = utility_name.substr(8) # after 'opacity-' + if val.begins_with("[") and val.ends_with("]"): + val = val.substr(1, val.length() - 2) + rule.properties["opacity"] = val.to_float() + elif val.is_valid_int(): + # Convert percentage (0-100) to decimal (0.0-1.0) + rule.properties["opacity"] = val.to_int() / 100.0 + return + # Handle more utility classes as needed # Add more cases here for other utilities diff --git a/Scripts/Constants.gd b/Scripts/Constants.gd index 3799a17..e5a5a64 100644 --- a/Scripts/Constants.gd +++ b/Scripts/Constants.gd @@ -22,6 +22,7 @@ a { text-[#1a0dab] } pre { text-xl font-mono } button { bg-[#1b1b1b] rounded-md text-white hover:bg-[#2a2a2a] active:bg-[#101010] } +button[disabled] { bg-[#666666] text-[#999999] cursor-not-allowed } """ var HTML_CONTENT2 = """
@@ -99,7 +100,7 @@ var HTML_CONTENT2 = """ """.to_utf8_buffer() -var HTML_CONTENT4 = """ +var HTML_CONTENT = """So
+Opacity 75% with cursor pointer and z-index 10 - Text should show pointer cursor, not I-beam
+Opacity 50% with cursor text and z-index 20 - Text should show I-beam cursor
+Custom opacity 0.25 with cursor default and z-index 999 - Text should show arrow cursor
+Cursor move - Text should show move cursor
+Cursor crosshair - Text should show crosshair cursor
+Cursor help - Text should show help cursor
+Cursor not-allowed - Text should show forbidden cursor
+This paragraph is inside a div with cursor-pointer.
+Both paragraphs should show pointer cursor instead of default I-beam.
+This nested paragraph should also inherit the pointer cursor.
+