-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hoshiryu
committed
Apr 24, 2020
1 parent
1b99766
commit 6437fd3
Showing
17 changed files
with
3,536 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#include "ui_KeyFrameEditor.h" | ||
#include <GuiBase/KeyFrameEditor/KeyFrameEditor.h> | ||
#include <GuiBase/KeyFrameEditor/KeyFrameEditorFrame.h> | ||
|
||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#ifndef RADIUMENGINE_KEYFRAME_EDITOR_H | ||
#define RADIUMENGINE_KEYFRAME_EDITOR_H | ||
|
||
#include <GuiBase/RaGuiBase.hpp> | ||
|
||
#include <map> | ||
#include <vector> | ||
|
||
#include <QDialog> | ||
#include <QGraphicsEllipseItem> | ||
#include <QGraphicsLineItem> | ||
#include <QGraphicsScene> | ||
|
||
#include <Core/CoreMacros.hpp> | ||
|
||
namespace Ra::Core::Animation { | ||
class KeyFramedValueBase; | ||
} | ||
|
||
namespace Ui { | ||
class KeyFrameEditor; | ||
} // namespace Ui | ||
|
||
namespace Ra::GuiBase { | ||
|
||
class RA_GUIBASE_API KeyFrameEditor : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
using KeyFrame = Ra::Core::Animation::KeyFramedValueBase; | ||
explicit KeyFrameEditor( Scalar maxTime = 0, QWidget* parent = nullptr ); | ||
~KeyFrameEditor() override; | ||
|
||
/// Set the KeyFramedValue to edit. | ||
void setKeyFramedValue( const std::string& name, KeyFrame* frame ); | ||
|
||
signals: | ||
/// Emitted when the user changes the current time in the editor frame. | ||
void cursorChanged( Scalar time ); | ||
|
||
/// Emitted when the user changes a keyframe's value in the editor frame. | ||
void keyFrameChanged( Scalar time ); | ||
|
||
/// Emitted when the user adds a keyframe to the KeyFramedValue in the editor frame. | ||
void keyFrameAdded( Scalar time ); | ||
|
||
/// Emitted when the user removes a keyframe from the KeyFramedValue in the editor frame. | ||
void keyFrameDeleted( Scalar time ); | ||
|
||
/// Emitted when the user changes a keyframe's time in the editor frame. | ||
void keyFrameMoved( Scalar time0, Scalar time1 ); | ||
|
||
/// Emitted when the user offsets keyframes time in the editor frame. | ||
void keyFramesMoved( Scalar time, Scalar offset ); | ||
|
||
public slots: | ||
/// Update the editor frame to match the given time. | ||
void onChangeCursor( Scalar time ); | ||
|
||
/// Update the editor frame to match the given duration. | ||
void onChangeDuration( Scalar duration ); | ||
|
||
/// Update the editor frame to match the updated KeyFramedValue. | ||
void onUpdateKeyFrames( Scalar currentTime ); | ||
|
||
protected: | ||
void resizeEvent( QResizeEvent* ev ) override; | ||
|
||
private: | ||
Ui::KeyFrameEditor* ui; | ||
}; | ||
|
||
} // namespace Ra::GuiBase | ||
|
||
#endif // RADIUMENGINE_KEYFRAME_EDITOR_H |
Oops, something went wrong.