Skip to content

Commit

Permalink
timeModeSwitch changes between TimeMode and IdleMode
Browse files Browse the repository at this point in the history
  • Loading branch information
lucretiomsp committed Jan 27, 2025
1 parent c8eca48 commit 7d971c3
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
28 changes: 12 additions & 16 deletions CoypuIDE/TbSwitch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,14 @@ TbSwitch >> initialize [
]

{ #category : 'as yet unclassified' }
TbSwitch >> initializeEvents [

switch
addEventHandler: (BlEventHandler
on: BlMouseDownEvent
do: [ :anEvent |
self toggle.
]).
switch
addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent |
self toggle.
]).
TbSwitch >> initializeEvents [

switch addEventHandler: (BlEventHandler
on: BlMouseDownEvent
do: [ :anEvent | self toggle. self callback value ]).
switch addEventHandler: (BlEventHandler
on: BlMouseUpEvent
do: [ :anEvent | self toggle ])
]

{ #category : 'as yet unclassified' }
Expand Down Expand Up @@ -236,9 +230,11 @@ TbSwitch >> toggle [

{ #category : 'initialization' }
TbSwitch >> toggleValue [
self value = 0
ifTrue: [ self value: 1 ]

self value = 0
ifTrue: [ self value: 1 ]
ifFalse: [ self value: 0 ].

]

{ #category : 'initialization' }
Expand Down
15 changes: 12 additions & 3 deletions CoypuIDE/Tp33.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Tp33 >> initialize [

| dsp p |
super initialize.
mode := TpIdleMode new.
mode := TpIdleMode new machine: self.
"notesArrray is neeeded to map the keyboard buttons to note numbers"
self initializeNotesArray.
isRunning := false.
Expand All @@ -49,7 +49,7 @@ Tp33 >> initialize [
self initializeNotesCallbacks.
"just temporary patternPlay"
p := Performance uniqueInstance forDsp: dsp.
'35 , 48 ,62 , 71, ~ , ~ , 52 , 38, 39 , 43, ~ , 53 , ~ , 36 , 46 , 51 , 75'
'40 , 40 , 41, 41, 43, 43, 40, 40, 40, 38, 38, 40, 38, 43, 43, 43'
asDirtNotes to: #Acid.
self initializeKnobsValuesAndRanges.

Expand Down Expand Up @@ -148,8 +148,11 @@ Tp33 >> initializeWidgetsCallbacks [
self widget_PitchMode callback: [ :v |
v isPitchMode: v isPitchMode not ].

"ENTER TIME MODE"
self widget_TimeMode switch callback: [
self mode handleSwitchTimeMode ].
"we need to access the button inside the widget"
(self widget_PatternClear children at: 4) callback: [
(self widget_PatternClear children at: 4) callback: [
16 rests to: #Acid ]
]

Expand Down Expand Up @@ -182,6 +185,12 @@ Tp33 >> mode [
^ mode
]

{ #category : 'accessing' }
Tp33 >> mode: aTpMode [

mode := aTpMode
]

{ #category : 'instance creation' }
Tp33 >> newWithDsp: aDsp [

Expand Down
6 changes: 6 additions & 0 deletions CoypuIDE/TpIdleMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ Class {
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'action handling' }
TpIdleMode >> handleSwitchTimeMode [

self machine mode: (TpTimeMode new machine: self machine )
]
21 changes: 21 additions & 0 deletions CoypuIDE/TpMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,28 @@ PlayMode: keyboard select different patterns in memory
Class {
#name : 'TpMode',
#superclass : 'Object',
#instVars : [
'machine'
],
#category : 'CoypuIDE-Acid',
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'action handling' }
TpMode >> handleSwitchTimeMode [

^ self subclassResponsibility
]

{ #category : 'accessing' }
TpMode >> machine [

^ machine
]

{ #category : 'accessing' }
TpMode >> machine: aTp33 [

machine := aTp33
]
6 changes: 6 additions & 0 deletions CoypuIDE/TpTimeMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ Class {
#package : 'CoypuIDE',
#tag : 'Acid'
}

{ #category : 'action handling' }
TpTimeMode >> handleSwitchTimeMode [

self machine mode: (TpIdleMode new machine: self machine)
]

0 comments on commit 7d971c3

Please sign in to comment.