about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-29 16:27:04 +0100
committerhut <hut@lavabit.com>2009-12-29 16:27:04 +0100
commit3f77e62a6dc8b700a736b5d0a7e9cf51dd0018df (patch)
treef207d1d17aa81a84940839bededed3e3e3497f8a /ranger
parent9d1ccd92d7f1e24777b24e54be09a8e6423a4206 (diff)
downloadranger-3f77e62a6dc8b700a736b5d0a7e9cf51dd0018df.tar.gz
Optimized moving/resizing of windows, fixed absolute position bug
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/displayable.py29
-rw-r--r--ranger/gui/widgets/filelist.py2
2 files changed, 23 insertions, 8 deletions
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index 40731449..404f66a0 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -18,9 +18,14 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 
 		self.x = 0
 		self.y = 0
+		self.yy = 0
+		self.xx = 0
+		self.absx = 0
+		self.absy = 0
 		self.wid = 0
 		self.hei = 0
 		self.colorscheme = self.settings.colorscheme
+		self.parent = None
 
 		if win is not None:
 			if isinstance(self, UI):
@@ -143,17 +148,25 @@ class Displayable(EnvironmentAware, FileManagerAware, SettingsAware):
 			if y + hei > maxy:
 				raise OutOfBoundsException("Y out of bounds!")
 
-		try:
-			self.win.resize(hei, wid)
-		except:
-			# Not enough space for resizing...
+		if hei != self.hei or wid != self.wid:
 			try:
-				self.win.mvderwin(0, 0)
 				self.win.resize(hei, wid)
 			except:
-				raise OutOfBoundsException("Resizing Failed!")
+				# Not enough space for resizing...
+				try:
+					self.win.mvderwin(0, 0)
+					self.win.resize(hei, wid)
+				except:
+					raise OutOfBoundsException("Resizing Failed!")
+
+		if y != self.absy or x != self.absx:
+			self.win.mvderwin(y, x)
+
+		self.yy, self.xx = y, x
+		if self.parent:
+			self.yy += self.parent.yy
+			self.xx += self.parent.xx
 
-		self.win.mvderwin(y, x)
 		self.absy, self.absx = y, x
 		self.x = 0
 		self.y = 0
@@ -229,6 +242,8 @@ class DisplayableContainer(Displayable):
 
 	def add_obj(self, *objs):
 		self.container.extend(objs)
+		for obj in objs:
+			obj.parent = self
 
 	def destroy(self):
 		"""Recursively called on objects in container"""
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index b2adc7e2..43f3834a 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -33,7 +33,7 @@ class FileList(Widget, DisplayableContainer):
 			pass
 
 		elif self.target.type is T_DIRECTORY:
-			index = self.scroll_begin + event.y - 1
+			index = self.scroll_begin + event.y - self.yy
 
 			if event.pressed(1):
 				if not self.main_display: