-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add toggle color layer visibility button #3943
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ac10a38
added toggle button and visibilty configuration for each color layer
MichaelBuessemeyer 37ce3f9
added changelog entry and adjusted the documentation
MichaelBuessemeyer 7969b11
applied feedback
MichaelBuessemeyer 7ab5f2a
changed naming to disabled and added tooltip when there are disabled …
MichaelBuessemeyer 728554c
removed console log
MichaelBuessemeyer 291d07e
disabled other options when layer is disabled
MichaelBuessemeyer 0775284
fixed typo
MichaelBuessemeyer fa76225
Merge branch 'master' into toggle-layer-visibility
MichaelBuessemeyer abe4cac
applied feedback and changed icon to a switch
MichaelBuessemeyer ffb61aa
Merge branch 'master' into toggle-layer-visibility
MichaelBuessemeyer 876fc91
made code pretty
MichaelBuessemeyer aa46072
Merge branch 'master' into toggle-layer-visibility
MichaelBuessemeyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @flow | ||
*/ | ||
|
||
import { Col, Collapse, Divider, Icon, Row, Select, Tag, Tooltip } from "antd"; | ||
import { Col, Collapse, Divider, Icon, Row, Select, Switch, Tag, Tooltip } from "antd"; | ||
import type { Dispatch } from "redux"; | ||
import { connect } from "react-redux"; | ||
import * as React from "react"; | ||
|
@@ -39,8 +39,8 @@ import constants, { | |
} from "oxalis/constants"; | ||
import messages, { settings } from "messages"; | ||
|
||
const Panel = Collapse.Panel; | ||
const Option = Select.Option; | ||
const { Panel } = Collapse; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also done by my ide |
||
const { Option } = Select; | ||
|
||
type DatasetSettingsProps = {| | ||
datasetConfiguration: DatasetConfiguration, | ||
|
@@ -65,20 +65,35 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> { | |
isLastLayer: boolean, | ||
) => { | ||
const isRGB = isRgb(this.props.dataset, layerName); | ||
const { brightness, contrast, alpha, color } = layer; | ||
const { brightness, contrast, alpha, color, isDisabled } = layer; | ||
return ( | ||
<div key={layerName}> | ||
<Row> | ||
<Col span={24}> | ||
{/* TODO Maybe use the new antd icons instead of the switch when upgrading antd. */} | ||
<Tooltip title={isDisabled ? "Enable" : "Disable"} placement="top"> | ||
{/* This div is necessary for the tooltip to be displayed */} | ||
<div style={{ display: "inline-block", marginRight: 8 }}> | ||
<Switch | ||
size="small" | ||
onChange={val => this.props.onChangeLayer(layerName, "isDisabled", !val)} | ||
checked={!isDisabled} | ||
/> | ||
</div> | ||
</Tooltip> | ||
<span style={{ fontWeight: 700 }}>{layerName}</span> | ||
<Tag style={{ cursor: "default", marginLeft: 8 }} color={isRGB && "#1890ff"}> | ||
{isRGB ? "24-bit" : "8-bit"} Layer | ||
</Tag> | ||
<Tooltip title="If you are having trouble finding your data, webKnossos can try to find a position which contains data."> | ||
<Icon | ||
type="scan" | ||
onClick={() => this.handleFindData(layerName)} | ||
style={{ float: "right", marginTop: 4, cursor: "pointer" }} | ||
onClick={!isDisabled ? () => this.handleFindData(layerName) : () => {}} | ||
style={{ | ||
float: "right", | ||
marginTop: 4, | ||
cursor: !isDisabled ? "pointer" : "not-allowed", | ||
}} | ||
/> | ||
</Tooltip> | ||
</Col> | ||
|
@@ -90,6 +105,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> { | |
step={5} | ||
value={brightness} | ||
onChange={_.partial(this.props.onChangeLayer, layerName, "brightness")} | ||
disabled={isDisabled} | ||
/> | ||
<NumberSliderSetting | ||
label="Contrast" | ||
|
@@ -98,19 +114,22 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> { | |
step={0.1} | ||
value={contrast} | ||
onChange={_.partial(this.props.onChangeLayer, layerName, "contrast")} | ||
disabled={isDisabled} | ||
/> | ||
<NumberSliderSetting | ||
label="Opacity" | ||
min={0} | ||
max={100} | ||
value={alpha} | ||
onChange={_.partial(this.props.onChangeLayer, layerName, "alpha")} | ||
disabled={isDisabled} | ||
/> | ||
<ColorSetting | ||
label="Color" | ||
value={Utils.rgbToHex(color)} | ||
onChange={_.partial(this.props.onChangeLayer, layerName, "color")} | ||
className="ant-btn" | ||
disabled={isDisabled} | ||
/> | ||
{!isLastLayer && <Divider />} | ||
</div> | ||
|
@@ -176,16 +195,31 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> { | |
); | ||
} | ||
|
||
renderPanelHeader = (hasInvisibleLayers: boolean) => | ||
hasInvisibleLayers ? ( | ||
<span> | ||
Color Layers | ||
<Tooltip title="Not all layers are currently visible."> | ||
<Icon type="exclamation-circle-o" style={{ marginLeft: 16, color: "coral" }} /> | ||
</Tooltip> | ||
</span> | ||
) : ( | ||
"Color Layers" | ||
); | ||
|
||
render() { | ||
const { layers } = this.props.datasetConfiguration; | ||
const colorSettings = Object.entries(layers).map((entry, index) => | ||
// $FlowFixMe Object.entries returns mixed for Flow | ||
this.getColorSettings(entry, index, index === _.size(layers) - 1), | ||
); | ||
|
||
const hasInvisibleLayers = | ||
Object.keys(layers).find( | ||
layerName => layers[layerName].isDisabled || layers[layerName].alpha === 0, | ||
) != null; | ||
return ( | ||
<Collapse bordered={false} defaultActiveKey={["1", "2", "3", "4"]}> | ||
<Panel header="Color Layers" key="1"> | ||
<Panel header={this.renderPanelHeader(hasInvisibleLayers)} key="1"> | ||
{colorSettings} | ||
</Panel> | ||
{this.props.hasSegmentation ? this.getSegmentationPanel() : null} | ||
|
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my ide beautifies code again 🤔
As this is accepted by prettier I suggest to keep it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, in the long run, this can be quite cumbersome. This is especially prone to merge conflicts. Can you please disable any IDE auto-formatting which differs from prettiers behavior?