summaryrefslogtreecommitdiff
path: root/src/size_manager.py
blob: 7e01d5d0ea5a755a3493d0e53b15a3f7482dd8d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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