allow customizing the editor draw brush width

This commit is contained in:
tibbi
2019-01-13 17:46:06 +01:00
parent 9ba021af11
commit d0d04f6ca6
6 changed files with 53 additions and 4 deletions

View File

@ -445,13 +445,28 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
private fun setupDrawButtons() {
updateDrawColor(config.lastEditorDrawColor)
bottom_draw_color.setOnClickListener {
bottom_draw_width.progress = config.lastEditorBrushSize
updateBrushSize(config.lastEditorBrushSize)
bottom_draw_color_clickable.setOnClickListener {
ColorPickerDialog(this, drawColor) { wasPositivePressed, color ->
if (wasPositivePressed) {
updateDrawColor(color)
}
}
}
bottom_draw_width.onSeekBarChangeListener {
config.lastEditorBrushSize = it
updateBrushSize(it)
}
}
private fun updateBrushSize(percent: Int) {
editor_draw_canvas.updateBrushSize(percent)
val scale = Math.max(0.03f, percent / 100f)
bottom_draw_color.scaleX = scale
bottom_draw_color.scaleY = scale
}
private fun updatePrimaryActionButtons() {

View File

@ -457,4 +457,8 @@ class Config(context: Context) : BaseConfig(context) {
var lastEditorDrawColor: Int
get() = prefs.getInt(LAST_EDITOR_DRAW_COLOR, primaryColor)
set(lastEditorDrawColor) = prefs.edit().putInt(LAST_EDITOR_DRAW_COLOR, lastEditorDrawColor).apply()
var lastEditorBrushSize: Int
get() = prefs.getInt(LAST_EDITOR_BRUSH_SIZE, 50)
set(lastEditorBrushSize) = prefs.edit().putInt(LAST_EDITOR_BRUSH_SIZE, lastEditorBrushSize).apply()
}

View File

@ -77,6 +77,7 @@ const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom"
const val LAST_EDITOR_DRAW_COLOR = "last_editor_draw_color"
const val LAST_EDITOR_BRUSH_SIZE = "last_editor_brush_size"
// slideshow
const val SLIDESHOW_INTERVAL = "slideshow_interval"

View File

@ -8,6 +8,7 @@ import android.graphics.Paint
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.extensions.config
import com.simplemobiletools.gallery.pro.models.MyPath
import com.simplemobiletools.gallery.pro.models.PaintOptions
@ -122,6 +123,10 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
mPaintOptions.color = newColor
}
fun updateBrushSize(newBrushSize: Int) {
mPaintOptions.strokeWidth = resources.getDimension(R.dimen.full_brush_size) * (newBrushSize / 100f)
}
fun updateBackgroundBitmap(bitmap: Bitmap) {
backgroundBitmap = bitmap
invalidate()