Skip to content

Commit

Permalink
Migrate BlDevElement to Bloc-Alexandrie
Browse files Browse the repository at this point in the history
Fixes #245
  • Loading branch information
tinchodias committed Dec 5, 2024
1 parent 40d9168 commit b492ee1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 32 deletions.
85 changes: 54 additions & 31 deletions src/Bloc-DevTool/BlDevElement.class.st
Original file line number Diff line number Diff line change
@@ -1,54 +1,77 @@
"
I am an element that draws 3 different kinds of bounds that all elements have.
* dashed red: self geometryBounds
* solid blue: self visualBounds
* dashed gray: self bounds inLocal
"
Class {
#name : #BlDevElement,
#superclass : #BlElement,
#category : #'Bloc-DevTool-Core'
}

{ #category : #drawing }
BlDevElement >> drawDebugInfoOnSpartaCanvas: aCanvas [
| aWidth |
BlDevElement >> aeDrawDebugInfoOn: aeCanvas [

| aWidth |
aWidth := (self globalBoundsToLocal: (BlBounds origin: 0@0 extent: 1@1)) width.

aCanvas stroke
path: self geometryBounds;
paint: (Color red alpha: 0.5);
dashPattern: { aWidth * 6 . aWidth * 6 };
width: aWidth;
draw.

aCanvas stroke
path: self visualBounds;
paint: (Color blue alpha: 0.5);
width: aWidth;
draw.

aCanvas stroke
path: self bounds inLocal asRectangle;
paint: (Color gray alpha: 0.5);
dashPattern: { aWidth * 6 . aWidth * 6 };
width: aWidth;
draw
aeCanvas
pathFactory: [ :context |
context rectangle: self geometryBounds ];
setBackgroundOff;
setOutskirtsOutside;
setBorderBlock: [
aeCanvas
setSourceColor: (Color red alpha: 0.5);
setDashes: { aWidth * 6 . aWidth * 6 } offset: 0;
setBorderWidth: aWidth ];
drawFigure.

aeCanvas
pathFactory: [ :context |
context rectangle: self visualBounds ];
setBackgroundOff;
setOutskirtsOutside;
setBorderBlock: [
aeCanvas
setSourceColor: (Color blue alpha: 0.5);
setDashes: #() offset: 0;
setBorderWidth: aWidth ];
drawFigure.

aeCanvas
pathFactory: [ :context |
context rectangle: self bounds inLocal asRectangle ];
setBackgroundOff;
setOutskirtsOutside;
setBorderBlock: [
aeCanvas
setSourceColor: (Color gray alpha: 0.5);
setDashes: { aWidth * 6 . aWidth * 6 } offset: 0;
setBorderWidth: aWidth ];
drawFigure
]

{ #category : #drawing }
BlDevElement >> drawOnSpartaCanvas: aCanvas [
super drawOnSpartaCanvas: aCanvas.
BlDevElement >> aeDrawOn: aeCanvas [

super aeDrawOn: aeCanvas.

self drawDebugInfoOnSpartaCanvas: aCanvas
self aeDrawDebugInfoOn: aeCanvas
]

{ #category : #'geometry bounds' }
BlDevElement >> invalidationBounds: aBounds [
"I compute and load damaged area in my local coordinates that would be invalidated
if #invalidate would be sent to me"
<return: #BlBounds>
| anInvalidationBounds |

| anInvalidationBounds |
anInvalidationBounds := super invalidationBounds: aBounds.
"in order to support debug drawing"

"Save a small margin to draw my borders"
anInvalidationBounds expandBy: 1.

^ anInvalidationBounds
]
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ BlGeometryVisualAndLayoutBoundsExamples >> emptyIconElement [
<sampleInstance>
^ BlDevElement new
size: 8 @ 12;
background: Color green muchDarker
background: Color green muchDarker;
yourself
]

{ #category : #bounds }
Expand Down

0 comments on commit b492ee1

Please sign in to comment.