<commit_before>"
I am a Woden application model.

I am the core a Woden based application. I take care of handling animation and coordinating my views for doing time based updates.
"
Class {
	#name : #WDAModel,
	#superclass : #WDCRenderingProcess,
	#traits : 'TWDCRenderingDependencyGraphNode',
	#classTraits : 'TWDCRenderingDependencyGraphNode classTrait',
	#instVars : [
		'views',
		'engine',
		'started',
		'session',
		'renderingDependencies'
	],
	#category : #'WodenEngine-Core-Application'
}

{ #category : #'instance creation' }
WDAModel class >> for: aWDCEngine [
	^ self basicNew initializeWithEngine: aWDCEngine
]

{ #category : #adding }
WDAModel >> addDependencyToWodenModel: renderingDependency [
	renderingDependencies add: renderingDependency
]

{ #category : #adding }
WDAModel >> addRenderingDependency: wodenModel [
	renderingDependencies add: wodenModel
]

{ #category : #adding }
WDAModel >> addRenderingElementsToGraph: renderingDependencyGraph [
	renderingDependencyGraph addNodes: views
]

{ #category : #adding }
WDAModel >> addView: aView [
	engine renderingProcessCritical: [
		views add: aView.
	]
]

{ #category : #adding }
WDAModel >> allViewsAreClosed [
	"Stop the process by default"
	self stop
]

{ #category : #accessing }
WDAModel >> continousUpdating [
	^ started
]

{ #category : #'as yet unclassified' }
WDAModel >> defaultViewClass [
	^ WDAView
]

{ #category : #accessing }
WDAModel >> engine [
	^ engine
]

{ #category : #initialization }
WDAModel >> initialize [
	super initialize.
	engine ifNil: [ engine := WDCEngine default. ].
	
	views := OrderedCollection new.
	renderingDependencies := OrderedCollection new.
	started := false.
	self initializeModel.
	self initializeForNewSession.
]

{ #category : #initialization }
WDAModel >> initializeForNewSession [
	session := Smalltalk session.
]

{ #category : #initialization }
WDAModel >> initializeModel [
	"This is the place for doing any model specific initialization"
]

{ #category : #initialization }
WDAModel >> initializeWithEngine: anEngine [
	engine := anEngine.
	self initialize
]

{ #category : #testing }
WDAModel >> needsToRender [
	^ views isNotEmpty

]

{ #category : #opening }
WDAModel >> open [
	^ self openWith: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openInMorphic [
	^ self openInMorphicWith: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openInMorphicWith: aView [
	| view |
	view := aView engine: engine model: self.
	view openInMorphic.
	self addView: view.
	self start.
	^ view
]

{ #category : #opening }
WDAModel >> openInOSWindow [
	^ self openInOSWindowWith: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openInOSWindowWith: aView [
	| view |
	view := aView engine: engine model: self.
	view openInOSWindow.
	self addView: view.
	self start.
	^ view
]

{ #category : #opening }
WDAModel >> openOnRenderTargetTexture: screenTexture [
	^ self openOnRenderTargetTexture: screenTexture with: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openOnRenderTargetTexture: screenTexture with: aView [
	| view |
	view := aView engine: engine model: self.
	view openOnRenderTargetTexture: screenTexture.
	self addView: view.
	self start.
	^ view
]

{ #category : #opening }
WDAModel >> openWith: aView [
	(Smalltalk os isMacOSX or: [ Smalltalk os isWindows ]) ifTrue: [
		^ self openInMorphicWith: aView
	].
 
	^ self openInOSWindowWith: aView
]

{ #category : #'rendering process stages' }
WDAModel >> processEvents [
	engine renderingProcessCritical: [ 
		views do: #processEvents
	]

]

{ #category : #adding }<commit_msg>Fallback to Morphic on blacklisted environments for OSWindow.<commit_after>"
I am a Woden application model.

I am the core a Woden based application. I take care of handling animation and coordinating my views for doing time based updates.
"
Class {
	#name : #WDAModel,
	#superclass : #WDCRenderingProcess,
	#traits : 'TWDCRenderingDependencyGraphNode',
	#classTraits : 'TWDCRenderingDependencyGraphNode classTrait',
	#instVars : [
		'views',
		'engine',
		'started',
		'session',
		'renderingDependencies'
	],
	#category : #'WodenEngine-Core-Application'
}

{ #category : #'instance creation' }
WDAModel class >> for: aWDCEngine [
	^ self basicNew initializeWithEngine: aWDCEngine
]

{ #category : #adding }
WDAModel >> addDependencyToWodenModel: renderingDependency [
	renderingDependencies add: renderingDependency
]

{ #category : #adding }
WDAModel >> addRenderingDependency: wodenModel [
	renderingDependencies add: wodenModel
]

{ #category : #adding }
WDAModel >> addRenderingElementsToGraph: renderingDependencyGraph [
	renderingDependencyGraph addNodes: views
]

{ #category : #adding }
WDAModel >> addView: aView [
	engine renderingProcessCritical: [
		views add: aView.
	]
]

{ #category : #adding }
WDAModel >> allViewsAreClosed [
	"Stop the process by default"
	self stop
]

{ #category : #accessing }
WDAModel >> continousUpdating [
	^ started
]

{ #category : #'as yet unclassified' }
WDAModel >> defaultViewClass [
	^ WDAView
]

{ #category : #accessing }
WDAModel >> engine [
	^ engine
]

{ #category : #initialization }
WDAModel >> initialize [
	super initialize.
	engine ifNil: [ engine := WDCEngine default. ].
	
	views := OrderedCollection new.
	renderingDependencies := OrderedCollection new.
	started := false.
	self initializeModel.
	self initializeForNewSession.
]

{ #category : #initialization }
WDAModel >> initializeForNewSession [
	session := Smalltalk session.
]

{ #category : #initialization }
WDAModel >> initializeModel [
	"This is the place for doing any model specific initialization"
]

{ #category : #initialization }
WDAModel >> initializeWithEngine: anEngine [
	engine := anEngine.
	self initialize
]

{ #category : #opening }
WDAModel >> isOSWindowBlacklisted [
	(#(null sdl2) includes: Smalltalk os windowSystemName) ifTrue: [ ^ false ].
	^ Smalltalk os isMacOSX or: [ Smalltalk os isWindows ]
]

{ #category : #testing }
WDAModel >> needsToRender [
	^ views isNotEmpty

]

{ #category : #opening }
WDAModel >> open [
	^ self openWith: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openInMorphic [
	^ self openInMorphicWith: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openInMorphicWith: aView [
	| view |
	view := aView engine: engine model: self.
	view openInMorphic.
	self addView: view.
	self start.
	^ view
]

{ #category : #opening }
WDAModel >> openInOSWindow [
	^ self openInOSWindowWith: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openInOSWindowWith: aView [
	| view |
	view := aView engine: engine model: self.
	view openInOSWindow.
	self addView: view.
	self start.
	^ view
]

{ #category : #opening }
WDAModel >> openOnRenderTargetTexture: screenTexture [
	^ self openOnRenderTargetTexture: screenTexture with: self defaultViewClass
]

{ #category : #opening }
WDAModel >> openOnRenderTargetTexture: screenTexture with: aView [
	| view |
	view := aView engine: engine model: self.
	view openOnRenderTargetTexture: screenTexture.
	self addView: view.
	self start.
	^ view
]

{ #category : #opening }
WDAModel >> openWith: aView [
	self isOSWindowBlacklisted ifTrue: [
		^ self openInMorphicWith: aView
	].
 
	^ self openInOSWindowWith: aView
]

{ #category : #'rendering process stages' }
WDAModel >> processEvents [
	engine renderingProcessCritical: [ 
		views do: #processEvents
	]

]

{ #category : #adding }
{'fraction_non_alphanumeric': 0.10804257038933046, 'fraction_numerical': 0.0001347164219318335, 'mean_word_length': 4.688888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2221522', 'n_tokens_mistral': 2458, 'n_tokens_neox': 2378, 'n_words': 641}