diff options
author | John Hoford <hoford@google.com> | 2013-04-08 19:32:45 -0700 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2013-04-08 19:48:35 -0700 |
commit | a5e47821f783cc14ba0ec3d3910af79dab3a870c (patch) | |
tree | 4ca09a111950c39ec1883d78ae986aec516ab76b /src/com/android/gallery3d/filtershow/editors/ParametricEditor.java | |
parent | d54c1e3d699defd21a581686eda4cdc94baa1fec (diff) | |
download | android_packages_apps_Snap-a5e47821f783cc14ba0ec3d3910af79dab3a870c.tar.gz android_packages_apps_Snap-a5e47821f783cc14ba0ec3d3910af79dab3a870c.tar.bz2 android_packages_apps_Snap-a5e47821f783cc14ba0ec3d3910af79dab3a870c.zip |
make basic editor based on ParametricEditor
Change-Id: Ie0a799d7e85f4e21fdd86ffbdca9814a3cc40c61
Diffstat (limited to 'src/com/android/gallery3d/filtershow/editors/ParametricEditor.java')
-rw-r--r-- | src/com/android/gallery3d/filtershow/editors/ParametricEditor.java | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java index cf00f4a8f..9c275d4f3 100644 --- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java +++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java @@ -34,6 +34,8 @@ import com.android.gallery3d.filtershow.controller.Control; import com.android.gallery3d.filtershow.controller.Parameter; import com.android.gallery3d.filtershow.controller.ParameterActionAndInt; import com.android.gallery3d.filtershow.controller.ParameterInteger; +import com.android.gallery3d.filtershow.controller.ParameterStyles; +import com.android.gallery3d.filtershow.controller.StyleChooser; import com.android.gallery3d.filtershow.controller.TitledSlider; import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation; import com.android.gallery3d.filtershow.filters.FilterRepresentation; @@ -49,7 +51,8 @@ public class ParametricEditor extends Editor { protected Control mControl; public static final int MINIMUM_WIDTH = 600; public static final int MINIMUM_HEIGHT = 800; - + View mActionButton; + View mEditControl; static HashMap<String, Class> portraitMap = new HashMap<String, Class>(); static HashMap<String, Class> landscapeMap = new HashMap<String, Class>(); static { @@ -57,6 +60,8 @@ public class ParametricEditor extends Editor { landscapeMap.put(ParameterInteger.sParameterType, TitledSlider.class); portraitMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class); landscapeMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class); + portraitMap.put(ParameterStyles.sParameterType, StyleChooser.class); + landscapeMap.put(ParameterStyles.sParameterType, StyleChooser.class); } static Constructor getConstructor(Class cl) { @@ -122,7 +127,7 @@ public class ParametricEditor extends Editor { }; } - // TODO: need a better way to decide when which representation + // TODO: need a better way to decide which representation static boolean useCompact(Context context) { WindowManager w = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)); Point size = new Point(); @@ -139,13 +144,23 @@ public class ParametricEditor extends Editor { return false; } + protected Parameter getParameterToEdit(FilterRepresentation rep) { + if (this instanceof Parameter) { + return (Parameter) this; + } else if (rep instanceof Parameter) { + return ((Parameter) rep); + } + return null; + } + @Override public void setUtilityPanelUI(View actionButton, View editControl) { + mActionButton = actionButton; + mEditControl = editControl; FilterRepresentation rep = getLocalRepresentation(); - if (this instanceof Parameter) { - control((Parameter) this, editControl); - } else if (rep instanceof Parameter) { - control((Parameter) rep, editControl); + Parameter param = getParameterToEdit(rep); + if (param != null) { + control(param, editControl); } else { mSeekBar = new SeekBar(editControl.getContext()); LayoutParams lp = new LinearLayout.LayoutParams( @@ -164,8 +179,10 @@ public class ParametricEditor extends Editor { if (c != null) { try { mControl = (Control) c.newInstance(); + p.setController(mControl); mControl.setUp((ViewGroup) editControl, p, this); + } catch (Exception e) { Log.e(LOGTAG, "Error in loading Control ", e); } |