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

feat: connection highlighter interface #7638

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,8 @@ export class BlockSvg
* @internal
*/
fadeForReplacement(add: boolean) {
this.pathObject.updateReplacementFade(add);
// TODO (7204): Remove these internal methods.
(this.pathObject as AnyDuringMigration).updateReplacementFade(add);
}

/**
Expand All @@ -1727,6 +1728,10 @@ export class BlockSvg
* @internal
*/
highlightShapeForInput(conn: RenderedConnection, add: boolean) {
this.pathObject.updateShapeForInputHighlight(conn, add);
// TODO (7204): Remove these internal methods.
(this.pathObject as AnyDuringMigration).updateShapeForInputHighlight(
conn,
add,
);
}
}
21 changes: 21 additions & 0 deletions core/interfaces/i_connection_highlighter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import type {RenderedConnection} from '../rendered_connection';

/**
* Visually highlights connections, usually to preview where a block will be
* connected if it is dropped.
*
* Often implemented by IPathObject classes.
*/
export interface IConnectionHighlighter {
/** Visually highlights the given connection. */
highlightConnection(conn: RenderedConnection): void;

/** Visually unhighlights the given connnection (if it was highlighted). */
unhighlightConnection(conn: RenderedConnection): void;
}
19 changes: 0 additions & 19 deletions core/renderers/common/i_path_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import type {BlockStyle} from '../../theme.js';
import type {BlockSvg} from '../../block_svg.js';
import type {ConstantProvider} from './constants.js';
import {RenderedConnection} from '../../rendered_connection.js';

/**
* An interface for a block's path object.
Expand Down Expand Up @@ -120,22 +119,4 @@ export interface IPathObject {
* @param enable True if the block is movable, false otherwise.
*/
updateMovable(enabled: boolean): void;

/**
* Add or remove styling that shows that if the dragging block is dropped,
* this block will be replaced. If a shadow block, it will disappear.
* Otherwise it will bump.
*
* @param enable True if styling should be added.
*/
updateReplacementFade(enabled: boolean): void;

/**
* Add or remove styling that shows that if the dragging block is dropped,
* this block will be connected to the input.
*
* @param conn The connection on the input to highlight.
* @param enable True if styling should be added.
*/
updateShapeForInputHighlight(conn: RenderedConnection, enable: boolean): void;
}