Skip to content
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

Make layer settings visually consistent #7295

Merged
merged 6 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
[Commits](https://github.com/scalableminds/webknossos/compare/23.09.0...HEAD)

### Added
- Added disabled drag handles to volume and skeleton layers for visual consistency. These layer cannot be dragged or reordered. [#7295](https://github.com/scalableminds/webknossos/pull/7295)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,47 @@ const SortableLayerSettingsContainer = SortableContainer(({ children }: { childr
return <div>{children}</div>;
});

const DragHandle = SortableHandle(() => (
<div
style={{
display: "inline-flex",
justifyContent: "center",
cursor: "grab",
alignItems: "center",
}}
>
<MenuOutlined
type DragHandleProps = {
hasLessThanTwoColorLayers: boolean;
};

function dragHandleIcon(isDisabled: boolean = false) {
return (
<div
style={{
display: "inline-block",
marginRight: 8,
display: "inline-flex",
justifyContent: "center",
cursor: "grab",
alignItems: "center",
color: isDisabled ? "rgba(0, 0, 0, 0.25)" : "rgba(0, 0, 0, 0.60)",
}}
/>
</div>
));
>
<MenuOutlined
style={{
display: "inline-block",
marginRight: 8,
}}
/>
</div>
);
}
const DragHandle = SortableHandle(({ hasLessThanTwoColorLayers }: DragHandleProps) => {
return hasLessThanTwoColorLayers ? (
<Tooltip title="Order is only changeable with more than one color layer.">
{dragHandleIcon(true)}
</Tooltip>
) : (
dragHandleIcon()
);
});

function DummyDragHandle({ layerType }: { layerType: string }) {
return (
<Tooltip title={`Layer not movable: ${layerType} layers are always rendered on top.`}>
{dragHandleIcon(true)}
</Tooltip>
);
}

function TransformationIcon({ layer }: { layer: APIDataLayer }) {
const dispatch = useDispatch();
Expand Down Expand Up @@ -484,7 +508,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerName: string,
elementClass: string,
layerSettings: DatasetLayerConfiguration,
draggingDisabled: boolean = true,
hasLessThanTwoColorLayers: boolean = true,
) => {
const { tracing, dataset } = this.props;
const { intensityRange } = layerSettings;
Expand Down Expand Up @@ -572,7 +596,11 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
const items = possibleItems.filter((el) => el);
return (
<div className="flex-container">
{draggingDisabled ? null : <DragHandle />}
{isColorLayer ? (
<DragHandle hasLessThanTwoColorLayers={hasLessThanTwoColorLayers} />
) : (
<DummyDragHandle layerType="Volume" />
)}
{this.getEnableDisableLayerSwitch(isDisabled, onChange)}
<div
className="flex-item"
Expand Down Expand Up @@ -841,12 +869,12 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerName,
layerConfiguration,
isColorLayer,
draggingDisabled = true,
hasLessThanTwoColorLayers = true,
}: {
layerName: string;
layerConfiguration: DatasetLayerConfiguration | null | undefined;
isColorLayer: boolean;
draggingDisabled?: boolean;
hasLessThanTwoColorLayers?: boolean;
}) => {
// Ensure that every layer needs a layer configuration and that color layers have a color layer.
if (!layerConfiguration || (isColorLayer && !layerConfiguration.color)) {
Expand All @@ -863,7 +891,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerName,
elementClass,
layerConfiguration,
draggingDisabled,
hasLessThanTwoColorLayers,
)}
{isDisabled ? null : (
<div
Expand Down Expand Up @@ -1058,6 +1086,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
paddingRight: 1,
}}
>
<DummyDragHandle layerType="Skeleton" />
<div
className="flex-item"
style={{
Expand Down Expand Up @@ -1288,7 +1317,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
const segmentationLayerNames = Object.keys(layers).filter(
(layerName) => !getIsColorLayer(this.props.dataset, layerName),
);
const isSortingDisabled = colorLayerOrder.length < 2;
const hasLessThanTwoColorLayers = colorLayerOrder.length < 2;
const colorLayerSettings = colorLayerOrder.map((layerName, index) => {
return (
<SortableLayerSettings
Expand All @@ -1297,8 +1326,8 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
layerConfiguration={layers[layerName]}
isColorLayer
index={index}
disabled={isSortingDisabled}
draggingDisabled={isSortingDisabled}
disabled={hasLessThanTwoColorLayers}
hasLessThanTwoColorLayers={hasLessThanTwoColorLayers}
/>
);
});
Expand Down