@@ -2,7 +2,7 @@ import React from "react";
2
2
import { withTranslation } from "react-i18next" ;
3
3
import { FaSearchMinus } from "react-icons/fa" ;
4
4
import { updateVisibleTipsAndBranchThicknesses } from "../../actions/tree" ;
5
- import { CHANGE_TREE_ZOOM } from "../../actions/types" ;
5
+ import { CHANGE_TREE_FOCUS } from "../../actions/types" ;
6
6
import Card from "../framework/card" ;
7
7
import Legend from "./legend/legend" ;
8
8
import PhyloTree from "./phyloTree/phyloTree" ;
@@ -40,7 +40,7 @@ class Tree extends React.Component {
40
40
this . clearSelectedNode = callbacks . clearSelectedNode . bind ( this ) ;
41
41
// this.handleIconClickHOF = callbacks.handleIconClickHOF.bind(this);
42
42
this . redrawTree = ( ) => {
43
- this . props . dispatch ( { type : CHANGE_TREE_ZOOM , data : "even" } ) ;
43
+ this . props . dispatch ( { type : CHANGE_TREE_FOCUS , data : "even" } ) ;
44
44
this . props . dispatch ( updateVisibleTipsAndBranchThicknesses ( {
45
45
root : [ 0 , 0 ]
46
46
} ) ) ;
@@ -112,9 +112,17 @@ class Tree extends React.Component {
112
112
}
113
113
114
114
getStyles = ( ) => {
115
- // FIXME: double-check this
116
- const activeResetTreeButton = true ;
117
- const activeZoomButton = true ;
115
+ const activeResetTreeButton = this . props . tree . idxOfInViewRootNode !== 0 ||
116
+ this . props . treeToo . idxOfInViewRootNode !== 0 ;
117
+
118
+ const filteredTree = ! ! this . props . tree . idxOfFilteredRoot &&
119
+ this . props . tree . idxOfInViewRootNode !== this . props . tree . idxOfFilteredRoot ;
120
+ const filteredTreeToo = ! ! this . props . treeToo . idxOfFilteredRoot &&
121
+ this . props . treeToo . idxOfInViewRootNode !== this . props . treeToo . idxOfFilteredRoot ;
122
+ const activeZoomButton = filteredTree || filteredTreeToo ;
123
+
124
+ const activeFocusButton = true ;
125
+
118
126
const treeIsZoomed = this . props . tree . idxOfInViewRootNode !== 0 ||
119
127
this . props . treeToo . idxOfInViewRootNode !== 0 ;
120
128
@@ -139,6 +147,13 @@ class Tree extends React.Component {
139
147
color : activeZoomButton ? darkGrey : lightGrey ,
140
148
pointerEvents : activeZoomButton ? "auto" : "none"
141
149
} ,
150
+ focusOnSelectedButton : {
151
+ zIndex : 100 ,
152
+ display : "inline-block" ,
153
+ cursor : activeFocusButton ? "pointer" : "auto" ,
154
+ color : activeFocusButton ? darkGrey : lightGrey ,
155
+ pointerEvents : activeFocusButton ? "auto" : "none"
156
+ } ,
142
157
zoomOutButton : {
143
158
zIndex : 100 ,
144
159
display : "inline-block" ,
@@ -162,20 +177,23 @@ class Tree extends React.Component {
162
177
) ;
163
178
}
164
179
165
- zoomToSelected = ( ) => {
166
- // if currently set to "even", start at "zoom "
167
- let treeZoomData = "zoom " ;
168
- if ( this . props . treeZoom . includes ( "zoom " ) ) {
169
- // if currently at "zoom ", increment to "zoom -2"
170
- if ( ! this . props . treeZoom . includes ( "-" ) ) {
171
- treeZoomData = "zoom -2" ;
180
+ focusOnSelected = ( ) => {
181
+ // if currently set to "even", start at "focus "
182
+ let treeFocusData = "focus " ;
183
+ if ( this . props . treeFocus . includes ( "focus " ) ) {
184
+ // if currently at "focus ", increment to "focus -2"
185
+ if ( ! this . props . treeFocus . includes ( "-" ) ) {
186
+ treeFocusData = "focus -2" ;
172
187
} else {
173
- // if currently at "zoom -2", increment to "zoom -3", etc...
174
- const increment = parseInt ( this . props . treeZoom . split ( '-' ) [ 1 ] , 10 ) + 1 ;
175
- treeZoomData = "zoom -" + increment . toString ( ) ;
188
+ // if currently at "focus -2", increment to "focus -3", etc...
189
+ const increment = parseInt ( this . props . treeFocus . split ( '-' ) [ 1 ] , 10 ) + 1 ;
190
+ treeFocusData = "focus -" + increment . toString ( ) ;
176
191
}
177
192
}
178
- this . props . dispatch ( { type : CHANGE_TREE_ZOOM , data : treeZoomData } ) ;
193
+ this . props . dispatch ( { type : CHANGE_TREE_FOCUS , data : treeFocusData } ) ;
194
+ } ;
195
+
196
+ zoomToSelected = ( ) => {
179
197
this . props . dispatch ( updateVisibleTipsAndBranchThicknesses ( {
180
198
root : [ this . props . tree . idxOfFilteredRoot , this . props . treeToo . idxOfFilteredRoot ]
181
199
} ) ) ;
@@ -266,6 +284,12 @@ class Tree extends React.Component {
266
284
>
267
285
{ t ( "Zoom to Selected" ) }
268
286
</ button >
287
+ < button
288
+ style = { { ...tabSingle , ...styles . focusOnSelectedButton } }
289
+ onClick = { this . focusOnSelected }
290
+ >
291
+ { t ( "Focus On Selected" ) }
292
+ </ button >
269
293
< button
270
294
style = { { ...tabSingle , ...styles . resetTreeButton } }
271
295
onClick = { this . redrawTree }
0 commit comments