From a2a2b711eb2934bfd50e19c9f608217c39802f1b Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Fri, 17 Oct 2014 10:36:05 +0100
Subject: [PATCH] Number of lightbox rows and columns are now fixed (i.e. they
 don't change when the image properties change).

---
 fsl/fslview/gl/lightboxcanvas.py | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/fsl/fslview/gl/lightboxcanvas.py b/fsl/fslview/gl/lightboxcanvas.py
index 04576f3d0..b8cea3c3d 100644
--- a/fsl/fslview/gl/lightboxcanvas.py
+++ b/fsl/fslview/gl/lightboxcanvas.py
@@ -35,7 +35,7 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
     """
 
     
-    ncols = props.Int(clamped=True, minval=1, maxval=15, default=5)
+    ncols = props.Int(clamped=True, minval=1, maxval=20, default=5)
     """This property controls the number of 
     slices to be displayed on a single row.
     """
@@ -250,9 +250,20 @@ class LightBoxCanvas(slicecanvas.SliceCanvas):
 
         if self._nslices == 0 or self._totalRows == 0:
             return
-
-        self.setConstraint('nrows',  'maxval', self._totalRows)
-        self.setConstraint('topRow', 'maxval', self._totalRows - self.nrows)
+        
+        # All slices are going to be displayed, so
+        # we'll 'disable' the topRow property
+        if self._totalRows < self.nrows:
+            self.setConstraint('topRow', 'minval', 0)
+            self.setConstraint('topRow', 'maxval', 0)
+
+        # nrows slices are going to be displayed,
+        # and the topRow property can be used to
+        # scroll through all available rows.
+        else:
+            self.setConstraint('topRow',
+                               'maxval',
+                               self._totalRows - self.nrows)
 
 
     def _zPosChanged(self, *a):
-- 
GitLab