@@ -24,6 +24,7 @@ def __init__(self, l: bool, settings: List[str]):
24
24
super ().__init__ ()
25
25
self .l = l
26
26
self .settings = settings
27
+ self .time_per_char = 0.05
27
28
28
29
for i , setting in enumerate (self .settings ):
29
30
if " " in setting :
@@ -47,12 +48,13 @@ def construct(self):
47
48
48
49
def add_details (self ):
49
50
down_shift = m .DOWN * 0.5
50
- self .camera .frame .scale_to_fit_width (18 * 1.1 )
51
51
project_root = m .Rectangle (
52
52
height = 9.0 ,
53
53
width = 18.0 ,
54
54
color = self .fontColor ,
55
- )
55
+ ).move_to ((0 , 1000 , 0 ))
56
+ self .camera .frame .scale_to_fit_width (18 * 1.1 )
57
+ self .camera .frame .move_to (project_root .get_center ())
56
58
57
59
cmd_text = m .Text (
58
60
self .trim_cmd (self .cmd , 50 ),
@@ -87,11 +89,11 @@ def add_details(self):
87
89
config_text .align_to (dot_git_text , m .UP ).shift (down_shift ).align_to (dot_git_text , m .LEFT ).shift (m .RIGHT * 0.5 )
88
90
89
91
if settings .animate :
90
- self .play (m .AddTextLetterByLetter (cmd_text ))
91
- self .play (m .Create (project_root ))
92
- self .play (m .AddTextLetterByLetter (project_root_text ))
93
- self .play (m .AddTextLetterByLetter (dot_git_text ))
94
- self .play (m .AddTextLetterByLetter (config_text ))
92
+ self .play (m .AddTextLetterByLetter (cmd_text , time_per_char = self . time_per_char ))
93
+ self .play (m .Create (project_root , time_per_char = self . time_per_char ))
94
+ self .play (m .AddTextLetterByLetter (project_root_text , time_per_char = self . time_per_char ))
95
+ self .play (m .AddTextLetterByLetter (dot_git_text , time_per_char = self . time_per_char ))
96
+ self .play (m .AddTextLetterByLetter (config_text , time_per_char = self . time_per_char ))
95
97
else :
96
98
self .add (cmd_text )
97
99
self .add (project_root )
@@ -102,23 +104,26 @@ def add_details(self):
102
104
config = self .repo .config_reader ()
103
105
if self .l :
104
106
last_element = config_text
105
- for section in config .sections ():
107
+ for i , section in enumerate ( config .sections () ):
106
108
section_text = m .Text (f"[{ section } ]" , font = self .font , color = self .fontColor , font_size = 20 ).align_to (last_element , m .UP ).shift (down_shift ).align_to (config_text , m .LEFT ).shift (m .RIGHT * 0.5 )
107
109
self .toFadeOut .add (section_text )
108
110
if settings .animate :
109
- self .play (m .AddTextLetterByLetter (section_text ))
111
+ self .play (m .AddTextLetterByLetter (section_text , time_per_char = self . time_per_char ))
110
112
else :
111
113
self .add (section_text )
112
114
last_element = section_text
113
- for option in config .options (section ):
115
+ project_root = self .resize_rectangle (project_root , last_element )
116
+ for j , option in enumerate (config .options (section )):
114
117
if option != "__name__" :
115
118
option_text = m .Text (f"{ option } = { config .get_value (section , option )} " , font = self .font , color = self .fontColor , font_size = 20 ).align_to (last_element , m .UP ).shift (down_shift ).align_to (section_text , m .LEFT ).shift (m .RIGHT * 0.5 )
116
119
self .toFadeOut .add (option_text )
117
120
last_element = option_text
118
121
if settings .animate :
119
- self .play (m .AddTextLetterByLetter (option_text ))
122
+ self .play (m .AddTextLetterByLetter (option_text , time_per_char = self . time_per_char ))
120
123
else :
121
124
self .add (option_text )
125
+ if not (i == len (config .sections ()) - 1 and j == len (config .options (section )) - 1 ):
126
+ project_root = self .resize_rectangle (project_root , last_element )
122
127
else :
123
128
if not self .settings :
124
129
print ("git-sim error: no config option specified" )
@@ -140,13 +145,12 @@ def add_details(self):
140
145
elif len (self .settings ) == 2 :
141
146
value = self .settings [1 ].strip ('"' ).strip ("'" ).strip ("\\ " )
142
147
section_text = m .Text (f"[{ self .trim_cmd (section , 50 )} ]" , font = self .font , color = self .fontColor , font_size = 20 , weight = m .BOLD ).align_to (config_text , m .UP ).shift (down_shift ).align_to (config_text , m .LEFT ).shift (m .RIGHT * 0.5 )
143
-
144
148
option_text = m .Text (f"{ self .trim_cmd (option , 40 )} = { self .trim_cmd (value , 40 )} " , font = self .font , color = self .fontColor , font_size = 20 , weight = m .BOLD ).align_to (section_text , m .UP ).shift (down_shift ).align_to (section_text , m .LEFT ).shift (m .RIGHT * 0.5 )
145
149
self .toFadeOut .add (section_text )
146
150
self .toFadeOut .add (option_text )
147
151
if settings .animate :
148
- self .play (m .AddTextLetterByLetter (section_text ))
149
- self .play (m .AddTextLetterByLetter (option_text ))
152
+ self .play (m .AddTextLetterByLetter (section_text , time_per_char = self . time_per_char ))
153
+ self .play (m .AddTextLetterByLetter (option_text , time_per_char = self . time_per_char ))
150
154
else :
151
155
self .add (section_text )
152
156
self .add (option_text )
@@ -156,3 +160,19 @@ def add_details(self):
156
160
self .toFadeOut .add (project_root_text )
157
161
self .toFadeOut .add (dot_git_text )
158
162
self .toFadeOut .add (config_text )
163
+
164
+ def resize_rectangle (self , rect , last_element ):
165
+ if last_element .get_bottom ()[1 ] - 3 * last_element .height > rect .get_bottom ()[1 ]:
166
+ return rect
167
+ new_rect = m .Rectangle (width = rect .width , height = rect .height + 2 * last_element .height , color = rect .color )
168
+ new_rect .align_to (rect , m .UP )
169
+ self .toFadeOut .remove (rect )
170
+ self .toFadeOut .add (new_rect )
171
+ if settings .animate :
172
+ self .recenter_frame ()
173
+ self .scale_frame ()
174
+ self .play (m .ReplacementTransform (rect , new_rect ))
175
+ else :
176
+ self .remove (rect )
177
+ self .add (new_rect )
178
+ return new_rect
0 commit comments