-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
87 lines (63 loc) · 3.01 KB
/
app.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from typing import List, Tuple
from cardlib import InputCard, MetaCard, CardType
class App:
"""A class that holds current status of the application"""
left_mouse_button_down: bool = False
left_mouse_button_down_pos: Tuple[int, int] = (0, 0)
middle_mouse_button_down: bool = False
middle_mouse_button_down_pos: Tuple[int, int] = (0, 0)
version_major: int = 0
version_minor: int = 1
version_revision: int = 0
screen_drag_x: int = 0
screen_drag_y: int = 0
cards: List[MetaCard] = []
def __init__(self):
pass
def add_card(self, card: CardType) -> None:
"""Add a card to the application"""
if not card in CardType:
raise TypeError("Card must be of type CardType")
match card:
case CardType.INPUTCARD:
self.cards.append(InputCard("Input Card", 300, 300))
def sort_cards_by_z_order(self) -> None:
"""Sort the cards in the application"""
self.cards.sort(key=lambda x: x.z_order)
def set_left_mouse_button_down_status(self, status, pos) -> None:
"""Set the status of the left mouse button"""
self.left_mouse_button_down = status
self.left_mouse_button_down_pos = pos
def set_left_mouse_button_down_pos(self, pos) -> None:
"""Set the position of the left mouse button"""
self.left_mouse_button_down_pos = pos
def set_middle_mouse_down_status(self, status, pos) -> None:
"""Set the status of the middle mouse button"""
self.middle_mouse_button_down = status
self.middle_mouse_button_down_pos = pos
def set_middle_mouse_down_pos(self, pos) -> None:
"""Set the position of the middle mouse button"""
self.middle_mouse_button_down_pos = pos
def get_left_mouse_button_down_status(self) -> bool:
"""Get the status of the left mouse button"""
return self.left_mouse_button_down
def get_left_mouse_button_down_pos(self) -> Tuple[int, int]:
"""Get the position of the left mouse button"""
return self.left_mouse_button_down_pos
def get_middle_mouse_button_down_status(self) -> bool:
"""Get the status of the middle mouse button"""
return self.middle_mouse_button_down
def get_middle_mouse_down_pos(self) -> Tuple[int, int]:
"""Get the position of the middle mouse button"""
return self.middle_mouse_button_down_pos
def set_screen_drag(self, starting_pos, current_pos) -> None:
"""Set the screen drag value"""
self.screen_drag_x += current_pos[0] - starting_pos[0]
self.screen_drag_y += current_pos[1] - starting_pos[1]
def get_screen_drag(self) -> Tuple[int, int]:
"""Get the screen drag value"""
return self.screen_drag_x, self.screen_drag_y
@property
def get_version(self) -> str:
"""Get the major version number"""
return f"{self.version_major}.{self.version_minor}.{self.version_revision}"