Loading res/layout/filtershow_control_color_chooser.xml +2 −3 Original line number Diff line number Diff line Loading @@ -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" /> Loading src/com/android/gallery3d/filtershow/controller/ColorChooser.java +20 −23 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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); Loading @@ -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; Loading @@ -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); } } Loading @@ -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 Loading @@ -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(); } Loading src/com/android/gallery3d/filtershow/controller/ParameterColor.java +21 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; } } src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java +9 −21 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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, Loading Loading @@ -98,13 +92,15 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { if (mTabletUI != null) { mTabletUI.setColorBorderRepresentation(cbRep); } return; } cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_COLOR); mParameterString = mContext.getString(R.string.color_border_color); cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_SIZE); mParameterString = mContext.getString(R.string.color_border_size); if (mEditControl != null) { control(cbRep.getCurrentParam(), mEditControl); } } } @Override public void openUtilityPanel(final LinearLayout accessoryViewList) { Loading Loading @@ -176,6 +172,7 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { ColorChooser c = (ColorChooser) mControl; c.setColorSet(mBasColors); } updateText(); mControl.updateUI(); mView.invalidate(); } Loading Loading @@ -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]; } } src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java +1 −9 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading @@ -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( Loading Loading
res/layout/filtershow_control_color_chooser.xml +2 −3 Original line number Diff line number Diff line Loading @@ -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" /> Loading
src/com/android/gallery3d/filtershow/controller/ColorChooser.java +20 −23 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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); Loading @@ -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; Loading @@ -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); } } Loading @@ -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 Loading @@ -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(); } Loading
src/com/android/gallery3d/filtershow/controller/ParameterColor.java +21 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; } }
src/com/android/gallery3d/filtershow/editors/EditorColorBorder.java +9 −21 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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, Loading Loading @@ -98,13 +92,15 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { if (mTabletUI != null) { mTabletUI.setColorBorderRepresentation(cbRep); } return; } cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_COLOR); mParameterString = mContext.getString(R.string.color_border_color); cbRep.setPramMode(FilterColorBorderRepresentation.PARAM_SIZE); mParameterString = mContext.getString(R.string.color_border_size); if (mEditControl != null) { control(cbRep.getCurrentParam(), mEditControl); } } } @Override public void openUtilityPanel(final LinearLayout accessoryViewList) { Loading Loading @@ -176,6 +172,7 @@ public class EditorColorBorder extends ParametricEditor implements FilterView { ColorChooser c = (ColorChooser) mControl; c.setColorSet(mBasColors); } updateText(); mControl.updateUI(); mView.invalidate(); } Loading Loading @@ -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]; } }
src/com/android/gallery3d/filtershow/editors/EditorColorBorderTabletUI.java +1 −9 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading @@ -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( Loading