package com.nexstreaming.nexplayerengine;

import android.graphics.Typeface;
import android.view.Gravity;

/**
 * \brief This class manages the attributes of the captions for NexCaptionPainter.
 */

public class NexCaptionSetting {
    /**
     * This indicates that a property set by the contents will be applied.
     */
    public static final int DEFAULT = 0x00FFFFFE;

    /**
     * \brief This enumeration defines the caption edge style.
     *
     * These are available caption edge styles :
     * - <b>NONE </b>: None.
     * - <b>DEFAULT </b>: Apply a effect by a content.
     * - <b>DROP_SHADOW </b>: Apply a drop shadow effect to caption text.
     * - <b>RAISED </b>: Apply a raised effect to caption text.
     * - <b>DEPRESSED </b>: Apply a depressed effect to caption text.
     * - <b>UNIFORM </b>: Apply a uniform effect to caption text.
     */
    public enum EdgeStyle {
        NONE, DEFAULT, DROP_SHADOW, RAISED, DEPRESSED, UNIFORM
    }

    /**
     * \brief This enumeration defines the behavior for caption string style.
     *
     * These are available caption string styles :
     * - <b>NONE </b>: None.
     * - <b>DEFAULT </b>: Apply a string style by provider.
     * - <b>APPLY </b>: Apply a string style by user.
     * - <b>REMOVE </b>: Remove a string style whatever it is provided by a user or a content to be applied.
     */
    public enum StringStyle {
        NONE, DEFAULT, APPLY, REMOVE
    }

    /**
     * This indicates the caption window as an argb color.
     */
    public int mWindowColor;

    /**
     * This indicates the caption edge as an argb color.
     */
    public int mEdgeColor;

    /**
     * This indicates the thickness of edge.
     */
    public float mEdgeWidth;

    /**
     * This indicates alignment of caption.
     * \see android.view.Gravity
     */
    public int mGravity;

    /**
     * This indicates scale of font size, as a \c float.
     */
    public float mFontScale;

    /**
     * This indicates margin from the left edge of the caption window to caption text, as an \c int.
     */
    public int mPaddingLeft;

    /**
     * This indicates margin from the top edge of the caption window to caption text, as an \c int.
     */
    public int mPaddingTop;

    /**
     * This indicates margin from the right edge of the caption window to caption text, as an \c int.
     */
    public int mPaddingRight;

    /**
     * This indicates margin from the bottom edge of the caption window to caption text, as an \c int.
     */
    public int mPaddingBottom;

    /**
     * \brief  This indicates the fonts to be used captions as a Typeface.
     */
    public Typeface mFontFamily;

    /**
     * This indicates edge style of caption.
     * \see NexCaptionSetting.EdgeStyle
     */
    public EdgeStyle mEdgeStyle;

    /**
     * This indicates the caption background as an argb color.
     */
    public int mBackgroundColor;

    /**
     * This indicates the caption font as an argb color.
     */
    public int mFontColor;

    /**
     * This indicates the bold string style.
     * \see NexCaptionSetting.StringStyle
     */
    public StringStyle mBold;

    /**
     * This indicates the italic string style.
     * \see NexCaptionSetting.StringStyle
     */
    public StringStyle mItalic;

    /**
     * This indicates the underline string style.
     * \see NexCaptionSetting.StringStyle
     */
    public StringStyle mUnderLine;

    /**
     * This indicates the font size in px, as a float
     */
    public float mFontSize;

    /**
     * This indicates the position of caption.
     * It can be set to a percentage of the caption render area.
     * \see NexCaptionWindowRect
     */
    public NexCaptionWindowRect mRelativeWindowRect;

    /**
     * \brief Constructor of NexCaptionSetting.
     * The attributes will be initialized by NexCaptionSetting.DEFAULT
     */
    public NexCaptionSetting() {
        init();
    }

    /**
     * \brief Constructor of NexCaptionSetting.
     * The attributes will be generated by initializing settings object values.
     *
     * \param ref A \c NexCaptionSetting object.
     */
    public NexCaptionSetting(NexCaptionSetting ref) {
        init();
        copyAllSettings(ref);
    }

