-
Notifications
You must be signed in to change notification settings - Fork 98
/
metrics.py
99 lines (81 loc) · 2.84 KB
/
metrics.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
88
89
90
91
92
93
94
95
96
97
98
99
"""
This module offers advice on how to size the UI appropriately
for the OS we're running on.
"""
import sys
def size(type):
"""
Returns the number of pixels to use for a certain context.
Recognized keywords:
windowBorder - around the edges of a window
buttonSpace - between buttons
relatedControls - between related controls
unrelatedControls - between unrelated controls
focusRing - space to leave to allow for focus rings
fontMin - smallest font size to ever use
fontMax - largest font size to use, as a recommendation
widgetTitle - starting font size for widget titles, as a recommendation
editorBody - starting font size for body editor, as a recommendation
fsEditorBody - starting font size for fullscreen editor, as a recommendation
storySettingsWidth - starting width of StorySettings editor
storySettingsHeight - starting height of StorySettings editor
"""
if type == 'windowBorder':
if sys.platform == 'win32': return 11
if sys.platform == 'darwin': return 16
return 13
if type == 'relatedControls':
if sys.platform == 'win32': return 7
if sys.platform == 'darwin': return 6
return 9
if type == 'unrelatedControls':
if sys.platform == 'win32': return 11
if sys.platform == 'darwin': return 12
return 9
if type == 'buttonSpace':
if sys.platform == 'win32': return 7
if sys.platform == 'darwin': return 12
return 9
if type == 'focusRing':
return 3
if type == 'fontMin':
if sys.platform == 'win32': return 8
if sys.platform == 'darwin': return 11
if type == 'fontMax':
return 24
if type == 'widgetTitle':
if sys.platform == 'win32': return 9
if sys.platform == 'darwin': return 13
return 11
if type == 'editorBody':
if sys.platform == 'win32': return 11
if sys.platform == 'darwin': return 13
return 11
if type == 'fsEditorBody':
if sys.platform == 'win32': return 16
if sys.platform == 'darwin': return 20
return 11
if type == 'storySettingsWidth':
if sys.platform == 'darwin': return 550
return 450
if type == 'storySettingsHeight':
if sys.platform == 'darwin': return 650
return 550
def face(type):
"""
Returns a font face name.
Recognized keywords:
sans - sans-serif
mono - monospaced
"""
if type == 'sans':
if sys.platform == 'win32': return 'Arial'
if sys.platform == 'darwin': return 'Helvetica'
return 'Sans'
if type == 'mono':
if sys.platform == 'win32': return 'Consolas'
if sys.platform == 'darwin': return 'Monaco'
return 'Fixed'
if type == 'mono2':
if sys.platform in ['win32', 'darwin']: return 'Courier New'
return 'Fixed'