76df65042c49 — Gerald Klix (speedy) 1 year, 9 months ago
SUM: Added a secondary action that filters by one state.
1 files changed, 33 insertions(+), 6 deletions(-)

M haver/office/NuMach.pck.st
M haver/office/NuMach.pck.st +33 -6
@@ 1,8 1,8 @@ 
-'From Haver 6.0 [latest update: #5832] on 1 June 2023 at 5:50:19 pm'!
+'From Haver 6.0 [latest update: #5832] on 1 June 2023 at 6:20:16 pm'!
 'Description NuMach is a very simple to list.
 
 Hopefully it will serve as a base for something more elaborate.'!
-!provides: 'NuMach' 1 20!
+!provides: 'NuMach' 1 21!
 !requires: 'Cuis-Base' 60 5780 nil!
 !requires: 'FacetsMorphs' 1 3 nil!
 !requires: 'IdGeneration' 1 0 nil!

          
@@ 65,7 65,7 @@ Modules environment: #NuMach ::
 
 !classDefinition: (Modules>>#NuMach>>#TodoItemContainerMorph) category: 'NuMach-Morphs'!
 (Modules>>#NuMach>>#AbstractItemMorph) subclass: #TodoItemContainerMorph
-	instanceVariableNames: 'subItemsMorph filteredStates'
+	instanceVariableNames: 'subItemsMorph filterButtonsPanel filteredStates'
 	classVariableNames: ''
 	poolDictionaries: ''
 	category: 'NuMach-Morphs'

          
@@ 898,11 898,11 @@ initialize
 	super initialize.
 	isTopLevel := false! !
 
-!(Modules>>#NuMach>>#TodoItemContainerMorph) methodsFor: 'GUI building' stamp: 'KLG 6/1/2023 15:29:27'!
+!(Modules>>#NuMach>>#TodoItemContainerMorph) methodsFor: 'GUI building' stamp: 'KLG 6/1/2023 18:13:57'!
 buildMorphicWidget
 	"Build me."
 
-	|  morphToAdd subItemsPanel filterButtonsPanel |
+	|  morphToAdd subItemsPanel  |
 	filterButtonsPanel := LayoutMorph newRow.
 	self model state model statesDo: [ :state |
 		filterButtonsPanel

          
@@ 911,7 911,13 @@ buildMorphicWidget
 					contents: state displayString
 					target: self
 					selector: #visible:state:
-					arguments: { state }) ].
+					arguments: { state } ::
+						secondarySelector: #visible:onlyThisState:;
+						setBalloonText:
+							'If on, show items in state ', state displayString italic,
+							`String newLineString, String newLineString`,
+							'Description:' bold, `String newLineString`,
+							state description) ].
 	self addMorph: filterButtonsPanel fixedHeight: Theme current buttonPaneHeight.
 	subItemsMorph := DetailsMorph newColumn.
 	morphToAdd := self isTopLevel

          
@@ 1012,6 1018,27 @@ showSubItemsAccordingToFilter
 					visible: (filteredStates includes: subMorph model state) not ] ]
 ! !
 
+!(Modules>>#NuMach>>#TodoItemContainerMorph) methodsFor: 'filtering' stamp: 'KLG 6/1/2023 18:15:40'!
+visible: aVisibleFlag onlyThisState: aState
+	"Filter aState according to aVisibleFlag. All other states if the negated visibility state."
+
+	| comparsionOperator |
+	"D: Transcript cr; show: self; show: ' visible: '; show: aVisibleFlag; show: ' onlyThisState: '; show:aState."
+	aVisibleFlag
+		ifTrue: [
+			filteredStates := Set new.
+			self model state model statesDo: [ :state |
+				state = aState ifFalse: [
+					filteredStates add: state ] ]		]
+		ifFalse: [ filteredStates := Set with: aState ].
+	self showSubItemsAccordingToFilter.
+	comparsionOperator := aVisibleFlag ifTrue: [ #= ] ifFalse: [ #~= ].
+	filterButtonsPanel submorphsDo: [ :filterButton |
+		filterButton 
+			isOn: (filterButton arguments first
+				perform: comparsionOperator
+				with: aState) ]! !
+
 !(Modules>>#NuMach>>#TodoItemContainerMorph) methodsFor: 'filtering' stamp: 'KLG 6/1/2023 17:45:31'!
 visible: aVisibleFlag state: aState
 	"Add or remove aState form the set of filtered states."