Skip to content

Commit

Permalink
move examples to listview presenter package to fix dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanlm committed Dec 18, 2023
1 parent 1eff529 commit 6cbe943
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 218 deletions.
56 changes: 0 additions & 56 deletions src/Spec2-Examples/SpDropDownPresenter.extension.st

This file was deleted.

162 changes: 0 additions & 162 deletions src/Spec2-Examples/SpListViewPresenter.extension.st

This file was deleted.

55 changes: 55 additions & 0 deletions src/Spec2-ListView/SpDropDownPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ SpDropDownPresenter class >> adapterName [
^ #DropDownAdapter
]

{ #category : 'examples' }
SpDropDownPresenter class >> example [
"This example show the simples list view you can make: A list with a label"

self new
application: (SpApplication new useBackend: #Gtk);
items: self environment allClasses;
setup: [ :aPresenter | aPresenter newLabel ];
bind: [ :aPresenter :aClass | aPresenter label: aClass name ];
display: [ :aClass | aClass name ];
open
]

{ #category : 'examples' }
SpDropDownPresenter class >> exampleWithIcons [
"This example shows how to construct a list with icons.
It shows also the fact you can put any presenter inside, giving a huge power
to your lists."

^ self new
application: (SpApplication new useBackend: #Gtk);
items: self environment allClasses;
setup: [ :aPresenter |
| presenter |
(presenter := aPresenter newPresenter)
layout: (SpBoxLayout newHorizontal
"spacing: 5;"
add: presenter newImage expand: false;
add: presenter newLabel;
yourself);
yourself ];
bind: [ :aPresenter :aClass | | icon image label |
icon := Smalltalk ui icons iconNamed: aClass systemIconName.
image := aPresenter layout children first.
image image: icon.
label := aPresenter layout children second.
label label: aClass name ];
open
]

{ #category : 'examples' }
SpDropDownPresenter class >> exampleWithSelectedItem [
"This example show the simples list view you can make: A list with a label"

self new
application: (SpApplication new useBackend: #Gtk);
items: self environment allClassesAndTraits;
setup: [ :aPresenter | aPresenter newLabel ];
bind: [ :aPresenter :aClass | aPresenter label: aClass name ];
display: [ :aClass | aClass name ];
selectItem: Object;
whenSelectionChangedDo: [ :aSelection | aSelection selectedItem crTrace ];
open
]

{ #category : 'api' }
SpDropDownPresenter >> bind: aBlock [

Expand Down
Loading

0 comments on commit 6cbe943

Please sign in to comment.