<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/background_main_toolbar" >
+ android:background="@color/background_screen" >
<LinearLayout
android:id="@+id/imageStatePanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
+ android:background="@color/background_main_toolbar"
custom:max_width="600dip"
android:orientation="vertical">
<LinearLayout
android:id="@+id/filterButtonsList"
android:layout_width="fill_parent"
- android:layout_height="96dip"
+ android:layout_height="@dimen/thumbnail_size"
android:background="@color/background_main_toolbar"
android:orientation="horizontal"
android:visibility="gone" >
<HorizontalScrollView
android:id="@+id/fxList"
android:layout_width="match_parent"
- android:layout_height="96dip"
+ android:layout_height="@dimen/thumbnail_size"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/listFilters"
android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:layout_marginLeft="@dimen/thumbnail_margin"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
<HorizontalScrollView
android:id="@+id/bordersList"
android:layout_width="match_parent"
- android:layout_height="96dip"
+ android:layout_height="@dimen/thumbnail_size"
android:visibility="gone"
android:scrollbars="none" >
android:id="@+id/listBorders"
android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:layout_marginLeft="@dimen/thumbnail_margin"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
<HorizontalScrollView
android:id="@+id/geometryList"
android:layout_width="fill_parent"
- android:layout_height="96dip"
+ android:layout_height="@dimen/thumbnail_size"
android:background="@color/background_main_toolbar"
android:visibility="gone"
android:scrollbars="none" >
<HorizontalScrollView
android:id="@+id/colorsFxList"
android:layout_width="fill_parent"
- android:layout_height="96dip"
+ android:layout_height="@dimen/thumbnail_size"
android:background="@color/background_main_toolbar"
android:visibility="gone"
android:scrollbars="none" >
android:id="@+id/listColorsFx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginLeft="@dimen/thumbnail_margin"
android:orientation="horizontal" >
<com.android.gallery3d.filtershow.ui.ImageButtonTitle
<ImageButton
android:id="@+id/fxButton"
- android:layout_width="wrap_content"
+ android:layout_width="@dimen/thumbnail_size"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/filtershow_button_background"
<ImageButton
android:id="@+id/borderButton"
- android:layout_width="wrap_content"
+ android:layout_width="@dimen/thumbnail_size"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/filtershow_button_background"
<ImageButton
android:id="@+id/geometryButton"
- android:layout_width="wrap_content"
+ android:layout_width="@dimen/thumbnail_size"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/filtershow_button_background"
<ImageButton
android:id="@+id/colorsButton"
- android:layout_width="wrap_content"
+ android:layout_width="@dimen/thumbnail_size"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/filtershow_button_background"
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<resources>
+ <!-- configuration for filtershow UI -->
+ <dimen name="thumbnail_size">128dip</dimen>
+ <dimen name="thumbnail_margin">3dip</dimen>
+</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<resources>
+ <!-- configuration for filtershow UI -->
+ <dimen name="thumbnail_size">128dip</dimen>
+ <dimen name="thumbnail_margin">3dip</dimen>
+</resources>
<!-- for manage cache bar -->
<dimen name="manage_cache_bottom_height">48dp</dimen>
+
+ <!-- configuration for filtershow UI -->
+ <dimen name="thumbnail_size">96dip</dimen>
+ <dimen name="thumbnail_margin">3dip</dimen>
</resources>
<color name="red">#FF0000</color>
<color name="blue">#0000FF</color>
<color name="text_toolbar">#FFFFFF</color>
+ <color name="background_screen">#000000</color>
<color name="background_toolbar">#363949</color>
<color name="background_main_toolbar">#1e2028</color>
<color name="toolbar_separation_line">#333333</color>
ImageFilterRS.setRenderScriptContext(this);
+ ImageShow.setDefaultBackgroundColor(getResources().getColor(R.color.background_screen));
// TODO: get those values from XML.
ImageShow.setTextSize((int) getPixelsFromDip(12));
ImageShow.setTextPadding((int) getPixelsFromDip(10));
ImageButtonTitle.setTextSize((int) getPixelsFromDip(12));
ImageButtonTitle.setTextPadding((int) getPixelsFromDip(10));
- ImageSmallFilter.setMargin((int) getPixelsFromDip(6));
+ ImageSmallFilter.setMargin((int) getPixelsFromDip(3));
ImageSmallFilter.setTextMargin((int) getPixelsFromDip(4));
mImageBorderSize = (int) getPixelsFromDip(20);
Drawable curveHandle = getResources().getDrawable(R.drawable.camera_crop_holo);
filter.setSelected(true);
mCurrentImageSmallFilter = filter;
- filter.setPreviousImageSmallFilter(null);
filter.setImageFilter(new ImageFilterFx(null,getString(R.string.ffx_original)));
filter.setController(this);
for (int i = 0; i < p; i++) {
filter = new ImageSmallFilter(this);
-
- filter.setPreviousImageSmallFilter(previousFilter);
filter.setImageFilter(fxArray[i]);
filter.setController(this);
filter.setImageLoader(mImageLoader);
ImageSmallFilter previousFilter = null;
for (int i = 0; i < p; i++) {
ImageSmallBorder filter = new ImageSmallBorder(this);
- filter.setPreviousImageSmallFilter(previousFilter);
filter.setImageFilter(borders[i]);
filter.setController(this);
filter.setBorder(true);
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
private boolean mDirtyGeometry = true;
private Bitmap mBackgroundImage = null;
- // TODO: remove protected here, it should be private
+ private final boolean USE_BACKGROUND_IMAGE = false;
+ private static int mBackgroundColor = Color.RED;
+
+ // TODO: remove protected here, it should be private
protected Bitmap mForegroundImage = null;
protected Bitmap mFilteredImage = null;
private SeekBar mSeekBar = null;
private PanelController mController = null;
+ public static void setDefaultBackgroundColor(int value) {
+ mBackgroundColor = value;
+ }
+
public static void setTextSize(int value) {
mTextSize = value;
}
}
public void drawBackground(Canvas canvas) {
- if (mBackgroundImage == null) {
- mBackgroundImage = mImageLoader.getBackgroundBitmap(getResources());
- }
- if (mBackgroundImage != null) {
- Rect s = new Rect(0, 0, mBackgroundImage.getWidth(),
- mBackgroundImage.getHeight());
- Rect d = new Rect(0, 0, getWidth(), getHeight());
- canvas.drawBitmap(mBackgroundImage, s, d, mPaint);
+ if (USE_BACKGROUND_IMAGE) {
+ if (mBackgroundImage == null) {
+ mBackgroundImage = mImageLoader.getBackgroundBitmap(getResources());
+ }
+ if (mBackgroundImage != null) {
+ Rect s = new Rect(0, 0, mBackgroundImage.getWidth(),
+ mBackgroundImage.getHeight());
+ Rect d = new Rect(0, 0, getWidth(), getHeight());
+ canvas.drawBitmap(mBackgroundImage, s, d, mPaint);
+ }
+ } else {
+ canvas.drawColor(mBackgroundColor);
}
}
@Override
public void onDraw(Canvas canvas) {
getFilteredImage();
- if (mIsSelected) {
- canvas.drawColor(mSelectedBackgroundColor);
- } else {
- canvas.drawColor(mBackgroundColor);
- }
+ canvas.drawColor(mBackgroundColor);
// TODO: simplify & make faster...
mPaint.setColor(mInnerBorderColor);
- RectF border = new RectF(mMargin, mMargin, getWidth() - mMargin - 1, getHeight() - mMargin);
+ RectF border = new RectF(mMargin, 2*mMargin, getWidth() - mMargin - 1, getWidth());
+
+ if (mIsSelected) {
+ mPaint.setColor(mSelectedBackgroundColor);
+ canvas.drawRect(0, mMargin, getWidth(), getWidth() + mMargin, mPaint);
+ }
+
canvas.drawLine(0, 0, getWidth(), 0, mPaint);
mPaint.setStrokeWidth(mInnerBorderWidth);
Path path = new Path();
canvas.drawPath(path, mPaint);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.save();
- canvas.clipRect(mMargin + 1, mMargin, getWidth() - mMargin - 2, getHeight() - mMargin - 1,
+ canvas.clipRect(mMargin + 1, 2*mMargin, getWidth() - mMargin - 2, getWidth() - 1,
Region.Op.INTERSECT);
canvas.translate(mMargin, mMargin + 1);
canvas.scale(mImageScaleFactor, mImageScaleFactor);
private boolean mSetBorder = false;
protected final Paint mPaint = new Paint();
protected boolean mIsSelected = false;
- protected boolean mNextIsSelected = false;
- private ImageSmallFilter mPreviousImageSmallFilter = null;
// TODO: move this to xml.
protected static int mMargin = 12;
mImagePreset.add(mImageFilter);
}
- public void setPreviousImageSmallFilter(ImageSmallFilter previous) {
- mPreviousImageSmallFilter = previous;
- }
-
@Override
public void setSelected(boolean value) {
if (mIsSelected != value) {
invalidate();
- if (mPreviousImageSmallFilter != null) {
- mPreviousImageSmallFilter.setNextSelected(value);
- }
}
mIsSelected = value;
}
- public void setNextSelected(boolean value) {
- if (mNextIsSelected != value) {
- invalidate();
- }
- mNextIsSelected = value;
- }
-
public void setBorder(boolean value) {
mSetBorder = value;
}
public void onDraw(Canvas canvas) {
getFilteredImage();
canvas.drawColor(mBackgroundColor);
- Rect d = new Rect(0, mMargin, getWidth() - mMargin, getWidth());
float textWidth = mPaint.measureText(getImagePreset().name());
int h = mTextSize + 2 * mTextPadding;
int x = (int) ((getWidth() - textWidth) / 2);
int y = getHeight();
if (mIsSelected) {
mPaint.setColor(mSelectedBackgroundColor);
- canvas.drawRect(0, 0, getWidth(), getWidth() + mMargin, mPaint);
- }
- if (mNextIsSelected) {
- mPaint.setColor(mSelectedBackgroundColor);
- canvas.drawRect(getWidth() - mMargin, 0, getWidth(), getWidth() + mMargin, mPaint);
+ canvas.drawRect(0, mMargin, getWidth(), getWidth() + mMargin, mPaint);
}
- drawImage(canvas, mFilteredImage, d);
+ Rect destination = new Rect(mMargin, 2*mMargin, getWidth() - mMargin, getWidth());
+ drawImage(canvas, mFilteredImage, destination);
mPaint.setTextSize(mTextSize);
mPaint.setColor(mTextColor);
canvas.drawText(getImagePreset().name(), x, y - mTextMargin, mPaint);
}
- public void drawImage(Canvas canvas, Bitmap image, Rect d) {
+ public void drawImage(Canvas canvas, Bitmap image, Rect destination) {
if (image != null) {
int iw = image.getWidth();
int ih = image.getHeight();
- int iy = (int) ((ih - iw) / 2.0f);
- int ix = 0;
+ int x = 0;
+ int y = 0;
+ int size = 0;
+ Rect source = null;
if (iw > ih) {
- iy = 0;
- ix = (int) ((iw - ih) / 2.0f);
+ size = ih;
+ x = (int) ((iw - size) / 2.0f);
+ y = 0;
+ } else {
+ size = iw;
+ x = 0;
+ y = (int) ((ih - size) / 2.0f);
}
- Rect s = new Rect(ix, iy, ix + iw, iy + iw);
- canvas.drawBitmap(image, s, d, mPaint);
+ source = new Rect(x, y, x + size, y + size);
+ canvas.drawBitmap(image, source, destination, mPaint);
}
}