feat: add universal controller focus pointer
This commit is contained in:
parent
41308768b7
commit
a99916c38b
11 changed files with 719 additions and 115 deletions
|
|
@ -20,8 +20,6 @@ var _dragging: bool = false
|
|||
func _ready() -> void:
|
||||
mouse_entered.connect(_set_hovered.bind(true))
|
||||
mouse_exited.connect(_set_hovered.bind(false))
|
||||
focus_entered.connect(_refresh_style)
|
||||
focus_exited.connect(_refresh_style)
|
||||
resized.connect(_update_visual_pivot)
|
||||
_update_visual_pivot()
|
||||
_apply_quantity_style()
|
||||
|
|
@ -60,7 +58,7 @@ func advance_presentation(elapsed: float, motion_enabled: bool) -> void:
|
|||
) * 0.014
|
||||
_visual_root.position = Vector2(0.0, bob)
|
||||
_visual_root.rotation = tilt
|
||||
var emphasis: float = 1.04 if _hovered or has_focus() else 1.0
|
||||
var emphasis: float = 1.04 if _hovered else 1.0
|
||||
_visual_root.scale = Vector2.ONE * _depth_scale * emphasis
|
||||
|
||||
|
||||
|
|
@ -103,9 +101,7 @@ func _refresh_style() -> void:
|
|||
)
|
||||
if _selected:
|
||||
style.bg_color = UtilityPageStyle.OCEAN_SELECTED
|
||||
if has_focus():
|
||||
style.bg_color = UtilityPageStyle.OCEAN_BUTTON_HOVER
|
||||
elif _hovered:
|
||||
if _hovered:
|
||||
style.bg_color = Color(UtilityPageStyle.OCEAN_PANEL_MID, 0.88)
|
||||
style.set_border_width_all(0)
|
||||
style.set_corner_radius_all(64)
|
||||
|
|
|
|||
|
|
@ -28,14 +28,11 @@ var neutral_position: Vector2 = Vector2.ZERO
|
|||
var presented_size: Vector2 = Vector2.ZERO
|
||||
var emphasis: float = 0.0
|
||||
var _hovered: bool = false
|
||||
var _focused: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_entered.connect(_set_hovered.bind(true))
|
||||
mouse_exited.connect(_set_hovered.bind(false))
|
||||
focus_entered.connect(_set_focused.bind(true))
|
||||
focus_exited.connect(_set_focused.bind(false))
|
||||
resized.connect(_update_pivot)
|
||||
_update_pivot()
|
||||
apply_profile()
|
||||
|
|
@ -151,7 +148,7 @@ func _apply_icon_presentation(bubble_size: Vector2) -> void:
|
|||
|
||||
|
||||
func advance_emphasis(delta: float) -> void:
|
||||
var target: float = 1.0 if _hovered or _focused else 0.0
|
||||
var target: float = 1.0 if _hovered else 0.0
|
||||
emphasis = move_toward(
|
||||
emphasis,
|
||||
target,
|
||||
|
|
@ -233,10 +230,6 @@ func _set_hovered(value: bool) -> void:
|
|||
_hovered = value
|
||||
|
||||
|
||||
func _set_focused(value: bool) -> void:
|
||||
_focused = value
|
||||
|
||||
|
||||
func _update_pivot() -> void:
|
||||
pivot_offset = size * 0.5
|
||||
|
||||
|
|
@ -247,12 +240,12 @@ func apply_profile() -> void:
|
|||
add_theme_stylebox_override("normal", profile.make_normal_style())
|
||||
var hover_style: StyleBoxFlat = profile.make_hover_style()
|
||||
add_theme_stylebox_override("hover", hover_style)
|
||||
add_theme_stylebox_override("focus", hover_style)
|
||||
add_theme_stylebox_override("focus", profile.make_normal_style())
|
||||
add_theme_stylebox_override("pressed", profile.make_pressed_style())
|
||||
add_theme_stylebox_override("disabled", profile.make_disabled_style())
|
||||
add_theme_color_override("font_color", profile.text_color)
|
||||
add_theme_color_override("font_hover_color", profile.text_hover_color)
|
||||
add_theme_color_override("font_focus_color", profile.text_hover_color)
|
||||
add_theme_color_override("font_focus_color", profile.text_color)
|
||||
add_theme_color_override("font_pressed_color", profile.text_pressed_color)
|
||||
add_theme_color_override("font_disabled_color", profile.text_disabled_color)
|
||||
var label_control: Control = get_label_control()
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@ var _quality_color := Color.WHITE
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
set_meta(&"controller_focus_inversion_disabled", true)
|
||||
resized.connect(_update_visual_pivot)
|
||||
focus_entered.connect(_refresh_style)
|
||||
focus_exited.connect(_refresh_style)
|
||||
mouse_entered.connect(func() -> void:
|
||||
_hovered = true
|
||||
_refresh_style()
|
||||
|
|
@ -108,7 +105,7 @@ func advance_presentation(delta: float, elapsed: float) -> void:
|
|||
var interaction_lift: float = 0.0
|
||||
if _batch_selected:
|
||||
interaction_lift += 3.0
|
||||
if _focused_catch or has_focus():
|
||||
if _focused_catch:
|
||||
interaction_lift += 1.5
|
||||
elif _hovered:
|
||||
interaction_lift += 0.8
|
||||
|
|
@ -117,7 +114,7 @@ func advance_presentation(delta: float, elapsed: float) -> void:
|
|||
var emphasis: float = 1.0
|
||||
if _batch_selected:
|
||||
emphasis += 0.085
|
||||
if _focused_catch or has_focus():
|
||||
if _focused_catch:
|
||||
emphasis += 0.035
|
||||
elif _hovered:
|
||||
emphasis += 0.045
|
||||
|
|
@ -154,7 +151,7 @@ func _refresh_style() -> void:
|
|||
var circle_visible: bool = (
|
||||
_batch_selected
|
||||
or _hovered
|
||||
or has_focus()
|
||||
or _focused_catch
|
||||
)
|
||||
var base_style: StyleBox = idle
|
||||
if circle_visible:
|
||||
|
|
@ -168,7 +165,7 @@ func _refresh_style() -> void:
|
|||
base_style,
|
||||
)
|
||||
add_theme_stylebox_override("hover", selected if _batch_selected else hover)
|
||||
add_theme_stylebox_override("focus", selected)
|
||||
add_theme_stylebox_override("focus", base_style)
|
||||
add_theme_stylebox_override("pressed", selected)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,15 +16,12 @@ extends Button
|
|||
@onready var _ink_outline: NotepadInkOutline = %InkOutline
|
||||
|
||||
var _hovered: bool = false
|
||||
var _focused: bool = false
|
||||
var _pressed: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_entered.connect(_set_hovered.bind(true))
|
||||
mouse_exited.connect(_set_hovered.bind(false))
|
||||
focus_entered.connect(_set_focused.bind(true))
|
||||
focus_exited.connect(_set_focused.bind(false))
|
||||
button_down.connect(_set_pressed.bind(true))
|
||||
button_up.connect(_set_pressed.bind(false))
|
||||
gui_input.connect(_on_gui_input)
|
||||
|
|
@ -42,11 +39,6 @@ func _set_hovered(value: bool) -> void:
|
|||
_refresh_ink()
|
||||
|
||||
|
||||
func _set_focused(value: bool) -> void:
|
||||
_focused = value
|
||||
_refresh_ink()
|
||||
|
||||
|
||||
func _set_pressed(value: bool) -> void:
|
||||
_pressed = value
|
||||
_refresh_ink()
|
||||
|
|
@ -75,7 +67,7 @@ func _refresh_ink() -> void:
|
|||
if not disabled:
|
||||
if persistent_mark:
|
||||
strength = 0.78
|
||||
if _hovered or _focused:
|
||||
if _hovered:
|
||||
strength = maxf(strength, 0.92)
|
||||
if _pressed:
|
||||
strength = 1.0
|
||||
|
|
@ -99,6 +91,6 @@ func _apply_text_color() -> void:
|
|||
var color: Color = disabled_ink_color if disabled else ink_color
|
||||
add_theme_color_override("font_color", color)
|
||||
add_theme_color_override("font_hover_color", color.darkened(0.08))
|
||||
add_theme_color_override("font_focus_color", color.darkened(0.08))
|
||||
add_theme_color_override("font_focus_color", color)
|
||||
add_theme_color_override("font_pressed_color", color.darkened(0.16))
|
||||
add_theme_color_override("font_disabled_color", disabled_ink_color)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ var _items: Array[String] = []
|
|||
var _item_ids: Array[int] = []
|
||||
var _selected_index: int = 0
|
||||
var _hovered: bool = false
|
||||
var _focused: bool = false
|
||||
var _opened_with_mouse: bool = false
|
||||
|
||||
|
||||
|
|
@ -43,8 +42,6 @@ func _ready() -> void:
|
|||
_apply_outline_geometry()
|
||||
mouse_entered.connect(_set_hovered.bind(true))
|
||||
mouse_exited.connect(_set_hovered.bind(false))
|
||||
focus_entered.connect(_set_focused.bind(true))
|
||||
focus_exited.connect(_set_focused.bind(false))
|
||||
gui_input.connect(_on_display_gui_input)
|
||||
for index: int in _choice_buttons.size():
|
||||
var button: Button = _choice_buttons[index]
|
||||
|
|
@ -202,15 +199,10 @@ func _set_hovered(value: bool) -> void:
|
|||
_refresh_ink()
|
||||
|
||||
|
||||
func _set_focused(value: bool) -> void:
|
||||
_focused = value
|
||||
_refresh_ink()
|
||||
|
||||
|
||||
func _refresh_ink() -> void:
|
||||
if is_node_ready():
|
||||
_ink_outline.set_mark_strength(
|
||||
0.88 if (_hovered or _focused) and not disabled else 0.0
|
||||
0.88 if _hovered and not disabled else 0.0
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -246,9 +238,9 @@ func _apply_paper_style() -> void:
|
|||
for state: StringName in [
|
||||
&"hover",
|
||||
&"pressed",
|
||||
&"focus",
|
||||
]:
|
||||
button.add_theme_stylebox_override(state, hover)
|
||||
button.add_theme_stylebox_override("focus", empty)
|
||||
button.add_theme_color_override("font_color", ink_color)
|
||||
button.add_theme_color_override(
|
||||
"font_hover_color",
|
||||
|
|
@ -256,7 +248,7 @@ func _apply_paper_style() -> void:
|
|||
)
|
||||
button.add_theme_color_override(
|
||||
"font_focus_color",
|
||||
ink_color.darkened(0.08),
|
||||
ink_color,
|
||||
)
|
||||
button.add_theme_color_override(
|
||||
"font_pressed_color",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue