Skip to content

Automation point adjustment mouse wheel and double click #5225

@tecknixia

Description

@tecknixia

https://cdn.discordapp.com/attachments/332258319228207114/629248936099708928/AutomationEditor2-2019-10-03_04.21.20.mp4

I have successfully made this usable already, but since I'm new to this, I'm not sure how what I did fits in with everything else, so it can be altered if necessary. There are also elements of this issue that could use polishing, which are:

  1. the values for detecting the point with the mouse on the y axis are hard coded and do not adapt to scaling changes of the y axis

  2. when moving the mouse over a point, the value of the tooltip willl reflect the y value of the mouse position, instead of the point's y level, until the mouse wheel moves. This causes an inaccurate reading of the point level depending on where the cursor is placed on the point, so the value jumps from the cursor y value to the point y level.

Here are instructions to make it work like I had it:

  • AutomationEditor.h

// set variable in header
@ line 212 (or wherever appropriate) insert float m_point_y_level;

  • AutomationEditor.cpp

// initialize variable
@ line 89 insert m_point_y_level( 0 ),

// reset variable to zero if mouse moves
@ line 733 (beginning of mouseMoveEvent, after vaid pattern check) insert m_point_y_level = 0;

// I originally intended to include a TODO comment for the 2nd point above (optional)
@ line 1102 TODO: when mouse is over a point (ti@me map key), show level of the point on tooltip instead of mouse cursor y position

// the tooltip value is decided, reads the variable that is set when mouse wheel is moved
@ line 1111 (starts with "QToolTip:showText") replace with:

        if (m_point_y_level == 0) {
		QToolTip::showText( tt_pos, QString::number( scaledLevel ), this );
	}

	if (m_point_y_level != 0) {
		QToolTip::showText( tt_pos, QString::number( m_point_y_level ), this );
	}

// when mouse wheel moves, detects the point on time map and sets
// variable to the point's y level to be read when displaying tool tip
@ line 1721 (within last "else" for wheelEvent after setting value for m_topBottomScroll) insert:

if( we->y() > TOP_MARGIN )
{

	float level = getLevel( we->y() );

	int x = we->x();

	if( x >= VALUES_WIDTH )
	{
		
		// set or move value

		x -= VALUES_WIDTH;

		// get tick in which the cursor is posated
		int pos_ticks = x * MidiTime::ticksPerTact() / m_ppt + m_currentPosition;

		// get time map of current pattern
		timeMap & time_map = m_pattern->getTimeMap();

		// will be our iterator in the following loop
		timeMap::iterator it = time_map.begin();

		// and check whether the user scrolls over an
		// existing value
		while( it != time_map.end() )
		{
			if( pos_ticks >= it.key() - MidiTime::ticksPerTact() *4 / m_ppt
			&& ( it+1==time_map.end() ||	pos_ticks <= (it+1).key() )
			&& ( pos_ticks<= it.key() + MidiTime::ticksPerTact() *4 / m_ppt)
			&& (level >= it.value() - 0.05) // substitute numbers with value for y scaling changes
			&& (level <= it.value() + 0.05) // substitute numbers with value for y scaling changes
			)
			{

				// when mouse wheel up
				if( we->delta() < 0 )
				{

					if( pos_ticks < 0 )
					{
						pos_ticks = 0;
					}

					// change level value
					level = it.value() - 0.001;
					m_point_y_level = level;

					// set new value
					m_pattern->setDragValue( MidiTime( pos_ticks ), level, true, false );

					// apply new value
					m_pattern->applyDragValue();

					break;

				}

				// when mouse wheel down
				else if( we->delta() > 0 )
				{
					if( pos_ticks < 0 )
					{
						pos_ticks = 0;
					}

					// change level value
					level = it.value() + 0.001;
					m_point_y_level = level;

					// set new value
					m_pattern->setDragValue( MidiTime( pos_ticks ), level, true, false );

					// apply new value
					m_pattern->applyDragValue();

					break;

				}
			}

			++it;

		}


	}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions