-
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.
- Loading branch information
Showing
8 changed files
with
327 additions
and
86 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> | ||
</> | ||
) | ||
} |
52 changes: 52 additions & 0 deletions
52
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,52 @@ | ||
import { lazy } from 'react' | ||
|
||
import { getBpDisplayStr, getSession } 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 RegionWidthEditorDialog = lazy(() => import('./RegionWidthEditorDialog')) | ||
|
||
const useStyles = makeStyles()({ | ||
bp: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
marginLeft: 5, | ||
cursor: 'pointer', | ||
minWidth: 50, | ||
'&:hover': { | ||
backgroundColor: 'rgba(0, 0, 0, 0.2)', | ||
}, | ||
}, | ||
}) | ||
|
||
const HeaderRegionWidth = observer(function ({ | ||
model, | ||
}: { | ||
model: LinearGenomeViewModel | ||
}) { | ||
const { classes } = useStyles() | ||
const { coarseTotalBp } = model | ||
return ( | ||
<Typography | ||
variant="body2" | ||
color="textSecondary" | ||
className={classes.bp} | ||
onClick={() => { | ||
getSession(model).queueDialog(handleClose => [ | ||
RegionWidthEditorDialog, | ||
{ | ||
model, | ||
handleClose, | ||
}, | ||
]) | ||
}} | ||
> | ||
{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 |
106 changes: 106 additions & 0 deletions
106
plugins/linear-genome-view/src/LinearGenomeView/components/HeaderZoomControls.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,106 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
import ZoomIn from '@mui/icons-material/ZoomIn' | ||
import ZoomOut from '@mui/icons-material/ZoomOut' | ||
import { IconButton, Slider, Tooltip } from '@mui/material' | ||
import { observer } from 'mobx-react' | ||
import { makeStyles } from 'tss-react/mui' | ||
|
||
import type { LinearGenomeViewModel } from '..' | ||
|
||
const useStyles = makeStyles()(theme => ({ | ||
container: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}, | ||
slider: { | ||
width: 100, | ||
color: theme.palette.text.secondary, | ||
}, | ||
})) | ||
|
||
const HeaderZoomControls = observer(function ({ | ||
model, | ||
}: { | ||
model: LinearGenomeViewModel | ||
}) { | ||
const { classes } = useStyles() | ||
const { maxBpPerPx, minBpPerPx, bpPerPx } = model | ||
const [value, setValue] = useState(-Math.log2(bpPerPx) * 100) | ||
useEffect(() => { | ||
setValue(-Math.log2(bpPerPx) * 100) | ||
}, [bpPerPx]) | ||
const zoomInDisabled = bpPerPx <= minBpPerPx + 0.0001 | ||
const zoomOutDisabled = bpPerPx >= maxBpPerPx - 0.0001 | ||
return ( | ||
<div className={classes.container}> | ||
<Tooltip title="Zoom out 15x"> | ||
<span> | ||
<IconButton | ||
data-testid="zoom_out_more" | ||
disabled={zoomOutDisabled} | ||
onClick={() => { | ||
model.zoom(bpPerPx * 15) | ||
}} | ||
> | ||
<ZoomOut fontSize="large" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
<Tooltip title="Zoom out 2x"> | ||
<span> | ||
<IconButton | ||
data-testid="zoom_out" | ||
disabled={zoomOutDisabled} | ||
onClick={() => { | ||
model.zoom(bpPerPx * 2) | ||
}} | ||
> | ||
<ZoomOut /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
|
||
<Slider | ||
size="small" | ||
className={classes.slider} | ||
value={value} | ||
min={-Math.log2(maxBpPerPx) * 100} | ||
max={-Math.log2(minBpPerPx) * 100} | ||
onChangeCommitted={() => model.zoomTo(2 ** (-value / 100))} | ||
onChange={(_, val) => { | ||
setValue(val as number) | ||
}} | ||
/> | ||
<Tooltip title="Zoom in 2x"> | ||
<span> | ||
<IconButton | ||
data-testid="zoom_in" | ||
disabled={zoomInDisabled} | ||
onClick={() => { | ||
model.zoom(model.bpPerPx / 2) | ||
}} | ||
> | ||
<ZoomIn /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
<Tooltip title="Zoom in 15x"> | ||
<span> | ||
<IconButton | ||
data-testid="zoom_in_more" | ||
disabled={zoomInDisabled} | ||
onClick={() => { | ||
model.zoom(model.bpPerPx / 15) | ||
}} | ||
> | ||
<ZoomIn fontSize="large" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
</div> | ||
) | ||
}) | ||
|
||
export default HeaderZoomControls |
Oops, something went wrong.