Loading src/com/android/gallery3d/filtershow/category/CategoryView.java +9 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public class CategoryView extends View implements View.OnClickListener { private Paint mSelectPaint; CategoryAdapter mAdapter; private int mSelectionStroke; private Paint mBorderPaint; private int mBorderStroke; public static void setTextSize(int size) { sTextSize = size; Loading @@ -63,6 +65,9 @@ public class CategoryView extends View implements View.OnClickListener { mSelectPaint = new Paint(); mSelectPaint.setStyle(Paint.Style.FILL); mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection)); mBorderPaint = new Paint(mSelectPaint); mBorderPaint.setColor(Color.BLACK); mBorderStroke = mSelectionStroke / 3; } public void drawText(Canvas canvas, String text) { Loading Loading @@ -91,8 +96,10 @@ public class CategoryView extends View implements View.OnClickListener { Bitmap bitmap = mAction.getImage(); canvas.drawBitmap(bitmap, 0, 0, mPaint); if (mAdapter.isSelected(this)) { SelectionRenderer.drawSelection(canvas, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mSelectionStroke, mSelectPaint); SelectionRenderer.drawSelection(canvas, 0, 0, Math.min(bitmap.getWidth(), getWidth()), Math.min(bitmap.getHeight(), getHeight()), mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint); } } mPaint.setColor(mBackgroundColor); Loading src/com/android/gallery3d/filtershow/ui/SelectionRenderer.java +16 −0 Original line number Diff line number Diff line Loading @@ -29,4 +29,20 @@ public class SelectionRenderer { canvas.drawRect(right - stroke, top, right, bottom, paint); } public static void drawSelection(Canvas canvas, int left, int top, int right, int bottom, int stroke, Paint selectPaint, int border, Paint borderPaint) { canvas.drawRect(left, top, right, top + stroke, selectPaint); canvas.drawRect(left, bottom - stroke, right, bottom, selectPaint); canvas.drawRect(left, top, left + stroke, bottom, selectPaint); canvas.drawRect(right - stroke, top, right, bottom, selectPaint); canvas.drawRect(left + stroke, top + stroke, right - stroke, top + stroke + border, borderPaint); canvas.drawRect(left + stroke, bottom - stroke - border, right - stroke, bottom - stroke, borderPaint); canvas.drawRect(left + stroke, top + stroke, left + stroke + border, bottom - stroke, borderPaint); canvas.drawRect(right - stroke - border, top + stroke, right - stroke, bottom - stroke, borderPaint); } } Loading
src/com/android/gallery3d/filtershow/category/CategoryView.java +9 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public class CategoryView extends View implements View.OnClickListener { private Paint mSelectPaint; CategoryAdapter mAdapter; private int mSelectionStroke; private Paint mBorderPaint; private int mBorderStroke; public static void setTextSize(int size) { sTextSize = size; Loading @@ -63,6 +65,9 @@ public class CategoryView extends View implements View.OnClickListener { mSelectPaint = new Paint(); mSelectPaint.setStyle(Paint.Style.FILL); mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection)); mBorderPaint = new Paint(mSelectPaint); mBorderPaint.setColor(Color.BLACK); mBorderStroke = mSelectionStroke / 3; } public void drawText(Canvas canvas, String text) { Loading Loading @@ -91,8 +96,10 @@ public class CategoryView extends View implements View.OnClickListener { Bitmap bitmap = mAction.getImage(); canvas.drawBitmap(bitmap, 0, 0, mPaint); if (mAdapter.isSelected(this)) { SelectionRenderer.drawSelection(canvas, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mSelectionStroke, mSelectPaint); SelectionRenderer.drawSelection(canvas, 0, 0, Math.min(bitmap.getWidth(), getWidth()), Math.min(bitmap.getHeight(), getHeight()), mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint); } } mPaint.setColor(mBackgroundColor); Loading
src/com/android/gallery3d/filtershow/ui/SelectionRenderer.java +16 −0 Original line number Diff line number Diff line Loading @@ -29,4 +29,20 @@ public class SelectionRenderer { canvas.drawRect(right - stroke, top, right, bottom, paint); } public static void drawSelection(Canvas canvas, int left, int top, int right, int bottom, int stroke, Paint selectPaint, int border, Paint borderPaint) { canvas.drawRect(left, top, right, top + stroke, selectPaint); canvas.drawRect(left, bottom - stroke, right, bottom, selectPaint); canvas.drawRect(left, top, left + stroke, bottom, selectPaint); canvas.drawRect(right - stroke, top, right, bottom, selectPaint); canvas.drawRect(left + stroke, top + stroke, right - stroke, top + stroke + border, borderPaint); canvas.drawRect(left + stroke, bottom - stroke - border, right - stroke, bottom - stroke, borderPaint); canvas.drawRect(left + stroke, top + stroke, left + stroke + border, bottom - stroke, borderPaint); canvas.drawRect(right - stroke - border, top + stroke, right - stroke, bottom - stroke, borderPaint); } }