summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.kt
blob: a5370af20e46c2d819f1d9a4295a102a7b958427 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.yuzu.yuzu_emu.features.settings.ui

import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout

/**
 * FrameLayout subclass with few Properties added to simplify animations.
 * Don't remove the methods appearing as unused, in order not to break the menu animations
 */
class SettingsFrameLayout : FrameLayout {
    private val mVisibleness = 1.0f

    constructor(context: Context?) : super(context!!)
    constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs)

    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int
    ) : super(context!!, attrs, defStyleAttr)

    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int,
        defStyleRes: Int
    ) : super(context!!, attrs, defStyleAttr, defStyleRes)

    var yFraction: Float
        get() = y / height
        set(yFraction) {
            val height = height
            y = (if (height > 0) yFraction * height else -9999) as Float
        }
    var visibleness: Float
        get() = mVisibleness
        set(visibleness) {
            scaleX = visibleness
            scaleY = visibleness
            alpha = visibleness
        }
}