Skip to content

Commit

Permalink
Disable domain menu items if unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Aug 3, 2024
1 parent a19f00b commit af9d380
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
7 changes: 7 additions & 0 deletions lib/apidocs/MsaView.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ type: types.literal('MsaView')
### MsaView - Getters
#### getter: actuallyShowDomains
```js
// type
boolean
```
#### getter: adapterTrackModels
```js
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/dialogs/DomainDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Dialog } from '@jbrowse/core/ui'
import { Tab, Tabs } from '@mui/material'

// locals
import InterProScanPanel from './InterProScanPanel'
import UserProvidedResultPanel from './UserProvidedResultPanel'
import InterProScanPanel from './InterProScanDialog'
import UserProvidedResultPanel from './UserProvidedDomainsDialog'
import TabPanel from './TabPanel'
import type { MsaViewModel } from '../../model'

Expand Down
11 changes: 6 additions & 5 deletions lib/src/components/dialogs/SettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ const MSASettings = observer(function MSASettings({
onChange={() => model.setBgColor(!bgColor)}
label="Color background tiles of MSA?"
/>
<Checkbox2
checked={contrastLettering}
onChange={() => model.setContrastLettering(!contrastLettering)}
label="Use contrast lettering"
/>

<div className={classes.flex}>
<Typography>Column width ({colWidth}px)</Typography>
Expand All @@ -158,11 +163,7 @@ const MSASettings = observer(function MSASettings({
onChange={(_, val) => model.setRowHeight(val as number)}
/>
</div>
<Checkbox2
checked={contrastLettering}
onChange={() => model.setContrastLettering(!contrastLettering)}
label="Use contrast lettering"
/>

<TextField
select
label="Color scheme"
Expand Down
6 changes: 3 additions & 3 deletions lib/src/components/header/HeaderMenuExtra.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const UserProvidedDomainsDialog = lazy(
const InterProScanDialog = lazy(() => import('../dialogs/InterProScanDialog'))

const HeaderMenuExtra = observer(({ model }: { model: MsaViewModel }) => {
const { showDomains, subFeatureRows, noDomains } = model
const { showDomains, actuallyShowDomains, subFeatureRows, noDomains } = model
return (
<CascadingMenuButton
menuItems={[
Expand Down Expand Up @@ -98,14 +98,14 @@ const HeaderMenuExtra = observer(({ model }: { model: MsaViewModel }) => {
label: `Show domains${noDomains ? ' (no domains loaded)' : ''}`,
disabled: noDomains,
icon: Visibility,
checked: showDomains,
checked: actuallyShowDomains ? showDomains : false,
type: 'checkbox',
onClick: () => model.setShowDomains(!showDomains),
},
{
label: `Use sub-row layout${noDomains ? ' (no domains loaded)' : ''}`,
disabled: noDomains,
checked: subFeatureRows,
checked: actuallyShowDomains ? subFeatureRows : false,
icon: Sort,
type: 'checkbox',
onClick: () => model.setSubFeatureRows(!subFeatureRows),
Expand Down
3 changes: 2 additions & 1 deletion lib/src/components/msa/MSACanvasBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const MSACanvasBlock = observer(function ({
return autorun(() => {
ctx.resetTransform()
ctx.clearRect(0, 0, blockSize, blockSize)
if (model.showDomains) {
const { actuallyShowDomains } = model
if (actuallyShowDomains) {
renderBoxFeatureCanvasBlock({
ctx,
offsetX,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/components/msa/renderMSABlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function renderMSABlock({
rowHeight,
fontSize,
highResScaleFactor,
showDomains,
actuallyShowDomains,
} = model
const k = highResScaleFactorOverride || highResScaleFactor
const bx = blockSizeXOverride || blockSize
Expand All @@ -53,7 +53,7 @@ export function renderMSABlock({
const xEnd = Math.max(0, Math.ceil((offsetX + bx) / colWidth))
const visibleLeaves = leaves.slice(yStart, yEnd)

if (!showDomains) {
if (!actuallyShowDomains) {
drawTiles({
model,
ctx,
Expand Down Expand Up @@ -154,7 +154,7 @@ function drawText({
}) {
const {
bgColor,
showDomains,
actuallyShowDomains,
showMsaLetters,
colorScheme,
columns,
Expand All @@ -178,7 +178,7 @@ function drawText({
const x = i * colWidth + offsetX - (offsetX % colWidth)

// note: -rowHeight/4 matches +rowHeight/4 in tree
ctx.fillStyle = showDomains
ctx.fillStyle = actuallyShowDomains
? 'black'
: bgColor
? contrast
Expand Down
6 changes: 6 additions & 0 deletions lib/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ function stateModelFactory() {
}))

.views(self => ({
/**
* #getter
*/
get actuallyShowDomains() {
return self.showDomains && !!self.interProAnnotations
},
/**
* #getter
*/
Expand Down

0 comments on commit af9d380

Please sign in to comment.