diff options
7 files changed, 63 insertions, 61 deletions
diff --git a/res/layout/filtershow_control_color_chooser.xml b/res/layout/filtershow_control_color_chooser.xml index 088286a3f..706402c2e 100644 --- a/res/layout/filtershow_control_color_chooser.xml +++ b/res/layout/filtershow_control_color_chooser.xml @@ -73,9 +73,8 @@ </HorizontalScrollView> <Button android:id="@+id/draw_color_popupbutton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" + android:layout_width="@dimen/draw_style_icon_dim" + android:layout_height="@dimen/draw_style_icon_dim" android:background="@android:drawable/ic_menu_more" android:layout_margin="1dp" /> diff --git a/src/com/android/gallery3d/filtershow/controller/ColorChooser.java b/src/com/android/gallery3d/filtershow/controller/ColorChooser.java index e27df2243..7fcffd7d7 100644 --- a/src/com/android/gallery3d/filtershow/controller/ColorChooser.java +++ b/src/com/android/gallery3d/filtershow/controller/ColorChooser.java @@ -39,13 +39,7 @@ public class ColorChooser implements Control { R.id.draw_color_button05, }; private Button[] mButton = new Button[mButtonsID.length]; - int[] mBasColors = { - Color.RED & 0x80FFFFFF, - Color.GREEN & 0x80FFFFFF, - Color.BLUE & 0x80FFFFFF, - Color.BLACK & 0x80FFFFFF, - Color.WHITE & 0x80FFFFFF - }; + int mSelectedButton = 0; @Override @@ -56,6 +50,7 @@ public class ColorChooser implements Control { mSelected = res.getColor(R.color.color_chooser_slected_border); mEditor = editor; mContext = container.getContext(); + int iconDim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim); mParameter = (ParameterColor) parameter; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -64,18 +59,17 @@ public class ColorChooser implements Control { mTopView.setVisibility(View.VISIBLE); mIconButton.clear(); - LayoutParams lp = new LayoutParams(120, 120); - + LayoutParams lp = new LayoutParams(iconDim, iconDim); + int [] palette = mParameter.getColorPalette(); for (int i = 0; i < mButtonsID.length; i++) { final Button button = (Button) mTopView.findViewById(mButtonsID[i]); mButton[i] = button; float[] hsvo = new float[4]; - Color.colorToHSV(mBasColors[i], hsvo); - hsvo[OPACITY_OFFSET] = (0xFF & (mBasColors[i] >> 24)) / (float) 255; + Color.colorToHSV(palette[i], hsvo); + hsvo[OPACITY_OFFSET] = (0xFF & (palette[i] >> 24)) / (float) 255; button.setTag(hsvo); GradientDrawable sd = ((GradientDrawable) button.getBackground()); - - sd.setColor(mBasColors[i]); + sd.setColor(palette[i]); sd.setStroke(3, (mSelectedButton == i) ? mSelected : mTransparent); final int buttonNo = i; @@ -98,28 +92,29 @@ public class ColorChooser implements Control { } public void setColorSet(int[] basColors) { - for (int i = 0; i < mBasColors.length; i++) { - mBasColors[i] = basColors[i]; + int []palette = mParameter.getColorPalette(); + for (int i = 0; i < palette.length; i++) { + palette[i] = basColors[i]; float[] hsvo = new float[4]; - Color.colorToHSV(mBasColors[i], hsvo); - hsvo[OPACITY_OFFSET] = (0xFF & (mBasColors[i] >> 24)) / (float) 255; + Color.colorToHSV(palette[i], hsvo); + hsvo[OPACITY_OFFSET] = (0xFF & (palette[i] >> 24)) / (float) 255; mButton[i].setTag(hsvo); GradientDrawable sd = ((GradientDrawable) mButton[i].getBackground()); - sd.setColor(mBasColors[i]); + sd.setColor(palette[i]); } } public int[] getColorSet() { - return mBasColors; + return mParameter.getColorPalette(); } private void resetBorders() { + int []palette = mParameter.getColorPalette(); for (int i = 0; i < mButtonsID.length; i++) { final Button button = mButton[i]; - GradientDrawable sd = ((GradientDrawable) button.getBackground()); - sd.setColor(mBasColors[i]); + sd.setColor(palette[i]); sd.setStroke(3, (mSelectedButton == i) ? mSelected : mTransparent); } } @@ -129,6 +124,7 @@ public class ColorChooser implements Control { float[] hsvo = (float[]) button.getTag(); mParameter.setValue(Color.HSVToColor((int) (hsvo[OPACITY_OFFSET] * 255), hsvo)); resetBorders(); + mEditor.commitLocalRepresentation(); } @Override @@ -150,14 +146,15 @@ public class ColorChooser implements Control { } public void changeSelectedColor(float[] hsvo) { + int []palette = mParameter.getColorPalette(); int c = Color.HSVToColor((int) (hsvo[3] * 255), hsvo); final Button button = mButton[mSelectedButton]; - GradientDrawable sd = ((GradientDrawable) button.getBackground()); sd.setColor(c); - mBasColors[mSelectedButton] = c; + palette[mSelectedButton] = c; mParameter.setValue(Color.HSVToColor((int) (hsvo[OPACITY_OFFSET] * 255), hsvo)); button.setTag(hsvo); + mEditor.commitLocalRepresentation(); button.invalidate(); } diff --git a/src/com/android/gallery3d/filtershow/controller/ParameterColor.java b/src/com/android/gallery3d/filtershow/controller/ParameterColor.java index 4f8248fb0..0f1a65880 100644 --- a/src/com/android/gallery3d/filtershow/controller/ParameterColor.java +++ b/src/com/android/gallery3d/filtershow/controller/ParameterColor.java @@ -18,6 +18,8 @@ package com.android.gallery3d.filtershow.controller; import android.graphics.Color; +import java.util.Arrays; + public class ParameterColor implements Parameter { public static String sParameterType = "ParameterColor"; protected Control mControl; @@ -26,6 +28,13 @@ public class ParameterColor implements Parameter { String mParameterName; int mValue; public final int ID; + int[] mBasColors = { + Color.RED & 0x80FFFFFF, + Color.GREEN & 0x80FFFFFF, + Color.BLUE & 0x80FFFFFF, + Color.BLACK & 0x80FFFFFF, + Color.WHITE & 0x80FFFFFF + }; public ParameterColor(int id, int defaultColor) { ID = id; @@ -91,4 +100,16 @@ public class ParameterColor implements Parameter { public void setFilterView(FilterView editor) { mEditor = editor; } + + public void copyPalletFrom(ParameterColor parameterColor) { + System.arraycopy(parameterColor.mBasColors,0,mBasColors,0,mBasColors.length); + } + + public void setColorpalette(int[] palette) { + mBasColors = Arrays.copyOf(palette, palette.length); + } + + public int[] getColorPalette() { + return mBasColors; + } } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java b/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java index 2561dcd98..8cdad7eda 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java @@ -20,6 +20,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.util.Log; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -40,17 +41,10 @@ import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.filters.ImageFilterColorBorder; import com.android.gallery3d.filtershow.imageshow.ImageShow; -public class EditorColorBorder extends ParametricEditor implements FilterView { +public class EditorColorBorder extends ParametricEditor { private static final String LOGTAG = "EditorColorBorder"; public static final int ID = R.id.editorColorBorder; - int[] brushIcons = { - R.drawable.brush_flat, - R.drawable.brush_round, - R.drawable.brush_gauss, - R.drawable.brush_marker, - R.drawable.brush_spatter - }; int[] mBasColors = { FilterColorBorderRepresentation.DEFAULT_MENU_COLOR1, @@ -98,11 +92,13 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { if (mTabletUI != null) { mTabletUI.setColorBorderRepresentation(cbRep); } - return; + + } + cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_SIZE); + mParameterString = mContext.getString(R.string.color_border_size); + if (mEditControl != null) { + control(cbRep.getCurrentParam(), mEditControl); } - cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_COLOR); - mParameterString = mContext.getString(R.string.color_border_color); - control(cbRep.getCurrentParam(), mEditControl); } } @@ -176,6 +172,7 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { ColorChooser c = (ColorChooser) mControl; c.setColorSet(mBasColors); } + updateText(); mControl.updateUI(); mView.invalidate(); } @@ -207,14 +204,5 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { return null; } - @Override - public void computeIcon(int index, BitmapCaller caller) { - Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), brushIcons[index]); - caller.available(bitmap); - } - - public int getBrushIcon(int type) { - return brushIcons[type]; - } } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java b/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java index 04aee2751..518c56af0 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java @@ -16,19 +16,14 @@ package com.android.gallery3d.filtershow.editors; -import android.app.ActionBar; import android.content.Context; import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.drawable.GradientDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; -import android.widget.ImageButton; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.SeekBar; import android.widget.TextView; @@ -39,7 +34,6 @@ import com.android.gallery3d.filtershow.colorpicker.ColorListener; import com.android.gallery3d.filtershow.colorpicker.ColorOpacityView; import com.android.gallery3d.filtershow.colorpicker.ColorSVRectView; import com.android.gallery3d.filtershow.controller.BasicParameterInt; -import com.android.gallery3d.filtershow.controller.BasicParameterStyle; import com.android.gallery3d.filtershow.controller.ParameterColor; import com.android.gallery3d.filtershow.filters.FilterColorBorderRepresentation; @@ -47,12 +41,10 @@ import java.util.Arrays; public class EditorColorBorderTabletUI { private EditorColorBorder mEditorDraw; - private int[] mBrushIcons; private static int sIconDim = 120; private int mSelectedColorButton; private FilterColorBorderRepresentation mRep; private Button[] mColorButton; - private ImageButton[] mStyleButton; private ColorHueView mHueView; private ColorSVRectView mSatValView; private ColorOpacityView mOpacityView; @@ -87,13 +79,13 @@ public class EditorColorBorderTabletUI { ParameterColor color; color = (ParameterColor) mRep.getParam(FilterColorBorderRepresentation.PARAM_COLOR); + mBasColors = color.getColorPalette(); color.setValue(mBasColors[mSelectedColorButton]); } public EditorColorBorderTabletUI(EditorColorBorder editorDraw, Context context, View base) { mEditorDraw = editorDraw; mBasColors = editorDraw.mBasColors; - mBrushIcons = editorDraw.brushIcons; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout lp = (LinearLayout) inflater.inflate( diff --git a/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java index eb9f53020..4f625d7b4 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterColorBorderRepresentation.java @@ -22,14 +22,11 @@ import android.util.JsonWriter; import com.android.gallery3d.R; import com.android.gallery3d.filtershow.controller.BasicParameterInt; -import com.android.gallery3d.filtershow.controller.BasicParameterStyle; import com.android.gallery3d.filtershow.controller.Parameter; import com.android.gallery3d.filtershow.controller.ParameterColor; import com.android.gallery3d.filtershow.editors.EditorColorBorder; -import com.android.gallery3d.filtershow.editors.ImageOnlyEditor; import java.io.IOException; -import java.util.ArrayList; public class FilterColorBorderRepresentation extends FilterRepresentation { private static final String LOGTAG = "FilterColorBorderRepresentation"; @@ -43,8 +40,8 @@ public class FilterColorBorderRepresentation extends FilterRepresentation { public static int DEFAULT_MENU_COLOR3 = Color.GRAY; public static int DEFAULT_MENU_COLOR4 = 0xFFFFCCAA; public static int DEFAULT_MENU_COLOR5 = 0xFFAAAAAA; - private BasicParameterInt mParamSize = new BasicParameterInt(PARAM_SIZE, 4, 2, 30); - private BasicParameterInt mParamRadius = new BasicParameterInt(PARAM_RADIUS, 4, 2, 100); + private BasicParameterInt mParamSize = new BasicParameterInt(PARAM_SIZE, 3, 2, 30); + private BasicParameterInt mParamRadius = new BasicParameterInt(PARAM_RADIUS, 2, 0, 100); private ParameterColor mParamColor = new ParameterColor(PARAM_COLOR, DEFAULT_MENU_COLOR1); private Parameter[] mAllParam = { @@ -65,6 +62,12 @@ public class FilterColorBorderRepresentation extends FilterRepresentation { mParamColor.setValue(color); mParamSize.setValue(size); mParamRadius.setValue(radius); + mParamColor.setColorpalette(new int[]{ + DEFAULT_MENU_COLOR1, + DEFAULT_MENU_COLOR2, + DEFAULT_MENU_COLOR3, + DEFAULT_MENU_COLOR4, + DEFAULT_MENU_COLOR5}); } public String toString() { @@ -90,6 +93,7 @@ public class FilterColorBorderRepresentation extends FilterRepresentation { FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) a; setName(representation.getName()); setColor(representation.getColor()); + mParamColor.copyPalletFrom(representation.mParamColor); setBorderSize(representation.getBorderSize()); setBorderRadius(representation.getBorderRadius()); } diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java index d4b4e87fa..f3245739f 100644 --- a/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java +++ b/src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java @@ -205,6 +205,7 @@ public class FilterDrawRepresentation extends FilterRepresentation { public void useParametersFrom(FilterRepresentation a) { if (a instanceof FilterDrawRepresentation) { FilterDrawRepresentation representation = (FilterDrawRepresentation) a; + mParamColor.copyPalletFrom(representation.mParamColor); try { if (representation.mCurrent != null) { mCurrent = (StrokeData) representation.mCurrent.clone(); |