gizmos: consolidated input param dragging code into reusable class
This commit is contained in:
@@ -191,11 +191,11 @@ void ViewerDisplayWidget::SetTime(const rational &time)
|
||||
|
||||
void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (gizmos_) {
|
||||
if (gizmos_->GizmoPress(gizmo_db_, event->pos(), QVector2D(GetTexturePosition(size())))) {
|
||||
gizmo_click_ = true;
|
||||
return;
|
||||
}
|
||||
if (gizmos_
|
||||
&& gizmos_->GizmoPress(gizmo_db_, event->pos(), QVector2D(GetTexturePosition(size())))) {
|
||||
gizmo_click_ = true;
|
||||
gizmo_drag_time_ = GetGizmoTime();
|
||||
return;
|
||||
}
|
||||
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
@@ -206,7 +206,7 @@ void ViewerDisplayWidget::mousePressEvent(QMouseEvent *event)
|
||||
void ViewerDisplayWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (gizmo_click_) {
|
||||
gizmos_->GizmoMove(event->pos(), QVector2D(GetTexturePosition(size())));
|
||||
gizmos_->GizmoMove(event->pos(), QVector2D(GetTexturePosition(size())), gizmo_drag_time_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ void ViewerDisplayWidget::paintGL()
|
||||
if (gizmos_) {
|
||||
GizmoTraverser gt;
|
||||
|
||||
rational node_time = GetAdjustedTime(GetTimeTarget(), gizmos_, time_, NodeParam::kInput);
|
||||
rational node_time = GetGizmoTime();
|
||||
|
||||
gizmo_db_ = gt.GenerateDatabase(gizmos_, TimeRange(node_time, node_time));
|
||||
|
||||
@@ -351,6 +351,11 @@ QPointF ViewerDisplayWidget::GetTexturePosition(const double &x, const double &y
|
||||
y / gizmo_params_.height());
|
||||
}
|
||||
|
||||
rational ViewerDisplayWidget::GetGizmoTime()
|
||||
{
|
||||
return GetAdjustedTime(GetTimeTarget(), gizmos_, time_, NodeParam::kInput);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
void ViewerDisplayWidget::ShowNouveauWarning()
|
||||
{
|
||||
|
||||
@@ -162,6 +162,8 @@ private:
|
||||
QPointF GetTexturePosition(const QSize& size);
|
||||
QPointF GetTexturePosition(const double& x, const double& y);
|
||||
|
||||
rational GetGizmoTime();
|
||||
|
||||
/**
|
||||
* @brief Internal reference to the OpenGL texture to draw. Set in SetTexture() and used in paintGL().
|
||||
*/
|
||||
@@ -188,11 +190,9 @@ private:
|
||||
ViewerSafeMarginInfo safe_margin_;
|
||||
|
||||
Node* gizmos_;
|
||||
|
||||
NodeValueDatabase gizmo_db_;
|
||||
|
||||
rational gizmo_drag_time_;
|
||||
VideoRenderingParams gizmo_params_;
|
||||
|
||||
bool gizmo_click_;
|
||||
|
||||
rational time_;
|
||||
|
||||
Reference in New Issue
Block a user