Skip to content

Commit

Permalink
Merge pull request #1693 from AlexisCnockaert/SpPresenterChanges
Browse files Browse the repository at this point in the history
changes on SPPresenter for resizing windows
  • Loading branch information
Ducasse authored Jan 9, 2025
2 parents c34e8e0 + 6f8c830 commit 516be66
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/Spec2-Core/SpPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ Class {
'#extent => ObservableSlot',
'#styles'
],
#classInstVars : [
'#preferredExtent',
'#customExtent'
],
#category : 'Spec2-Core-Base',
#package : 'Spec2-Core',
#tag : 'Base'
Expand All @@ -111,6 +115,12 @@ SpPresenter class >> currentApplication [
^ SpApplication defaultApplication
]

{ #category : 'accessing' }
SpPresenter class >> defaultPreferredExtent [

^ 700@500
]

{ #category : 'labeled-presenters' }
SpPresenter class >> iconWidth [
^ 24
Expand Down Expand Up @@ -184,6 +194,18 @@ SpPresenter class >> owner: anOwningPresenter on: aDomainObject [
yourself
]

{ #category : 'accessing' }
SpPresenter class >> preferredExtent [

^ customExtent ifNil: [ customExtent := self defaultPreferredExtent ]
]

{ #category : 'accessing' }
SpPresenter class >> preferredExtent: aPoint [

customExtent := aPoint
]

{ #category : 'specs' }
SpPresenter class >> title [

Expand Down Expand Up @@ -643,8 +665,9 @@ SpPresenter >> initializeWindow: aWindowPresenter [

aWindowPresenter
title: self title;
initialExtent: self initialExtent;
windowIcon: self windowIcon
initialExtent: self class preferredExtent;
windowIcon: self windowIcon;
whenResizingDo: [ :ann | self preferredExtent: ann newSize ].
]

{ #category : 'inspector - extensions' }
Expand Down Expand Up @@ -777,6 +800,22 @@ SpPresenter >> on: anAnnouncement send: aSelector to: aTarget [
to: aTarget
]

{ #category : 'accessing' }
SpPresenter >> preferredExtent [
"The preferred extent logic manages the fact that if the user resizes a window, the preferred extent reflects this new size. Notice that this preferred extent is on a per presenter (i.e. class level) shared between all the instances of the class."

^ self class preferredExtent
]

{ #category : 'accessing' }
SpPresenter >> preferredExtent: aSize [

(self window isMaximized
or: [ self window isMinimized ])
ifTrue: [ ^ self ].
self class preferredExtent: aSize
]

{ #category : 'accessing' }
SpPresenter >> presenterAt: aName [
"Retrieves a subpresenter of this composed presenter."
Expand Down

0 comments on commit 516be66

Please sign in to comment.