Tools__ViewTreeApplication.st
changeset 3124 1973e28a2c75
parent 3123 5bdc0a26498c
child 3141 c3fb91a71410
equal deleted inserted replaced
3123:5bdc0a26498c 3124:1973e28a2c75
    14 "{ NameSpace: Tools }"
    14 "{ NameSpace: Tools }"
    15 
    15 
    16 ToolApplicationModel subclass:#ViewTreeInspectorApplication
    16 ToolApplicationModel subclass:#ViewTreeInspectorApplication
    17 	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
    17 	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
    18 		motionAction process followFocusChannel showNamesHolder
    18 		motionAction process followFocusChannel showNamesHolder
    19 		inspectorView inspectorModeIndexHolder path'
    19 		inspectorView inspectorModeIndexHolder path
       
    20 		isCatchingEventsChannel'
    20 	classVariableNames:''
    21 	classVariableNames:''
    21 	poolDictionaries:''
    22 	poolDictionaries:''
    22 	category:'Interface-Smalltalk'
    23 	category:'Interface-Smalltalk'
    23 !
    24 !
    24 
    25 
   167     <resource: #help>
   168     <resource: #help>
   168 
   169 
   169     ^super flyByHelpSpec addPairsFrom:#(
   170     ^super flyByHelpSpec addPairsFrom:#(
   170 
   171 
   171 #doUncatchEvents
   172 #doUncatchEvents
   172 'Release Picked View and Uncatch Events (Currently Locked)'  
   173 'Release picked view and uncatch events\(currently locked for widget selection)'  
   173 
   174 
   174 #doCatchEvents
   175 #doCatchEvents
   175 'Release Picked View and Uncatch Events (Currently Unlocked)'  
   176 'Lock view and catch events for widget selection\(currently unlocked)'  
   176 
   177 
   177 )
   178 )
   178 ! !
   179 ! !
   179 
   180 
   180 !ViewTreeInspectorApplication class methodsFor:'image specs'!
   181 !ViewTreeInspectorApplication class methodsFor:'image specs'!
   829             hideMenuOnActivated: false
   830             hideMenuOnActivated: false
   830             labelImage: (ResourceRetriever #'Tools::ViewTreeInspectorApplication' pickWindowIcon2)
   831             labelImage: (ResourceRetriever #'Tools::ViewTreeInspectorApplication' pickWindowIcon2)
   831           )
   832           )
   832          (MenuItem
   833          (MenuItem
   833             enabled: hasTargetWidgetChannel
   834             enabled: hasTargetWidgetChannel
       
   835             isVisible: isNotCatchingEventsChannel
       
   836             label: 'Catch Events of Picked View'
       
   837             activeHelpKey: doCatchEvents
       
   838             itemValue: doCatchEvents
       
   839             nameKey: doCatchEvents
       
   840             isButton: true
       
   841             labelImage: (ResourceRetriever nil releaseViewIcon)
       
   842           )
       
   843          (MenuItem
       
   844             enabled: hasTargetWidgetChannel
       
   845             isVisible: isCatchingEventsChannel
   834             label: 'Release Picked View and Uncatch Events'
   846             label: 'Release Picked View and Uncatch Events'
   835             activeHelpKey: doUncatchEvents
   847             activeHelpKey: doUncatchEvents
   836             itemValue: doUncatchEvents
   848             itemValue: doUncatchEvents
   837             nameKey: doUncatchEvents
   849             nameKey: doUncatchEvents
   838             isButton: true
   850             isButton: true
   839             labelImage: (ResourceRetriever nil releaseViewIcon)
   851             labelImage: (ResourceRetriever nil lockViewIcon)
   840           )
   852           )
   841          (MenuItem
   853          (MenuItem
   842             label: '-'
   854             label: '-'
   843           )
   855           )
   844          (MenuItem
   856          (MenuItem
   873     |app|
   885     |app|
   874 
   886 
   875     app := self new.
   887     app := self new.
   876     app open.
   888     app open.
   877     app doPickView.
   889     app doPickView.
       
   890     ^ app
       
   891 !
       
   892 
       
   893 openInPickModeAndRelease
       
   894     "release the pick-lock after picking"
       
   895 
       
   896     |app|
       
   897 
       
   898     app := self openInPickMode.
       
   899     app doUncatchEvents.
       
   900     ^ app
   878 !
   901 !
   879 
   902 
   880 openOn:aView
   903 openOn:aView
   881     "show a particular window's topView hierarchy,
   904     "show a particular window's topView hierarchy,
   882      select the given view"
   905      select the given view"
   884     |app|
   907     |app|
   885 
   908 
   886     app := self new.
   909     app := self new.
   887     app open.
   910     app open.
   888     app showWindow:aView.
   911     app showWindow:aView.
       
   912     ^ app
   889 ! !
   913 ! !
   890 
   914 
   891 !ViewTreeInspectorApplication methodsFor:'actions'!
   915 !ViewTreeInspectorApplication methodsFor:'actions'!
   892 
   916 
   893 indicatorClicked:anIndex
   917 indicatorClicked:anIndex
   961 
   985 
   962 inspectorModes
   986 inspectorModes
   963     ^ #('Widget' 'Application' 'WindowGroup' 'Sensor' 'Model')
   987     ^ #('Widget' 'Application' 'WindowGroup' 'Sensor' 'Model')
   964 
   988 
   965     "Created: / 30-07-2013 / 09:42:16 / cg"
   989     "Created: / 30-07-2013 / 09:42:16 / cg"
       
   990 !
       
   991 
       
   992 isCatchingEventsChannel
       
   993     ^ isCatchingEventsChannel
       
   994 !
       
   995 
       
   996 isNotCatchingEventsChannel
       
   997     ^ BlockValue forLogicalNot:self isCatchingEventsChannel
   966 !
   998 !
   967 
   999 
   968 listOfItems
  1000 listOfItems
   969     "returns the hierarchical list of items"
  1001     "returns the hierarchical list of items"
   970 
  1002 
  1315 
  1347 
  1316     super initialize.
  1348     super initialize.
  1317 
  1349 
  1318     hasSingleSelectionHolder := false asValue.
  1350     hasSingleSelectionHolder := false asValue.
  1319     followFocusChannel       := false asValue.
  1351     followFocusChannel       := false asValue.
       
  1352     isCatchingEventsChannel  := false asValue.
  1320     inspectorModeIndexHolder := 1 asValue.
  1353     inspectorModeIndexHolder := 1 asValue.
  1321     inspectorModeIndexHolder onChangeSend:#inspectorModeIndexHolderChanged to:self.
  1354     inspectorModeIndexHolder onChangeSend:#inspectorModeIndexHolderChanged to:self.
  1322 
  1355 
  1323     model := ViewTreeModel new.
  1356     model := ViewTreeModel new.
  1324     model inputEventAction:[:ev| self processEvent:ev ].
  1357     model inputEventAction:[:ev| self processEvent:ev ].
  1914     ].
  1947     ].
  1915 
  1948 
  1916     "Modified: / 28-08-2013 / 23:57:42 / cg"
  1949     "Modified: / 28-08-2013 / 23:57:42 / cg"
  1917 !
  1950 !
  1918 
  1951 
       
  1952 doCatchEvents
       
  1953     model catchEvents:true.
       
  1954     isCatchingEventsChannel value:true.
       
  1955 "/    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
       
  1956 "/        enabled:true;
       
  1957 "/        label:(self class releaseViewIcon);
       
  1958 "/        activeHelpKey:#doUncatchEvents.
       
  1959 !
       
  1960 
  1919 doDestroy
  1961 doDestroy
  1920     "destroy the current selected view"
  1962     "destroy the current selected view"
  1921 
  1963 
  1922     |item parent|
  1964     |item parent|
  1923 
  1965 
  2024 !
  2066 !
  2025 
  2067 
  2026 doRedraw
  2068 doRedraw
  2027     "redraw the app"
  2069     "redraw the app"
  2028 
  2070 
  2029     model rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
  2071     model rootView notNil ifTrue:[
       
  2072         model rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
       
  2073     ]
  2030 !
  2074 !
  2031 
  2075 
  2032 doSelectNextOfApplicationClass:aClass startingIn:anItem
  2076 doSelectNextOfApplicationClass:aClass startingIn:anItem
  2033     |startItem firstFound searchNext|
  2077     |startItem firstFound searchNext|
  2034 
  2078 
  2080         model selectItem:firstFound
  2124         model selectItem:firstFound
  2081     ].
  2125     ].
  2082 !
  2126 !
  2083 
  2127 
  2084 doUncatchEvents
  2128 doUncatchEvents
       
  2129     "release the inspected window (no longer catch its events)"
       
  2130 
  2085     model catchEvents:false.
  2131     model catchEvents:false.
  2086     ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
  2132     isCatchingEventsChannel value:false.
  2087         label:(self class releaseViewIcon);
  2133 "/    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
  2088         enabled:false;
  2134 "/        label:(self class releaseViewIcon);
  2089         activeHelpKey:#doCatchEvents.
  2135 "/        enabled:false;
       
  2136 "/        activeHelpKey:#doCatchEvents.
  2090     self doRedraw
  2137     self doRedraw
  2091 !
  2138 !
  2092 
  2139 
  2093 doUnpick
  2140 doUnpick
  2094     "release current picked window and contained subwindows"
  2141     "release current picked window and contained subwindows"
  2106 
  2153 
  2107     | topWindow |
  2154     | topWindow |
  2108 
  2155 
  2109     topWindow := aView topView.
  2156     topWindow := aView topView.
  2110 
  2157 
  2111     model catchEvents:true.
  2158     self doCatchEvents.
  2112     ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
       
  2113         enabled:true;
       
  2114         label:(self class releaseViewIcon);
       
  2115         activeHelpKey:#doUncatchEvents.
       
  2116     self setRootItem:(ViewTreeItem buildViewsFrom:topWindow).
  2159     self setRootItem:(ViewTreeItem buildViewsFrom:topWindow).
  2117     self selectView:aView.
  2160     self selectView:aView.
  2118 ! !
  2161 ! !
  2119 
  2162 
  2120 !ViewTreeInspectorApplication::MenuDesc class methodsFor:'building'!
  2163 !ViewTreeInspectorApplication::MenuDesc class methodsFor:'building'!