Added a stronger randomize() to the GUI when holding Shift...
With different styling to indicate that the effect will be greater...
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.gson.Gson
|
|||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import org.openrndr.Extension
|
import org.openrndr.Extension
|
||||||
import org.openrndr.KEY_F11
|
import org.openrndr.KEY_F11
|
||||||
|
import org.openrndr.KEY_LEFT_SHIFT
|
||||||
import org.openrndr.KeyModifier
|
import org.openrndr.KeyModifier
|
||||||
import org.openrndr.Program
|
import org.openrndr.Program
|
||||||
import org.openrndr.color.ColorRGBa
|
import org.openrndr.color.ColorRGBa
|
||||||
@@ -76,6 +77,10 @@ class GUI : Extension {
|
|||||||
|
|
||||||
private lateinit var panel: ControlManager
|
private lateinit var panel: ControlManager
|
||||||
|
|
||||||
|
// Randomize button
|
||||||
|
private var shiftDown = false
|
||||||
|
private var randomizeButton: Button? = null // FIXME should this be null or is there a better way?
|
||||||
|
|
||||||
fun onChange(listener: (name: String, value: Any?) -> Unit) {
|
fun onChange(listener: (name: String, value: Any?) -> Unit) {
|
||||||
onChangeListener = listener
|
onChangeListener = listener
|
||||||
}
|
}
|
||||||
@@ -88,6 +93,18 @@ class GUI : Extension {
|
|||||||
panel.enabled = enabled
|
panel.enabled = enabled
|
||||||
sidebarState().hidden = !enabled
|
sidebarState().hidden = !enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (it.key == KEY_LEFT_SHIFT) {
|
||||||
|
shiftDown = true
|
||||||
|
randomizeButton!!.classes.add(ElementClass("randomize-strong"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
program.keyboard.keyUp.listen {
|
||||||
|
if (it.key == KEY_LEFT_SHIFT) {
|
||||||
|
shiftDown = false
|
||||||
|
randomizeButton!!.classes.remove(ElementClass("randomize-strong"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
panel = program.controlManager {
|
panel = program.controlManager {
|
||||||
@@ -160,6 +177,15 @@ class GUI : Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
styleSheet(has class_ "randomize-strong") {
|
||||||
|
color = Color.RGBa(ColorRGBa.PINK)
|
||||||
|
|
||||||
|
and(has state "hover") {
|
||||||
|
color = Color.RGBa(ColorRGBa.BLACK)
|
||||||
|
background = Color.RGBa(ColorRGBa.PINK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
styleSheet(has type "dropdown-button") {
|
styleSheet(has type "dropdown-button") {
|
||||||
this.width = 175.px
|
this.width = 175.px
|
||||||
}
|
}
|
||||||
@@ -169,10 +195,10 @@ class GUI : Extension {
|
|||||||
div("container") {
|
div("container") {
|
||||||
id = "container"
|
id = "container"
|
||||||
val header = div("toolbar") {
|
val header = div("toolbar") {
|
||||||
button {
|
randomizeButton = button {
|
||||||
label = "Randomize"
|
label = "Randomize"
|
||||||
clicked {
|
clicked {
|
||||||
randomize()
|
randomize(strength = if (shiftDown) .75 else .05)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
|
|||||||
Reference in New Issue
Block a user