mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Starting implementation of overlay in GeometryView to inform on the
current action (Rotation, Scaling).
This commit is contained in:
@@ -312,6 +312,7 @@ set(VMIX_RSC_FILES
|
|||||||
./rsc/mesh/icon_lock.ply
|
./rsc/mesh/icon_lock.ply
|
||||||
./rsc/mesh/icon_unlock.ply
|
./rsc/mesh/icon_unlock.ply
|
||||||
./rsc/mesh/icon_circle.ply
|
./rsc/mesh/icon_circle.ply
|
||||||
|
./rsc/mesh/icon_square.ply
|
||||||
./rsc/mesh/icon_clock.ply
|
./rsc/mesh/icon_clock.ply
|
||||||
./rsc/mesh/icon_grid.ply
|
./rsc/mesh/icon_grid.ply
|
||||||
./rsc/mesh/h_line.ply
|
./rsc/mesh/h_line.ply
|
||||||
|
|||||||
@@ -293,8 +293,9 @@ Symbol::Symbol(Type t, glm::vec3 pos) : Node(), type_(t)
|
|||||||
icons[LOCK] = new Mesh("mesh/icon_lock.ply");
|
icons[LOCK] = new Mesh("mesh/icon_lock.ply");
|
||||||
icons[UNLOCK] = new Mesh("mesh/icon_unlock.ply");
|
icons[UNLOCK] = new Mesh("mesh/icon_unlock.ply");
|
||||||
icons[CIRCLE] = new Mesh("mesh/icon_circle.ply");
|
icons[CIRCLE] = new Mesh("mesh/icon_circle.ply");
|
||||||
|
icons[SQUARE] = new Mesh("mesh/icon_square.ply");
|
||||||
icons[CLOCK] = new Mesh("mesh/icon_clock.ply");
|
icons[CLOCK] = new Mesh("mesh/icon_clock.ply");
|
||||||
icons[CLOCK] = new Mesh("mesh/icon_grid.ply");
|
icons[GRID] = new Mesh("mesh/icon_grid.ply");
|
||||||
icons[EMPTY] = new Mesh("mesh/icon_empty.ply");
|
icons[EMPTY] = new Mesh("mesh/icon_empty.ply");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ protected:
|
|||||||
class Symbol : public Node
|
class Symbol : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef enum { POINT = 0, IMAGE, VIDEO, SESSION, CLONE, RENDER, DOTS, BUSY, LOCK, UNLOCK, CIRCLE, CLOCK, GRID, EMPTY } Type;
|
typedef enum { POINT = 0, IMAGE, VIDEO, SESSION, CLONE, RENDER, DOTS, BUSY, LOCK, UNLOCK, CIRCLE, SQUARE, CLOCK, GRID, EMPTY } Type;
|
||||||
Symbol(Type t = POINT, glm::vec3 pos = glm::vec3(0.f));
|
Symbol(Type t = POINT, glm::vec3 pos = glm::vec3(0.f));
|
||||||
~Symbol();
|
~Symbol();
|
||||||
|
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ void UserInterface::handleMouse()
|
|||||||
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
|
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
|
||||||
|
|
||||||
// indicate to view that an action can be initiated (e.g. grab)
|
// indicate to view that an action can be initiated (e.g. grab)
|
||||||
Mixer::manager().view()->storeStatus();
|
Mixer::manager().view()->initiate();
|
||||||
}
|
}
|
||||||
// no source is selected
|
// no source is selected
|
||||||
else
|
else
|
||||||
@@ -464,6 +464,7 @@ void UserInterface::handleMouse()
|
|||||||
view_drag = nullptr;
|
view_drag = nullptr;
|
||||||
mousedown = false;
|
mousedown = false;
|
||||||
picked = { nullptr, glm::vec2(0.f) };
|
picked = { nullptr, glm::vec2(0.f) };
|
||||||
|
Mixer::manager().view()->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) )
|
if ( ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) )
|
||||||
@@ -490,7 +491,7 @@ void UserInterface::handleMouse()
|
|||||||
view_drag = Mixer::manager().view();
|
view_drag = Mixer::manager().view();
|
||||||
|
|
||||||
// indicate to view that an action can be initiated (e.g. grab)
|
// indicate to view that an action can be initiated (e.g. grab)
|
||||||
Mixer::manager().view()->storeStatus();
|
Mixer::manager().view()->initiate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// only operate if the view didn't change
|
// only operate if the view didn't change
|
||||||
@@ -529,6 +530,7 @@ void UserInterface::handleMouse()
|
|||||||
// cancel all operations on view when interacting on GUI
|
// cancel all operations on view when interacting on GUI
|
||||||
view_drag = nullptr;
|
view_drag = nullptr;
|
||||||
mousedown = false;
|
mousedown = false;
|
||||||
|
Mixer::manager().view()->terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
96
View.cpp
96
View.cpp
@@ -107,7 +107,7 @@ std::pair<Node *, glm::vec2> View::pick(glm::vec2 P)
|
|||||||
return pick;
|
return pick;
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::storeStatus()
|
void View::initiate()
|
||||||
{
|
{
|
||||||
for (auto sit = Mixer::manager().session()->begin();
|
for (auto sit = Mixer::manager().session()->begin();
|
||||||
sit != Mixer::manager().session()->end(); sit++){
|
sit != Mixer::manager().session()->end(); sit++){
|
||||||
@@ -620,23 +620,39 @@ GeometryView::GeometryView() : View(GEOMETRY)
|
|||||||
Surface *rect = new Surface;
|
Surface *rect = new Surface;
|
||||||
scene.bg()->attach(rect);
|
scene.bg()->attach(rect);
|
||||||
|
|
||||||
|
// Geometry Scene foreground
|
||||||
Frame *border = new Frame(Frame::SHARP, Frame::THIN, Frame::NONE);
|
Frame *border = new Frame(Frame::SHARP, Frame::THIN, Frame::NONE);
|
||||||
border->color = glm::vec4( COLOR_FRAME, 1.f );
|
border->color = glm::vec4( COLOR_FRAME, 1.f );
|
||||||
scene.fg()->attach(border);
|
scene.fg()->attach(border);
|
||||||
|
|
||||||
// selection box
|
// User interface foreground
|
||||||
// selection_box_ = new Box;
|
Group *g = new Group;
|
||||||
// selection_box_->visible_ = false;
|
Symbol *s = new Symbol(Symbol::CLOCK);
|
||||||
// scene.ws()->attach(selection_box_);
|
g->attach(s);
|
||||||
|
Symbol *d = new Symbol(Symbol::POINT);
|
||||||
|
d->color = glm::vec4(0.f, 0.f, 0.f, 0.25f);
|
||||||
|
d->scale_ = glm::vec3(28.f, 28.f, 1.f);
|
||||||
|
d->translation_.z = -0.1;
|
||||||
|
g->attach(d);
|
||||||
|
overlay_rotation_clock_ = g;
|
||||||
|
overlay_rotation_clock_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
||||||
|
scene.fg()->attach(overlay_rotation_clock_);
|
||||||
|
overlay_rotation_clock_->visible_ = false;
|
||||||
|
|
||||||
|
overlay_rotation_circle_ = new Symbol(Symbol::CIRCLE);
|
||||||
|
overlay_rotation_circle_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
||||||
|
scene.fg()->attach(overlay_rotation_circle_);
|
||||||
|
overlay_rotation_circle_->visible_ = false;
|
||||||
|
|
||||||
Symbol *circle = new Symbol(Symbol::CIRCLE);
|
overlay_grid_ = new Symbol(Symbol::GRID);
|
||||||
circle->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
overlay_grid_->scale_ = glm::vec3(1.f, 1.f, 1.f);
|
||||||
scene.fg()->attach(circle);
|
scene.fg()->attach(overlay_grid_);
|
||||||
|
overlay_grid_->visible_ = false;
|
||||||
|
|
||||||
Symbol *clock = new Symbol(Symbol::CLOCK);
|
overlay_scaling_ = new Symbol(Symbol::SQUARE);
|
||||||
clock->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
overlay_scaling_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
||||||
scene.fg()->attach(clock);
|
scene.fg()->attach(overlay_scaling_);
|
||||||
|
overlay_scaling_->visible_ = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,6 +798,12 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the resizing handles in the corners
|
// picking on the resizing handles in the corners
|
||||||
if ( pick.first == s->handle_[Handles::RESIZE] ) {
|
if ( pick.first == s->handle_[Handles::RESIZE] ) {
|
||||||
|
|
||||||
|
overlay_scaling_->visible_ = true;
|
||||||
|
glm::vec4 icon = corner_to_scene_transform * glm::vec4(0.f, 0.f, 0.f, 1.f);
|
||||||
|
overlay_scaling_->translation_.x = icon.x;
|
||||||
|
overlay_scaling_->translation_.y = icon.y;
|
||||||
|
overlay_scaling_->update(0);
|
||||||
|
|
||||||
// RESIZE CORNER
|
// RESIZE CORNER
|
||||||
// proportional SCALING with SHIFT
|
// proportional SCALING with SHIFT
|
||||||
if (UserInterface::manager().shiftModifier()) {
|
if (UserInterface::manager().shiftModifier()) {
|
||||||
@@ -826,6 +848,12 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the BORDER RESIZING handles left or right
|
// picking on the BORDER RESIZING handles left or right
|
||||||
else if ( pick.first == s->handle_[Handles::RESIZE_H] ) {
|
else if ( pick.first == s->handle_[Handles::RESIZE_H] ) {
|
||||||
|
|
||||||
|
overlay_scaling_->visible_ = true;
|
||||||
|
glm::vec4 icon = corner_to_scene_transform * glm::vec4(0.f, 1.f, 0.f, 1.f);
|
||||||
|
overlay_scaling_->translation_.x = icon.x;
|
||||||
|
overlay_scaling_->translation_.y = icon.y;
|
||||||
|
overlay_scaling_->update(0);
|
||||||
|
|
||||||
// SHIFT: HORIZONTAL SCALE to restore source aspect ratio
|
// SHIFT: HORIZONTAL SCALE to restore source aspect ratio
|
||||||
if (UserInterface::manager().shiftModifier()) {
|
if (UserInterface::manager().shiftModifier()) {
|
||||||
sourceNode->scale_.x = ABS(sourceNode->scale_.y) * SIGN(sourceNode->scale_.x);
|
sourceNode->scale_.x = ABS(sourceNode->scale_.y) * SIGN(sourceNode->scale_.x);
|
||||||
@@ -858,6 +886,12 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the BORDER RESIZING handles top or bottom
|
// picking on the BORDER RESIZING handles top or bottom
|
||||||
else if ( pick.first == s->handle_[Handles::RESIZE_V] ) {
|
else if ( pick.first == s->handle_[Handles::RESIZE_V] ) {
|
||||||
|
|
||||||
|
overlay_scaling_->visible_ = true;
|
||||||
|
glm::vec4 icon = corner_to_scene_transform * glm::vec4(1.f, 0.f, 0.f, 1.f);
|
||||||
|
overlay_scaling_->translation_.x = icon.x;
|
||||||
|
overlay_scaling_->translation_.y = icon.y;
|
||||||
|
overlay_scaling_->update(0);
|
||||||
|
|
||||||
// SHIFT: VERTICAL SCALE to restore source aspect ratio
|
// SHIFT: VERTICAL SCALE to restore source aspect ratio
|
||||||
if (UserInterface::manager().shiftModifier()) {
|
if (UserInterface::manager().shiftModifier()) {
|
||||||
sourceNode->scale_.y = ABS(sourceNode->scale_.x) * SIGN(sourceNode->scale_.y);
|
sourceNode->scale_.y = ABS(sourceNode->scale_.x) * SIGN(sourceNode->scale_.y);
|
||||||
@@ -890,6 +924,11 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the CENTRER SCALING handle
|
// picking on the CENTRER SCALING handle
|
||||||
else if ( pick.first == s->handle_[Handles::SCALE] ) {
|
else if ( pick.first == s->handle_[Handles::SCALE] ) {
|
||||||
|
|
||||||
|
overlay_scaling_->visible_ = true;
|
||||||
|
overlay_scaling_->translation_.x = s->stored_status_->translation_.x;
|
||||||
|
overlay_scaling_->translation_.y = s->stored_status_->translation_.y;
|
||||||
|
overlay_scaling_->update(0);
|
||||||
|
|
||||||
// PROPORTIONAL ONLY
|
// PROPORTIONAL ONLY
|
||||||
if (UserInterface::manager().shiftModifier()) {
|
if (UserInterface::manager().shiftModifier()) {
|
||||||
float factor = glm::length( glm::vec2( source_to ) ) / glm::length( glm::vec2( source_from ) );
|
float factor = glm::length( glm::vec2( source_to ) ) / glm::length( glm::vec2( source_from ) );
|
||||||
@@ -911,6 +950,12 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
else if ( pick.first == s->handle_[Handles::ROTATE] ) {
|
else if ( pick.first == s->handle_[Handles::ROTATE] ) {
|
||||||
|
|
||||||
// ROTATION on CENTER
|
// ROTATION on CENTER
|
||||||
|
overlay_rotation_clock_->visible_ = false;
|
||||||
|
overlay_rotation_circle_->visible_ = true;
|
||||||
|
overlay_rotation_circle_->translation_.x = s->stored_status_->translation_.x;
|
||||||
|
overlay_rotation_circle_->translation_.y = s->stored_status_->translation_.y;
|
||||||
|
overlay_rotation_circle_->update(0);
|
||||||
|
|
||||||
// rotation center to center of source (disregarding scale)
|
// rotation center to center of source (disregarding scale)
|
||||||
glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), s->stored_status_->translation_);
|
glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), s->stored_status_->translation_);
|
||||||
source_from = glm::inverse(T) * glm::vec4( scene_from, 1.f );
|
source_from = glm::inverse(T) * glm::vec4( scene_from, 1.f );
|
||||||
@@ -924,6 +969,10 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
if (UserInterface::manager().altModifier()) {
|
if (UserInterface::manager().altModifier()) {
|
||||||
degrees = (degrees / 10) * 10;
|
degrees = (degrees / 10) * 10;
|
||||||
sourceNode->rotation_.z = glm::radians( float(degrees) );
|
sourceNode->rotation_.z = glm::radians( float(degrees) );
|
||||||
|
overlay_rotation_clock_->visible_ = true;
|
||||||
|
overlay_rotation_clock_->translation_.x = s->stored_status_->translation_.x;
|
||||||
|
overlay_rotation_clock_->translation_.y = s->stored_status_->translation_.y;
|
||||||
|
overlay_rotation_clock_->update(0);
|
||||||
}
|
}
|
||||||
// show cursor for rotation
|
// show cursor for rotation
|
||||||
ret.type = Cursor_Hand;
|
ret.type = Cursor_Hand;
|
||||||
@@ -961,14 +1010,6 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
info << ", " << sourceNode->translation_.y << ")";
|
info << ", " << sourceNode->translation_.y << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // don't have a handle, we can only move the source
|
|
||||||
// else {
|
|
||||||
// sourceNode->translation_ = start_translation + gl_Position_to - gl_Position_from;
|
|
||||||
// ret.type = Cursor_ResizeAll;
|
|
||||||
// info << "Position (" << std::fixed << std::setprecision(3) << sourceNode->translation_.x;
|
|
||||||
// info << ", " << sourceNode->translation_.y << ")";
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// request update
|
// request update
|
||||||
s->touch();
|
s->touch();
|
||||||
@@ -977,13 +1018,22 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
View::Cursor GeometryView::over (Source*, glm::vec2, std::pair<Node *, glm::vec2>)
|
|
||||||
{
|
|
||||||
View::Cursor ret = Cursor_Arrow;
|
|
||||||
|
|
||||||
return ret;
|
void GeometryView::terminate()
|
||||||
|
{
|
||||||
|
overlay_rotation_clock_->visible_ = false;
|
||||||
|
overlay_rotation_circle_->visible_ = false;
|
||||||
|
overlay_grid_->visible_ = false;
|
||||||
|
overlay_scaling_->visible_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//View::Cursor GeometryView::over (Source*, glm::vec2, std::pair<Node *, glm::vec2>)
|
||||||
|
//{
|
||||||
|
// View::Cursor ret = Cursor_Arrow;
|
||||||
|
|
||||||
|
// return ret;
|
||||||
|
//}
|
||||||
|
|
||||||
View::Cursor GeometryView::drag (glm::vec2 from, glm::vec2 to)
|
View::Cursor GeometryView::drag (glm::vec2 from, glm::vec2 to)
|
||||||
{
|
{
|
||||||
Cursor ret = View::drag(from, to);
|
Cursor ret = View::drag(from, to);
|
||||||
|
|||||||
15
View.h
15
View.h
@@ -57,15 +57,16 @@ public:
|
|||||||
virtual Cursor drag (glm::vec2, glm::vec2);
|
virtual Cursor drag (glm::vec2, glm::vec2);
|
||||||
|
|
||||||
// grab a source provided a start and an end point in screen coordinates and the picking point
|
// grab a source provided a start and an end point in screen coordinates and the picking point
|
||||||
virtual void storeStatus();
|
virtual void initiate();
|
||||||
|
virtual void terminate() {}
|
||||||
virtual Cursor grab (Source*, glm::vec2, glm::vec2, std::pair<Node *, glm::vec2>) {
|
virtual Cursor grab (Source*, glm::vec2, glm::vec2, std::pair<Node *, glm::vec2>) {
|
||||||
return Cursor();
|
return Cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test mouse over provided a point in screen coordinates and the picking point
|
// // test mouse over provided a point in screen coordinates and the picking point
|
||||||
virtual Cursor over (Source*, glm::vec2, std::pair<Node *, glm::vec2>) {
|
// virtual Cursor over (Source*, glm::vec2, std::pair<Node *, glm::vec2>) {
|
||||||
return Cursor();
|
// return Cursor();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// accessible scene
|
// accessible scene
|
||||||
Scene scene;
|
Scene scene;
|
||||||
@@ -142,12 +143,14 @@ public:
|
|||||||
|
|
||||||
std::pair<Node *, glm::vec2> pick(glm::vec2 P) override;
|
std::pair<Node *, glm::vec2> pick(glm::vec2 P) override;
|
||||||
Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick) override;
|
Cursor grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick) override;
|
||||||
Cursor over (Source *s, glm::vec2 pos, std::pair<Node *, glm::vec2> pick) override;
|
// Cursor over (Source *s, glm::vec2 pos, std::pair<Node *, glm::vec2> pick) override;
|
||||||
Cursor drag (glm::vec2, glm::vec2) override;
|
Cursor drag (glm::vec2, glm::vec2) override;
|
||||||
|
void terminate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Node *overlay_rotation_circle_;
|
Node *overlay_rotation_circle_;
|
||||||
Node *overlay_rotation_clock_;
|
Node *overlay_rotation_clock_;
|
||||||
|
Node *overlay_scaling_;
|
||||||
Node *overlay_grid_;
|
Node *overlay_grid_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user