# Path: tilenol/widgets/base.py
# class Widget(metaclass=ABCMeta):
# 
#     bar = dependency(Bar, 'bar')
#     stretched = False
# 
#     def __init__(self, right=False):
#         self.right = right
# 
#     @abstractmethod
#     def draw(self, canvas, left, right):
#         return left, right
# 
# Path: tilenol/theme.py
# class Theme(SubTheme):
# 
#     def __init__(self):
# 
#         blue = 0x4c4c99
#         dark_blue = 0x191933
#         orange = 0x99994c
#         gray = 0x808080
#         red = 0x994c4c
#         black = 0x000000
#         white = 0xffffff
# 
#         self.window = SubTheme('window')
#         self.window.border_width = 2
#         self.window.set_color('active_border', blue)
#         self.window.set_color('inactive_border', gray)
#         self.window.set_color('background', black)
# 
#         self.bar = SubTheme('bar')
#         self.bar.set_color('background', black)
#         self.bar.font = Font('Consolas', 18)
#         self.bar.box_padding = Padding(2, 2, 2, 2)
#         self.bar.text_padding = Padding(2, 4, 7, 4)
#         self.bar.icon_spacing = 2
#         self.bar.set_color('text_color', white)
#         self.bar.set_color('dim_color', gray)
#         self.bar.set_color('bright_color', orange)
#         self.bar.set_color('active_border', blue)
#         self.bar.set_color('subactive_border', gray)
#         self.bar.set_color('urgent_border', red)
#         self.bar.border_width = 2
#         self.bar.height = 24
#         self.bar.set_color('graph_color', blue)
#         self.bar.set_color('graph_fill_color', dark_blue)
#         self.bar.graph_line_width = 2
#         self.bar.separator_width = 1
#         self.bar.set_color('separator_color', gray)
# 
#         self.menu = SubTheme('bar')
#         self.menu.set_color('background', gray)
#         self.menu.set_color('text', white)
#         self.menu.set_color('highlight', blue)
#         self.menu.set_color('selection', blue)
#         self.menu.set_color('selection_text', white)
#         self.menu.set_color('cursor', black)
#         self.menu.font = Font('Consolas', 18)
#         self.menu.padding = Padding(2, 4, 7, 4)
#         self.menu.line_height = 24
# 
#         self.hint = SubTheme('hint')
#         self.hint.font = Font('Consolas', 18)
#         self.hint.set_color('background', black)
#         self.hint.set_color('border_color', gray)
#         self.hint.set_color('text_color', white)
#         self.hint.border_width = 2
#         self.hint.padding = Padding(5, 6, 9, 6)
# 
#         self.tabs = SubTheme('tabs')
#         self.tabs.font = Font('Monofur', 12)
#         self.tabs.set_color('background', black)
#         self.tabs.set_color('inactive_title', gray)
#         self.tabs.set_color('inactive_bg', black)
#         self.tabs.set_color('active_title', white)
#         self.tabs.set_color('active_bg', blue)
#         self.tabs.set_color('urgent_title', white)
#         self.tabs.set_color('urgent_bg', orange)
#         self.tabs.section_font = Font('Monofur', 12)
#         self.tabs.set_color('section_color', gray)
#         self.tabs.padding = Padding(5, 6, 6, 4)
#         self.tabs.margin = Padding(4, 4, 4, 4)
#         self.tabs.border_radius = 5
#         self.tabs.spacing = 2
#         self.tabs.icon_size = 14
#         self.tabs.icon_spacing = 6
#         self.tabs.section_padding = Padding(6, 2, 2, 2)
# 
#     def update_from(self, dic):
#         for key, sub in self.__dict__.items():
#             if isinstance(sub, SubTheme) and key in dic:
#                 sub.update_from(dic[key])
# 
# Path: tilenol/gestures.py
# GRAD = pi/180
# SYNAPTICS_SHM = 23947
# START = marker_object('gestures.START')
# PARTIAL = marker_object('gestures.PARTIAL')
# FULL = marker_object('gestures.FULL')
# COMMIT = marker_object('gestures.COMMIT')
# UNDO = marker_object('gestures.UNDO')
# CANCEL = marker_object('gestures.CANCEL')
# class SynapticsSHM(ctypes.Structure):
# class Gestures(object):
#     def __init__(self):
#     def __zorro_di_done__(self):
#     def add_callback(self, name, fun):
#     def active_gestures(self):
#     def _shm_checker(self):
#     def _shm_loop(self, ptr):


from math import pi
from zorro.di import dependency, has_dependencies
from  .base import Widget
from tilenol.theme import Theme
from tilenol import gestures as G

    theme = dependency(Theme, 'theme')
    gestures = dependency(G.Gestures, 'gestures')

    def __init__(self, *, gestures=None, right=False):
        super().__init__(right=right)
        self.format = format
        self.gesture_names = gestures
        self.state = (None, None, None, None)

    def __zorro_di_done__(self):
        bar = self.theme.bar
        self.font = bar.font
        self.color = bar.text_color_pat
        self.background = bar.background_pat
        self.dig = bar.bright_color_pat
        self.inactive_color = bar.dim_color_pat
        self.padding = bar.text_padding
        self.gwidth = self.height - self.padding.top - self.padding.bottom
        if self.gesture_names is None:
            for name in self.gestures.active_gestures:
                self.gestures.add_callback(name, self._update_gesture)
        else:
            for name in self.gesture_names:
                self.gestures.add_callback(name, self._update_gesture)

    def _update_gesture(self, name, percent, state, cfg):
        px = min(int(percent*self.gwidth), self.gwidth)
        st = (name, px, state, cfg)
        if self.state != st:

