Skip to content

Commit

Permalink
#3545 update beginning text position when hovering peptide /RNA chains
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlaStarla committed Jan 9, 2024
1 parent bc4d3a4 commit 2ea12ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/ketcher-core/src/application/editor/tools/Bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class PolymerBond implements BaseTool {
);
}

this.editor.renderersContainer.markForRecalculateBegin();
this.editor.renderersContainer.update(modelChanges);
}

Expand Down Expand Up @@ -174,6 +175,7 @@ class PolymerBond implements BaseTool {
);
}

this.editor.renderersContainer.markForRecalculateBegin();
this.editor.renderersContainer.update(modelChanges);
}

Expand All @@ -188,6 +190,7 @@ class PolymerBond implements BaseTool {
renderer.monomer,
this.bondRenderer?.polymerBond,
);
this.editor.renderersContainer.markForRecalculateBegin();
this.editor.renderersContainer.update(modelChanges);
}
}
Expand All @@ -203,6 +206,7 @@ class PolymerBond implements BaseTool {
renderer.monomer,
this.bondRenderer?.polymerBond,
);
this.editor.renderersContainer.markForRecalculateBegin();
this.editor.renderersContainer.update(modelChanges);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ export abstract class BaseMonomerRenderer extends BaseRenderer {
} | void;

protected get beginningElementColor() {
if (this.monomer.hovered) {
return '#0097A8';
}
return '#7C7C7F';
}

Expand Down Expand Up @@ -419,7 +422,12 @@ export abstract class BaseMonomerRenderer extends BaseRenderer {

public reDrawChainBeginning() {
assert(this.beginningElement);
this.beginningElement.text(this.beginning);
assert(this.beginningElementPosition);
this.beginningElement
.attr('fill', this.beginningElementColor)
.attr('x', this.beginningElementPosition.x)
.attr('y', this.beginningElementPosition.y)
.text(this.beginning);
}

public show(theme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export class PeptideRenderer extends BaseMonomerRenderer {
}

protected get beginningElementPosition() {
if (this.monomer.hovered) {
return { x: 0, y: -29 };
}
return { x: 0, y: -2 };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class RenderersManager {
this.needRecalculateMonomersEnumeration = true;
}

private markForRecalculateBegin() {
public markForRecalculateBegin() {
this.needRecalculateMonomersBeginning = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ export class SugarRenderer extends BaseMonomerRenderer {
}

protected get beginningElementPosition() {
if (this.monomer.hovered) {
return { x: 0, y: -29 };
}
return { x: -4, y: -2 };
}

protected get beginningElementColor() {
return '#0097A8';
}
}

0 comments on commit 2ea12ae

Please sign in to comment.