add flag for smooth transitions
This commit is contained in:
parent
a53928ef5e
commit
2b8eaeee49
|
@ -27,6 +27,7 @@ import (
|
||||||
|
|
||||||
var preset string
|
var preset string
|
||||||
var scriptPath string
|
var scriptPath string
|
||||||
|
var transition bool
|
||||||
|
|
||||||
type script []string
|
type script []string
|
||||||
|
|
||||||
|
@ -68,9 +69,9 @@ func handleWindowEvent(event *sdl.WindowEvent, m *milkDropWindow) {
|
||||||
func handleKeyboardEvent(event *sdl.KeyboardEvent, m *milkDropWindow) {
|
func handleKeyboardEvent(event *sdl.KeyboardEvent, m *milkDropWindow) {
|
||||||
scancode := event.Keysym.Scancode
|
scancode := event.Keysym.Scancode
|
||||||
if event.Type == sdl.KEYDOWN && scancode == sdl.SCANCODE_RIGHT && event.Repeat == 0 {
|
if event.Type == sdl.KEYDOWN && scancode == sdl.SCANCODE_RIGHT && event.Repeat == 0 {
|
||||||
m.nextPreset()
|
m.nextPreset(transition)
|
||||||
} else if event.Type == sdl.KEYDOWN && scancode == sdl.SCANCODE_LEFT && event.Repeat == 0 {
|
} else if event.Type == sdl.KEYDOWN && scancode == sdl.SCANCODE_LEFT && event.Repeat == 0 {
|
||||||
m.prevPreset()
|
m.prevPreset(transition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +168,8 @@ func init() {
|
||||||
|
|
||||||
// Cobra also supports local flags, which will only run
|
// Cobra also supports local flags, which will only run
|
||||||
// when this action is called directly.
|
// when this action is called directly.
|
||||||
|
rootCmd.Flags().BoolVarP(&transition, "transition", "t", false, "smoothly transition between presets")
|
||||||
|
|
||||||
rootCmd.Flags().StringVarP(&preset, "preset", "p", "", "preset file to use")
|
rootCmd.Flags().StringVarP(&preset, "preset", "p", "", "preset file to use")
|
||||||
rootCmd.Flags().StringVarP(&scriptPath, "script", "s", "", "script file to use")
|
rootCmd.Flags().StringVarP(&scriptPath, "script", "s", "", "script file to use")
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,14 @@ func (m *milkDropWindow) setupPresets(presets []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *milkDropWindow) nextPreset() {
|
func (m *milkDropWindow) nextPreset(smooth bool) {
|
||||||
m.preset = m.preset.Next()
|
m.preset = m.preset.Next()
|
||||||
m.loadPreset(true)
|
m.loadPreset(smooth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *milkDropWindow) prevPreset() {
|
func (m *milkDropWindow) prevPreset(smooth bool) {
|
||||||
m.preset = m.preset.Prev()
|
m.preset = m.preset.Prev()
|
||||||
m.loadPreset(true)
|
m.loadPreset(smooth)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMilkDropWindow(width, height int32, presets []string) (*milkDropWindow, error) {
|
func newMilkDropWindow(width, height int32, presets []string) (*milkDropWindow, error) {
|
||||||
|
|
Loading…
Reference in New Issue