handle single presets

This commit is contained in:
filifa 2024-09-02 23:10:46 -05:00
parent 56d3c2c555
commit 5c95c5346f
2 changed files with 19 additions and 10 deletions

View File

@ -79,7 +79,11 @@ func milkbucket(cmd *cobra.Command, args []string) {
}
defer m.destroy()
m.loadPreset(preset)
if preset != "" {
m.setupPresets([]string{preset})
}
m.loadPreset(false)
running := true
for running {

View File

@ -67,23 +67,27 @@ func (m *milkDropWindow) loadScript(scriptPath string) error {
return err
}
m.preset = ring.New(len(s.Presets))
for _, preset := range s.Presets {
m.preset.Value = preset
m.preset = m.preset.Next()
}
m.setupPresets(s.Presets)
return nil
}
func (m *milkDropWindow) setupPresets(presets []string) {
m.preset = ring.New(len(presets))
for _, preset := range presets {
m.preset.Value = preset
m.preset = m.preset.Next()
}
}
func (m *milkDropWindow) nextPreset() {
m.preset = m.preset.Next()
m.loadPreset(m.preset.Value.(string))
m.loadPreset(true)
}
func (m *milkDropWindow) prevPreset() {
m.preset = m.preset.Prev()
m.loadPreset(m.preset.Value.(string))
m.loadPreset(true)
}
func newMilkDropWindow(width, height int32, scriptPath string) (*milkDropWindow, error) {
@ -123,10 +127,11 @@ func (m *milkDropWindow) destroy() {
m.window.Destroy()
}
func (m *milkDropWindow) loadPreset(preset string) {
func (m *milkDropWindow) loadPreset(smooth bool) {
preset := m.preset.Value.(string)
cPreset := C.CString(preset)
defer C.free(unsafe.Pointer(cPreset))
C.projectm_load_preset_file(m.handle, cPreset, true)
C.projectm_load_preset_file(m.handle, cPreset, C.bool(smooth))
}
func (m *milkDropWindow) render() (bool, error) {