(
actor: Clutter.Actor | null,
parent: Clutter.Actor | null,
first = false
)
| 109 | }; |
| 110 | |
| 111 | export const reparentActor = ( |
| 112 | actor: Clutter.Actor | null, |
| 113 | parent: Clutter.Actor | null, |
| 114 | first = false |
| 115 | ) => { |
| 116 | if (!actor || !parent) return; |
| 117 | |
| 118 | const currentParent = actor.get_parent(); |
| 119 | |
| 120 | if (currentParent === parent) return; |
| 121 | |
| 122 | Me.instance.reparentInProgress = true; |
| 123 | const restoreFocusTo = actor.has_key_focus() |
| 124 | ? actor |
| 125 | : isParentOfActor(actor, global.stage.key_focus) |
| 126 | ? global.stage.key_focus |
| 127 | : null; |
| 128 | |
| 129 | if (restoreFocusTo) { |
| 130 | Main.layoutManager.uiGroup.grab_key_focus(); |
| 131 | } |
| 132 | if (currentParent) { |
| 133 | currentParent.remove_child(actor); |
| 134 | } |
| 135 | if (first) { |
| 136 | parent.insert_child_at_index(actor, 0); |
| 137 | } else { |
| 138 | parent.add_child(actor); |
| 139 | } |
| 140 | if (restoreFocusTo) { |
| 141 | restoreFocusTo.grab_key_focus(); |
| 142 | } |
| 143 | Me.instance.reparentInProgress = false; |
| 144 | }; |
| 145 | |
| 146 | export const InfinityTo0 = (number: number) => { |
| 147 | return Math.abs(number) === Infinity ? 0 : number; |
no test coverage detected