input styling, globalize timer functions
This commit is contained in:
@@ -362,11 +362,24 @@ func parse_rule(rule_data: Dictionary) -> CSSRule:
|
||||
var properties_text = rule_data.properties
|
||||
|
||||
var utility_classes = properties_text.split(" ")
|
||||
|
||||
var base_utilities = []
|
||||
var pseudo_utilities = []
|
||||
|
||||
for utility_name in utility_classes:
|
||||
utility_name = utility_name.strip_edges()
|
||||
if utility_name.is_empty():
|
||||
continue
|
||||
|
||||
if utility_name.begins_with("hover:") or utility_name.begins_with("active:"):
|
||||
pseudo_utilities.append(utility_name)
|
||||
else:
|
||||
base_utilities.append(utility_name)
|
||||
|
||||
for utility_name in base_utilities:
|
||||
parse_utility_class_internal(rule, utility_name)
|
||||
|
||||
for utility_name in pseudo_utilities:
|
||||
parse_utility_class(rule, utility_name)
|
||||
|
||||
return rule
|
||||
@@ -382,11 +395,14 @@ func parse_utility_class(rule: CSSRule, utility_name: String) -> void:
|
||||
|
||||
pseudo_rule.selector = rule.selector
|
||||
pseudo_rule.event_prefix = pseudo
|
||||
pseudo_rule.selector_type = "simple"
|
||||
pseudo_rule.selector_parts = [rule.selector]
|
||||
pseudo_rule.selector_type = rule.selector_type
|
||||
pseudo_rule.selector_parts = rule.selector_parts.duplicate()
|
||||
pseudo_rule.calculate_specificity()
|
||||
pseudo_rule.specificity += 100
|
||||
|
||||
for property in rule.properties:
|
||||
pseudo_rule.properties[property] = rule.properties[property]
|
||||
|
||||
parse_utility_class_internal(pseudo_rule, actual_utility)
|
||||
stylesheet.add_rule(pseudo_rule)
|
||||
return
|
||||
|
||||
@@ -24,11 +24,14 @@ pre { text-xl font-mono }
|
||||
button { text-[16px] bg-[#1b1b1b] rounded-md text-white hover:bg-[#2a2a2a] active:bg-[#101010] px-3 py-1.5 }
|
||||
button[disabled] { bg-[#666666] text-[#999999] cursor-not-allowed }
|
||||
|
||||
input { text-[#000000] border border-[#000000] rounded-[3px] bg-transparent px-3 py-1.5 }
|
||||
input:active { border-[3px] border-[#000000] }
|
||||
|
||||
select { text-[#000000] border border-[#000000] rounded-[3px] bg-transparent px-3 py-1.5 }
|
||||
select:active { text-[#000000] border-[3px] border-[#000000] }
|
||||
|
||||
input[type="color"] { w-32 }
|
||||
input[type="range"] { w-32 }
|
||||
input[type="text"] { w-64 }
|
||||
input[type="number"] { w-32 text-[16px] bg-transparent border border-[#000000] rounded-[3px] text-[#000000] hover:border-[3px] hover:border-[#000000] px-3 py-1.5 }
|
||||
input[type="date"] { w-28 text-[16px] bg-[#1b1b1b] rounded-md text-white hover:bg-[#2a2a2a] active:bg-[#101010] px-3 py-1.5 }
|
||||
"""
|
||||
|
||||
var HTML_CONTENT = """
|
||||
|
||||
@@ -774,7 +774,7 @@ static func apply_flexcontainer_centering(node: Control, styles: Dictionary) ->
|
||||
if not node is FlexContainer:
|
||||
return
|
||||
|
||||
var should_center_h = styles.has("mx-auto") or styles.has("justify-self-center") or (styles.has("text-align") and styles["text-align"] == "center")
|
||||
var should_center_h = styles.has("mx-auto") or styles.has("justify-self-center")
|
||||
var should_center_v = styles.has("my-auto") or styles.has("align-self-center")
|
||||
|
||||
if should_center_h and not node.has_meta("size_flags_horizontal_set"):
|
||||
@@ -787,7 +787,7 @@ static func apply_flexcontainer_centering(node: Control, styles: Dictionary) ->
|
||||
node.set_meta("size_flags_set_by_style_manager", true)
|
||||
|
||||
static func apply_element_centering(node: Control, styles: Dictionary) -> void:
|
||||
var should_center_h = styles.has("mx-auto") or styles.has("justify-self-center") or (styles.has("text-align") and styles["text-align"] == "center")
|
||||
var should_center_h = styles.has("mx-auto") or styles.has("justify-self-center")
|
||||
var should_center_v = styles.has("my-auto") or styles.has("align-self-center")
|
||||
|
||||
# For FlexContainers, use the existing logic with metadata checks
|
||||
|
||||
@@ -603,9 +603,40 @@ func apply_stylebox_to_input(control: Control, styles: Dictionary) -> void:
|
||||
if not has_bottom_padding:
|
||||
style_box.content_margin_bottom = 2.0
|
||||
|
||||
var hover_styles = _parser.get_element_styles_with_inheritance(_element, "hover", [])
|
||||
var active_styles = _parser.get_element_styles_with_inheritance(_element, "active", [])
|
||||
var hover_style_box = null
|
||||
var active_style_box = null
|
||||
|
||||
if not hover_styles.is_empty():
|
||||
hover_style_box = BackgroundUtils.create_stylebox_from_styles(hover_styles)
|
||||
if not hover_styles.has("padding") and not hover_styles.has("padding-left"):
|
||||
hover_style_box.content_margin_left = 5.0
|
||||
if not hover_styles.has("padding") and not hover_styles.has("padding-right"):
|
||||
hover_style_box.content_margin_right = 5.0
|
||||
if not hover_styles.has("padding") and not hover_styles.has("padding-top"):
|
||||
hover_style_box.content_margin_top = 2.0
|
||||
if not hover_styles.has("padding") and not hover_styles.has("padding-bottom"):
|
||||
hover_style_box.content_margin_bottom = 2.0
|
||||
|
||||
if not active_styles.is_empty():
|
||||
active_style_box = BackgroundUtils.create_stylebox_from_styles(active_styles)
|
||||
if not active_styles.has("padding") and not active_styles.has("padding-left"):
|
||||
active_style_box.content_margin_left = 5.0
|
||||
if not active_styles.has("padding") and not active_styles.has("padding-right"):
|
||||
active_style_box.content_margin_right = 5.0
|
||||
if not active_styles.has("padding") and not active_styles.has("padding-top"):
|
||||
active_style_box.content_margin_top = 2.0
|
||||
if not active_styles.has("padding") and not active_styles.has("padding-bottom"):
|
||||
active_style_box.content_margin_bottom = 2.0
|
||||
|
||||
if control is LineEdit:
|
||||
control.add_theme_stylebox_override("normal", style_box)
|
||||
control.add_theme_stylebox_override("focus", style_box)
|
||||
if hover_style_box:
|
||||
control.add_theme_stylebox_override("hover", hover_style_box)
|
||||
if active_style_box:
|
||||
control.add_theme_stylebox_override("pressed", active_style_box)
|
||||
elif control is SpinBox:
|
||||
# NOTE: currently broken, it goes over the buttons, dont have time to fix
|
||||
#style_box.expand_margin_right += 32.0 # More space for stepper buttons
|
||||
@@ -614,6 +645,14 @@ func apply_stylebox_to_input(control: Control, styles: Dictionary) -> void:
|
||||
if line_edit:
|
||||
line_edit.add_theme_stylebox_override("normal", style_box)
|
||||
line_edit.add_theme_stylebox_override("focus", style_box)
|
||||
if hover_style_box:
|
||||
line_edit.add_theme_stylebox_override("hover", hover_style_box)
|
||||
if active_style_box:
|
||||
line_edit.add_theme_stylebox_override("pressed", active_style_box)
|
||||
|
||||
elif control is Button:
|
||||
control.add_theme_stylebox_override("normal", style_box)
|
||||
if hover_style_box:
|
||||
control.add_theme_stylebox_override("hover", hover_style_box)
|
||||
if active_style_box:
|
||||
control.add_theme_stylebox_override("pressed", active_style_box)
|
||||
|
||||
@@ -293,17 +293,18 @@ func _setup_threaded_gurt_api():
|
||||
lua_vm.lua_pushcallable(_gurt_create_handler, "gurt.create")
|
||||
lua_vm.lua_setfield(-2, "create")
|
||||
|
||||
lua_vm.lua_pushcallable(_set_timeout_handler, "gurt.setTimeout")
|
||||
lua_vm.lua_setfield(-2, "setTimeout")
|
||||
# Add timer functions as global functions
|
||||
lua_vm.lua_pushcallable(_set_timeout_handler, "setTimeout")
|
||||
lua_vm.lua_setglobal("setTimeout")
|
||||
|
||||
lua_vm.lua_pushcallable(lua_api._gurt_clear_timeout_handler, "gurt.clearTimeout")
|
||||
lua_vm.lua_setfield(-2, "clearTimeout")
|
||||
lua_vm.lua_pushcallable(lua_api._gurt_clear_timeout_handler, "clearTimeout")
|
||||
lua_vm.lua_setglobal("clearTimeout")
|
||||
|
||||
lua_vm.lua_pushcallable(_set_interval_handler, "gurt.setInterval")
|
||||
lua_vm.lua_setfield(-2, "setInterval")
|
||||
lua_vm.lua_pushcallable(_set_interval_handler, "setInterval")
|
||||
lua_vm.lua_setglobal("setInterval")
|
||||
|
||||
lua_vm.lua_pushcallable(lua_api._gurt_clear_interval_handler, "gurt.clearInterval")
|
||||
lua_vm.lua_setfield(-2, "clearInterval")
|
||||
lua_vm.lua_pushcallable(lua_api._gurt_clear_interval_handler, "clearInterval")
|
||||
lua_vm.lua_setglobal("clearInterval")
|
||||
|
||||
lua_vm.lua_newtable()
|
||||
lua_vm.lua_pushcallable(lua_api._gurt_location_reload_handler, "gurt.location.reload")
|
||||
|
||||
Reference in New Issue
Block a user