Skip to content

Commit

Permalink
Few interaction fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 6, 2023
1 parent a7bd87a commit 607d962
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 102 deletions.
42 changes: 22 additions & 20 deletions Pharo/OpenPonk-ERD/OPErdAbstractNodeShape.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #OPErdAbstractNodeShape,
#superclass : #OPShape,
#superclass : #OPBoundNode,
#instVars : [
'adornmentCreationBlock'
],
Expand All @@ -13,30 +13,32 @@ OPErdAbstractNodeShape >> adornmentCreationBlock: aBlock [
adornmentCreationBlock := aBlock
]

{ #category : #rendering }
OPErdAbstractNodeShape >> renderShapeDetails [

| selectable |
selectable := OPRSSelectable new.
self setupHighlight: selectable.
self roassalShape @ selectable.
self roassalShape @ OPRSSelectionDraggable.
self roassalShape @ OPRSResizable.
self roassalShape
when: RSPositionChangedEvent do: [ self updateRenderFromModel ];
when: RSExtentChangedEvent do: [ self updateRenderFromModel ]
]

{ #category : #hooks }
OPErdAbstractNodeShape >> setupHighlight: aHighlightable [
{ #category : #interactions }
OPErdAbstractNodeShape >> selectableInteraction [

aHighlightable highlightAdornments: [ :builder |
| selectableInteraction |
selectableInteraction := OPRSSelectable highlightBorderColorBlue.
adornmentCreationBlock ifNil: [ ^ selectableInteraction ].
selectableInteraction highlightAdornments: [ :builder |
builder horizontalLocation
outer;
right.
builder verticalLocation
inner;
middle.
top.
builder directionDown.
adornmentCreationBlock value: builder ]
adornmentCreationBlock value: builder ].
^ selectableInteraction
]

{ #category : #interactions }
OPErdAbstractNodeShape >> shouldBePositionableByUser [

^ true
]

{ #category : #interactions }
OPErdAbstractNodeShape >> shouldBeResizableByUser [

^ true
]
64 changes: 30 additions & 34 deletions Pharo/OpenPonk-ERD/OPErdAttributeShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,44 @@ OPErdAttributeShape >> renderShapeDetails [
label := RSLabel new
color: Color black;
height: 11;
width: 10;
width: 10;
model: self;
yourself.
RSLocation new stick: label on: self roassalShape.
border := RSEllipse new
radius: (self roassalShape radius);
width: (self roassalShape width);
height: (self roassalShape height);
color: Color transparent;
border: (RSBorder new
dashArray: #(10 10);
width: 1.5;
yourself);
model: self;
yourself.
radius: self roassalShape radius;
width: self roassalShape width;
height: self roassalShape height;
color: Color transparent;
border: (RSBorder new
dashArray: #( 10 10 );
width: 1.5;
yourself);
model: self;
yourself.
RSLocation new stick: border on: self roassalShape.
innerEllipse := RSEllipse new
radius: (self roassalShape radius - 3);
width: (self roassalShape width - 7);
height: (self roassalShape height - 7);
color: Color transparent;
border: (RSBorder new
color: Color transparent;
width: 1.5;
yourself);
yourself.
radius: self roassalShape radius - 3;
width: self roassalShape width - 7;
height: self roassalShape height - 7;
color: Color transparent;
border: (RSBorder new
color: Color transparent;
width: 1.5;
yourself);
yourself.
RSLocation new stick: innerEllipse on: self roassalShape.
self canvas
add: border;
add: label;
add: innerEllipse.
self roassalShape when: RSShapeRemovedEvent do: [
label remove.
border remove.
innerEllipse remove ]
]

{ #category : #rendering }
OPErdAttributeShape >> setupHighlight: aHighlightable [

super setupHighlight: aHighlightable.
aHighlightable highlightBorderColor: Color blue
add: border;
add: label;
add: innerEllipse.
self roassalShape
when: RSShapeRemovedEvent
do: [
label remove.
border remove.
innerEllipse remove ]
for: self
]

{ #category : #'as yet unclassified' }
Expand Down
38 changes: 19 additions & 19 deletions Pharo/OpenPonk-ERD/OPErdEntityShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ OPErdEntityShape >> renderShapeDetails [
yourself.
RSLocation new stick: label on: self roassalShape.
weak := RSBox new
"Size changing according to main shape"
height: (self roassalShape height - 7);
width: (self roassalShape width - 7);
color: Color transparent;
border: (RSBorder new
color: Color transparent;
width: 1.5;
yourself);
yourself.
height: self roassalShape height - 7;
width: self roassalShape width - 7;
color: Color transparent;
border: (RSBorder new
color: Color transparent;
width: 1.5;
yourself);
yourself.

self addEventForwardingFrom: weak to: self roassalShape.
self addEventForwardingFrom: label to: self roassalShape.

"Size changing according to main shape"
RSLocation new stick: weak on: self roassalShape.
self canvas
add: label;
add: weak.
self roassalShape when: RSShapeRemovedEvent do: [
label remove.
weak remove ]
]

{ #category : #rendering }
OPErdEntityShape >> setupHighlight: aHighlightable [

super setupHighlight: aHighlightable.
aHighlightable highlightBorderColor: Color blue
self roassalShape
when: RSShapeRemovedEvent
do: [
label remove.
weak remove ]
for: self
]

{ #category : #rendering }
Expand Down
7 changes: 0 additions & 7 deletions Pharo/OpenPonk-ERD/OPErdExtensionsShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ OPErdExtensionsShape >> renderShapeDetails [
label remove]
]

{ #category : #hooks }
OPErdExtensionsShape >> setupHighlight: aHighlightable [

super setupHighlight: aHighlightable.
aHighlightable highlightBorderColor: Color blue
]

{ #category : #'as yet unclassified' }
OPErdExtensionsShape >> updateDetails [
self updateLabel
Expand Down
43 changes: 21 additions & 22 deletions Pharo/OpenPonk-ERD/OPErdRelationShape.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,31 @@ OPErdRelationShape >> renderShapeDetails [
yourself.
RSLocation new stick: label on: self roassalShape.
identifying := RSPolygon new
points: "{ 0@21. 31@0. 0@(-21). -31@0. }"
{ ((self roassalShape points at: 1) asPoint x)
@((self roassalShape points at: 1) asPoint y - 3).
((self roassalShape points at: 2) asPoint x - 4)
@((self roassalShape points at: 2) asPoint y).
((self roassalShape points at: 3) asPoint x)
@((self roassalShape points at: 3) asPoint y + 3).
((self roassalShape points at: 4) asPoint x + 4)
@((self roassalShape points at: 4) asPoint y).};
color: Color transparent;
borderColor: Color transparent;
yourself.
points: {
((self roassalShape points at: 1) asPoint x
@ ((self roassalShape points at: 1) asPoint y - 3)).
((self roassalShape points at: 2) asPoint x - 4
@ (self roassalShape points at: 2) asPoint y).
((self roassalShape points at: 3) asPoint x
@ ((self roassalShape points at: 3) asPoint y + 3)).
((self roassalShape points at: 4) asPoint x + 4
@ (self roassalShape points at: 4) asPoint y) };
color: Color transparent;
borderColor: Color transparent;
yourself. "{ 0@21. 31@0. 0@(-21). -31@0. }"

self addEventForwardingFrom: identifying to: self roassalShape.

RSLocation new stick: identifying on: self roassalShape.
self canvas
add: label;
add: identifying.
self roassalShape when: RSShapeRemovedEvent do: [
label remove.
identifying remove ]
]

{ #category : #rendering }
OPErdRelationShape >> setupHighlight: aHighlightable [

super setupHighlight: aHighlightable.
aHighlightable highlightBorderColor: Color blue
self roassalShape
when: RSShapeRemovedEvent
do: [
label remove.
identifying remove ]
for: self
]

{ #category : #rendering }
Expand Down

0 comments on commit 607d962

Please sign in to comment.