Skip to content

Automation Editor, Move Selection

tecknixia edited this page Jan 4, 2020 · 17 revisions

Move A Selection

When MOVE mode is entered:

  • the array that holds the values for moving is cleared and a function called getSelectedValues is run
m_selValuesForMove.clear();
getSelectedValues(m_selValuesForMove);
  • m_selValuesForMove holds the values for the selection area

When mouseMove and LeftButton and m_editMode = MOVE with points selected:

  • If m_selectedTick is greater than zero
  • and if m_selectStartTick plus ticks_diff is less than zero
  • then set ticks_diff equal to the negative of m_selectStartTick
	if(m_selectedTick > 0)
	{
		if((int) m_selectStartTick + ticks_diff < 0)
		{
			ticks_diff = -m_selectStartTick;
		}
	}
  • else, if m_selectStartTick plus m_selectedTick plus ticks_diff is less than zero
  • then set ticks_diff to the negative of m_selectStartTick plus m_selectedTick
	else
	{
		if((int) m_selectStartTick + m_selectedTick + ticks_diff < 0)
		{
			ticks_diff = -(m_selectStartTick + m_selectedTick);
		}
	}
  • after that, increment m_selectStartTick by the amount of ticks_diff
m_selectStartTick += ticks_diff;

Um... what?!

selectionBoxMove

Let me try again in normal language.

  • if the difference in ticks between the tick the mouse moved to and the start of the selection is greater than zero
  • and if the start click of the selection plus the number of ticks the selection was moved is less than zero
  • then set the variable ticks_diff to the negative of the start tick of the selection area.
  • else, if the sum of the select box start tick, the length of the ticks between the tick at the start of the selection area and the current tick the mouse moved to
  • and the length between the tick at the start of moving the selection and the current tick the mouse moved to is less than zero
  • then set the variable ticks_diff to the negative of the sum of the tick at the start of the selection area and the amount of ticks between the start of the selection area and the current tick the mouse moved to

Um... what?!

After further experimentation. It seems this has something to do with not letting the edge of the selection box go less than zero, and locking the selection box to the points when moving the the points. There is also one line that I could not figure out it's purpose, but at least I have a general idea now.

  • a new array is declared for the selected point's new positions timeMap new_selValuesForMove;
  • a loop is run which assigns new positions to the new array:
  • it figures out each point's new position (one at a time)
  • it removes each point from their old position m_pattern->removeValue(it.key());
  • assigns the new position to a variable new_value_pos = MidiTime(value_bar, value_ticks);
  • it sets each one into the new array
	new_selValuesForMove[
		m_pattern->putValue(
			new_value_pos, it.value () + level_diff, false
		)
	]
		= it.value() + level_diff;
  • after loop completes:
  • m_selValuesForMove is set to the new array
  • m_moveStartTick is set to the new mouse tick
  • m_moveStartLevel is set to the new mouse level

Ohhh... this shines a light on some things...

void AutomationEditor::removeSelection()
{
	m_selectStartTick = 0;
	m_selectedTick = 0;
	m_selectStartLevel = 0;
	m_selectedLevels = 0;
}

It seems I probably drew the diagram wrong. I think m_selectStartTick belongs on the corner of the selection, and moves with the selection.


Also, I believe I have figured out how the move works:

when MOVE mode is entered:

  • the array that holds the values for moving is cleared and a function called getSelectedValues is run
m_selValuesForMove.clear();
getSelectedValues(m_selValuesForMove);
  • m_selValuesForMove holds the values for the selection area

when mouseMove and LeftButton and m_editMode = MOVE with points selected:

  • a new array is declared for the selected point's new positions timeMap new_selValuesForMove;
  • a loop is run which assigns new positions to the new array:
  • it figures out each point's new position (one at a time)
  • it removes each point from their old position m_pattern->removeValue(it.key());
  • assigns the new position to a variable new_value_pos = MidiTime(value_bar, value_ticks);
  • it sets each one into the new array
	new_selValuesForMove[
		m_pattern->putValue(
			new_value_pos, it.value () + level_diff, false
		)
	]
		= it.value() + level_diff;
  • after loop completes:
  • m_selValuesForMove is set to the new array
  • m_moveStartTick is set to the new mouse tick
  • m_moveStartLevel is set to the new mouse level

So, the problem is that the points are being moved and placed with each mouse move, instead of being dragged. I tried using setDragValue, but it seems to condense all the points in the selection to a single point. So, "how to apply a drag value to multiple points?" seems to be the next question.


// Automation Editor - Drag Points

me->x() me->y()
convert mouse position to tick and level positions
handle scroll changes while dragging
quantize
make sure points won't go outside boundary conditions

off_ticks

  • off_ticks relate to staying within the boundaries and scrolling while dragging
  • m_currentPosition relates to horizontal scroll bar
  • m_mouseDownTick is set to m_currentPosition when drawing a note
  • The difference between m_mouseDownTick and m_currentPosition is subtracted from off_ticks
  • is the result positive or negative? Subtracting a negative adds values

Back to Automation Editor

Clone this wiki locally