OSDN Git Service

fix draw issues on tablet
authorJohn Hoford <hoford@google.com>
Tue, 20 Aug 2013 16:21:02 +0000 (09:21 -0700)
committerJohn Hoford <hoford@google.com>
Tue, 20 Aug 2013 19:19:41 +0000 (12:19 -0700)
bug:8579593
Change-Id: I75c9daa4d1048b02943ab33362dd8674faa39149

res/layout-land/filtershow_draw_ui.xml [new file with mode: 0644]
res/values/filtershow_values.xml
src/com/android/gallery3d/filtershow/colorpicker/ColorHueView.java
src/com/android/gallery3d/filtershow/colorpicker/ColorOpacityView.java
src/com/android/gallery3d/filtershow/controller/StyleChooser.java
src/com/android/gallery3d/filtershow/editors/EditorDraw.java
src/com/android/gallery3d/filtershow/editors/EditorDrawTabletUI.java [new file with mode: 0644]
src/com/android/gallery3d/filtershow/filters/FilterDrawRepresentation.java
src/com/android/gallery3d/filtershow/filters/ImageFilterDraw.java

diff --git a/res/layout-land/filtershow_draw_ui.xml b/res/layout-land/filtershow_draw_ui.xml
new file mode 100644 (file)
index 0000000..b98a87c
--- /dev/null
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/top"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:visibility="visible">
+
+    <FrameLayout
+            android:id="@+id/editorContainer"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="6"
+            android:layout_gravity="bottom">
+
+        <LinearLayout
+                android:id="@+id/controls"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="bottom"
+                android:orientation="vertical"
+                android:visibility="visible">
+
+            <Button
+                    android:id="@+id/clearButton"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"
+                    android:text="@string/draw_clear"/>
+
+            <GridLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"
+                    android:columnCount="2"
+                    android:orientation="horizontal">
+
+                <TextView
+                        android:id="@+id/controlName1"
+                        android:layout_gravity="left"
+                        android:layout_marginLeft="8dip"
+                        android:text="@string/draw_size"/>
+
+                <TextView
+                        android:id="@+id/drawSizeValue"
+                        android:layout_gravity="right"
+                        android:layout_marginRight="8dip"
+                        android:textStyle="bold"/>
+
+                <SeekBar
+                        android:id="@+id/drawSizeSeekBar"
+                        android:layout_width="match_parent"
+                        android:layout_column="0"
+                        android:layout_columnSpan="2"
+                        android:layout_gravity="fill_horizontal"
+                        style="@style/FilterShowSlider"/>
+            </GridLayout>
+
+            <HorizontalScrollView
+                    android:id="@+id/scrollList"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"
+                    android:scrollbars="none">
+
+                <LinearLayout
+                        android:id="@+id/listStyles"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:orientation="horizontal">
+
+                </LinearLayout>
+            </HorizontalScrollView>
+
+        </LinearLayout>
+
+        <LinearLayout
+                android:id="@+id/colorPicker"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical"
+                android:visibility="gone">
+
+            <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/draw_color"
+                    android:layout_marginLeft="8dip"
+                    android:id="@+id/textView"/>
+
+            <com.android.gallery3d.filtershow.colorpicker.ColorOpacityView
+                    android:id="@+id/colorOpacityView"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"/>
+
+            <com.android.gallery3d.filtershow.colorpicker.ColorSVRectView
+                    android:id="@+id/colorRectView"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="4"
+                    android:layout_marginRight="1dp"/>
+
+            <com.android.gallery3d.filtershow.colorpicker.ColorHueView
+                    android:id="@+id/ColorHueView"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"/>
+
+        </LinearLayout>
+    </FrameLayout>
+
+    <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_marginBottom="10dp"
+            android:layout_marginTop="10dp"
+            android:layout_marginLeft="1dp"
+            android:layout_marginRight="1dp">
+
+        <HorizontalScrollView
+                android:id="@+id/scrollList"
+                android:layout_width="0dp"
+                android:layout_weight="5"
+                android:layout_height="match_parent"
+                android:scrollbars="none">
+
+            <LinearLayout
+                    android:id="@+id/listColors"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:orientation="horizontal">
+
+                <Button
+                        android:id="@+id/draw_color_button01"
+                        android:layout_width="0dip"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1"
+                        android:background="@drawable/filtershow_color_picker_circle"
+                        android:layout_margin="2dp"/>
+
+                <Button
+                        android:id="@+id/draw_color_button02"
+                        android:layout_width="0dip"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1"
+                        android:background="@drawable/filtershow_color_picker_circle"
+                        android:layout_margin="2dp"/>
+
+                <Button
+                        android:id="@+id/draw_color_button03"
+                        android:layout_width="0dip"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1"
+                        android:background="@drawable/filtershow_color_picker_circle"
+                        android:layout_margin="2dp"/>
+
+                <Button
+                        android:id="@+id/draw_color_button04"
+                        android:layout_width="0dip"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1"
+                        android:background="@drawable/filtershow_color_picker_circle"
+                        android:layout_margin="2dp"/>
+
+                <Button
+                        android:id="@+id/draw_color_button05"
+                        android:layout_width="0dip"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="1"
+                        android:background="@drawable/filtershow_color_picker_circle"
+                        android:layout_margin="2dp"/>
+
+            </LinearLayout>
+        </HorizontalScrollView>
+
+        <Button
+                android:id="@+id/draw_color_popupbutton"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:background="@android:drawable/ic_menu_more"
+                android:layout_margin="1dp"/>
+    </LinearLayout>
+</LinearLayout>
index 01e3bdd..0cf723f 100644 (file)
@@ -51,4 +51,7 @@
     <!-- Grad filter minimum touch distance -->
     <dimen name="draw_rect_round">10dip</dimen>
 
