summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-29 00:29:54 +0200
committermathieui <mathieui@mathieui.net>2014-04-29 00:29:54 +0200
commit9e72f8336da77c566fbbe6aad7caf6e79a0aab58 (patch)
treeafb033f9bec033df97d8c67064cc81cb6f897521 /src
parent8241f5d6fce71cc434bfdbb03a50ce8e37794a22 (diff)
downloadpoezio-9e72f8336da77c566fbbe6aad7caf6e79a0aab58.tar.gz
poezio-9e72f8336da77c566fbbe6aad7caf6e79a0aab58.tar.bz2
poezio-9e72f8336da77c566fbbe6aad7caf6e79a0aab58.tar.xz
poezio-9e72f8336da77c566fbbe6aad7caf6e79a0aab58.zip
Add the size manager (forgotten in the previous commits)
Diffstat (limited to 'src')
-rw-r--r--src/size_manager.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/size_manager.py b/src/size_manager.py
new file mode 100644
index 00000000..7e01d5d0
--- /dev/null
+++ b/src/size_manager.py
@@ -0,0 +1,52 @@
+"""
+Size Manager:
+ used to check size boundaries of the whole window and
+ specific tabs
+"""
+from windows import g_lock
+
+THRESHOLD_WIDTH_DEGRADE = 45
+THRESHOLD_HEIGHT_DEGRADE = 10
+
+FULL_WIDTH_DEGRADE = 66
+FULL_HEIGHT_DEGRADE = 10
+
+class SizeManager(object):
+
+ def __init__(self, core, win_cls):
+ self._win_class = win_cls
+ self._core = core
+
+ @property
+ def tab_scr(self):
+ return self._win_class._tab_win
+
+ @property
+ def core_scr(self):
+ return self._core.stdscr
+
+ @property
+ def tab_degrade_x(self):
+ with g_lock:
+ _, x = self.tab_scr.getmaxyx()
+ return x < THRESHOLD_WIDTH_DEGRADE
+
+ @property
+ def tab_degrade_y(self):
+ with g_lock:
+ y, x = self.tab_scr.getmaxyx()
+ return y < THRESHOLD_HEIGHT_DEGRADE
+
+ @property
+ def core_degrade_x(self):
+ with g_lock:
+ y, x = self.core_scr.getmaxyx()
+ return x < FULL_WIDTH_DEGRADE
+
+ @property
+ def core_degrade_y(self):
+ with g_lock:
+ y, x = self.core_scr.getmaxyx()
+ return y < FULL_HEIGHT_DEGRADE
+
+