mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-03 12:30:13 +01:00
Revert "Added Color Picker button in Photo Editor."
This reverts commit c3da4abe
This commit is contained in:
parent
5785088a19
commit
13be430274
@ -50,8 +50,6 @@ public class RenderView extends TextureView {
|
||||
|
||||
private boolean shuttingDown;
|
||||
|
||||
public boolean isColorPicker = false;
|
||||
|
||||
public RenderView(Context context, Painting paint, Bitmap b) {
|
||||
super(context);
|
||||
setOpaque(false);
|
||||
@ -155,9 +153,6 @@ public class RenderView extends TextureView {
|
||||
if (internal == null || !internal.initialized || !internal.ready) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isColorPicker) return true;
|
||||
|
||||
input.process(event, getScaleX());
|
||||
return true;
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -35,7 +33,6 @@ public class ColorPicker extends FrameLayout {
|
||||
void onFinishedColorPicking();
|
||||
void onSettingsPressed();
|
||||
void onUndoPressed();
|
||||
boolean onColorPicker();
|
||||
}
|
||||
|
||||
private ColorPickerDelegate delegate;
|
||||
@ -68,8 +65,6 @@ public class ColorPicker extends FrameLayout {
|
||||
1.0f
|
||||
};
|
||||
|
||||
private PorterDuffColorFilter colorPickerFilter = new PorterDuffColorFilter(0xff51bdf3, PorterDuff.Mode.MULTIPLY);
|
||||
private ImageView colorPickerButton;
|
||||
private ImageView settingsButton;
|
||||
private ImageView undoButton;
|
||||
private Drawable shadowDrawable;
|
||||
@ -103,25 +98,6 @@ public class ColorPicker extends FrameLayout {
|
||||
}
|
||||
});
|
||||
|
||||
colorPickerButton = new ImageView(context);
|
||||
colorPickerButton.setScaleType(ImageView.ScaleType.CENTER);
|
||||
colorPickerButton.setImageResource(R.drawable.photo_color_picker);
|
||||
addView(colorPickerButton, LayoutHelper.createFrame(60, 52));
|
||||
colorPickerButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (delegate != null) {
|
||||
boolean p = delegate.onColorPicker();
|
||||
|
||||
PorterDuffColorFilter f = null;
|
||||
if (p) f = colorPickerFilter;
|
||||
|
||||
colorPickerButton.setColorFilter(f);
|
||||
colorPickerButton.setImageResource(R.drawable.photo_color_picker);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
undoButton = new ImageView(context);
|
||||
undoButton.setScaleType(ImageView.ScaleType.CENTER);
|
||||
undoButton.setImageResource(R.drawable.photo_undo);
|
||||
@ -210,13 +186,6 @@ public class ColorPicker extends FrameLayout {
|
||||
return Color.argb(255, r, g, b);
|
||||
}
|
||||
|
||||
public void setSwatchPaintColor(int color) {
|
||||
findColorLocation(color);
|
||||
swatchPaint.setColor(color);
|
||||
swatchStrokePaint.setColor(color);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setLocation(float value) {
|
||||
int color = colorForLocation(location = value);
|
||||
swatchPaint.setColor(color);
|
||||
@ -296,14 +265,12 @@ public class ColorPicker extends FrameLayout {
|
||||
int width = right - left;
|
||||
int height = bottom - top;
|
||||
|
||||
gradientPaint.setShader(new LinearGradient(AndroidUtilities.dp(56), 0, width - AndroidUtilities.dp(52) * 2, 0, COLORS, LOCATIONS, Shader.TileMode.REPEAT));
|
||||
gradientPaint.setShader(new LinearGradient(AndroidUtilities.dp(56), 0, width - AndroidUtilities.dp(56), 0, COLORS, LOCATIONS, Shader.TileMode.REPEAT));
|
||||
int y = height - AndroidUtilities.dp(32);
|
||||
rectF.set(AndroidUtilities.dp(56), y, width - AndroidUtilities.dp(52) * 2, y + AndroidUtilities.dp(12));
|
||||
rectF.set(AndroidUtilities.dp(56), y, width - AndroidUtilities.dp(56), y + AndroidUtilities.dp(12));
|
||||
|
||||
// Move settingButton left after coloPickerButton.
|
||||
settingsButton.layout(width - settingsButton.getMeasuredWidth() * 2 - AndroidUtilities.dp(30), height - AndroidUtilities.dp(52), width, height);
|
||||
settingsButton.layout(width - settingsButton.getMeasuredWidth(), height - AndroidUtilities.dp(52), width, height);
|
||||
undoButton.layout(0, height - AndroidUtilities.dp(52), settingsButton.getMeasuredWidth(), height);
|
||||
colorPickerButton.layout(width - colorPickerButton.getMeasuredWidth(), height - AndroidUtilities.dp(52), width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -354,15 +321,4 @@ public class ColorPicker extends FrameLayout {
|
||||
setDraggingFactor(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void findColorLocation(int color) {
|
||||
for (float i = 0; i <= 1; i += 0.001f) {
|
||||
int colorOnLine = colorForLocation(i);
|
||||
if (Math.abs(color - colorOnLine) < 10000) {
|
||||
setLocation(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,31 +139,6 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
|
||||
addView(curtainView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
|
||||
renderView = new RenderView(context, new Painting(getPaintingSize()), bitmap);
|
||||
renderView.setOnTouchListener((v, event) -> {
|
||||
if (!renderView.isColorPicker) return false;
|
||||
int x = (int)event.getX();
|
||||
int y = (int)event.getY();
|
||||
|
||||
if (x >= v.getWidth()) return false;
|
||||
if (y >= v.getHeight()) return false;
|
||||
if (x <= 0) return false;
|
||||
if (y <= 0) return false;
|
||||
|
||||
int finalX;
|
||||
int finalY;
|
||||
if (!isSidewardOrientation()) {
|
||||
finalX = (int)((float)x / (float)v.getWidth() * bitmap.getWidth());
|
||||
finalY = (int)((float)y / (float)v.getHeight() * bitmap.getHeight());
|
||||
} else {
|
||||
finalY = (int)((float)(v.getWidth() - x) / (float)v.getWidth() * bitmap.getHeight());
|
||||
finalX = (int)((float)y / (float)v.getHeight() * bitmap.getWidth());
|
||||
}
|
||||
|
||||
int pixel = bitmap.getPixel(finalX, finalY);
|
||||
renderView.setColor(pixel);
|
||||
colorPicker.setSwatchPaintColor(pixel);
|
||||
return false;
|
||||
});
|
||||
renderView.setDelegate(new RenderView.RenderViewDelegate() {
|
||||
|
||||
@Override
|
||||
@ -277,12 +252,6 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
|
||||
public void onUndoPressed() {
|
||||
undoStore.undo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onColorPicker() {
|
||||
renderView.isColorPicker = !renderView.isColorPicker;
|
||||
return renderView.isColorPicker;
|
||||
}
|
||||
});
|
||||
|
||||
toolsView = new FrameLayout(context);
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
Loading…
Reference in New Issue
Block a user