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() defer m.destroy()
m.loadPreset(preset) if preset != "" {
m.setupPresets([]string{preset})
}
m.loadPreset(false)
running := true running := true
for running { for running {

View File

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