    /**
     * \brief This method resets all the attributes of NexCaptionSetting.
     */
    public void init() {
        mWindowColor = DEFAULT;
        mEdgeColor = DEFAULT;
        mEdgeWidth = DEFAULT;
        mGravity = DEFAULT;
        mFontScale = DEFAULT;
        mPaddingLeft = DEFAULT;
        mPaddingRight = DEFAULT;
        mPaddingTop = DEFAULT;
        mPaddingBottom = DEFAULT;
        mFontFamily = null;
        mEdgeStyle = EdgeStyle.DEFAULT;
        mFontColor = DEFAULT;
        mBackgroundColor = DEFAULT;
        mBold = StringStyle.DEFAULT;
        mItalic = StringStyle.DEFAULT;
        mUnderLine = StringStyle.DEFAULT;
        mFontSize = DEFAULT;
        mRelativeWindowRect = new NexCaptionWindowRect();
    }

    /**
     * \brief This method sets the values of the attributes by settings the object values including NexCaptionSetting.DEFAULT
     *
     * \param ref A \c NexCaptionSetting object.
     */
    public void copyAllSettings(NexCaptionSetting ref) {
        if (null != ref) {
            mWindowColor = ref.mWindowColor;
            mEdgeColor = ref.mEdgeColor;
            mEdgeWidth = ref.mEdgeWidth;
            mGravity = ref.mGravity;
            mFontScale = ref.mFontScale;
            mPaddingLeft = ref.mPaddingLeft;
            mPaddingRight = ref.mPaddingRight;
            mPaddingTop = ref.mPaddingTop;
            mPaddingBottom = ref.mPaddingBottom;
            mFontFamily = ref.mFontFamily;
            mEdgeStyle = ref.mEdgeStyle;
            mBackgroundColor = ref.mBackgroundColor;
            mFontColor = ref.mFontColor;
            mBold = ref.mBold;
            mItalic = ref.mItalic;
            mUnderLine = ref.mUnderLine;
            mFontSize = ref.mFontSize;
            mRelativeWindowRect.copyAllSettings(ref.mRelativeWindowRect);
        }
    }

    /**
     * \brief This method sets the values of the attributes by settings the object values excepting NexCaptionSetting.DEFAULT
     *
     * \param ref A \c NexCaptionSetting object.
     */
    public void copyTouchedSettings(NexCaptionSetting ref) {
        if (null != ref) {
            if (DEFAULT != ref.mWindowColor) {
                mWindowColor = ref.mWindowColor;
            }
            if (DEFAULT != ref.mEdgeColor) {
                mEdgeColor = ref.mEdgeColor;
            }
            if (DEFAULT != ref.mEdgeWidth) {
                mEdgeWidth = ref.mEdgeWidth;
            }
            if (DEFAULT != ref.mGravity) {
                mGravity = ref.mGravity;
            }
            if (DEFAULT != ref.mFontScale) {
                mFontScale = ref.mFontScale;
            }
            if (DEFAULT != ref.mPaddingLeft) {
                mPaddingLeft = ref.mPaddingLeft;
            }
            if (DEFAULT != ref.mPaddingRight) {
                mPaddingRight = ref.mPaddingRight;
            }
            if (DEFAULT != ref.mPaddingTop) {
                mPaddingTop = ref.mPaddingTop;
            }
            if (DEFAULT != ref.mPaddingBottom) {
                mPaddingBottom = ref.mPaddingBottom;
            }
            if (null != ref.mFontFamily) {
                mFontFamily = ref.mFontFamily;
            }
            if (EdgeStyle.DEFAULT != ref.mEdgeStyle) {
                mEdgeStyle = ref.mEdgeStyle;
            }
            if (DEFAULT != ref.mBackgroundColor) {
                mBackgroundColor = ref.mBackgroundColor;
            }
            if (DEFAULT != ref.mFontColor) {
                mFontColor = ref.mFontColor;
            }
            if (StringStyle.DEFAULT != ref.mBold) {
                mBold = ref.mBold;
            }
            if (StringStyle.DEFAULT != ref.mItalic) {
                mItalic = ref.mItalic;
            }
            if (StringStyle.DEFAULT != ref.mUnderLine) {
                mUnderLine = ref.mUnderLine;
            }
            if (DEFAULT != ref.mFontSize) {
                mFontSize = ref.mFontSize;
            }

            mRelativeWindowRect.copyTouchedSettings(ref.mRelativeWindowRect);
        }
    }
}