diff --git a/View.cpp b/View.cpp index f90c035..a98b562 100644 --- a/View.cpp +++ b/View.cpp @@ -679,3 +679,74 @@ View::Cursor LayerView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair return Cursor(Cursor_ResizeAll, info.str() ); } +// TRANSITION + +TransitionView::TransitionView() : View(TRANSITION), duration_(1000.f) +{ + // read default settings + if ( Settings::application.views[mode_].name.empty() ) { + // no settings found: store application default + Settings::application.views[mode_].name = "Transition"; + scene.root()->scale_ = glm::vec3(TRANSITION_DEFAULT_SCALE, TRANSITION_DEFAULT_SCALE, 1.0f); + saveSettings(); + } + + // Geometry Scene background + Surface *rect = new Surface; + rect->shader()->color.a = 0.3f; + scene.bg()->attach(rect); + + Frame *border = new Frame(Frame::ROUND, Frame::THIN, Frame::GLOW); + border->color = glm::vec4( COLOR_FRAME, 0.7f ); + scene.bg()->attach(border); + + // Add a source in the scene root : output preview + +} + +void TransitionView::update(float dt) +{ + View::update(dt); + + +} + +void TransitionView::draw() +{ + // draw scene of this view + scene.root()->draw(glm::identity(), Rendering::manager().Projection()); + + // maybe enough if scene contains the session source to transition + // and the preview +} + + +void TransitionView::zoom (float factor) +{ +// float z = scene.root()->scale_.x; +// z = CLAMP( z + 0.1f * factor, LAYER_MIN_SCALE, LAYER_MAX_SCALE); +// scene.root()->scale_.x = z; +// scene.root()->scale_.y = z; +} + + +View::Cursor TransitionView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair pick) +{ + if (!s) + return Cursor(); + + // unproject + glm::vec3 gl_Position_from = Rendering::manager().unProject(from, scene.root()->transform_); + glm::vec3 gl_Position_to = Rendering::manager().unProject(to, scene.root()->transform_); + + // compute delta translation +// glm::vec3 dest_translation = s->stored_status_->translation_ + gl_Position_to - gl_Position_from; + + // apply change + + std::ostringstream info; +// info << "Depth " << std::fixed << std::setprecision(2) << d; + return Cursor(Cursor_ResizeAll, info.str() ); +} + + diff --git a/View.h b/View.h index 01587ea..8858a02 100644 --- a/View.h +++ b/View.h @@ -11,7 +11,7 @@ class View { public: - typedef enum {RENDERING = 0, MIXING=1, GEOMETRY=2, LAYER=3, INVALID=4 } Mode; + typedef enum {RENDERING = 0, MIXING=1, GEOMETRY=2, LAYER=3, TRANSITION=4, INVALID=5 } Mode; View(Mode m); virtual ~View() {} @@ -143,5 +143,20 @@ private: float aspect_ratio; }; +class TransitionView : public View +{ +public: + TransitionView(); + + void draw () override; + void update (float dt) override; + void zoom (float factor) override; + Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair pick) override; + +private: + float duration_; +}; + + #endif // VIEW_H diff --git a/defines.h b/defines.h index e1ff183..047c607 100644 --- a/defines.h +++ b/defines.h @@ -37,6 +37,7 @@ #define LAYER_DEFAULT_SCALE 0.8f #define LAYER_MIN_SCALE 0.4f #define LAYER_MAX_SCALE 1.7f +#define TRANSITION_DEFAULT_SCALE 3.0f #define IMGUI_TITLE_MAINWINDOW ICON_FA_CIRCLE_NOTCH " vimix" #define IMGUI_TITLE_MEDIAPLAYER ICON_FA_FILM " Media Player"