[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Drop get_width() method



commit 537ca9dc3047a3fd0b29c669f6f60375ba7642d0
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Jul 15 08:40:14 2016 -0700

    Drop get_width() method
    
    Had it for symmetry with get_height() but was unused. The header and graph
    panels override get_height() so we still need that for the moment.
---
 nyx/controller.py     |  5 ++++-
 nyx/panel/__init__.py | 30 ++++++++----------------------
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/nyx/controller.py b/nyx/controller.py
index fc38185..c5b90d6 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -278,7 +278,10 @@ class Controller(object):
 
     for panel_impl in display_panels:
       panel_impl.set_top(occupied_content)
-      occupied_content += panel_impl.get_height()
+      height = panel_impl.get_height()
+
+      if height:
+        occupied_content += height
 
     # apparently curses may cache display contents unless we explicitely
     # request a redraw here...
diff --git a/nyx/panel/__init__.py b/nyx/panel/__init__.py
index 1d6ae9f..b572d66 100644
--- a/nyx/panel/__init__.py
+++ b/nyx/panel/__init__.py
@@ -71,11 +71,7 @@ class Panel(object):
 
   def __init__(self):
     self._visible = False
-
     self._top = 0
-    self._left = 0
-    self._height = -1
-    self._width = -1
 
   def set_visible(self, is_visible):
     """
@@ -107,17 +103,12 @@ class Panel(object):
 
   def get_height(self):
     """
-    Provides the height used for subwindows (-1 if it isn't limited).
-    """
+    Provides the height used by this panel.
 
-    return self._height
-
-  def get_width(self):
-    """
-    Provides the width used for subwindows (-1 if it isn't limited).
+    :returns: **int** for the height of the panel or **None** if unlimited
     """
 
-    return self._width
+    return None
 
   def get_preferred_size(self):
     """
@@ -129,15 +120,13 @@ class Panel(object):
     with nyx.curses.raw_screen() as stdscr:
       new_height, new_width = stdscr.getmaxyx()
 
-    set_height, set_width = self.get_height(), self.get_width()
     new_height = max(0, new_height - self._top)
-    new_width = max(0, new_width - self._left)
+    new_width = max(0, new_width)
 
-    if set_height != -1:
-      new_height = min(new_height, set_height)
+    set_height = self.get_height()
 
-    if set_width != -1:
-      new_width = min(new_width, set_width)
+    if set_height is not None:
+      new_height = min(new_height, set_height)
 
     return (new_height, new_width)
 
@@ -173,10 +162,7 @@ class Panel(object):
     if not self._visible or HALT_ACTIVITY:
       return
 
-    height = self.get_height() if self.get_height() != -1 else None
-    width = self.get_width() if self.get_width() != -1 else None
-
-    nyx.curses.draw(self.draw, top = self._top, width = width, height = height)
+    nyx.curses.draw(self.draw, top = self._top, height = self.get_height())
 
 
 class DaemonPanel(Panel, threading.Thread):



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits