Skip to content

Commit

Permalink
Improved coloring of elements
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 7, 2024
1 parent 905d94a commit aafa5a0
Show file tree
Hide file tree
Showing 62 changed files with 414 additions and 267 deletions.
24 changes: 17 additions & 7 deletions repository/OpenPonk-Core/OPBoundary.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Class {
#name : 'OPBoundary',
#superclass : 'OPDiagramOnlyShapeWithText',
#traits : 'OPTColoredAsFillAndBorderColoredAsStroke',
#classTraits : 'OPTColoredAsFillAndBorderColoredAsStroke classTrait',
#instVars : [
'name'
],
Expand All @@ -24,11 +26,23 @@ OPBoundary >> addSelectionDraggableInteraction [
@ OPRSSelectionDraggableBorder thatAlsoDragsContainedShapes
]

{ #category : 'accessing' }
OPBoundary >> defaultFillColor [

^ Color transparent
]

{ #category : 'accessing' }
OPBoundary >> defaultHeight [
^ 400
]

{ #category : 'accessing' }
OPBoundary >> defaultStrokeColor [

^ Color gray slightlyDarker
]

{ #category : 'accessing' }
OPBoundary >> defaultWidth [
^ 500
Expand Down Expand Up @@ -64,21 +78,17 @@ OPBoundary >> printOn: aStream [
nextPutAll: ''')'
]

{ #category : 'creating - subelements' }
{ #category : 'rendering' }
OPBoundary >> renderBasicShape [

^ RSBox new
color: Color transparent;
width: self defaultWidth;
height: self defaultHeight;
borderDo: [ :border |
border
color: Color gray;
dashArray: #( 4 ) ];
borderDo: [ :border | border dashArray: #( 4 ) ];
yourself
]

{ #category : 'creating - subelements' }
{ #category : 'interactions' }
OPBoundary >> selectableInteraction [

^ OPRSSelectable
Expand Down
6 changes: 6 additions & 0 deletions repository/OpenPonk-Core/OPCommonElementController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ OPCommonElementController >> isCommon [
^ true
]

{ #category : 'testing' }
OPCommonElementController >> isHideable [

^ false
]

{ #category : 'accessing' }
OPCommonElementController >> model [

Expand Down
1 change: 1 addition & 0 deletions repository/OpenPonk-Core/OPController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ OPController >> internalUnsubscribeFrom: aModel [

{ #category : 'testing' }
OPController >> isHideable [

^ false
]

Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPDiagramController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ OPDiagramController >> typeOfModel: aModel [
^ OPModelObjectType
named:
((aModel className withoutPrefix: self commonModelClassPrefix)
splitOnCapitals joinUsing: ' ')
splitCamelCase joinUsing: ' ')
]

{ #category : 'undo/redo' }
Expand Down
7 changes: 7 additions & 0 deletions repository/OpenPonk-Core/OPDiagramElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ OPDiagramElement >> removeRender [
roassalShape := nil
]

{ #category : 'accessing' }
OPDiagramElement >> removeStylePropertyNamed: aName [

self localStyle ifNotNil: [ :style |
style removeKey: aName ifAbsent: [ ] ]
]

{ #category : 'rendering' }
OPDiagramElement >> renderBasicShape [

Expand Down
8 changes: 0 additions & 8 deletions repository/OpenPonk-Core/OPDiagramOnlyShape.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Class {
#name : 'OPDiagramOnlyShape',
#superclass : 'OPBoundNode',
#traits : 'OPTBorderColoredAsStroke - {#updateRenderFromStyles}',
#classTraits : 'OPTBorderColoredAsStroke classTrait',
#instVars : [
'uuid',
'announcer'
Expand Down Expand Up @@ -67,12 +65,6 @@ OPDiagramOnlyShape >> modelElements: aCollection [
self shouldNotImplement
]

{ #category : 'accessing' }
OPDiagramOnlyShape >> strokeColor: aColor [

"ignore for now"
]

{ #category : 'rendering' }
OPDiagramOnlyShape >> updateRenderFromModel [

Expand Down
2 changes: 1 addition & 1 deletion repository/OpenPonk-Core/OPEditElementTextCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OPEditElementTextCommand class >> executeAccessor: anAccessor on: anObject [
OPEditElementTextCommand >> accessor: anAccessor [
self getSelector: anAccessor.
self setSelector: anAccessor , ':'.
self name: (anAccessor capitalized splitOnCapitals joinUsing: ' ')
self name: (anAccessor capitalized splitCamelCase joinUsing: ' ')
]

{ #category : 'execute' }
Expand Down
6 changes: 6 additions & 0 deletions repository/OpenPonk-Core/OPElementController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ OPElementController >> isCommon [
^ false
]

{ #category : 'testing' }
OPElementController >> isHideable [

^ true
]

{ #category : 'deprecated' }
OPElementController >> loadModel [
self deprecated: 'Method will be removed without replacement.'
Expand Down
29 changes: 29 additions & 0 deletions repository/OpenPonk-Core/OPNoModelAdapter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Class {
#name : 'OPNoModelAdapter',
#superclass : 'Object',
#classInstVars : [
'instance'
],
#category : 'OpenPonk-Core-Adapters',
#package : 'OpenPonk-Core',
#tag : 'Adapters'
}

{ #category : 'accessing' }
OPNoModelAdapter class >> instance [

^ instance ifNil: [ instance := self basicNew ]
]

{ #category : 'instance creation' }
OPNoModelAdapter class >> new [

^ self instance
]

{ #category : 'initialization' }
OPNoModelAdapter class >> reset [

<script>
instance := nil
]
22 changes: 22 additions & 0 deletions repository/OpenPonk-Core/OPNoShape.class.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
Class {
#name : 'OPNoShape',
#superclass : 'Object',
#classInstVars : [
'instance'
],
#category : 'OpenPonk-Core-DiagramElements',
#package : 'OpenPonk-Core',
#tag : 'DiagramElements'
}

{ #category : 'accessing' }
OPNoShape class >> instance [

^ instance ifNil: [ instance := self basicNew ]
]

{ #category : 'instance creation' }
OPNoShape class >> new [

^ self instance
]

{ #category : 'initialization' }
OPNoShape class >> reset [

<script>
instance := nil
]

{ #category : 'testing' }
OPNoShape >> doesNotExist [

Expand Down
43 changes: 33 additions & 10 deletions repository/OpenPonk-Core/OPNote.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Class {
#name : 'OPNote',
#superclass : 'OPDiagramOnlyShapeWithText',
#traits : 'OPTColoredAsFillAndBorderColoredAsStroke',
#classTraits : 'OPTColoredAsFillAndBorderColoredAsStroke classTrait',
#instVars : [
'text',
'topLeftBox',
Expand Down Expand Up @@ -29,9 +31,9 @@ OPNote class >> stonAllInstVarNames [
]

{ #category : 'accessing' }
OPNote >> attachedShapes [
OPNote >> attachedElementShapes [

^ super attachedShapes , {
^ {
topLeftBox.
upperTopRightBox.
lowerTopRightBox.
Expand All @@ -41,19 +43,23 @@ OPNote >> attachedShapes [
middleBottomBox.
leftFillBox.
bottomFillBox.
triangle } , lines
triangle }
]

{ #category : 'accessing' }
OPNote >> attachedShapes [

^ super attachedShapes , self attachedElementShapes , lines
]

{ #category : 'creating - subelements' }
OPNote >> createOwnedBorderLines [

| lineShape innerLineShape |
lineShape := RSLine new
color: Color darkGray;
width: 1;
yourself.
innerLineShape := RSLine new
color: Color gray;
width: 1;
yourself.
lines := {
Expand All @@ -72,16 +78,14 @@ OPNote >> createOwnedBorderLines [
(lineShape copy
from: topLeftBox;
to: upperTopRightBox) } asGroup.
roassalShape canvas addAll: lines.
roassalShape canvas addAll: lines
]

{ #category : 'creating - subelements' }
OPNote >> createOwnedCornerTriangle [

triangle := RSSVGPath new
svgPath: 'M0,0L20,0L0,-20Z';
color: Color lightYellow darker;
borderColor: Color lightGray;
model: self;
yourself.
self canvas add: triangle
Expand All @@ -92,7 +96,6 @@ OPNote >> createOwnedFillBoxes [

| fillBoxShape |
fillBoxShape := RSBox new
color: Color lightYellow;
borderColor: Color transparent;
yourself.
leftFillBox := fillBoxShape model: #left.
Expand All @@ -107,7 +110,6 @@ OPNote >> createOwnedInvisibleBoxes [

| invisibleBoxShape invisibleBoxes |
invisibleBoxShape := RSBox new
color: Color transparent;
borderColor: Color transparent;
width: 1;
height: 1;
Expand All @@ -130,6 +132,12 @@ OPNote >> createOwnedInvisibleBoxes [
self canvas addAll: invisibleBoxes
]

{ #category : 'accessing' }
OPNote >> defaultFillColor [

^ OPDiagramFigureYellowFillColorCommand new color
]

{ #category : 'initialization' }
OPNote >> initialize [

Expand Down Expand Up @@ -259,3 +267,18 @@ OPNote >> updateOwnedElements [
extent: roassalShape extent + (0 @ -20);
translateTo: roassalShape position + (0 @ 10)
]
{ #category : 'initialization' }
OPNote >> updateRoassalShapeBorderColorFromStyles [
lines do: [ :each | each color: self borderColor ].
triangle borderColor:
(self borderColor alphaMixed: 0.35 with: Color white)
]
{ #category : 'initialization' }
OPNote >> updateRoassalShapeColorFromStyles [
self attachedElementShapes do: [ :each | each color: self color ].
triangle color: self color slightlyDarker
]
9 changes: 9 additions & 0 deletions repository/OpenPonk-Core/OPShapeStyle.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ OPShapeStyle >> removeKey: aSymbol [
^ result
]

{ #category : 'removing' }
OPShapeStyle >> removeKey: aSymbol ifAbsent: aBlock [

| result |
result := properties removeKey: aSymbol ifAbsent: [ ^ aBlock value ].
self styledElements do: #styleChanged.
^ result
]

{ #category : 'accessing' }
OPShapeStyle >> removedFromStyledElement: aDiagramElement [

Expand Down
18 changes: 16 additions & 2 deletions repository/OpenPonk-Core/OPTBorderColoredAsStroke.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@ OPTBorderColoredAsStroke >> borderColor [
^ self strokeColor
]

{ #category : 'accessing' }
OPTBorderColoredAsStroke >> defaultStrokeColor [

^ Color black
]

{ #category : 'accessing' }
OPTBorderColoredAsStroke >> strokeColor [

^ self stylePropertyNamed: #strokeColor ifAbsent: [ Color black ]
^ self
stylePropertyNamed: #strokeColor
ifAbsent: [ self defaultStrokeColor ]
]

{ #category : 'accessing' }
Expand All @@ -36,7 +44,7 @@ OPTBorderColoredAsStroke >> updateBorderColorFromStyles [
ifPresent: [ :previousBorder |
previousBorder do: [ :each | each color: self borderColor ].
^ self ] ].
self roassalShape borderColor: self borderColor
self updateRoassalShapeBorderColorFromStyles
]

{ #category : 'accessing' }
Expand All @@ -47,3 +55,9 @@ OPTBorderColoredAsStroke >> updateRenderFromStyles [
super updateRenderFromStyles.
self roassalShape signalUpdate
]

{ #category : 'initialization' }
OPTBorderColoredAsStroke >> updateRoassalShapeBorderColorFromStyles [

self roassalShape borderColor: self borderColor
]
8 changes: 7 additions & 1 deletion repository/OpenPonk-Core/OPTColored.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OPTColored >> updateColorFromStyles [
at: key
put: (OrderedCollection with: self color).
^ self ] ].
self roassalShape color: self color
self updateRoassalShapeColorFromStyles
]

{ #category : 'initialization' }
Expand All @@ -35,3 +35,9 @@ OPTColored >> updateRenderFromStyles [
super updateRenderFromStyles.
self roassalShape signalUpdate
]

{ #category : 'initialization' }
OPTColored >> updateRoassalShapeColorFromStyles [

self roassalShape color: self color
]
Loading

0 comments on commit aafa5a0

Please sign in to comment.