8000 Add the ability to show class defining instance variable to GtPharoSt… · feenkcom/gt4pharo@e5fff0d · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit e5fff0d

Browse files
committed
Add the ability to show class defining instance variable to GtPharoStyler
1 parent 0d6b2a3 commit e5fff0d

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

src/GToolkit-Pharo-Coder-Method-UI/GtPharoStyler.class.st

+23-30
Original file line numberDiff line numberDiff line change
@@ -53,49 +53,42 @@ GtPharoStyler >> colorParenthesesLeft: aLeftIndex right: aRightIndex atNestingLe
5353

5454
{ #category : #'visiting - variables' }
5555
GtPharoStyler >> definitionTooltipAttributeFor: aNamedVariable [
56-
| definer |
56+
| definer aptitude |
5757
definer := self coderViewModel behavior
5858
whichClassDefinesInstVar: aNamedVariable name value.
5959
definer ifNil: [ ^ BlFontWeightAttribute semiBold ].
60-
^ BrTextAdornmentDynamicAttribute new
61-
beOverlay;
62-
stencil: [ :aTextPiece :anEditorElement |
63-
| aContainer aValueElement tooltipContent |
64-
aContainer := BlElement new
65-
clipChildren: false;
66-
layout: BlFrameLayout new;
67-
constraintsDo: [ :c |
68-
c horizontal exact: aTextPiece textLength * 10.
69-
c vertical exact: 15 ].
70-
aValueElement := BlElement new
71-
clipChildren: true;
72-
constraintsDo: [ :c |
73-
c horizontal matchParent.
74-
c vertical matchParent ].
75-
tooltipContent := [ BrLabel new
76-
aptitude: BrLabelAptitude;
77-
padding: (BlInsets all: 5);
78-
text: (aNamedVariable name value , ' defined in ') asRopedText
79-
, definer name asRopedText glamorousCodeFont;
80-
alignCenter ] asStencil.
81-
aValueElement
82-
addAptitude: (BrGlamorousWithExplicitTooltipAptitude content: tooltipContent).
83-
aContainer addChild: aValueElement ]
60+
aptitude := BrGlamorousWithExplicitTooltipAptitude new
61+
stencil: [ :aContext |
62+
BrMenuExplicitHandle new
63+
menu: (BrMenuLabelItem new
64+
label: 'Defined in ' asRopedText , definer asRopedText glamorousCodeDefaultFont) ].
65+
^ BrTextHoverAttribute new
66+
enterAction: [ :aText :aTextElement :aTextEditor :anEvent |
67+
| bounds offset |
68+
offset := aText textOffset - aTextElement text textOffset + (aText size / 2).
69+
bounds := aTextElement globalCursorBoundsForIndex: offset.
70+
aptitude relocator: (BrPopoverExplicitRelocator new globalBounds: bounds).
71+
aTextElement addAptitude: aptitude.
72+
aptitude show ];
73+
leaveAction: [ :aText :aTextElement :aTextEditor :anEvent |
74+
aTextElement dispatchEvent: BrTooltipHideWish new.
75+
aTextElement removeAptitude: aptitude ];
76+
yourself
8477
]
8578

8679
{ #category : #private }
8780
GtPharoStyler >> highlightParenthesesLeft: aLeftIndex right: aRightIndex [
88-
| theParanthesesMarker cursorEnterAction cursorLeaveAction |
81+
| theParenthesesMarker cursorEnterAction cursorLeaveAction |
8982

90-
theParanthesesMarker := BrTextInvisibleMarkerAttribute new.
83+
theParenthesesMarker := BrTextInvisibleMarkerAttribute new.
9184
text
92-
attribute: theParanthesesMarker
85+
attribute: theParenthesesMarker
9386
from: aLeftIndex + 1
9487
to: aRightIndex - 1.
9588

9689
cursorEnterAction := [ :aTextEditor |
9790
aTextEditor text
98-
findAttribute: theParanthesesMarker
91+
findAttribute: theParenthesesMarker
9992
indicesDo: [ :aParanthesesStart :aParanthesesEnd |
10093
aTextEditor text
10194
attribute: (GtPharoParenthesesHighlightAttribute paint: BrGlamorousColors neutralBackgroundColor)
@@ -104,7 +97,7 @@ GtPharoStyler >> highlightParenthesesLeft: aLeftIndex right: aRightIndex [
10497

10598
cursorLeaveAction := [ :aTextEditor |
10699
aTextEditor text
107-
findAttribute: theParanthesesMarker
100+
findAttribute: theParenthesesMarker
108101
indicesDo: [ :aParanthesesStart :aParanthesesEnd |
109102
(aTextEditor text
110103
from: aParanthesesStart

0 commit comments

Comments
 (0)
0