-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathKeyFrameEditor.cpp
More file actions
94 lines (76 loc) · 3.01 KB
/
Copy pathKeyFrameEditor.cpp
File metadata and controls
94 lines (76 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "ui_KeyFrameEditor.h"
#include <GuiBase/KeyFrameEditor/KeyFrameEditor.hpp>
#include <GuiBase/KeyFrameEditor/KeyFrameEditorFrame.hpp>
#include <Core/Animation/KeyFramedValue.hpp>
#include <fstream>
#include <iostream>
#include <QFileDialog>
#include <QResizeEvent>
namespace Ra::GuiBase {
KeyFrameEditor::KeyFrameEditor( Scalar maxTime, QWidget* parent ) :
QDialog( parent ),
ui( new Ui::KeyFrameEditor ) {
ui->setupUi( this );
// set sizePolicy to allow zoom in scrollArea
ui->scrollAreaWidgetContents->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
// first draw of ruler with current width (default in Timeline.ui) of dialog
ui->scrollArea->onDrawRuler( width() - 2,
height() - 2 ); // left/right border width = 2 *1 pixel
// --- SET INTERNAL REFERENCES ---
ui->m_editorFrame->setEditorUi( ui );
ui->m_timeScale->setScrollArea( ui->scrollArea );
ui->m_valueScale->setScrollArea( ui->scrollArea );
ui->m_frameScale->setScrollArea( ui->scrollArea );
ui->m_frameScale->setEditorFrame( ui->m_editorFrame );
// set duration
ui->m_editorFrame->setDuration( maxTime );
// --- CREATE INTERNAL CONNECTIONS ---
connect( ui->m_editorFrame, &KeyFrameEditorFrame::updated, [=]() { update(); } );
// --- CONNECT INTERNAL SIGNALS TO EXTERNAL SIGNALS ---
connect( ui->m_editorFrame,
&KeyFrameEditorFrame::cursorChanged,
this,
&KeyFrameEditor::cursorChanged );
connect( ui->m_editorFrame,
&KeyFrameEditorFrame::keyFrameChanged,
this,
&KeyFrameEditor::keyFrameChanged );
connect( ui->m_editorFrame,
&KeyFrameEditorFrame::keyFrameAdded,
this,
&KeyFrameEditor::keyFrameAdded );
connect( ui->m_editorFrame,
&KeyFrameEditorFrame::keyFrameDeleted,
this,
&KeyFrameEditor::keyFrameDeleted );
connect( ui->m_editorFrame,
&KeyFrameEditorFrame::keyFrameMoved,
this,
&KeyFrameEditor::keyFrameMoved );
connect( ui->m_editorFrame,
&KeyFrameEditorFrame::keyFramesMoved,
this,
&KeyFrameEditor::keyFramesMoved );
}
KeyFrameEditor::~KeyFrameEditor() {
delete ui;
}
void KeyFrameEditor::onChangeCursor( Scalar time ) {
ui->m_editorFrame->onChangeCursor( time, false );
update();
}
void KeyFrameEditor::onChangeDuration( Scalar duration ) {
ui->m_editorFrame->setDuration( duration );
update();
}
void KeyFrameEditor::onUpdateKeyFrames( Scalar currentTime ) {
ui->m_editorFrame->onUpdateKeyFrames( currentTime );
}
void KeyFrameEditor::resizeEvent( QResizeEvent* event ) {
ui->scrollArea->onDrawRuler( event->size().width() - 2, event->size().height() - 2 );
}
void KeyFrameEditor::setKeyFramedValue( const std::string& name, KeyFrame* frame ) {
ui->m_valueName->setText( QString::fromStdString( name ) );
ui->m_editorFrame->setKeyFramedValue( frame );
}
} // namespace Ra::GuiBase