summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/citra/citra_emu/features/settings/ui/SettingsFrameLayout.java
blob: 67bde570996cc41002b40a6d204b14cc6f1f23c3 (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
44
45
46
47
48
package org.citra.citra_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
 */
public final class SettingsFrameLayout extends FrameLayout {
    private float mVisibleness = 1.0f;

    public SettingsFrameLayout(Context context) {
        super(context);
    }

    public SettingsFrameLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SettingsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public SettingsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public float getYFraction() {
        return getY() / getHeight();
    }

    public void setYFraction(float yFraction) {
        final int height = getHeight();
        setY((height > 0) ? (yFraction * height) : -9999);
    }

    public float getVisibleness() {
        return mVisibleness;
    }

    public void setVisibleness(float visibleness) {
        setScaleX(visibleness);
        setScaleY(visibleness);
        setAlpha(visibleness);
    }
}