Skip to content

Commit

Permalink
Make update dialogs zoom aware
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaslehnertum committed Dec 23, 2023
1 parent 0f00b6b commit 0edaf28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/components/controls/popover/popover-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const PopoverContainer = styled.div<Props>`
max-width: 276px;
position: absolute;
text-align: left;
text-align: start;
text-decoration: none;
text-transform: none;
text-shadow: none;
Expand All @@ -30,6 +29,7 @@ export const PopoverContainer = styled.div<Props>`
word-break: normal;
word-spacing: normal;
word-wrap: break-word;
transform-origin: top left;
*,
*:before,
Expand All @@ -41,6 +41,7 @@ export const PopoverContainer = styled.div<Props>`
let x = `${props.position.x}px`;
let y = `${props.position.y}px`;
const alignment = props.alignment === 'start' ? 0 : props.alignment === 'end' ? 100 : 50;
switch (props.placement) {
case 'top':
x += ` - ${alignment}%`;
Expand Down
1 change: 1 addition & 0 deletions src/main/components/controls/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Props = {
alignment?: 'start' | 'center' | 'end';
position: { x: number; y: number };
maxHeight?: number;
zoomFactor: number;
} & HTMLAttributes<HTMLDivElement>;

export const Popover = forwardRef<HTMLDivElement, Props>(
Expand Down
12 changes: 11 additions & 1 deletion src/main/components/update-pane/update-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type StateProps = {
element: IUMLElement | null;
disabled: boolean;
mode: ApollonMode;
zoomFactor: number;
};

type DispatchProps = {
Expand All @@ -42,6 +43,7 @@ const enhance = compose<ComponentClass<OwnProps>>(
element: state.elements[state.updating[0]],
disabled: !state.editor.enablePopups,
mode: state.editor.mode,
zoomFactor: state.editor.zoomFactor,
}),
{
updateEnd: UMLElementRepository.updateEnd,
Expand Down Expand Up @@ -92,7 +94,14 @@ class UnwrappedUpdatePane extends Component<Props, State> {
}

return createPortal(
<Popover ref={this.popover} position={position} placement={placement} alignment={alignment} maxHeight={500}>
<Popover
ref={this.popover}
position={position}
placement={placement}
alignment={alignment}
maxHeight={500}
zoomFactor={this.props.zoomFactor}
>
<CustomPopupComponent element={element} />
</Popover>,
this.props.root,
Expand Down Expand Up @@ -130,6 +139,7 @@ class UnwrappedUpdatePane extends Component<Props, State> {
const absolute: Point = this.props
// relative to drawing area (0,0)
.getAbsolutePosition(element.id)
.scale(this.props.zoomFactor)
.add(
canvas
.origin()
Expand Down

0 comments on commit 0edaf28

Please sign in to comment.