diff -r 50b4b75edc7b -r 034b6149d8bc NoteBookView.st --- a/NoteBookView.st Sat Aug 13 12:41:38 2016 +0200 +++ b/NoteBookView.st Sat Aug 13 16:11:42 2016 +0200 @@ -28,7 +28,8 @@ removeTabEnteredIcon removeTabDisabledIcon showingEnteredRemoveTabButton lastUserSelection minimumTabWidth addTabAction addTabIcon addTabEnteredIcon addTabDisabledIcon - showingEnteredAddTabButton canvasLevel' + showingEnteredAddTabButton canvasLevel + showDestroyTabButtonOnSingleTab' classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultActiveForegroundColor DefaultActiveBackgroundColor DefaultShadowColor DefaultHalfShadowColor DefaultLightColor @@ -374,7 +375,12 @@ ! list:newTabItemListOrNil - "set the tab-list" + "set the tab-list. + warning: transforms the given list to a list of tabItems, + where each holds on to a corresponding list element. + When a new list comes in, the list elements are compared for identity. + This may make problems, when strings come in. + Q: should we compare for equality here?" |selectionName newList newTabItemList oldSelectedTab| @@ -894,7 +900,7 @@ ]. tabExtent := tabExtent + tabLabelInset. - (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ + (self showingDestroyButton) ifTrue:[ tabExtent := tabExtent + ((self destroyButtonUsedWidth) @ 0). ]. ^ tabExtent. @@ -1073,16 +1079,39 @@ ! showDestroyTabButton + "if true, a close-tab icon is shown" + ^ showDestroyTabButton ! showDestroyTabButton:aBoolean + "if true, a close-tab icon is shown" + showDestroyTabButton == aBoolean ifTrue:[^ self]. showDestroyTabButton := aBoolean. self styleChanged. ! +showDestroyTabButtonOnSingleTab + "if true, AND showDestroyTabButton is true, + a close-tab icon is shown even for a single tab. + Otherwise, it is hidden if there is only one tab-item left" + + ^ showDestroyTabButtonOnSingleTab +! + +showDestroyTabButtonOnSingleTab:aBoolean + "if true, AND showDestroyTabButton is true, + a close-tab icon is shown even for a single tab. + Otherwise, it is hidden if there is only one tab-item left" + + showDestroyTabButtonOnSingleTab == aBoolean ifTrue:[^ self]. + showDestroyTabButtonOnSingleTab := aBoolean. + + self styleChanged. +! + tabBottomMargin "returns the margin between the tabs and the canvas " @@ -1843,7 +1872,7 @@ "/ if we have to show a different icon while over the tab... tab := self tabContainingPointX:x y:y. (tab notNil and:[tab == self selectedTab]) ifTrue:[ - (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ + (self showingDestroyButton) ifTrue:[ mustShowEntered := (self destroyButtonFrameForTab:tab) containsPoint:(x@y). mustShowEntered ~~ showingEnteredRemoveTabButton ifTrue:[ showingEnteredRemoveTabButton := mustShowEntered. @@ -2293,7 +2322,7 @@ tab := self tabContainingPointX:x y:y. tab notNil ifTrue:[ - (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[ + (self showingDestroyButton) ifTrue:[ (tab == self selectedTab or:[ self disableDestroyButtonOfInactiveTabs not ]) ifTrue:[ ((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[ @@ -3346,7 +3375,7 @@ aTab destroyTabButtonShown ifTrue:[^ true]. - (showDestroyTabButton and:[destroyTabAction notNil]) ifFalse:[ + (self showingDestroyButton) ifFalse:[ ^ false ]. self showDestroyButtonOfInactiveTabs ifTrue:[^ true]. @@ -3375,6 +3404,12 @@ nextTab := list at:(index + 1) ifAbsent:nil. ^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr] +! + +showingDestroyButton + ^ showDestroyTabButton + and:[destroyTabAction notNil + and:[(showDestroyTabButtonOnSingleTab ~~ true) or:[list size > 1]]] ! ! !NoteBookView methodsFor:'selection'!