Skip to content

Commit

Permalink
Added GtTitleWithCenteredTextsSlide
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Nierstrasz committed Sep 2, 2024
1 parent 900b95c commit adcea90
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/GToolkit-Presenter/GtProtoLiveSlide.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ GtProtoLiveSlide >> title [
definingMethod: (GtPhlowDefiningMethodsCollector forContext: thisContext) collect
]

{ #category : #decorating }
GtProtoLiveSlide >> titleWithCenteredTexts [
^ GtTitleWithCenteredTextsSlide new
definingMethod: (GtPhlowDefiningMethodsCollector forContext: thisContext) collect
]

{ #category : #decorating }
GtProtoLiveSlide >> titleWithFooter [
^ GtTitleWithFooterLiveSlide new
Expand Down
7 changes: 6 additions & 1 deletion src/GToolkit-Presenter/GtTitleLiveSlide.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ GtTitleLiveSlide >> create [
text: subtitle))
]

{ #category : #initialization }
GtTitleLiveSlide >> defaultTitleBottomPadding [
^ 30
]

{ #category : #initialization }
GtTitleLiveSlide >> initialize [
super initialize.
self title: ''.
self subtitle: ''.
self titleBottomPadding: 10
self titleBottomPadding: self defaultTitleBottomPadding
]

{ #category : #accessing }
Expand Down
120 changes: 120 additions & 0 deletions src/GToolkit-Presenter/GtTitleWithCenteredTextsSlide.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"
Like a title slide but with as many centred texts below as you like.
"
Class {
#name : #GtTitleWithCenteredTextsSlide,
#superclass : #GtTitleLiveSlide,
#instVars : [
'texts',
'textMargin',
'subtitleBottomPadding',
'textBottomPadding'
],
#category : #'GToolkit-Presenter'
}

{ #category : #'api - instantiation' }
GtTitleWithCenteredTextsSlide >> create [
| container textContainer |
container := BlElement new
constraintsDo: [ :c |
c horizontal matchParent.
c vertical matchParent ];
layout: BlLinearLayout horizontal.
textContainer := BlElement new
constraintsDo: [ :c |
c horizontal matchParent.
c vertical fitContent.
c linear vertical alignCenter ];
layout: BlLinearLayout vertical.
textContainer
addChild: (BlTextElement new
constraintsDo: [ :c | c linear horizontal alignCenter ];
padding: (BlInsets
top: 40;
bottom: self titleBottomPadding);
text: title).
subtitle isEmpty
ifFalse: [ textContainer
addChild: (BlTextElement new
constraintsDo: [ :c | c linear horizontal alignCenter ];
padding: (BlInsets
top: 40;
bottom: self subtitleBottomPadding);
text: subtitle) ].
texts
do: [ :aText |
textContainer
addChild: (BlTextElement new
constraintsDo: [ :c | c linear horizontal alignCenter ];
padding: (BlInsets
top: 40;
bottom: self textBottomPadding);
text: aText) ].
container addChild: textContainer.
^ container
]

{ #category : #initialization }
GtTitleWithCenteredTextsSlide >> defaultSubtitleBottomPadding [
^ 40
]

{ #category : #initialization }
GtTitleWithCenteredTextsSlide >> defaultTextBottomPadding [
^ 10
]

{ #category : #acccessing }
GtTitleWithCenteredTextsSlide >> defaultTextMargin [
^ 50
]

{ #category : #initialization }
GtTitleWithCenteredTextsSlide >> initialize [
super initialize.
self subtitleBottomPadding: self defaultSubtitleBottomPadding.
self textBottomPadding: self defaultTextBottomPadding.
self textMargin: self defaultTextMargin.
texts := OrderedCollection new
]

{ #category : #acccessing }
GtTitleWithCenteredTextsSlide >> newText: aRopedText [
self newTextWithFormat: (aRopedText asRopedText glamorousRegularFont; fontSize: 20)
]

{ #category : #acccessing }
GtTitleWithCenteredTextsSlide >> newTextWithFormat: aRopedText [
texts add: aRopedText asRopedText
]

{ #category : #accessing }
GtTitleWithCenteredTextsSlide >> subtitleBottomPadding [
^ subtitleBottomPadding
]

{ #category : #accessing }
GtTitleWithCenteredTextsSlide >> subtitleBottomPadding: anObject [
subtitleBottomPadding := anObject
]

{ #category : #accessing }
GtTitleWithCenteredTextsSlide >> textBottomPadding [
^ textBottomPadding
]

{ #category : #accessing }
GtTitleWithCenteredTextsSlide >> textBottomPadding: anObject [
textBottomPadding := anObject
]

{ #category : #acccessing }
GtTitleWithCenteredTextsSlide >> textMargin [
^ textMargin
]

{ #category : #acccessing }
GtTitleWithCenteredTextsSlide >> textMargin: aNumber [
textMargin := aNumber
]
2 changes: 1 addition & 1 deletion src/GToolkit-Presenter/GtTitleWithFooterLiveSlide.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ GtTitleWithFooterLiveSlide >> footerWithFormat: aText [
footer := aText
]

{ #category : #accessing }
{ #category : #initialization }
GtTitleWithFooterLiveSlide >> initialize [
super initialize.
self subtitleBottomPadding: 10
Expand Down

0 comments on commit adcea90

Please sign in to comment.