-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to edit region size as 'Custom zoom' (#4789)
- Loading branch information
Showing
14 changed files
with
344 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
plugins/linear-genome-view/src/LinearGenomeView/components/HeaderPanControls.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import ArrowBackIcon from '@mui/icons-material/ArrowBack' | ||
import ArrowForwardIcon from '@mui/icons-material/ArrowForward' | ||
import { Button, alpha } from '@mui/material' | ||
import { makeStyles } from 'tss-react/mui' | ||
|
||
import { SPACING } from '../consts' | ||
|
||
import type { LinearGenomeViewModel } from '..' | ||
|
||
type LGV = LinearGenomeViewModel | ||
const useStyles = makeStyles()(theme => ({ | ||
panButton: { | ||
background: alpha(theme.palette.background.paper, 0.8), | ||
color: theme.palette.text.primary, | ||
margin: SPACING, | ||
}, | ||
|
||
buttonSpacer: { | ||
marginRight: theme.spacing(2), | ||
}, | ||
})) | ||
|
||
export default function HeaderPanControls({ model }: { model: LGV }) { | ||
const { classes } = useStyles() | ||
return ( | ||
<> | ||
<Button | ||
variant="outlined" | ||
className={classes.panButton} | ||
onClick={() => { | ||
model.slide(-0.9) | ||
}} | ||
> | ||
<ArrowBackIcon /> | ||
</Button> | ||
<Button | ||
variant="outlined" | ||
className={classes.panButton} | ||
onClick={() => { | ||
model.slide(0.9) | ||
}} | ||
> | ||
<ArrowForwardIcon /> | ||
</Button> | ||
</> | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
plugins/linear-genome-view/src/LinearGenomeView/components/HeaderRegionWidth.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getBpDisplayStr } from '@jbrowse/core/util' | ||
import { Typography } from '@mui/material' | ||
import { observer } from 'mobx-react' | ||
import { makeStyles } from 'tss-react/mui' | ||
|
||
import type { LinearGenomeViewModel } from '..' | ||
|
||
const useStyles = makeStyles()({ | ||
bp: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
marginLeft: 5, | ||
cursor: 'pointer', | ||
}, | ||
}) | ||
|
||
const HeaderRegionWidth = observer(function ({ | ||
model, | ||
}: { | ||
model: LinearGenomeViewModel | ||
}) { | ||
const { classes } = useStyles() | ||
const { coarseTotalBp } = model | ||
return ( | ||
<Typography variant="body2" color="textSecondary" className={classes.bp}> | ||
{getBpDisplayStr(coarseTotalBp)} | ||
</Typography> | ||
) | ||
}) | ||
|
||
export default HeaderRegionWidth |
34 changes: 34 additions & 0 deletions
34
plugins/linear-genome-view/src/LinearGenomeView/components/HeaderTrackSelectorButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons' | ||
import { IconButton } from '@mui/material' | ||
import { observer } from 'mobx-react' | ||
import { makeStyles } from 'tss-react/mui' | ||
|
||
import type { LinearGenomeViewModel } from '..' | ||
|
||
const useStyles = makeStyles()(theme => ({ | ||
toggleButton: { | ||
height: 44, | ||
border: 'none', | ||
marginLeft: theme.spacing(4), | ||
}, | ||
})) | ||
|
||
const HeaderTrackSelectorButton = observer(function ({ | ||
model, | ||
}: { | ||
model: LinearGenomeViewModel | ||
}) { | ||
const { classes } = useStyles() | ||
return ( | ||
<IconButton | ||
onClick={model.activateTrackSelector} | ||
className={classes.toggleButton} | ||
title="Open track selector" | ||
value="track_select" | ||
> | ||
<TrackSelectorIcon /> | ||
</IconButton> | ||
) | ||
}) | ||
|
||
export default HeaderTrackSelectorButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
plugins/linear-genome-view/src/LinearGenomeView/components/RegionWidthEditorDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
import { Dialog } from '@jbrowse/core/ui' | ||
import { toLocale } from '@jbrowse/core/util' | ||
import { | ||
Button, | ||
DialogActions, | ||
DialogContent, | ||
TextField, | ||
Typography, | ||
} from '@mui/material' | ||
import { observer } from 'mobx-react' | ||
|
||
import type { LinearGenomeViewModel } from '../model' | ||
|
||
const toP = (s = 0) => +(+s).toFixed(1) | ||
|
||
const RegionWidthEditorDialog = observer(function ({ | ||
model, | ||
handleClose, | ||
}: { | ||
model: LinearGenomeViewModel | ||
handleClose: () => void | ||
}) { | ||
const { bpPerPx, width } = model | ||
const [val, setVal] = useState(toLocale(toP(bpPerPx * width))) | ||
useEffect(() => { | ||
setVal(toLocale(bpPerPx * width)) | ||
}, [bpPerPx, width]) | ||
const val2 = val.replace(/,/g, '') | ||
return ( | ||
<Dialog title="Edit zoom level" open onClose={handleClose}> | ||
<DialogContent | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: 30, | ||
}} | ||
> | ||
<Typography> | ||
Enter a specific number of base pairs to change the viewport to show. | ||
This is approximate and does not account for padding between regions | ||
or off-screen scrolling | ||
</Typography> | ||
<TextField | ||
helperText="current zoom level (in bp)" | ||
value={val} | ||
onChange={event => { | ||
setVal(event.target.value) | ||
}} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
variant="contained" | ||
color="secondary" | ||
onClick={() => { | ||
handleClose() | ||
}} | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
onClick={() => { | ||
model.zoomTo(+val2 / model.width) | ||
handleClose() | ||
}} | ||
> | ||
Submit | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
}) | ||
|
||
export default RegionWidthEditorDialog |
Oops, something went wrong.