-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add font size + font weight + TU + Plugin + properties
- Loading branch information
YannLEGOFF
committed
Jul 31, 2023
1 parent
caf9a64
commit 17226c7
Showing
5 changed files
with
175 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Class { | ||
#name : #PyramidBlocTextPlugin, | ||
#superclass : #Object, | ||
#traits : 'TPyramidPlugin', | ||
#classTraits : 'TPyramidPlugin classTrait', | ||
#category : #'Pyramid-Bloc-plugin-bloc-text' | ||
} | ||
|
||
{ #category : #accessing } | ||
PyramidBlocTextPlugin class >> changeText [ | ||
|
||
| property | | ||
property := PyramidProperty new | ||
name: 'Text'; | ||
command: PyramidChangeTextCommand new; | ||
pyramidInputPresenterClass: PyramidTextInputPresenter; | ||
yourself. | ||
property pyramidInputPresenterModel help: | ||
'Change the value of the text'. | ||
^ property | ||
] | ||
|
||
{ #category : #accessing } | ||
PyramidBlocTextPlugin class >> fontSize [ | ||
|
||
| property | | ||
property := PyramidProperty new | ||
name: 'Font size'; | ||
command: PyramidFontSizeCommand new; | ||
pyramidInputPresenterClass: PyramidNumberInputPresenter; | ||
yourself. | ||
property pyramidInputPresenterModel help: | ||
'Change the font size.'. | ||
^ property | ||
] | ||
|
||
{ #category : #accessing } | ||
PyramidBlocTextPlugin class >> fontWeight [ | ||
|
||
| property | | ||
property := PyramidProperty new | ||
name: 'Font weight'; | ||
command: PyramidFontWeightCommand new; | ||
pyramidInputPresenterClass: PyramidNumberInputPresenter; | ||
yourself. | ||
property pyramidInputPresenterModel help: 'Change the font weight.'. | ||
^ property | ||
] | ||
|
||
{ #category : #'class initialization' } | ||
PyramidBlocTextPlugin class >> initialize [ | ||
|
||
PyramidPluginManager uniqueInstance addPlugin: self | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
PyramidBlocTextPlugin >> connectOn: aPyramidEditor [ | ||
|
||
aPyramidEditor propertiesManager addProperty: self class changeText. | ||
aPyramidEditor propertiesManager addProperty: self class fontSize. | ||
aPyramidEditor propertiesManager addProperty: self class fontWeight | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Class { | ||
#name : #PyramidFontSizeCommand, | ||
#superclass : #PyramidBlocTextCommand, | ||
#category : #'Pyramid-Bloc-plugin-bloc-text' | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
PyramidFontSizeCommand >> getValueFor: aBlTextElement [ | ||
|
||
aBlTextElement text attributesFinder | ||
findAttributesSuchThat: [ :a | a class = BlFontSizeAttribute ] | ||
indicesDo: [ :new :old :a | ^ a size ]. | ||
self flag: #TODO. "I put 10 as a default font size. I don't know where this information come from." | ||
^ 10 | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
PyramidFontSizeCommand >> setValueFor: aBlTextElement with: aNumber [ | ||
|
||
aBlTextElement text attribute: | ||
(BlFontSizeAttribute size: aNumber) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Class { | ||
#name : #PyramidFontSizeCommandTest, | ||
#superclass : #TestCase, | ||
#traits : 'TPyramidFontAttributeCommandTest', | ||
#classTraits : 'TPyramidFontAttributeCommandTest classTrait', | ||
#category : #'Pyramid-Tests-cases-plugin-bloc-text' | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
PyramidFontSizeCommandTest >> attributeClass [ | ||
|
||
^ BlFontSizeAttribute | ||
] | ||
|
||
{ #category : #accessing } | ||
PyramidFontSizeCommandTest >> command [ | ||
|
||
^ PyramidFontSizeCommand new | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
PyramidFontSizeCommandTest >> targetContainers [ | ||
|
||
^ { | ||
(PyramidCommandTestContainer | ||
no: 'test1' asRopedText asElement | ||
with: ('test1' asRopedText | ||
fontSize: 20; | ||
yourself) asElement | ||
prop: 20). | ||
(PyramidCommandTestContainer | ||
no: ('test2' asRopedText | ||
fontSize: 20; | ||
yourself) asElement | ||
with: ('test2' asRopedText | ||
fontSize: 5; | ||
yourself) asElement | ||
prop: 5). | ||
(PyramidCommandTestContainer | ||
no: ('test3' asRopedText | ||
bold; | ||
attribute: (BlFontSizeAttribute size: 20); | ||
attribute: (BlTextForegroundAttribute color: Color green); | ||
yourself) asElement | ||
with: ('test3' asRopedText | ||
bold; | ||
attribute: (BlFontSizeAttribute size: 30); | ||
attribute: (BlTextForegroundAttribute color: Color green); | ||
yourself) asElement | ||
prop: 30) } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Pyramid-Tests/TPyramidFontAttributeCommandTest.trait.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Trait { | ||
#name : #TPyramidFontAttributeCommandTest, | ||
#traits : 'TPyramidCommandTest', | ||
#classTraits : 'TPyramidCommandTest classTrait', | ||
#category : #'Pyramid-Tests-cases-plugin-bloc-text' | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
TPyramidFontAttributeCommandTest >> attributeClass [ | ||
|
||
^ self shouldBeImplemented | ||
] | ||
|
||
{ #category : #tests } | ||
TPyramidFontAttributeCommandTest >> testSetValueForWith [ | ||
|
||
| attributes | | ||
self targetsWithoutValuesAndValues do: [ :each | | ||
attributes := (each key text attributesFinder | ||
attributesAndIndicesSuchThat: [ :a | | ||
self attributeClass ~= a class ]) collect: [ :a | | ||
a key ]. | ||
self command setValueFor: each key with: each value. | ||
self assert: (self command getValueFor: each key) equals: each value. | ||
self | ||
assert: | ||
((each key text attributesFinder attributesAndIndicesSuchThat: [ | ||
:a | true ]) | ||
collect: [ :a | a key ] | ||
thenSelect: [ :a | self attributeClass ~= a class ]) | ||
equals: attributes ] | ||
] |