-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[997] Improve routing handle rendering style
Bug: #997 Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
- Loading branch information
Showing
3 changed files
with
89 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
/** @jsx svg */ | ||
import { VNode } from 'snabbdom'; | ||
import { RenderingContext, RoutedPoint, setAttr, SRoutingHandle, SRoutingHandleView } from 'sprotty'; | ||
|
||
/** | ||
* View used to handle 'source', 'target' and 'junction' routing handles. | ||
*/ | ||
export class RoutingHandleView extends SRoutingHandleView { | ||
render(handle: Readonly<SRoutingHandle>, context: RenderingContext, args?: { route?: RoutedPoint[] }): VNode { | ||
const handleVNode = super.render(handle, context, args); | ||
setAttr(handleVNode, 'stroke', 'var(--daintree)'); | ||
setAttr(handleVNode, 'stroke-width', '1'); | ||
setAttr(handleVNode, 'fill', '#fafafa'); | ||
|
||
if (handle.hoverFeedback) { | ||
setAttr(handleVNode, 'fill', 'var(--blue-lagoon-lighten-20)'); | ||
} | ||
|
||
if (handle.selected) { | ||
setAttr(handleVNode, 'fill', 'var(--blue-lagoon)'); | ||
setAttr(handleVNode, 'opacity', '1'); | ||
} | ||
|
||
return handleVNode; | ||
} | ||
|
||
getRadius(): number { | ||
return 2.5; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
frontend/src/diagram/sprotty/views/VolatileRoutingHandleView.tsx
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
/** @jsx svg */ | ||
import { VNode } from 'snabbdom'; | ||
import { RenderingContext, RoutedPoint, setAttr, SRoutingHandle, SRoutingHandleView } from 'sprotty'; | ||
|
||
/** | ||
* View used to handle 'line' routing handles. | ||
*/ | ||
export class VolatileRoutingHandleView extends SRoutingHandleView { | ||
render(handle: Readonly<SRoutingHandle>, context: RenderingContext, args?: { route?: RoutedPoint[] }): VNode { | ||
const handleVNode = super.render(handle, context, args); | ||
setAttr(handleVNode, 'stroke', 'var(--daintree)'); | ||
setAttr(handleVNode, 'stroke-width', '1'); | ||
setAttr(handleVNode, 'fill', '#fafafa'); | ||
setAttr(handleVNode, 'opacity', '0.35'); | ||
|
||
if (handle.hoverFeedback) { | ||
setAttr(handleVNode, 'opacity', '0.65'); | ||
} | ||
|
||
if (handle.selected) { | ||
setAttr(handleVNode, 'fill', 'var(--blue-lagoon)'); | ||
setAttr(handleVNode, 'opacity', '1'); | ||
} | ||
|
||
return handleVNode; | ||
} | ||
|
||
getRadius(): number { | ||
return 2.5; | ||
} | ||
} |