SettingsDialog.st
changeset 16988 533bb733d68b
parent 16987 5f68a7467da7
child 16991 73558621b29b
--- a/SettingsDialog.st	Sun Oct 30 16:26:57 2016 +0100
+++ b/SettingsDialog.st	Sun Oct 30 18:33:20 2016 +0100
@@ -714,21 +714,25 @@
                (MenuItem
                   label: 'Expand All'
                   itemValue: menuExpandAll
+                  hideMenuOnActivated: false
                 )
                (MenuItem
                   label: 'Collapse All'
                   itemValue: menuCollapseAll
+                  hideMenuOnActivated: false
                 )
                (MenuItem
                   label: '-'
                 )
                (MenuItem
                   label: 'Show Search Field'
+                  hideMenuOnActivated: false
                   indication: quickSearchFieldShownHolder
                 )
                (MenuItem
                   label: 'Show Non-Default Settings'
                   isVisible: showNonDefaultSettingsMenuItemVisibleHolder
+                  hideMenuOnActivated: false
                   indication: showNonDefaultSettingsHolder
                 )
                )
@@ -1664,8 +1668,12 @@
     self subCanvasApplicationHolder value:app.
     self modifiedChanged.
     
-    self highlightWidgetsWithMatchingSearchString
-
+    self highlightWidgetsWithMatchingSearchString.
+    "/ does not yet work fully
+    false ifTrue:[
+        self highlightWidgetsWithChangedSettings.
+    ].
+    
     "Modified: / 29-10-2010 / 11:51:13 / cg"
     "Modified: / 17-02-2012 / 10:24:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
@@ -1686,6 +1694,69 @@
     super update:something with:aParameter from:changedObject
 ! !
 
+!SettingsDialog methodsFor:'changed settings highlighting'!
+
+highlightWidgetsWithChangedSettings
+    "whenever an app is selected AND a quick search string is present,
+     go through the widgets and highlight those which match.
+     This is done by looking at the helpkey and model aspects for a match"
+
+    |app pattern widgetsToHighlight|
+    
+    highlightedWidgetsOriginalAttributes notNil ifTrue:[
+        self unhighlightWidgets.
+    ].
+    
+    (app := subCanvasApplicationHolder value) isNil ifTrue:[^ self].
+
+    widgetsToHighlight := self widgetsWithChangedSettingsIn:app.
+    self highlightWidgets:widgetsToHighlight.
+!
+
+showNonDefaultSettingsHolderChanged
+    "the show-non-default settings check box has changed.
+     remember the current selection, 
+     update the highlighting of matching fields (and expand corresponding tree nodes),
+     then reselect (because the treeView is too stupid in loosing the selection,
+     when expanding/hiding)"
+     
+    |oldSelection pattern showNonDefault matchingTreeItems|
+    
+    oldSelection := self selectedItem value.
+    self unhighlightFoundItemsFromSearch.
+    
+    (showNonDefault := self showNonDefaultSettingsHolder value) ifFalse:[^ self].
+
+    self highlightApplicationsForWhich:[:app | app hasValuesDifferentFromDefault].
+    
+    oldSelection notNil ifTrue:[
+        oldSelection makeVisible.
+        self selectedItem value:oldSelection.
+        self highlightWidgetsWithChangedSettings
+    ].    
+!
+
+widgetsWithChangedSettingsIn:anApplication
+    "helper:
+     go through the widgets and find those which have a value different
+     from the default settings.
+     This is done by looking at model value (hope they have)"
+
+    |  widgetsToHighlight |
+    
+    widgetsToHighlight := Set new.
+    
+    anApplication widgetsWithChangedSettingsDo:[:eachView |
+        |alreadyIn|
+
+        "/ check if a superview also has it (frames/framedboxes, etc.)
+        alreadyIn := false.
+        eachView allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
+        alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
+    ].
+    ^ widgetsToHighlight.
+! !
+
 !SettingsDialog methodsFor:'initialization & release'!
 
 closeRequest
@@ -1911,7 +1982,7 @@
         perWidget at:#borderWidth: put:w borderWidth.
         perWidget at:#borderColor: put:w borderColor.
         
-        w borderWidth:2.
+        w borderWidth:1.
         w borderColor:Color red.
     ].
 !
@@ -1974,29 +2045,6 @@
     ].    
 !
 
-showNonDefaultSettingsHolderChanged
-    "the show-non-default settings check box has changed.
-     remember the current selection, 
-     update the highlighting of matching fields (and expand corresponding tree nodes),
-     then reselect (because the treeView is too stupid in loosing the selection,
-     when expanding/hiding)"
-     
-    |oldSelection pattern showNonDefault matchingTreeItems|
-    
-    oldSelection := self selectedItem value.
-    self unhighlightFoundItemsFromSearch.
-    
-    (showNonDefault := self showNonDefaultSettingsHolder value) ifFalse:[^ self].
-
-    self highlightApplicationsForWhich:[:app | app hasValuesDifferentFromDefault].
-    
-    oldSelection notNil ifTrue:[
-        oldSelection makeVisible.
-        self selectedItem value:oldSelection.
-        self highlightWidgetsWithMatchingSearchString.
-    ].    
-!
-
 unhighlightFoundItemsFromSearch
     "undo any highlighting of matching fields (from the previous show matching items)"
 
@@ -2085,8 +2133,23 @@
                 "/ check if a superview also has it (frames/framedboxes, etc.)
                 alreadyIn := false.
                 eachView allSuperViewsDo:[:sv | (widgetsToHighlight includes:sv) ifTrue:[ alreadyIn := true]].
-                alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
-            ] ifFalse:[
+                alreadyIn ifFalse:[
+                    ((eachView superView isKindOf:HorizontalPanelView)
+                    or:[eachView superView class == View]) ifTrue:[
+                        (widgetsToHighlight includes:eachView superView) ifFalse:[
+                            eachView superView subViews size > 1 ifTrue:[
+                                (eachView superView subViews contains:[:some | widgetsToHighlight includes:some])
+                                ifTrue:[
+                                    "/ multiple in a panel; highlight the panel, not the children.
+                                    widgetsToHighlight add:eachView superView.
+                                    widgetsToHighlight removeAllFoundIn:eachView superView subViews.
+                                    alreadyIn := true.
+                                ].    
+                            ].    
+                        ].    
+                    ].    
+                    alreadyIn ifFalse:[ widgetsToHighlight add:eachView ].
+                ]    
             ].    
         ].   
     ].