Skip to content

Commit

Permalink
border UI editor
Browse files Browse the repository at this point in the history
bug:9470514
Change-Id: I4d5cd91775c9b8742f847fd9a955f6f28e66cd38
  • Loading branch information
jafu888 committed Aug 22, 2013
1 parent 73d0f42 commit 4979893
Show file tree
Hide file tree
Showing 15 changed files with 873 additions and 58 deletions.
230 changes: 230 additions & 0 deletions res/layout-land/filtershow_color_border_ui.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
<?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/color_border_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/color_border_size"/>

<TextView
android:id="@+id/colorBorderSizeValue"
android:layout_gravity="right"
android:layout_marginRight="8dip"
android:textStyle="bold"/>

<SeekBar
android:id="@+id/colorBorderSizeSeekBar"
android:layout_width="match_parent"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="fill_horizontal"
style="@style/FilterShowSlider"/>
</GridLayout>

<GridLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:columnCount="2"
android:orientation="horizontal">

<TextView
android:id="@+id/controlName2"
android:layout_gravity="left"
android:layout_marginLeft="8dip"
android:text="@string/color_border_corner_size"/>

<TextView
android:id="@+id/colorBorderCornerValue"
android:layout_gravity="right"
android:layout_marginRight="8dip"
android:textStyle="bold"/>

<SeekBar
android:id="@+id/colorBorderCornerSizeSeekBar"
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>
35 changes: 35 additions & 0 deletions res/menu/filtershow_menu_color_border.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<group android:id="@+id/curves_popupmenu">
<item
android:id="@+id/color_border_menu_corner_size"
android:title="@string/color_border_corner_size"/>
<item
android:id="@+id/color_border_menu_size"
android:title="@string/color_border_size"/>
<item
android:id="@+id/color_border_menu_color"
android:title="@string/color_border_color"/>
<item
android:id="@+id/color_border_menu_clear"
android:title="@string/color_border_clear"/>
</group>

</menu>
1 change: 1 addition & 0 deletions res/values/filtershow_ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<item type="id" name="imageCurves" />
<item type="id" name="imageZoom" />
<item type="id" name="editorDraw" />
<item type="id" name="editorColorBorder" />
<item type="id" name="editorRedEye" />
<item type="id" name="imageOnlyEditor" />
<item type="id" name="vignetteEditor" />
Expand Down
10 changes: 10 additions & 0 deletions res/values/filtershow_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@
<!-- Label for the removing drawing from screen [CHAR LIMIT=14] -->
<string name="draw_clear">Clear</string>


<!-- Label for the with of the border[CHAR LIMIT=14] -->
<string name="color_border_size">thickness</string>
<!-- Label for the border corner size (or rounding) [CHAR LIMIT=14] -->
<string name="color_border_corner_size">Corner Size</string>
<!-- Label for selecting the border color [CHAR LIMIT=14] -->
<string name="color_border_color">Color</string>
<!-- Label for the removing borders [CHAR LIMIT=14] -->
<string name="color_border_clear">Clear</string>

<!-- Label for the select the color [CHAR LIMIT=35] -->
<string name="color_pick_select">Choose custom color</string>
<!-- The title for the color pick dialog [CHAR LIMIT=20] -->
Expand Down
2 changes: 2 additions & 0 deletions src/com/android/gallery3d/filtershow/FilterShowActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import com.android.gallery3d.filtershow.editors.BasicEditor;
import com.android.gallery3d.filtershow.editors.Editor;
import com.android.gallery3d.filtershow.editors.EditorChanSat;
import com.android.gallery3d.filtershow.editors.EditorColorBorder;
import com.android.gallery3d.filtershow.editors.EditorCrop;
import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.editors.EditorGrad;
Expand Down Expand Up @@ -496,6 +497,7 @@ private void fillEditors() {
mEditorPlaceHolder.addEditor(new EditorChanSat());
mEditorPlaceHolder.addEditor(new EditorGrad());
mEditorPlaceHolder.addEditor(new EditorDraw());
mEditorPlaceHolder.addEditor(new EditorColorBorder());
mEditorPlaceHolder.addEditor(new BasicEditor());
mEditorPlaceHolder.addEditor(new ImageOnlyEditor());
mEditorPlaceHolder.addEditor(new EditorTinyPlanet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@

package com.android.gallery3d.filtershow.controller;

import android.graphics.Color;

public class ParameterColor implements Parameter {
public static String sParameterType = "ParameterColor";
protected Control mControl;
protected FilterView mEditor;
float[] mHSVO = new float[4];
String mParameterName;
int mValue;
public final int ID;
public final int ID;

public ParameterColor(int id) {
public ParameterColor(int id, int defaultColor) {
ID = id;
Color.colorToHSV(defaultColor, mHSVO);
mHSVO[3] = ((defaultColor >> 24) & 0xFF) / (float) 255;
}

@Override
Expand All @@ -36,32 +40,31 @@ public String getParameterType() {

public void setColor(float[] hsvo) {
mHSVO = hsvo;
mValue = Color.HSVToColor((int) (hsvo[3] * 255), mHSVO);
}

public float[] getColor() {
mHSVO[3] = getValue() ;
return mHSVO;
}


public void copyFrom(Parameter src) {
if (!(src instanceof BasicParameterInt)) {
if (!(src instanceof ParameterColor)) {
throw new IllegalArgumentException(src.getClass().getName());
}
BasicParameterInt p = (BasicParameterInt) src;
ParameterColor p = (ParameterColor) src;

mValue = p.mValue;
System.arraycopy(p.mHSVO, 0, mHSVO, 0, 4);
}


@Override
public String getParameterName() {
return mParameterName;
}

@Override
public String getValueString() {
return "("+Integer.toHexString(mValue)+")";
return "(" + Integer.toHexString(mValue) + ")";
}

@Override
Expand All @@ -75,6 +78,8 @@ public int getValue() {

public void setValue(int value) {
mValue = value;
Color.colorToHSV(mValue, mHSVO);
mHSVO[3] = ((mValue >> 24) & 0xFF) / (float) 255;
}

@Override
Expand Down
Loading

0 comments on commit 4979893

Please sign in to comment.