From dc43e9c1ea1221e84f8cae8b854c4cfe94b41367 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 19 Feb 2024 16:25:29 +0100 Subject: [PATCH] adds save and change tab button to history view --- .../SBHistoryView.class.st | 53 +++++++++++++++---- .../SBVariantsView.class.st | 6 +++ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBHistoryView.class.st b/packages/Sandblocks-Babylonian/SBHistoryView.class.st index 115b18d1..0781adfa 100644 --- a/packages/Sandblocks-Babylonian/SBHistoryView.class.st +++ b/packages/Sandblocks-Babylonian/SBHistoryView.class.st @@ -31,7 +31,8 @@ SBHistoryView >> buildMetaUsageIn: aRow [ ^ self containerRow cellGap: 5@0; addAllMorphsBack: {self deleteEpocheButton: aRow. - TextMorph new contents: (Text fromString: TimeStamp current asStringOrText) allBold} + TextMorph new contents: (Text fromString: TimeStamp current asStringOrText) allBold. + SBLabel new contents: 'Notes'} ] @@ -40,9 +41,8 @@ SBHistoryView >> buildMetaUsageIn: aRow [ SBHistoryView >> buildSnapshotTabView [ ^ SBTabView - namedBlocks: (SBExploriants uniqueInstance namedBlocks - select: #wantsHistory - thenCollect: [:aTab | SBNamedBlock block: aTab snapshot named: aTab name]) + namedBlocks: (self tabsToSnapshot + collect: [:aTab | SBNamedBlock block: aTab snapshot named: aTab name]) activeIndex: (SBExploriants uniqueInstance active wantsHistory ifTrue: [SBExploriants uniqueInstance activeIndex] ifFalse: [1]) @@ -52,23 +52,27 @@ SBHistoryView >> buildSnapshotTabView [ { #category : #building } SBHistoryView >> buttons [ - ^ super buttons, {self clearButton} + ^ super buttons, {self clearButton. self changeTabsButton. self saveButton } ] { #category : #building } -SBHistoryView >> clearButton [ +SBHistoryView >> changeTabsButton [ ^ SBButton new - icon: SBIcon iconClockO - label: 'Clear History' - do: [self clean. self block addMorphBack: self buildButtonRow]; + icon: SBIcon iconTable + label: 'Change All Tabs To' + do: [self offerChangeTabMenu]; cornerStyle: #squared ] { #category : #building } -SBHistoryView >> collectSnapshots [ +SBHistoryView >> clearButton [ - ^ (SBExploriants uniqueInstance namedBlocks collect: [:aView | aView snapshot]) flatten + ^ SBButton new + icon: SBIcon iconClockO + label: 'Clear History' + do: [self clean. self block addMorphBack: self buildButtonRow]; + cornerStyle: #squared ] { #category : #building } @@ -99,6 +103,33 @@ SBHistoryView >> maxEpoches [ ^ 100 ] +{ #category : #building } +SBHistoryView >> offerChangeTabMenu [ + + | index options | + options := self tabsToSnapshot collect: #name. + index := UIManager default chooseFrom: options. + index = 0 ifTrue: [^ self]. + + self block submorphs allButFirst do: [:anEpoche | anEpoche lastSubmorph activeIndex: index]. +] + +{ #category : #building } +SBHistoryView >> saveButton [ + + ^ SBButton new + icon: SBIcon iconSave + label: 'Save As PNG' + do: [self block exportAsPNG]; + cornerStyle: #squared +] + +{ #category : #accessing } +SBHistoryView >> tabsToSnapshot [ + + ^ SBExploriants uniqueInstance namedBlocks select: #wantsHistory +] + { #category : #actions } SBHistoryView >> visualize [ diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index c2bab30c..3c746903 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -56,3 +56,9 @@ SBVariantsView >> visualize [ ifNotEmptyDo: [:theMethods | theMethods do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]] ifEmpty: [self buildNoVariantsText] ] + +{ #category : #copying } +SBVariantsView >> wantsHistory [ + + ^ false +]