1915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford/* 2915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * Copyright (C) 2013 The Android Open Source Project 3915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * 4915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * Licensed under the Apache License, Version 2.0 (the "License"); 5915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * you may not use this file except in compliance with the License. 6915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * You may obtain a copy of the License at 7915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * 8915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * http://www.apache.org/licenses/LICENSE-2.0 9915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * 10915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * Unless required by applicable law or agreed to in writing, software 11915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * distributed under the License is distributed on an "AS IS" BASIS, 12915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * See the License for the specific language governing permissions and 14915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford * limitations under the License. 15915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford */ 16915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 17915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordpackage com.android.gallery3d.filtershow.editors; 18915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 1997d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.app.ActionBar; 20915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.content.Context; 2197d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.content.res.Resources; 22f4b659334750a5aa75f929d18857a2ab93c9d939John Hofordimport android.graphics.Bitmap; 23f4b659334750a5aa75f929d18857a2ab93c9d939John Hofordimport android.graphics.BitmapFactory; 24a4f38c0f8f70c998391780b672eea5d5e49277c7John Hofordimport android.graphics.Color; 2597d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.graphics.drawable.GradientDrawable; 2697d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.view.LayoutInflater; 275921b53e411a1ee5de8daea34fda90c2ada31974John Hofordimport android.view.Menu; 28915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.view.MenuItem; 29915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.view.View; 30915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.view.View.OnClickListener; 3197d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.view.ViewGroup; 32915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.widget.Button; 33915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.widget.FrameLayout; 3497d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.widget.ImageButton; 3597d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.widget.ImageView; 36915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.widget.LinearLayout; 37915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport android.widget.PopupMenu; 3897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport android.widget.SeekBar; 39915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 40915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport com.android.gallery3d.R; 4164fc2ed005e2f1dc9ed0b34481c46a370c244b86John Hofordimport com.android.gallery3d.filtershow.FilterShowActivity; 4297d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport com.android.gallery3d.filtershow.colorpicker.ColorHueView; 4397d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport com.android.gallery3d.filtershow.colorpicker.ColorListener; 4497d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport com.android.gallery3d.filtershow.colorpicker.ColorOpacityView; 4597d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport com.android.gallery3d.filtershow.colorpicker.ColorSVRectView; 46f4b659334750a5aa75f929d18857a2ab93c9d939John Hofordimport com.android.gallery3d.filtershow.controller.BitmapCaller; 47a4f38c0f8f70c998391780b672eea5d5e49277c7John Hofordimport com.android.gallery3d.filtershow.controller.ColorChooser; 48f4b659334750a5aa75f929d18857a2ab93c9d939John Hofordimport com.android.gallery3d.filtershow.controller.FilterView; 4997d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hofordimport com.android.gallery3d.filtershow.controller.ParameterColor; 5019161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hofordimport com.android.gallery3d.filtershow.filters.FilterDrawRepresentation; 5119161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hofordimport com.android.gallery3d.filtershow.filters.FilterRepresentation; 52915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport com.android.gallery3d.filtershow.filters.ImageFilterDraw; 53915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hofordimport com.android.gallery3d.filtershow.imageshow.ImageDraw; 54915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 55f4b659334750a5aa75f929d18857a2ab93c9d939John Hofordpublic class EditorDraw extends ParametricEditor implements FilterView { 56915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford private static final String LOGTAG = "EditorDraw"; 57915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford public static final int ID = R.id.editorDraw; 5819161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford public ImageDraw mImageDraw; 59f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford private static final int MODE_SIZE = FilterDrawRepresentation.PARAM_SIZE; 60f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford private static final int MODE_SIZEE = FilterDrawRepresentation.PARAM_SIZE; 61f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford private static final int MODE_STYLE = FilterDrawRepresentation.PARAM_STYLE; 62a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford private static final int MODE_COLOR = FilterDrawRepresentation.PARAM_COLOR; 63f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford int[] brushIcons = { 64f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford R.drawable.brush_flat, 65d3ca24707a0a0ab019dec0a17b0d540b685e459aJohn Hoford R.drawable.brush_round, 66a7836003e689af28725930ba6a2c191275876577John Hoford R.drawable.brush_gauss, 67f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford R.drawable.brush_marker, 68f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford R.drawable.brush_spatter 69f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford }; 7097d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 71a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford int[] mBasColors = { 7249798939f1bc58eaf5842bbc8bc5424284ab7930John Hoford FilterDrawRepresentation.DEFAULT_MENU_COLOR1, 7349798939f1bc58eaf5842bbc8bc5424284ab7930John Hoford FilterDrawRepresentation.DEFAULT_MENU_COLOR2, 7449798939f1bc58eaf5842bbc8bc5424284ab7930John Hoford FilterDrawRepresentation.DEFAULT_MENU_COLOR3, 7549798939f1bc58eaf5842bbc8bc5424284ab7930John Hoford FilterDrawRepresentation.DEFAULT_MENU_COLOR4, 7649798939f1bc58eaf5842bbc8bc5424284ab7930John Hoford FilterDrawRepresentation.DEFAULT_MENU_COLOR5, 77a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford }; 7897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford private EditorDrawTabletUI mTabletUI; 7997d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford private String mParameterString; 8097d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford private int mSelectedColorButton; 815921b53e411a1ee5de8daea34fda90c2ada31974John Hoford private String mDrawString = null; 82915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 83915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford public EditorDraw() { 84915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford super(ID); 85915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 86915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 87915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford @Override 88f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford public String calculateUserMessage(Context context, String effectName, Object parameterValue) { 89f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford FilterDrawRepresentation rep = getDrawRep(); 905921b53e411a1ee5de8daea34fda90c2ada31974John Hoford if (mDrawString != null) { 915921b53e411a1ee5de8daea34fda90c2ada31974John Hoford mImageDraw.displayDrawLook(); 925921b53e411a1ee5de8daea34fda90c2ada31974John Hoford return mDrawString; 935921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 94f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford if (rep == null) { 95f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford return ""; 96f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 975921b53e411a1ee5de8daea34fda90c2ada31974John Hoford if (!ParametricEditor.useCompact(mContext)) { 985921b53e411a1ee5de8daea34fda90c2ada31974John Hoford 995921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 10097d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford if (mParameterString == null) { 10197d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford mParameterString = ""; 10297d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 103f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford String paramString; 104f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford String val = rep.getValueString(); 1054e289659f746cf659e300c9fcd2048960e115f0cJohn Hoford 1064e289659f746cf659e300c9fcd2048960e115f0cJohn Hoford mImageDraw.displayDrawLook(); 107f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford return mParameterString + val; 108f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 109f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford 110f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford @Override 111915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford public void createEditor(Context context, FrameLayout frameLayout) { 11219161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford mView = mImageShow = mImageDraw = new ImageDraw(context); 113f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford super.createEditor(context, frameLayout); 11419161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford mImageDraw.setEditor(this); 11519161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford 116915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 117915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 118915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford @Override 11919161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford public void reflectCurrentFilter() { 12019161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford super.reflectCurrentFilter(); 12119161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford FilterRepresentation rep = getLocalRepresentation(); 12219161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford if (rep != null && getLocalRepresentation() instanceof FilterDrawRepresentation) { 12319161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford FilterDrawRepresentation drawRep = (FilterDrawRepresentation) getLocalRepresentation(); 12419161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford mImageDraw.setFilterDrawRepresentation(drawRep); 12597d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford if (!ParametricEditor.useCompact(mContext)) { 12697d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford if (mTabletUI != null) { 12797d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 12897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford mTabletUI.setDrawRepresentation(drawRep); 12997d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 13097d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford return; 13197d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 13297d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 133f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford drawRep.getParam(FilterDrawRepresentation.PARAM_STYLE).setFilterView(this); 134a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford drawRep.setPramMode(FilterDrawRepresentation.PARAM_COLOR); 135fddcb482a89e6c30f74f0c8cf7d9d1e6e31a5789John Hoford mParameterString = mContext.getString(R.string.draw_color); 136f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford control(drawRep.getCurrentParam(), mEditControl); 13719161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford } 13819161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford } 13919161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford 14019161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford @Override 141915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford public void openUtilityPanel(final LinearLayout accessoryViewList) { 142001283a72d451999e3308f45dc365d4defc0af39John Hoford Button view = (Button) accessoryViewList.findViewById(R.id.applyEffect); 14319161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford 1445921b53e411a1ee5de8daea34fda90c2ada31974John Hoford view.setText(mContext.getString(R.string.draw_color)); 1455921b53e411a1ee5de8daea34fda90c2ada31974John Hoford view.setOnClickListener(new OnClickListener() { 1465921b53e411a1ee5de8daea34fda90c2ada31974John Hoford 1475921b53e411a1ee5de8daea34fda90c2ada31974John Hoford @Override 1485921b53e411a1ee5de8daea34fda90c2ada31974John Hoford public void onClick(View arg0) { 1495921b53e411a1ee5de8daea34fda90c2ada31974John Hoford showPopupMenu(accessoryViewList); 1505921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 1515921b53e411a1ee5de8daea34fda90c2ada31974John Hoford }); 1525921b53e411a1ee5de8daea34fda90c2ada31974John Hoford 153915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 154915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 15591be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard @Override 15691be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard public boolean showsSeekBar() { 15791be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard return false; 15891be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard } 15991be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard 160915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford private void showPopupMenu(LinearLayout accessoryViewList) { 161001283a72d451999e3308f45dc365d4defc0af39John Hoford final Button button = (Button) accessoryViewList.findViewById( 162001283a72d451999e3308f45dc365d4defc0af39John Hoford R.id.applyEffect); 163915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford if (button == null) { 164915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford return; 165915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 16619161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford final PopupMenu popupMenu = new PopupMenu(mImageShow.getActivity(), button); 167915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_draw, popupMenu.getMenu()); 1685921b53e411a1ee5de8daea34fda90c2ada31974John Hoford if (!ParametricEditor.useCompact(mContext)) { 1695921b53e411a1ee5de8daea34fda90c2ada31974John Hoford Menu menu = popupMenu.getMenu(); 1705921b53e411a1ee5de8daea34fda90c2ada31974John Hoford int count = menu.size(); 1715921b53e411a1ee5de8daea34fda90c2ada31974John Hoford for (int i = 0; i < count; i++) { 1725921b53e411a1ee5de8daea34fda90c2ada31974John Hoford MenuItem item = menu.getItem(i); 1735921b53e411a1ee5de8daea34fda90c2ada31974John Hoford if (item.getItemId() != R.id.draw_menu_clear) { 1745921b53e411a1ee5de8daea34fda90c2ada31974John Hoford item.setVisible(false); 1755921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 176915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 1775921b53e411a1ee5de8daea34fda90c2ada31974John Hoford popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 1785921b53e411a1ee5de8daea34fda90c2ada31974John Hoford 1795921b53e411a1ee5de8daea34fda90c2ada31974John Hoford @Override 1805921b53e411a1ee5de8daea34fda90c2ada31974John Hoford public boolean onMenuItemClick(MenuItem item) { 1815921b53e411a1ee5de8daea34fda90c2ada31974John Hoford clearDrawing(); 1825921b53e411a1ee5de8daea34fda90c2ada31974John Hoford return true; 1835921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 1845921b53e411a1ee5de8daea34fda90c2ada31974John Hoford }); 1855921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } else { 1865921b53e411a1ee5de8daea34fda90c2ada31974John Hoford popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 1875921b53e411a1ee5de8daea34fda90c2ada31974John Hoford 1885921b53e411a1ee5de8daea34fda90c2ada31974John Hoford @Override 1895921b53e411a1ee5de8daea34fda90c2ada31974John Hoford public boolean onMenuItemClick(MenuItem item) { 1905921b53e411a1ee5de8daea34fda90c2ada31974John Hoford selectMenuItem(item); 1915921b53e411a1ee5de8daea34fda90c2ada31974John Hoford return true; 1925921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 1935921b53e411a1ee5de8daea34fda90c2ada31974John Hoford }); 1945921b53e411a1ee5de8daea34fda90c2ada31974John Hoford } 195915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford popupMenu.show(); 19664fc2ed005e2f1dc9ed0b34481c46a370c244b86John Hoford ((FilterShowActivity)mContext).onShowMenu(popupMenu); 197915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 198915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 199f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford protected void selectMenuItem(MenuItem item) { 200f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford ImageFilterDraw filter = (ImageFilterDraw) mImageShow.getCurrentFilter(); 201f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford FilterDrawRepresentation rep = getDrawRep(); 202f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford if (rep == null) { 203f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford return; 204f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 205915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford 206f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford switch (item.getItemId()) { 207f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford case R.id.draw_menu_clear: 20897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford clearDrawing(); 209f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford break; 210f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford case R.id.draw_menu_size: 211f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford rep.setPramMode(FilterDrawRepresentation.PARAM_SIZE); 212f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford break; 213f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford case R.id.draw_menu_style: 214f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford rep.setPramMode(FilterDrawRepresentation.PARAM_STYLE); 215f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford break; 216a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford case R.id.draw_menu_color: 217a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford rep.setPramMode(FilterDrawRepresentation.PARAM_COLOR); 218f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford break; 219f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 220f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford if (item.getItemId() != R.id.draw_menu_clear) { 221f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford mParameterString = item.getTitle().toString(); 222fddcb482a89e6c30f74f0c8cf7d9d1e6e31a5789John Hoford updateText(); 223f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 224a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford if (mControl instanceof ColorChooser) { 225a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford ColorChooser c = (ColorChooser) mControl; 226a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford mBasColors = c.getColorSet(); 227a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford } 228f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford control(rep.getCurrentParam(), mEditControl); 229a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford if (mControl instanceof ColorChooser) { 230a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford ColorChooser c = (ColorChooser) mControl; 231a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford c.setColorSet(mBasColors); 232a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford } 233f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford mControl.updateUI(); 234f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford mView.invalidate(); 235915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 23619161944e0efb1ffe23274d7cf5315ce047e9dacJohn Hoford 23797d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford public void clearDrawing(){ 23897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford ImageDraw idraw = (ImageDraw) mImageShow; 23997d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford idraw.resetParameter(); 24097d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford commitLocalRepresentation(); 24197d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 24297d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 24397d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford @Override 24497d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford public void setUtilityPanelUI(View actionButton, View editControl) { 24597d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford if (ParametricEditor.useCompact(mContext)) { 24697d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford super.setUtilityPanelUI(actionButton, editControl); 24797d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford return; 24897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 2495921b53e411a1ee5de8daea34fda90c2ada31974John Hoford 25097d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar); 25197d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford if (mSeekBar != null) { 25297d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford mSeekBar.setVisibility(View.GONE); 25397d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 25497d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford LayoutInflater inflater = 25597d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 25697d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford LinearLayout lp = (LinearLayout) inflater.inflate( 25797d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford R.layout.filtershow_draw_ui, (ViewGroup) editControl, true); 25897d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 25997d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford mTabletUI = new EditorDrawTabletUI(this, mContext, lp); 2605921b53e411a1ee5de8daea34fda90c2ada31974John Hoford mDrawString = mContext.getResources().getString(R.string.imageDraw).toUpperCase(); 2615921b53e411a1ee5de8daea34fda90c2ada31974John Hoford setMenuIcon(true); 26297d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 26397d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford } 26497d76abecd25656bcd622c56d9cf4e2c9b236ea3John Hoford 265f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford FilterDrawRepresentation getDrawRep() { 266f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford FilterRepresentation rep = getLocalRepresentation(); 267f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford if (rep instanceof FilterDrawRepresentation) { 268f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford return (FilterDrawRepresentation) rep; 269f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 270f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford return null; 271f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford } 272f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford 273f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford @Override 274f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford public void computeIcon(int index, BitmapCaller caller) { 275f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), brushIcons[index]); 276f4b659334750a5aa75f929d18857a2ab93c9d939John Hoford caller.available(bitmap); 277915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford } 2784e289659f746cf659e300c9fcd2048960e115f0cJohn Hoford 279a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford public int getBrushIcon(int type) { 280a4f38c0f8f70c998391780b672eea5d5e49277c7John Hoford return brushIcons[type]; 2814e289659f746cf659e300c9fcd2048960e115f0cJohn Hoford } 2824e289659f746cf659e300c9fcd2048960e115f0cJohn Hoford 283915d60a378b0ca7bbe3af6312ccd2f4b94eb2da1John Hoford} 284