+    <!-- Grad filter minimum touch distance -->
+    <dimen name="draw_style_icon_dim">64dip</dimen>
+
 </resources>
\ No newline at end of file
index f8cb81e..713ab11 100644 (file)
@@ -178,8 +178,8 @@ public class ColorHueView extends View implements ColorListener {
 
         mRect.left = mBorder;
         mRect.right = mWidth - mBorder;
-        mRect.top = mBorder;
-        mRect.bottom = mHeight - mBorder;
+        mRect.top = 0;
+        mRect.bottom = mHeight;
         canvas.drawRect(mRect,mCheckPaint);
         canvas.drawBitmap(mBitmap, null, mRect, mPaint);
 
index 5ace102..de4b2f9 100644 (file)
@@ -163,8 +163,8 @@ public class ColorOpacityView extends View implements ColorListener {
     protected void onDraw(Canvas canvas) {
         super.onDraw(canvas);
         canvas.drawColor(mBgcolor);
-        canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mCheckPaint);
-        canvas.drawRect(mBorder, mBorder, mWidth - mBorder, mHeight - mBorder, mBarPaint1);
+        canvas.drawRect(mBorder, 0, mWidth - mBorder, mHeight, mCheckPaint);
+        canvas.drawRect(mBorder, 0, mWidth - mBorder, mHeight, mBarPaint1);
         canvas.drawLine(mDotX, mDotY, mWidth - mBorder, mDotY, mLinePaint1);
         canvas.drawLine(mBorder, mDotY, mDotX, mDotY, mLinePaint2);
         if (mDotX != Float.NaN) {
index 97a47dd..f5afec9 100644 (file)
@@ -2,6 +2,7 @@ package com.android.gallery3d.filtershow.controller;
 
 import android.app.ActionBar.LayoutParams;
 import android.content.Context;
+import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -39,7 +40,9 @@ public class StyleChooser implements Control {
         mTopView.setVisibility(View.VISIBLE);
         int n = mParameter.getNumberOfStyles();
         mIconButton.clear();
-        LayoutParams lp = new LayoutParams(120, 120);
+        Resources res = context.getResources();
+        int dim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim);
+        LayoutParams lp = new LayoutParams(dim, dim);
         for (int i = 0; i < n; i++) {
             final ImageButton button = new ImageButton(context);
             button.setScaleType(ScaleType.CENTER_CROP);
index 9845382..97c889c 100644 (file)
 
 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.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.ViewGroup;
 import android.widget.Button;
 import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.PopupMenu;
+import android.widget.SeekBar;
 
 import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorHueView;
+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.BitmapCaller;
 import com.android.gallery3d.filtershow.controller.ColorChooser;
 import com.android.gallery3d.filtershow.controller.FilterView;
+import com.android.gallery3d.filtershow.controller.ParameterColor;
 import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation;
 import com.android.gallery3d.filtershow.filters.FilterRepresentation;
 import com.android.gallery3d.filtershow.filters.ImageFilterDraw;
@@ -52,6 +65,7 @@ public class EditorDraw extends ParametricEditor implements FilterView {
             R.drawable.brush_marker,
             R.drawable.brush_spatter
     };
+
     int[] mBasColors = {
             Color.RED & 0x80FFFFFF,
             Color.GREEN & 0x80FFFFFF,
@@ -59,7 +73,9 @@ public class EditorDraw extends ParametricEditor implements FilterView {
             Color.BLACK & 0x80FFFFFF,
             Color.WHITE & 0x80FFFFFF
     };
-    String mParameterString;
+    private EditorDrawTabletUI mTabletUI;
+    private String mParameterString;
+    private int mSelectedColorButton;
 
     public EditorDraw() {
         super(ID);
@@ -71,6 +87,9 @@ public class EditorDraw extends ParametricEditor implements FilterView {
         if (rep == null) {
             return "";
         }
+        if (mParameterString == null) {
+            mParameterString = "";
+        }
         String paramString;
         String val = rep.getValueString();
 
@@ -93,6 +112,14 @@ public class EditorDraw extends ParametricEditor implements FilterView {
         if (rep != null && getLocalRepresentation() instanceof FilterDrawRepresentation) {
             FilterDrawRepresentation drawRep = (FilterDrawRepresentation) getLocalRepresentation();
             mImageDraw.setFilterDrawRepresentation(drawRep);
+            if (!ParametricEditor.useCompact(mContext)) {
+                if (mTabletUI != null) {
+
+                    mTabletUI.setDrawRepresentation(drawRep);
+                }
+                return;
+            }
+
             drawRep.getParam(FilterDrawRepresentation.PARAM_STYLE).setFilterView(this);
             drawRep.setPramMode(FilterDrawRepresentation.PARAM_COLOR);
             mParameterString = mContext.getString(R.string.draw_hue);
@@ -147,9 +174,7 @@ public class EditorDraw extends ParametricEditor implements FilterView {
 
         switch (item.getItemId()) {
             case R.id.draw_menu_clear:
-                ImageDraw idraw = (ImageDraw) mImageShow;
-                idraw.resetParameter();
-                commitLocalRepresentation();
+                clearDrawing();
                 break;
             case R.id.draw_menu_size:
                 rep.setPramMode(FilterDrawRepresentation.PARAM_SIZE);
@@ -177,6 +202,31 @@ public class EditorDraw extends ParametricEditor implements FilterView {
         mView.invalidate();
     }
 
+    public void clearDrawing(){
+        ImageDraw idraw = (ImageDraw) mImageShow;
+        idraw.resetParameter();
+        commitLocalRepresentation();
+    }
+
+    @Override
+    public void setUtilityPanelUI(View actionButton, View editControl) {
+        if (ParametricEditor.useCompact(mContext)) {
+            super.setUtilityPanelUI(actionButton, editControl);
+            return;
+        }
+        mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+        if (mSeekBar != null) {
+            mSeekBar.setVisibility(View.GONE);
+        }
+        LayoutInflater inflater =
+                (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        LinearLayout lp = (LinearLayout) inflater.inflate(
+                R.layout.filtershow_draw_ui, (ViewGroup) editControl, true);
+
+        mTabletUI = new EditorDrawTabletUI(this, mContext, lp);
+
+    }
+
     FilterDrawRepresentation getDrawRep() {
         FilterRepresentation rep = getLocalRepresentation();
         if (rep instanceof FilterDrawRepresentation) {
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorDrawTabletUI.java b/src/com/android/gallery3d/filtershow/editors/EditorDrawTabletUI.java
new file mode 100644 (file)
index 0000000..01fd9ed
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.View;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import com.android.gallery3d.R;
+import com.android.gallery3d.filtershow.colorpicker.ColorHueView;
+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.FilterDrawRepresentation;
+
+import java.util.Arrays;
+
+public class EditorDrawTabletUI {
+    private EditorDraw mEditorDraw;
+    private int[] mBrushIcons;
+    private static int sIconDim = 120;
+    private int mSelectedColorButton;
+    private int mSelectedStyleButton;
+    private FilterDrawRepresentation mRep;
+    private Button[] mColorButton;
+    private ImageButton[] mStyleButton;
+    private ColorHueView mHueView;
+    private ColorSVRectView mSatValView;
+    private ColorOpacityView mOpacityView;
+
+    private int[] mBasColors;
+    private int mSelected;
+    private int mTransparent;
+    private SeekBar mdrawSizeSeekBar;
+    private int[] ids = {
+            R.id.draw_color_button01,
+            R.id.draw_color_button02,
+            R.id.draw_color_button03,
+            R.id.draw_color_button04,
+            R.id.draw_color_button05,
+    };
+
+    public void setDrawRepresentation(FilterDrawRepresentation rep) {
+        mRep = rep;
+        BasicParameterInt size;
+        size = (BasicParameterInt) mRep.getParam(FilterDrawRepresentation.PARAM_SIZE);
+        mdrawSizeSeekBar.setProgress(size.getDefaultValue());
+        mdrawSizeSeekBar.setMax(size.getMaximum() - size.getMinimum());
+        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);
+    }
+
+    public EditorDrawTabletUI(EditorDraw editorDraw, Context context, LinearLayout lp) {
+        mEditorDraw = editorDraw;
+        mBasColors = editorDraw.mBasColors;
+        mBrushIcons = editorDraw.brushIcons;
+        Resources res = context.getResources();
+        sIconDim = res.getDimensionPixelSize(R.dimen.draw_style_icon_dim);
+        LinearLayout buttonContainer = (LinearLayout) lp.findViewById(R.id.listStyles);
+
+        mdrawSizeSeekBar = (SeekBar) lp.findViewById(R.id.drawSizeSeekBar);
+        TextView drawSizeValue = (TextView) lp.findViewById(R.id.drawSizeValue);
+
+        Button clearButton = (Button) lp.findViewById(R.id.clearButton);
+        clearButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                mEditorDraw.clearDrawing();
+            }
+        });
+
+        mdrawSizeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+
+            @Override
+            public void onStopTrackingTouch(SeekBar seekBar) {
+            }
+
+            @Override
+            public void onStartTrackingTouch(SeekBar seekBar) {
+            }
+
+            @Override
+            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+                BasicParameterInt size;
+                size = (BasicParameterInt) mRep.getParam(FilterDrawRepresentation.PARAM_SIZE);
+                size.setValue(progress + size.getMinimum());
+                mEditorDraw.commitLocalRepresentation();
+            }
+        });
+
+        ActionBar.LayoutParams params = new ActionBar.LayoutParams(sIconDim, sIconDim);
+        mStyleButton = new ImageButton[mBrushIcons.length];
+        for (int i = 0; i < mBrushIcons.length; i++) {
+            final ImageButton button = new ImageButton(context);
+            mStyleButton[i] = button;
+            button.setScaleType(ImageView.ScaleType.CENTER_CROP);
+            button.setLayoutParams(params);
+            Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), mBrushIcons[i]);
+            button.setImageBitmap(bitmap);
+            button.setBackgroundResource(android.R.color.transparent);
+            buttonContainer.addView(button);
+            final int current = i;
+            button.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    mSelectedStyleButton = current;
+                    if (mRep == null) {
+                        return;
+                    }
+                    BasicParameterStyle style = (BasicParameterStyle)
+                            mRep.getParam(FilterDrawRepresentation.PARAM_STYLE);
+                    style.setSelected(current);
+                    resetStyle();
+                    mEditorDraw.commitLocalRepresentation();
+                }
+            });
+        }
+
+        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;
+                    }
+                    ParameterColor pram;
+                    pram = (ParameterColor) mRep.getParam(FilterDrawRepresentation.PARAM_COLOR);
+                    pram.setValue(mBasColors[mSelectedColorButton]);
+                    mEditorDraw.commitLocalRepresentation();
+                    mHueView.setColor(hsvo);
+                    mSatValView.setColor(hsvo);
+                    mOpacityView.setColor(hsvo);
+                }
+            });
+        }
+        mHueView = (ColorHueView) lp.findViewById(R.id.ColorHueView);
+        mSatValView = (ColorSVRectView) lp.findViewById(R.id.colorRectView);
+        mOpacityView = (ColorOpacityView) lp.findViewById(R.id.colorOpacityView);
+        mHueView.addColorListener(mSatValView);
+        mSatValView.addColorListener(mHueView);
+        mHueView.addColorListener(mOpacityView);
+        mSatValView.addColorListener(mOpacityView);
+        mOpacityView.addColorListener(mSatValView);
+        mOpacityView.addColorListener(mHueView);
+        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(FilterDrawRepresentation.PARAM_COLOR);
+                pram.setValue(color);
+                mEditorDraw.commitLocalRepresentation();
+            }
+        };
+        mHueView.addColorListener(colorListener);
+        mSatValView.addColorListener(colorListener);
+        mOpacityView.addColorListener(colorListener);
+    }
+
+    public void resetStyle() {
+        for (int i = 0; i < mStyleButton.length; i++) {
+            int rid = (i == mSelectedStyleButton) ? android.R.color.holo_blue_light :
+                    android.R.color.transparent;
+            mStyleButton[i].setBackgroundResource(rid);
+
+        }
+    }
+
+    private void resetBorders() {
+        for (int i = 0; i < ids.length; i++) {
+            final Button button = mColorButton[i];
+
+            GradientDrawable sd = ((GradientDrawable) button.getBackground());
+            sd.setColor(mBasColors[i]);
+            sd.setStroke(3, (mSelectedColorButton == i) ? mSelected : mTransparent);
+        }
+    }
+}
index d47d735..f05910b 100644 (file)
@@ -47,7 +47,6 @@ public class FilterDrawRepresentation extends FilterRepresentation {
     public static final int PARAM_STYLE = 1;
     public static final int PARAM_COLOR = 2;
     private BasicParameterInt mParamSize = new BasicParameterInt(PARAM_SIZE, 20, 2, 300);
-
     private BasicParameterStyle mParamStyle = new BasicParameterStyle(PARAM_STYLE, 5);
     ParameterColor mParamColor = new ParameterColor(PARAM_COLOR);
     int mParamMode;
index 3ae316d..8fd5b02 100644 (file)
@@ -230,10 +230,11 @@ public class ImageFilterDraw extends ImageFilter {
         paint.setStrokeWidth(40);
 
         if (mParameters.getDrawing().isEmpty() && mParameters.getCurrentDrawing() == null) {
+            mOverlayBitmap = null;
+            mCachedStrokes = -1;
             return;
         }
         if (quality == FilterEnvironment.QUALITY_FINAL) {
-            Log.v(LOGTAG,"################### paint QUALITY_FINAL");
 
             for (FilterDrawRepresentation.StrokeData strokeData : mParameters.getDrawing()) {
                 paint(strokeData, canvas, originalRotateToScreen, quality);
@@ -258,8 +259,6 @@ public class ImageFilterDraw extends ImageFilter {
 
         StrokeData stroke = mParameters.getCurrentDrawing();
         if (stroke != null) {
-            Log.v(LOGTAG,"################### paint current");
-
             paint(stroke, canvas, originalRotateToScreen, quality);
         }
     }
@@ -272,7 +271,6 @@ public class ImageFilterDraw extends ImageFilter {
         for (int i = mCachedStrokes; i < n; i++) {
             paint(v.get(i), drawCache, originalRotateToScreen, FilterEnvironment.QUALITY_PREVIEW);
         }
-        Log.v(LOGTAG,"################### filling buffer with "+mCachedStrokes+" to "+n);
         mCachedStrokes = n;
     }