# Path: tilenol/widgets/base.py
# class Widget(metaclass=ABCMeta):
# 
#     bar = dependency(Bar, 'bar')
#     stretched = False
# 
#     def __init__(self, right=False):
#         self.right = right
# 
#     @abstractmethod
#     def draw(self, canvas, left, right):
#         return left, right
# 
# Path: tilenol/theme.py
# class Theme(SubTheme):
# 
#     def __init__(self):
# 
#         blue = 0x4c4c99
#         dark_blue = 0x191933
#         orange = 0x99994c
#         gray = 0x808080
#         red = 0x994c4c
#         black = 0x000000
#         white = 0xffffff
# 
#         self.window = SubTheme('window')
#         self.window.border_width = 2
#         self.window.set_color('active_border', blue)
#         self.window.set_color('inactive_border', gray)
#         self.window.set_color('background', black)
# 
#         self.bar = SubTheme('bar')
#         self.bar.set_color('background', black)
#         self.bar.font = Font('Consolas', 18)
#         self.bar.box_padding = Padding(2, 2, 2, 2)
#         self.bar.text_padding = Padding(2, 4, 7, 4)
#         self.bar.icon_spacing = 2
#         self.bar.set_color('text_color', white)
#         self.bar.set_color('dim_color', gray)
#         self.bar.set_color('bright_color', orange)
#         self.bar.set_color('active_border', blue)
#         self.bar.set_color('subactive_border', gray)
#         self.bar.set_color('urgent_border', red)
#         self.bar.border_width = 2
#         self.bar.height = 24
#         self.bar.set_color('graph_color', blue)
#         self.bar.set_color('graph_fill_color', dark_blue)
#         self.bar.graph_line_width = 2
#         self.bar.separator_width = 1
#         self.bar.set_color('separator_color', gray)
# 
#         self.menu = SubTheme('bar')
#         self.menu.set_color('background', gray)
#         self.menu.set_color('text', white)
#         self.menu.set_color('highlight', blue)
#         self.menu.set_color('selection', blue)
#         self.menu.set_color('selection_text', white)
#         self.menu.set_color('cursor', black)
#         self.menu.font = Font('Consolas', 18)
#         self.menu.padding = Padding(2, 4, 7, 4)
#         self.menu.line_height = 24
# 
#         self.hint = SubTheme('hint')
#         self.hint.font = Font('Consolas', 18)
#         self.hint.set_color('background', black)
#         self.hint.set_color('border_color', gray)
#         self.hint.set_color('text_color', white)
#         self.hint.border_width = 2
#         self.hint.padding = Padding(5, 6, 9, 6)
# 
#         self.tabs = SubTheme('tabs')
#         self.tabs.font = Font('Monofur', 12)
#         self.tabs.set_color('background', black)
#         self.tabs.set_color('inactive_title', gray)
#         self.tabs.set_color('inactive_bg', black)
#         self.tabs.set_color('active_title', white)
#         self.tabs.set_color('active_bg', blue)
#         self.tabs.set_color('urgent_title', white)
#         self.tabs.set_color('urgent_bg', orange)
#         self.tabs.section_font = Font('Monofur', 12)
#         self.tabs.set_color('section_color', gray)
#         self.tabs.padding = Padding(5, 6, 6, 4)
#         self.tabs.margin = Padding(4, 4, 4, 4)
#         self.tabs.border_radius = 5
#         self.tabs.spacing = 2
#         self.tabs.icon_size = 14
#         self.tabs.icon_spacing = 6
#         self.tabs.section_padding = Padding(6, 2, 2, 2)
# 
#     def update_from(self, dic):
#         for key, sub in self.__dict__.items():
#             if isinstance(sub, SubTheme) and key in dic:
#                 sub.update_from(dic[key])
# 
# Path: tilenol/gestures.py
# GRAD = pi/180
# SYNAPTICS_SHM = 23947
# START = marker_object('gestures.START')
# PARTIAL = marker_object('gestures.PARTIAL')
# FULL = marker_object('gestures.FULL')
# COMMIT = marker_object('gestures.COMMIT')
# UNDO = marker_object('gestures.UNDO')
# CANCEL = marker_object('gestures.CANCEL')
# class SynapticsSHM(ctypes.Structure):
# class Gestures(object):
#     def __init__(self):
#     def __zorro_di_done__(self):
#     def add_callback(self, name, fun):
#     def active_gestures(self):
#     def _shm_checker(self):
#     def _shm_loop(self, ptr):


# Path: tilenol/widgets/gesture.py
from math import pi
from zorro.di import dependency, has_dependencies
from  .base import Widget
from tilenol.theme import Theme
from tilenol import gestures as G


    theme = dependency(Theme, 'theme')
    gestures = dependency(G.Gestures, 'gestures')

    def __init__(self, *, gestures=None, right=False):
        super().__init__(right=right)
        self.format = format
        self.gesture_names = gestures
        self.state = (None, None, None, None)

    def __zorro_di_done__(self):
        bar = self.theme.bar
        self.font = bar.font
        self.color = bar.text_color_pat
        self.background = bar.background_pat
        self.dig = bar.bright_color_pat
        self.inactive_color = bar.dim_color_pat
        self.padding = bar.text_padding
        self.gwidth = self.height - self.padding.top - self.padding.bottom
        if self.gesture_names is None:
            for name in self.gestures.active_gestures:
                self.gestures.add_callback(name, self._update_gesture)
        else:
            for name in self.gesture_names:
                self.gestures.add_callback(name, self._update_gesture)

    def _update_gesture(self, name, percent, state, cfg):
        px = min(int(percent*self.gwidth), self.gwidth)
        st = (name, px, state, cfg)
        if self.state != st:

            if state in {G.CANCEL, G.COMMIT}: