Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose setBrightness to public #48

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions colorpicker-compose/api/colorpicker-compose.api
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
public final fun selectByColor-DxMtmZc (JZ)V
public final fun selectByCoordinate (FFZ)V
public final fun selectCenter (Z)V
public final fun setBrightness (FZ)V
public final fun setDebounceDuration (J)V
public final fun setEnabled (Z)V
public final fun setPaletteContentScale (Lcom/github/skydoves/colorpicker/compose/PaletteContentScale;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -76,10 +78,10 @@ public class ColorPickerController {
internal var pureSelectedColor: MutableState<Color> = mutableStateOf(Color.Transparent)

/** Alpha value to be applied with the selected color. */
internal var alpha: MutableState<Float> = mutableStateOf(1.0f)
internal var alpha: MutableState<Float> = mutableFloatStateOf(1.0f)

/** Brightness value to be applied with the selected color. */
internal var brightness: MutableState<Float> = mutableStateOf(1.0f)
internal var brightness: MutableState<Float> = mutableFloatStateOf(1.0f)

/** Radius to draw default wheel. */
internal var wheelRadius: Dp = 12.dp
Expand Down Expand Up @@ -110,7 +112,7 @@ public class ColorPickerController {
/** Indicates if the brightness slider has been attached. */
internal var isAttachedBrightnessSlider: Boolean = false

internal var reviseTick = mutableStateOf(0)
internal var reviseTick = mutableIntStateOf(0)

internal var colorChangedTick = MutableStateFlow<ColorEnvelope?>(null)

Expand All @@ -133,7 +135,7 @@ public class ColorPickerController {
paletteBitmap = resized.asImageBitmap()
copiedBitmap.recycle()
selectCenter(fromUser = false)
reviseTick.value++
reviseTick.intValue++
}

/** Set a [PaletteContentScale] to the palette bitmap. */
Expand All @@ -149,25 +151,25 @@ public class ColorPickerController {
/** Set a radius to draw default wheel. */
public fun setWheelRadius(radius: Dp) {
wheelRadius = radius
reviseTick.value++
reviseTick.intValue++
}

/** Set a paint to draw default wheel. */
public fun setWheelPaint(paint: Paint) {
wheelPaint = paint
reviseTick.value++
reviseTick.intValue++
}

/** Set a color for the wheel. */
public fun setWheelColor(color: Color) {
wheelPaint.color = color
reviseTick.value++
reviseTick.intValue++
}

/** Set an alpha for the wheel. */
public fun setWheelAlpha(alpha: Float) {
wheelPaint.alpha = alpha
reviseTick.value++
reviseTick.intValue++
}

/** Enable or unable color selection. */
Expand Down Expand Up @@ -271,7 +273,7 @@ public class ColorPickerController {
}

/** Combine the brightness value to the selected pure color. */
internal fun setBrightness(brightness: Float, fromUser: Boolean) {
public fun setBrightness(brightness: Float, fromUser: Boolean) {
this.brightness.value = brightness
val hsv = FloatArray(3)
android.graphics.Color.colorToHSV(pureSelectedColor.value.toArgb(), hsv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ public fun HsvColorPicker(
}
}
}
controller.reviseTick.value
controller.reviseTick.intValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public fun ImageColorPicker(
this.drawOnPosSelected()
}
}
controller.reviseTick.value
controller.reviseTick.intValue
}
}

Expand Down
Loading