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);
}
}
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]);
}
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);
}
Aggregations