Search in sources :

Example 1 with ParameterColor

use of com.android.gallery3d.filtershow.controller.ParameterColor in project android_packages_apps_Gallery2 by LineageOS.

the class EditorColorBorderTabletUI method setupColor.

private void setupColor(LinearLayout lp, Resources res) {
    final LinearLayout ctls = (LinearLayout) lp.findViewById(R.id.controls);
    final LinearLayout pick = (LinearLayout) lp.findViewById(R.id.colorPicker);
    Button b = (Button) lp.findViewById(R.id.draw_color_popupbutton);
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            boolean b = ctls.getVisibility() == View.VISIBLE;
            ctls.setVisibility((b) ? View.GONE : View.VISIBLE);
            pick.setVisibility((!b) ? View.GONE : View.VISIBLE);
        }
    });
    mTransparent = res.getColor(R.color.color_chooser_unslected_border);
    mSelected = res.getColor(R.color.color_chooser_slected_border);
    mColorButton = new Button[ids.length];
    for (int i = 0; i < ids.length; i++) {
        mColorButton[i] = (Button) lp.findViewById(ids[i]);
        float[] hsvo = new float[4];
        Color.colorToHSV(mBasColors[i], hsvo);
        hsvo[3] = (0xFF & (mBasColors[i] >> 24)) / (float) 255;
        mColorButton[i].setTag(hsvo);
        GradientDrawable sd = ((GradientDrawable) mColorButton[i].getBackground());
        sd.setColor(mBasColors[i]);
        sd.setStroke(3, (0 == i) ? mSelected : mTransparent);
        final int buttonNo = i;
        mColorButton[i].setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mSelectedColorButton = buttonNo;
                float[] hsvo = Arrays.copyOf((float[]) mColorButton[buttonNo].getTag(), 4);
                resetBorders();
                if (mRep == null) {
                    return;
                }
                int type = FilterColorBorderRepresentation.PARAM_COLOR;
                ParameterColor pram = (ParameterColor) mRep.getParam(type);
                pram.setValue(mBasColors[mSelectedColorButton]);
                mEditorDraw.commitLocalRepresentation();
                mHueView.setColor(hsvo);
                mSatValView.setColor(hsvo);
                mOpacityView.setColor(hsvo);
                mColorCompareView.setOrigColor(hsvo);
            }
        });
    }
    mHueView = (ColorHueView) lp.findViewById(R.id.ColorHueView);
    mSatValView = (ColorSVRectView) lp.findViewById(R.id.colorRectView);
    mOpacityView = (ColorOpacityView) lp.findViewById(R.id.colorOpacityView);
    mColorCompareView = (ColorCompareView) lp.findViewById(R.id.btnSelect);
    float[] hsvo = new float[4];
    Color.colorToHSV(mBasColors[0], hsvo);
    hsvo[3] = (0xFF & (mBasColors[0] >> 24)) / (float) 255;
    mColorCompareView.setOrigColor(hsvo);
    ColorListener[] colorViews = { mHueView, mSatValView, mOpacityView, mColorCompareView };
    for (int i = 0; i < colorViews.length; i++) {
        colorViews[i].setColor(hsvo);
        for (int j = 0; j < colorViews.length; j++) {
            if (i == j) {
                continue;
            }
            colorViews[i].addColorListener(colorViews[j]);
        }
    }
    ColorListener colorListener = new ColorListener() {

        @Override
        public void setColor(float[] hsvo) {
            int color = Color.HSVToColor((int) (hsvo[3] * 255), hsvo);
            Button b = mColorButton[mSelectedColorButton];
            float[] f = (float[]) b.getTag();
            System.arraycopy(hsvo, 0, f, 0, 4);
            mBasColors[mSelectedColorButton] = color;
            GradientDrawable sd = ((GradientDrawable) b.getBackground());
            sd.setColor(color);
            resetBorders();
            ParameterColor pram;
            pram = (ParameterColor) mRep.getParam(FilterColorBorderRepresentation.PARAM_COLOR);
            pram.setValue(color);
            mEditorDraw.commitLocalRepresentation();
        }

        @Override
        public void addColorListener(ColorListener l) {
        }
    };
    for (int i = 0; i < colorViews.length; i++) {
        colorViews[i].addColorListener(colorListener);
    }
}
Also used : ColorListener(com.android.gallery3d.filtershow.colorpicker.ColorListener) Button(android.widget.Button) ColorCompareView(com.android.gallery3d.filtershow.colorpicker.ColorCompareView) ColorOpacityView(com.android.gallery3d.filtershow.colorpicker.ColorOpacityView) TextView(android.widget.TextView) ColorHueView(com.android.gallery3d.filtershow.colorpicker.ColorHueView) View(android.view.View) ColorSVRectView(com.android.gallery3d.filtershow.colorpicker.ColorSVRectView) ParameterColor(com.android.gallery3d.filtershow.controller.ParameterColor) LinearLayout(android.widget.LinearLayout) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 2 with ParameterColor

