Skip to content

Commit

Permalink
Various fixes:
Browse files Browse the repository at this point in the history
+ Sequencer timeline: Only show relevant context menu actions in
  automation edit mode
+ Set as First Beat of Song: Fix automation not moving with items
  • Loading branch information
L3337 committed Mar 8, 2023
1 parent 109ba71 commit 9b2fae4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
8 changes: 8 additions & 0 deletions src/sglib/models/daw/atm_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ def __init__(self):
self.plugins = {}
self.points = []

def set_first_beat(self, beat):
if not self.points:
return
_min = min(x.beat for x in self.points)
offset = int(beat - _min)
for point in self.points:
point.beat += offset

def split(self, a_points, a_plugins=None, a_port=None):
if a_points[0] != 0.0:
a_points.insert(0, 0.0)
Expand Down
49 changes: 27 additions & 22 deletions src/sgui/daw/sequencer/header_context_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ def show(event):
)
set_first_beat_action.triggered.connect(set_first_beat)

if _shared.SEQUENCE_EDITOR_MODE == 0:
_add_items_menu(items_menu)

x = shared.SEQUENCER.header_event_pos * _shared.SEQUENCER_PX_PER_BEAT
pos_line = QGraphicsLineItem(
x,
0,
x,
_shared.SEQUENCE_EDITOR_HEADER_HEIGHT,
shared.SEQUENCER.header,
)
pos_line_pen = QPen(
QColor(
theme.SYSTEM_COLORS.daw.seq_header_event_pos,
),
6.0,
)
pos_line.setPen(pos_line_pen)
global POS_LINE
POS_LINE = pos_line
# Otherwise, the entire scene gets redrawn and we should not delete it
if not menu.exec(QCursor.pos()):
shared.SEQUENCER.scene.removeItem(pos_line)

def _add_items_menu(items_menu):
items_menu.addSeparator()

select_all_action = QAction(
Expand Down Expand Up @@ -192,31 +217,11 @@ def show(event):
select_end_left_action.triggered.connect(select_end_left)
items_menu.addAction(select_end_left_action)


x = shared.SEQUENCER.header_event_pos * _shared.SEQUENCER_PX_PER_BEAT
pos_line = QGraphicsLineItem(
x,
0,
x,
_shared.SEQUENCE_EDITOR_HEADER_HEIGHT,
shared.SEQUENCER.header,
)
pos_line_pen = QPen(
QColor(
theme.SYSTEM_COLORS.daw.seq_header_event_pos,
),
6.0,
)
pos_line.setPen(pos_line_pen)
global POS_LINE
POS_LINE = pos_line
# Otherwise, the entire scene gets redrawn and we should not delete it
if not menu.exec(QCursor.pos()):
shared.SEQUENCER.scene.removeItem(pos_line)

def set_first_beat():
shared.CURRENT_SEQUENCE.set_first_beat(shared.SEQUENCER.header_event_pos)
shared.ATM_SEQUENCE.set_first_beat(shared.SEQUENCER.header_event_pos)
constants.DAW_PROJECT.save_sequence(shared.CURRENT_SEQUENCE)
constants.DAW_PROJECT.save_atm_sequence(shared.ATM_SEQUENCE)
constants.DAW_PROJECT.commit(_("Set first beat"))
shared.SEQ_WIDGET.open_sequence()

Expand Down

0 comments on commit 9b2fae4

Please sign in to comment.