Skip to content

Commit

Permalink
#4692 - Macro: Cursors should be copied from small mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-asiyuk-epam committed May 27, 2024
1 parent 0c3b2de commit 66d6d0b
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createPolymerEditorCanvas } from '../../../helpers/dom';
import { PeptideRenderer } from 'application/render/renderers/PeptideRenderer';
import { PeptideRenderer } from 'application/render/renderers';
import { Peptide } from 'domain/entities/Peptide';
import { peptideMonomerItem, polymerEditorTheme } from '../../../mock-data';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ exports[`PeptideRenderer should render peptide 1`] = `
<use
fill="yellow"
href="#peptide"
style="cursor: pointer;"
/>
<text
fill="black"
Expand Down
1 change: 1 addition & 0 deletions packages/ketcher-core/src/application/editor/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './Editor';
export * from './EditorHistory';
export * from './shared/coordinates';
export * from './editor.types';
export * from './tools/SelectRectangle';
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class SelectRectangle implements BaseTool {
this.brushArea.call(this.brush);

this.brushArea.select('rect.selection').style('fill', 'transparent');
this.brushArea.select('rect.overlay').attr('cursor', 'default');

const handleResizeCanvas = () => {
const { canvas } = this.editor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BaseMonomer } from 'domain/entities/BaseMonomer';
import { D3SvgElementSelection } from 'application/render/types';
import { DrawingEntity } from 'domain/entities/DrawingEntity';
import { editorEvents } from 'application/editor/editorEvents';
import { CoreEditor, SelectRectangle } from 'application/editor/internal';
import assert from 'assert';
import {
attachmentPointNumberToAngle,
Expand All @@ -23,6 +24,7 @@ const labelPositions: { [key: string]: { x: number; y: number } | undefined } =

export abstract class BaseMonomerRenderer extends BaseRenderer {
private editorEvents: typeof editorEvents;
private editor: CoreEditor;
private selectionCircle?: D3SvgElementSelection<SVGCircleElement, void>;
private selectionBorder?: D3SvgElementSelection<SVGUseElement, void>;

Expand Down Expand Up @@ -54,6 +56,7 @@ export abstract class BaseMonomerRenderer extends BaseRenderer {
super(monomer as DrawingEntity);
this.monomer.setRenderer(this);
this.editorEvents = editorEvents;
this.editor = CoreEditor?.provideEditorInstance();
this.monomerSymbolElement = document.querySelector(
`${monomerSymbolElementId} .monomer-body`,
) as SVGUseElement | SVGRectElement;
Expand Down Expand Up @@ -318,8 +321,13 @@ export abstract class BaseMonomerRenderer extends BaseRenderer {
public appendHover(
hoverAreaElement: D3SvgElementSelection<SVGGElement, void>,
) {
let cursor = 'default';

if (this.hoverElement) this.hoverElement.remove();
if (this.editor.selectedTool instanceof SelectRectangle) cursor = 'move';

return hoverAreaElement
.style('cursor', cursor)
.append('use')
.attr('href', this.monomerHoveredElementId)
.attr('pointer-events', 'none')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class ChemRenderer extends BaseMonomerRenderer {
.append('use')
.data([this])
.attr('href', CHEM_SYMBOL_ELEMENT_ID)
.style('cursor', 'pointer')
.attr('stroke', theme.monomer.color.CHEM.regular);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class PeptideRenderer extends BaseMonomerRenderer {
.append('use')
.data([this])
.attr('href', PEPTIDE_SYMBOL_ELEMENT_ID)
.style('cursor', 'pointer')
.attr('fill', this.getMonomerColor(theme));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class PhosphateRenderer extends BaseMonomerRenderer {
.append('use')
.data([this])
.attr('href', PHOSPHATE_SYMBOL_ELEMENT_ID)
.style('cursor', 'pointer')
.attr('fill', this.getMonomerColor(theme));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class RNABaseRenderer extends BaseMonomerRenderer {
.append('use')
.data([this])
.attr('href', RNABASE_SYMBOL_ELEMENT_ID)
.style('cursor', 'pointer')
.attr('fill', this.getMonomerColor(theme));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class SugarRenderer extends BaseMonomerRenderer {
.append('use')
.data([this])
.attr('href', SUGAR_SYMBOL_ELEMENT_ID)
.style('cursor', 'pointer')
.attr('fill', this.getMonomerColor(theme));
}

Expand Down

0 comments on commit 66d6d0b

Please sign in to comment.