use of com.android.gallery3d.filtershow.controller.ParameterColor in project android_packages_apps_Gallery2 by LineageOS.

the class EditorColorBorderTabletUI method setColorBorderRepresentation.

public void setColorBorderRepresentation(FilterColorBorderRepresentation rep) {
    mRep = rep;
    BasicParameterInt size;
    size = (BasicParameterInt) mRep.getParam(FilterColorBorderRepresentation.PARAM_SIZE);
    mCBSizeSeekBar.setMax(size.getMaximum() - size.getMinimum());
    mCBSizeSeekBar.setProgress(size.getValue());
    BasicParameterInt radius;
    radius = (BasicParameterInt) mRep.getParam(FilterColorBorderRepresentation.PARAM_RADIUS);
    mCBCornerSizeSeekBar.setMax(radius.getMaximum() - radius.getMinimum());
    mCBCornerSizeSeekBar.setProgress(radius.getValue());
    ParameterColor color;
    color = (ParameterColor) mRep.getParam(FilterColorBorderRepresentation.PARAM_COLOR);
    mBasColors = color.getColorPalette();
    color.setValue(mBasColors[mSelectedColorButton]);
}
Also used : BasicParameterInt(com.android.gallery3d.filtershow.controller.BasicParameterInt) ParameterColor(com.android.gallery3d.filtershow.controller.ParameterColor)

Example 3 with ParameterColor

use of com.android.gallery3d.filtershow.controller.ParameterColor in project android_packages_apps_Gallery2 by LineageOS.

the class EditorDrawTabletUI method setDrawRepresentation.

public void setDrawRepresentation(FilterDrawRepresentation rep) {
    mRep = rep;
    BasicParameterInt size;
    size = (BasicParameterInt) mRep.getParam(FilterDrawRepresentation.PARAM_SIZE);
    mdrawSizeSeekBar.setMax(size.getMaximum() - size.getMinimum());
    mdrawSizeSeekBar.setProgress(size.getValue());
    ParameterColor color;
    color = (ParameterColor) mRep.getParam(FilterDrawRepresentation.PARAM_COLOR);
    color.setValue(mBasColors[mSelectedColorButton]);
    BasicParameterStyle style;
    style = (BasicParameterStyle) mRep.getParam(FilterDrawRepresentation.PARAM_STYLE);
    style.setSelected(mSelectedStyleButton);
}
Also used : BasicParameterInt(com.android.gallery3d.filtershow.controller.BasicParameterInt) ParameterColor(com.android.gallery3d.filtershow.controller.ParameterColor) BasicParameterStyle(com.android.gallery3d.filtershow.controller.BasicParameterStyle)

Aggregations

ParameterColor (com.android.gallery3d.filtershow.controller.ParameterColor)3 BasicParameterInt (com.android.gallery3d.filtershow.controller.BasicParameterInt)2 GradientDrawable (android.graphics.drawable.GradientDrawable)1 View (android.view.View)1 Button (android.widget.Button)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 ColorCompareView (com.android.gallery3d.filtershow.colorpicker.ColorCompareView)1 ColorHueView (com.android.gallery3d.filtershow.colorpicker.ColorHueView)1 ColorListener (com.android.gallery3d.filtershow.colorpicker.ColorListener)1 ColorOpacityView (com.android.gallery3d.filtershow.colorpicker.ColorOpacityView)1 ColorSVRectView (com.android.gallery3d.filtershow.colorpicker.ColorSVRectView)1 BasicParameterStyle (com.android.gallery3d.filtershow.controller.BasicParameterStyle)1