mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-19 14:19:57 +01:00
New using arrow Keys to simulate source grabbing
Allows combining arrows with Mouse Pointer effects (e.g. grid). Also added progressive acceleration of movement during the first 1 second of key press (starting very slow movement for precise displacement). Bugs fixed in Mouse Pointer.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "BoundingBoxVisitor.h"
|
||||
#include "ActionManager.h"
|
||||
#include "MixingGroup.h"
|
||||
#include "MousePointer.h"
|
||||
|
||||
#include "MixingView.h"
|
||||
|
||||
@@ -680,10 +681,16 @@ View::Cursor MixingView::over (glm::vec2 pos)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define MAX_DURATION 1000.f
|
||||
#define MIN_SPEED_M 0.005f
|
||||
#define MAX_SPEED_M 0.5f
|
||||
|
||||
void MixingView::arrow (glm::vec2 movement)
|
||||
{
|
||||
static float accumulator = 0.f;
|
||||
accumulator += dt_ * 0.2;
|
||||
static float _duration = 0.f;
|
||||
static glm::vec2 _from(0.f);
|
||||
static glm::vec2 _displacement(0.f);
|
||||
|
||||
Source *current = Mixer::manager().currentSource();
|
||||
|
||||
if (!current && !Mixer::selection().empty())
|
||||
@@ -693,88 +700,59 @@ void MixingView::arrow (glm::vec2 movement)
|
||||
|
||||
if (current_action_ongoing_) {
|
||||
|
||||
glm::vec2 Position_from = glm::vec2( Rendering::manager().project(current->stored_status_->translation_, scene.root()->transform_) );
|
||||
glm::vec2 Position_to = Position_from + movement * accumulator;
|
||||
// TODO : precise movement ?
|
||||
|
||||
if ( current->mixinggroup_ != nullptr )
|
||||
// add movement to displacement
|
||||
_duration += dt_;
|
||||
const float speed = MIN_SPEED_M + (MAX_SPEED_M - MIN_SPEED_M) * glm::min(1.f,_duration / MAX_DURATION);
|
||||
_displacement += movement * dt_ * speed;
|
||||
|
||||
// set coordinates of target
|
||||
glm::vec2 _to = _from + _displacement;
|
||||
|
||||
// update mouse pointer action
|
||||
MousePointer::manager().active()->update(_to, dt_ / 1000.f);
|
||||
|
||||
if (current->mixinggroup_ != nullptr )
|
||||
current->mixinggroup_->setAction( MixingGroup::ACTION_GRAB_ALL );
|
||||
|
||||
grab(current, Position_from, Position_to, std::make_pair(current->group(mode_), glm::vec2(0.f) ) );
|
||||
// simulate mouse grab
|
||||
grab(current, _from, MousePointer::manager().active()->target(),
|
||||
std::make_pair(current->group(mode_), glm::vec2(0.f) ) );
|
||||
|
||||
// draw mouse pointer effect
|
||||
MousePointer::manager().active()->draw();
|
||||
}
|
||||
else {
|
||||
|
||||
if (UserInterface::manager().altModifier() || Settings::application.mouse_pointer_lock)
|
||||
MousePointer::manager().setActiveMode( (Pointer::Mode) Settings::application.mouse_pointer );
|
||||
else
|
||||
MousePointer::manager().setActiveMode( Pointer::POINTER_DEFAULT );
|
||||
|
||||
// reset
|
||||
_duration = 0.f;
|
||||
_displacement = glm::vec2(0.f);
|
||||
|
||||
// initiate view action and store status of source
|
||||
initiate();
|
||||
accumulator = 0.f;
|
||||
|
||||
// get coordinates of source and set this as start of mouse position
|
||||
_from = glm::vec2( Rendering::manager().project(current->group(mode_)->translation_, scene.root()->transform_) );
|
||||
|
||||
// Initiate mouse pointer action
|
||||
MousePointer::manager().active()->initiate(_from);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
else {
|
||||
terminate(true);
|
||||
|
||||
|
||||
// glm::vec3 gl_Position_from = Rendering::manager().unProject(glm::vec2(0.f), scene.root()->transform_);
|
||||
// glm::vec3 gl_Position_to = Rendering::manager().unProject(movement, scene.root()->transform_);
|
||||
// glm::vec3 gl_delta = gl_Position_to - gl_Position_from;
|
||||
|
||||
|
||||
// bool first = true;
|
||||
// glm::vec3 delta_translation(0.f);
|
||||
// for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) {
|
||||
|
||||
// // individual move with SHIFT
|
||||
// if ( !Source::isCurrent(*it) && UserInterface::manager().shiftModifier() )
|
||||
// continue;
|
||||
|
||||
// Group *sourceNode = (*it)->group(mode_);
|
||||
// glm::vec3 dest_translation(0.f);
|
||||
|
||||
// if (first) {
|
||||
// // dest starts at current
|
||||
// dest_translation = sourceNode->translation_;
|
||||
|
||||
// // + ALT : discrete displacement
|
||||
// if (UserInterface::manager().altModifier()) {
|
||||
// if (accumulator > 100.f) {
|
||||
// dest_translation += glm::sign(gl_delta) * 0.1f;
|
||||
// dest_translation.x = ROUND(dest_translation.x, 10.f);
|
||||
// dest_translation.y = ROUND(dest_translation.y, 10.f);
|
||||
// accumulator = 0.f;
|
||||
// }
|
||||
// else
|
||||
// break;
|
||||
// }
|
||||
// else {
|
||||
// // normal case: dest += delta
|
||||
// dest_translation += gl_delta * ARROWS_MOVEMENT_FACTOR * dt_;
|
||||
// accumulator = 0.f;
|
||||
// }
|
||||
|
||||
// // store action in history
|
||||
// std::ostringstream info;
|
||||
// if ((*it)->active()) {
|
||||
// info << "Alpha " << std::fixed << std::setprecision(3) << (*it)->blendingShader()->color.a << " ";
|
||||
// info << ( ((*it)->blendingShader()->color.a > 0.f) ? ICON_FA_EYE : ICON_FA_EYE_SLASH);
|
||||
// }
|
||||
// else
|
||||
// info << "Inactive " << ICON_FA_SNOWFLAKE;
|
||||
// current_action_ = (*it)->name() + ": " + info.str();
|
||||
|
||||
// // delta for others to follow
|
||||
// delta_translation = dest_translation - sourceNode->translation_;
|
||||
// }
|
||||
// else {
|
||||
// // dest = current + delta from first
|
||||
// dest_translation = sourceNode->translation_ + delta_translation;
|
||||
// }
|
||||
|
||||
// // apply & request update
|
||||
// sourceNode->translation_ = dest_translation;
|
||||
// (*it)->touch();
|
||||
|
||||
// first = false;
|
||||
// }
|
||||
// reset
|
||||
_duration = 0.f;
|
||||
_from = glm::vec2(0.f);
|
||||
_displacement = glm::vec2(0.f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user