Skip to content

Commit

Permalink
Merge pull request #65 from jecisc/45-add-spacers-to-layouts
Browse files Browse the repository at this point in the history
45-add-spacers-to-layouts
  • Loading branch information
jecisc authored Oct 16, 2018
2 parents bc63f1c + 99fc8fd commit 298eb26
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Spec-Core/ComposablePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,11 @@ ComposablePresenter >> specSelectors [
^ self class specSelectors
]

{ #category : #accessing }
ComposablePresenter >> specSpacer [
^ SpacerPresenter new
]

{ #category : #'private-focus' }
ComposablePresenter >> takeKeyboardFocus [

Expand Down
17 changes: 17 additions & 0 deletions src/Spec-Core/SpacerPresenter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"
Description
--------------------
I am a simple presenter to add spacers to spec layouts.
"
Class {
#name : #SpacerPresenter,
#superclass : #AbstractWidgetPresenter,
#category : #'Spec-Core-Widgets'
}

{ #category : #specs }
SpacerPresenter class >> adapterName [

^ #SpacerAdapter
]
1 change: 1 addition & 0 deletions src/Spec-Core/SpecAdapterBindings.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SpecAdapterBindings >> initializeBindings [
at: #MenuItemAdapter put: #MenuItemAdapter;
at: #RadioButtonAdapter put: #RadioButtonAdapter;
at: #SliderAdapter put: #SliderAdapter;
at: #SpacerAdapter put: #SpacerAdapter;
at: #TabManagerAdapter put: #TabManagerAdapter;
at: #TabAdapter put: #TabAdapter;
at: #TableContainerAdapter put: #TableContainerAdapter;
Expand Down
6 changes: 6 additions & 0 deletions src/Spec-Core/SpecLayout.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Extension { #name : #SpecLayout }

{ #category : #'*Spec-Core' }
SpecLayout >> addSpacer [
self add: #specSpacer
]
5 changes: 5 additions & 0 deletions src/Spec-Examples/SpecDemoDynamicMemoryGamePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ SpecDemoDynamicMemoryGamePresenter class >> defaultSpec [
newRow: #differentCardsCountSlider height: self buttonHeight ]
]

{ #category : #example }
SpecDemoDynamicMemoryGamePresenter class >> example [
^ self new openWithSpec
]

{ #category : #accessing }
SpecDemoDynamicMemoryGamePresenter >> cardPairsCount [
^ self differentCardsCountSlider value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Class {
#category : #'Spec-Examples-Demo-Dynamic'
}

{ #category : #example }
SpecDemoDynamicPresentersListBuilder class >> example [
^ self new openWithSpec
]

{ #category : #specs }
SpecDemoDynamicPresentersListBuilder class >> pageName [

Expand Down
132 changes: 132 additions & 0 deletions src/Spec-Examples/SpecSpacerDemo.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"
Description
--------------------
I am a simple demo to show how to use spacers in Spec layouts.
```
SpecSpacerDemo example
```
"
Class {
#name : #SpecSpacerDemo,
#superclass : #ComposablePresenter,
#instVars : [
'input2',
'input3',
'input4',
'button1',
'button2',
'button3',
'button4',
'input1'
],
#category : #'Spec-Examples-Demo-Layouts'
}

{ #category : #specs }
SpecSpacerDemo class >> defaultSpec [
^ SpecLayout composed
newColumn: [ :c |
c
newRow: #input1 height: self inputTextHeight;
addSpacer;
newRow: #input2 height: self inputTextHeight;
newRow: #input3 height: self inputTextHeight;
addSpacer;
addSpacer;
newRow: #input4 height: self inputTextHeight;
addSpacer;
newRow: [ :r |
r
add: #button1;
addSpacer;
add: #button2;
"addSpacer;"
add: #button3;
"addSpacer;"
add: #button4 ]
height: self toolbarHeight ];
yourself
]

{ #category : #specs }
SpecSpacerDemo class >> example [
^ self new openWithSpec
]

{ #category : #specs }
SpecSpacerDemo class >> title [
^ 'Spacer demo'
]

{ #category : #accessing }
SpecSpacerDemo >> button1 [
^ button1
]

{ #category : #accessing }
SpecSpacerDemo >> button2 [
^ button2
]

{ #category : #accessing }
SpecSpacerDemo >> button3 [
^ button3
]

{ #category : #accessing }
SpecSpacerDemo >> button4 [
^ button4
]

{ #category : #specs }
SpecSpacerDemo >> extent [
^ 700@500
]

{ #category : #initialization }
SpecSpacerDemo >> initializeWidgets [

input1 := self newTextInput.
input2 := self newTextInput.
input3 := self newTextInput.
input4 := self newTextInput.

button1 := self newButton.
button2 := self newButton.
button3 := self newButton.
button4 := self newButton.

input1 ghostText: 'Input 1'.
input2 ghostText: 'Input 2'.
input3 ghostText: 'Input 3'.
input4 ghostText: 'Input 4'.

button1 label: 'Button 1'.
button2 label: 'Button 2'.
button3 label: 'Button 3'.
button4 label: 'Button 4'
]

{ #category : #accessing }
SpecSpacerDemo >> input1 [
^ input1
]

{ #category : #accessing }
SpecSpacerDemo >> input2 [
^ input2
]

{ #category : #accessing }
SpecSpacerDemo >> input3 [
^ input3
]

{ #category : #accessing }
SpecSpacerDemo >> input4 [
^ input4
]
1 change: 1 addition & 0 deletions src/Spec-MorphicAdapters/MorphicAdapterBindings.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ MorphicAdapterBindings >> initializeBindings [
at: #MenuItemAdapter put: #MorphicMenuItemAdapter;
at: #RadioButtonAdapter put: #MorphicRadioButtonAdapter;
at: #SliderAdapter put: #MorphicSliderAdapter;
at: #SpacerAdapter put: #MorphicSpacerAdapter;
at: #TabManagerAdapter put: #MorphicTabManagerAdapter;
at: #TabAdapter put: #MorphicTabAdapter;
at: #TableContainerAdapter put: #MorphicTableContainerAdapter;
Expand Down
14 changes: 14 additions & 0 deletions src/Spec-MorphicAdapters/MorphicSpacerAdapter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Class {
#name : #MorphicSpacerAdapter,
#superclass : #AbstractMorphicAdapter,
#category : #'Spec-MorphicAdapters-Base'
}

{ #category : #factory }
MorphicSpacerAdapter >> buildWidget [
^ PanelMorph new
changeTableLayout;
hResizing: #spaceFill;
vResizing: #spaceFill;
yourself
]
1 change: 1 addition & 0 deletions src/Spec-StubAdapter/SpecStubAdapterBindings.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SpecStubAdapterBindings >> initializeBindings [
at: #MenuItemAdapter put: #SpecStubMenuItemAdapter;
at: #RadioButtonAdapter put: #SpecStubRadioButtonAdapter;
at: #SliderAdapter put: #SpecStubSliderAdapter;
at: #SpacerAdapter put: #SpecStubSpacerAdapter;
at: #TabManagerAdapter put: #SpecStubTabManagerAdapter;
at: #TabAdapter put: #SpecStubTabAdapter;
at: #TableContainerAdapter put: #SpecStubTableContainerAdapter;
Expand Down
13 changes: 13 additions & 0 deletions src/Spec-StubAdapter/SpecStubSpacerAdapter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"
Stub
"
Class {
#name : #SpecStubSpacerAdapter,
#superclass : #SpecStubAbstractAdapter,
#category : #'Spec-StubAdapter-Adapters'
}

{ #category : #factory }
SpecStubSpacerAdapter >> buildWidget [
^ SpecStubSpacerView new
]
8 changes: 8 additions & 0 deletions src/Spec-StubAdapter/SpecStubSpacerView.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"
Stub
"
Class {
#name : #SpecStubSpacerView,
#superclass : #SpecStubViews,
#category : #'Spec-StubAdapter-Views'
}

0 comments on commit 298eb26

Please sign in to comment.