ImageView.st
changeset 5596 0ec4341756f5
parent 5595 7a58ff8c13f1
child 5597 fd48983043d6
--- a/ImageView.st	Tue Sep 05 16:45:40 2017 +0200
+++ b/ImageView.st	Wed Sep 06 12:54:04 2017 +0200
@@ -14,8 +14,9 @@
 "{ NameSpace: Smalltalk }"
 
 View subclass:#ImageView
-	instanceVariableNames:'image magnifiedImage adjust magnificationFactor tileMode
-		tileOffset lastMousePoint adjustHolder imageEditAction'
+	instanceVariableNames:'image magnifiedImage adjust explicitMagnificationFactor
+		magnificationFactor tileMode tileOffset lastMousePoint
+		adjustHolder imageEditAction'
 	classVariableNames:'DoNotMagnifyQuery'
 	poolDictionaries:''
 	category:'Views-Misc'
@@ -428,8 +429,8 @@
 !
 
 magnificationFactor:aNumber
-    magnificationFactor ~= aNumber ifTrue:[
-        magnificationFactor := aNumber.
+    explicitMagnificationFactor ~= aNumber ifTrue:[
+        magnificationFactor := explicitMagnificationFactor := aNumber.
         "/    magnificationFactor fractionPart < 0.1 ifTrue:[
         "/        "magnifying by integer factor is faster"
         "/        magnificationFactor := magnificationFactor truncated.
@@ -440,6 +441,8 @@
         ].    
         self invalidate.
     ].
+
+    "Modified: / 06-09-2017 / 12:51:28 / Maren"
 !
 
 model:aValueHolder
@@ -576,7 +579,11 @@
 
     imgWidth := image width.
     imgHeight := image height.
-    
+
+    ((adjust == #fit) or:[adjust == #fitBig or:[adjust == #fitSmall]]) ifTrue:[
+        magnificationFactor := explicitMagnificationFactor.
+    ].
+
     tileMode ~~ true ifTrue:[
         ((imgWidth > innerWidth)
         or:[imgHeight > innerHeight]) ifTrue:[
@@ -603,9 +610,13 @@
             magnifiedImage := image
         ].
     ].
+    (magnifiedImage width == 0 or:[magnifiedImage height == 0]) ifTrue:[
+        magnifiedImage := nil.
+    ].
     self contentsChanged.
 
     "Modified: / 16-02-2017 / 01:27:05 / cg"
+    "Modified: / 06-09-2017 / 12:52:19 / Maren"
 !
 
 redrawX:x y:y width:w height:h