Skip to content

Commit

Permalink
new notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Nov 19, 2023
1 parent b74ea95 commit dabc4fa
Show file tree
Hide file tree
Showing 10 changed files with 317 additions and 22 deletions.
165 changes: 151 additions & 14 deletions src/Toplo-Incubator/ToNotebook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Class {
#instVars : [
'rebuildPaneOnSelect',
'header',
'body'
'headerPositioning',
'body',
'resizablePanes'
],
#category : 'Toplo-Incubator',
#package : 'Toplo-Incubator'
Expand All @@ -25,16 +27,59 @@ ToNotebook >> addButtonWithText: aText withPaneBuilder: aValuable [
self addButton: but
]

{ #category : 'configuration - private' }
ToNotebook >> applyHeaderPositioning [

self headerPositioning applyOn: self
]

{ #category : 'configuration - private' }
ToNotebook >> applyResizablePanesConfiguration [

self body removeDividers.
self resizablePanes ifTrue: [ self body addDividers ]
]

{ #category : 'accessing' }
ToNotebook >> body [

^ body
]

{ #category : 'accessing - private' }
ToNotebook >> buttonGeometry [

^ self headerPositioning buttonGeometry
]

{ #category : 'accessing' }
ToNotebook >> buttons [

^ self header buttons
]

{ #category : 'configuration' }
ToNotebook >> checkingStrategy [

^ self header checkingStrategy
]

{ #category : 'configuration' }
ToNotebook >> checkingStrategy: aCheckingStrategy [

self header checkingStrategy: aCheckingStrategy
]

{ #category : 'initialization' }
ToNotebook >> defaultHeaderPositioning [

^ ToNotebookHeaderOnTop new
]

{ #category : 'accessing' }
ToNotebook >> body: anObject [
ToNotebook >> group [

body := anObject
^ self header group
]

{ #category : 'accessing' }
Expand All @@ -43,51 +88,143 @@ ToNotebook >> header [
^ header
]

{ #category : 'accessing' }
ToNotebook >> header: anObject [
{ #category : 'configuration' }
ToNotebook >> headerPositioning [

^ headerPositioning
]

{ #category : 'configuration' }
ToNotebook >> headerPositioning: aPositioningStategy [

header := anObject
headerPositioning := aPositioningStategy.
self headerPositioning applyOn: self
]

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

super initialize.
rebuildPaneOnSelect := false.
self beVertical.
resizablePanes := false.
self matchParent.
header := ToNotebookHeader horizontal.
header := ToNotebookHeader new.
body := ToPane vertical matchParent.
self headerPositioning: self defaultHeaderPositioning.
self addChild: header as: #header.
self addChild: body as: #body
self addChild: body as: #body.
self withVerticalBody.
self checkingStrategy: ToCheckableGroupStrictStrategy new

]

{ #category : 'adding-removing' }
{ #category : 'adding-removing - private' }
ToNotebook >> onButtonRemoved: aButton [


]

{ #category : 'accessing' }
{ #category : 'configuration' }
ToNotebook >> preservePaneOnSelect [

^ self rebuildPaneOnSelect not
]

{ #category : 'accessing' }
{ #category : 'configuration' }
ToNotebook >> preservePaneOnSelect: aBoolean [

self rebuildPaneOnSelect: aBoolean not
]

{ #category : 'accessing' }
{ #category : 'configuration' }
ToNotebook >> rebuildPaneOnSelect [

^ rebuildPaneOnSelect
]

{ #category : 'accessing' }
{ #category : 'configuration' }
ToNotebook >> rebuildPaneOnSelect: aBoolean [

rebuildPaneOnSelect := aBoolean
]

{ #category : 'configuration' }
ToNotebook >> resizablePanes [

^ resizablePanes
]

{ #category : 'configuration' }
ToNotebook >> resizablePanes: aBoolean [

resizablePanes := aBoolean.
self applyResizablePanesConfiguration
]

{ #category : 'configuration' }
ToNotebook >> withHeaderOnBottom [

self headerPositioning: ToNotebookHeaderOnBottom new
]

{ #category : 'configuration' }
ToNotebook >> withHeaderOnLeft [

self headerPositioning: ToNotebookHeaderOnLeft new
]

{ #category : 'configuration' }
ToNotebook >> withHeaderOnRight [

self headerPositioning: ToNotebookHeaderOnRight new
]

{ #category : 'configuration' }
ToNotebook >> withHeaderOnTop [

self headerPositioning: ToNotebookHeaderOnTop new
]

{ #category : 'configuration' }
ToNotebook >> withHorizontalBody [

self body beHorizontal
]

{ #category : 'configuration' }
ToNotebook >> withResizablePanes [

self resizablePanes ifTrue: [ ^ self ].
self resizablePanes: true
]

{ #category : 'configuration' }
ToNotebook >> withStrictCheckingStrategy [

self group withStrictCheckingStrategy
]

{ #category : 'configuration' }
ToNotebook >> withUncheckingStrategy [

self group withUncheckingStrategy
]

{ #category : 'configuration' }
ToNotebook >> withVerticalBody [

self body beVertical
]

{ #category : 'configuration' }
ToNotebook >> withoutCheckingStrategy [

self group withoutCheckingStrategy
]

{ #category : 'configuration' }
ToNotebook >> withoutResizablePanes [

self resizablePanes ifFalse: [ ^ self ].
self resizablePanes: false
]
16 changes: 8 additions & 8 deletions src/Toplo-Incubator/ToNotebookButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@ ToNotebookButton >> defaultBorder [
{ #category : 'skin' }
ToNotebookButton >> defaultGeometry [

^ BlRoundedRectangleGeometry cornerRadii: (BlCornerRadii new
topLeft: 8;
topRight: 8;
bottomLeft: 0;
bottomRight: 0;
yourself)
^ self notebook buttonGeometry
]

{ #category : 'skin' }
Expand Down Expand Up @@ -146,6 +141,7 @@ ToNotebookButton >> onAddedToParent [
ToNotebookButton >> onDeselected [

self removeInnerPaneFromBody.
self notebook applyResizablePanesConfiguration.
self notebook preservePaneOnSelect ifFalse: [ innerPane := nil ]
]

Expand All @@ -165,14 +161,18 @@ ToNotebookButton >> onRemovedFromParent: aParentElement [
ToNotebookButton >> onSelected [

(self notebook preservePaneOnSelect and: [ innerPane notNil ])
ifTrue: [
ifTrue: [
self body addChild: innerPane.
self notebook applyResizablePanesConfiguration.
^ self ].
innerPane := ToPane new
matchParent;
yourself.
self paneBuilder value: innerPane value: self body parent.
self body addChild: innerPane
self body addChild: innerPane.
self notebook applyResizablePanesConfiguration.


]

{ #category : 'accessing' }
Expand Down
4 changes: 4 additions & 0 deletions src/Toplo-Incubator/ToNotebookExamples.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ToNotebookExamples class >> example_notPreservingPane [

| nb but |
nb := ToNotebook new.
nb withoutCheckingStrategy.
nb withHorizontalBody.
nb preservePaneOnSelect: false.
1 to: 5 do: [ :index |
but := ToNotebookButton new.
Expand All @@ -41,6 +43,8 @@ ToNotebookExamples class >> example_preservingPane [
| nb but |
nb := ToNotebook new.
nb preservePaneOnSelect: true.
nb withoutCheckingStrategy.
nb resizablePanes: true.
1 to: 5 do: [ :index |
but := ToNotebookButton new.
but closable: true.
Expand Down
19 changes: 19 additions & 0 deletions src/Toplo-Incubator/ToNotebookHeader.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ ToNotebookHeader >> checkableGroupChangedEvent: anEvent [
anEvent checkedButtons do: [ :but | ].
]

{ #category : 'accessing' }
ToNotebookHeader >> checkingStrategy [

^ self group checkingStrategy
]

{ #category : 'accessing' }
ToNotebookHeader >> checkingStrategy: aCheckingStrategy [

^ self group checkingStrategy: aCheckingStrategy
]

{ #category : 'accessing' }
ToNotebookHeader >> group [

Expand All @@ -49,6 +61,13 @@ ToNotebookHeader >> notebook [
^ self parent
]

{ #category : 'hooks - children' }
ToNotebookHeader >> onAddedToParent [

super onAddedToParent.
self parent applyHeaderPositioning
]

{ #category : 'add-remove' }
ToNotebookHeader >> onButtonAdded: aButton [

Expand Down
28 changes: 28 additions & 0 deletions src/Toplo-Incubator/ToNotebookHeaderOnBottom.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Class {
#name : 'ToNotebookHeaderOnBottom',
#superclass : 'ToNotebookHeaderPositioning',
#category : 'Toplo-Incubator',
#package : 'Toplo-Incubator'
}

{ #category : 'hook' }
ToNotebookHeaderOnBottom >> applyOn: aNotebook [

aNotebook beVertical.
aNotebook beRightToLeft.
aNotebook header beHorizontal.
aNotebook header hMatchParent.
aNotebook header vFitContent.
aNotebook buttons do: [ :b | b geometry: self buttonGeometry ].
]

{ #category : 'as yet unclassified' }
ToNotebookHeaderOnBottom >> buttonGeometry [

^ BlRoundedRectangleGeometry cornerRadii: (BlCornerRadii new
topLeft: 0;
topRight: 0;
bottomLeft: 8;
bottomRight: 8;
yourself)
]
28 changes: 28 additions & 0 deletions src/Toplo-Incubator/ToNotebookHeaderOnLeft.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Class {
#name : 'ToNotebookHeaderOnLeft',
#superclass : 'ToNotebookHeaderPositioning',
#category : 'Toplo-Incubator',
#package : 'Toplo-Incubator'
}

{ #category : 'hook' }
ToNotebookHeaderOnLeft >> applyOn: aNotebook [

aNotebook beHorizontal.
aNotebook beLeftToRight.
aNotebook header beVertical.
aNotebook header hFitContent.
aNotebook header vMatchParent.
aNotebook buttons do: [ :b | b geometry: self buttonGeometry ].
]

{ #category : 'accessing' }
ToNotebookHeaderOnLeft >> buttonGeometry [

^ BlRoundedRectangleGeometry cornerRadii: (BlCornerRadii new
topLeft: 8;
topRight: 0;
bottomLeft: 8;
bottomRight: 0;
yourself)
]
Loading

0 comments on commit dabc4fa

Please sign in to comment.