Skip to content

Commit

Permalink
- Добавил кнопку для горизонтального выравнивания
Browse files Browse the repository at this point in the history
 - Добавил информацию в окне подсказок горячих клавиш
  • Loading branch information
svsdval committed Oct 22, 2024
1 parent 6ade8fc commit 9bfa44b
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions v2m.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,34 +655,40 @@ def change_cnt(sender):
print('change count')
updatekeys(1)

def vertical_align_keys( separate_black_keys = 1 ):
def is_black_key(key_id : int) -> bool:
j = key_id % 12
return (j == 1) or ( j == 3 ) or ( j == 6 ) or ( j == 8) or ( j == 10 )


def vertical_align_keys( separate_black_keys = 1, align = 1 ):
print(f"lastkeygrabid {lastkeygrabid}")
if lastkeygrabid < 0 or lastkeygrabid > len(prefs.keys_pos):
return

y = prefs.keys_pos[lastkeygrabid][1]
j = lastkeygrabid % 12
selected_black_key = (j == 1) or ( j == 3 ) or ( j == 6 ) or ( j == 8) or ( j == 10 )
y = prefs.keys_pos[lastkeygrabid][align]
selected_black_key = is_black_key(lastkeygrabid)


for idx in range (len(prefs.keys_pos)):
j = idx % 12
if separate_black_keys == 1:
if selected_black_key:
if (j == 1) or ( j == 3 ) or ( j == 6 ) or ( j == 8) or ( j == 10 ):
prefs.keys_pos[idx][1] = y
if is_black_key(idx):
prefs.keys_pos[idx][align] = y
else:
if not ((j == 1) or ( j == 3 ) or ( j == 6 ) or ( j == 8) or ( j == 10 )):
prefs.keys_pos[idx][1] = y
if not is_black_key(idx):
prefs.keys_pos[idx][align] = y
else:
prefs.keys_pos[idx][align] = y

def valign(sender):
vertical_align_keys()
vertical_align_keys(align=1)
def halign(sender):
vertical_align_keys(align=0)


wh = ( (len(prefs.keyp_colors) // 2)+2 ) * 24 - 24
colorWindow = GLWindow(24, 50, 274, wh, "color map")
settingsWindow = GLWindow(24+275, 80, 550, 380, "Settings")
helpWindow = GLWindow(24+270, 50, 750, 490, "help")
helpWindow = GLWindow(24+270, 50, 750, 535, "help")

extraWindow = GLWindow(24+270+550+6, 80, 510, 250, "extra/experimental")

Expand Down Expand Up @@ -723,7 +729,9 @@ def valign(sender):
[ / ] - change base octave
F2 / F3 - save / load settings, F4 - move all windows to the mouse point
Escape - quit, TAB - Show/Hide all windows
Space - abort re-creation and save midi file to disk""")
Space - abort re-creation and save midi file to disk
4,6,8,2 on numpad - move the selected key by 1 pixel on each axis
1,3 - vertical / horizontal alignment""")


settingsWindow.appendChild( GLButton(260, 20 ,140,20,0 , [128,128,128], "start recreate midi" , start_recreate_midi , hint = "q - hot key") )
Expand Down Expand Up @@ -768,7 +776,8 @@ def valign(sender):
settingsWindow.appendChild( GLButton(260 + i * 32,230 ,32,20,0, [128,128,128], navbtns_info[i]['name'] , navbtns_info[i]['func'], hint = navbtns_info[i]['hint']) )

settingsWindow.appendChild( GLButton(260 , 295 ,140,20,0, [128,128,128], "update count", change_cnt , hint = "Change keys count" ) )
settingsWindow.appendChild( GLButton(260+141, 295 ,140,20,0, [128,128,128], "v. align", valign , hint = "vertical alignment of keys to the selected key" ) )
settingsWindow.appendChild( GLButton(260+141, 295 ,70,20,0, [128,128,128], "v. align", valign , hint = "vertical alignment of keys to the selected key" ) )
settingsWindow.appendChild( GLButton(260+141+70, 295 ,70,20,0, [128,128,128], "h. align", halign , hint = "horizontal alignment of keys to the selected key" ) )


helpWindow.appendChild(helpWindow_label1)
Expand Down Expand Up @@ -863,8 +872,6 @@ def valign(sender):
extraWindow.appendChild(extraWindow_slider2)




sparks_slider_height = GLSlider(160,25, 150,18, 1,60,1,None, label="Sparks height")
sparks_slider_height.round=0
sparks_switch = GLButton(313,24 ,100,22,1, [128,128,128], "use sparks" ,change_use_sparks,switch=1, switch_status=prefs.use_sparks )
Expand Down Expand Up @@ -1630,8 +1637,10 @@ def main():
if event.key == pygame.K_KP2:
if lastkeygrabid >0 and lastkeygrabid < len(prefs.keys_pos):
prefs.keys_pos[lastkeygrabid][1] += 1
if event.key == pygame.K_KP5:
vertical_align_keys()
if event.key == pygame.K_KP1:
vertical_align_keys(1, 1)
if event.key == pygame.K_KP3:
vertical_align_keys(1, 0)


elif event.type == pygame.MOUSEBUTTONUP:
Expand Down

0 comments on commit 9bfa44b

Please sign in to comment.