allow customizing the editor draw brush width
This commit is contained in:
parent
9ba021af11
commit
d0d04f6ca6
6 changed files with 53 additions and 4 deletions
|
@ -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() {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -7,16 +7,39 @@
|
|||
android:layout_height="@dimen/bottom_actions_height"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySeekBar
|
||||
android:id="@+id/bottom_draw_width"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:max="100"
|
||||
android:progress="50"
|
||||
app:layout_constraintBottom_toBottomOf="@id/bottom_draw_color"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/bottom_draw_color"
|
||||
app:layout_constraintTop_toTopOf="@+id/bottom_draw_color"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bottom_draw_color_clickable"
|
||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_height="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bottom_draw_color"
|
||||
android:layout_width="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_height="@dimen/bottom_editor_color_picker_size"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:clickable="false"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:src="@drawable/circle_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -19,4 +19,5 @@
|
|||
<dimen name="bottom_editor_actions_shadow_height">180dp</dimen>
|
||||
<dimen name="default_status_action_height">86dp</dimen>
|
||||
<dimen name="widget_initial_size">110dp</dimen>
|
||||
<dimen name="full_brush_size">40dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue