Starting implementation of overlay in GeometryView to inform on the

current action (Rotation, Scaling).
This commit is contained in:
brunoherbelin
2020-09-08 23:45:36 +02:00
parent 2c52530a92
commit 32234c4d7c
7 changed files with 92 additions and 2435 deletions

View File

@@ -312,6 +312,7 @@ set(VMIX_RSC_FILES
./rsc/mesh/icon_lock.ply
./rsc/mesh/icon_unlock.ply
./rsc/mesh/icon_circle.ply
./rsc/mesh/icon_square.ply
./rsc/mesh/icon_clock.ply
./rsc/mesh/icon_grid.ply
./rsc/mesh/h_line.ply

View File

@@ -293,8 +293,9 @@ Symbol::Symbol(Type t, glm::vec3 pos) : Node(), type_(t)
icons[LOCK] = new Mesh("mesh/icon_lock.ply");
icons[UNLOCK] = new Mesh("mesh/icon_unlock.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_grid.ply");
icons[GRID] = new Mesh("mesh/icon_grid.ply");
icons[EMPTY] = new Mesh("mesh/icon_empty.ply");
}

View File

@@ -57,7 +57,7 @@ protected:
class Symbol : public Node
{
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();

View File

@@ -444,7 +444,7 @@ void UserInterface::handleMouse()
navigator.showPannelSource( Mixer::manager().indexCurrentSource() );
// indicate to view that an action can be initiated (e.g. grab)
Mixer::manager().view()->storeStatus();
Mixer::manager().view()->initiate();
}
// no source is selected
else
@@ -464,6 +464,7 @@ void UserInterface::handleMouse()
view_drag = nullptr;
mousedown = false;
picked = { nullptr, glm::vec2(0.f) };
Mixer::manager().view()->terminate();
}
if ( ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) )
@@ -490,7 +491,7 @@ void UserInterface::handleMouse()
view_drag = Mixer::manager().view();
// 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
@@ -529,6 +530,7 @@ void UserInterface::handleMouse()
// cancel all operations on view when interacting on GUI
view_drag = nullptr;
mousedown = false;
Mixer::manager().view()->terminate();
}
}

View File

@@ -107,7 +107,7 @@ std::pair<Node *, glm::vec2> View::pick(glm::vec2 P)
return pick;
}
void View::storeStatus()
void View::initiate()
{
for (auto sit = Mixer::manager().session()->begin();
sit != Mixer::manager().session()->end(); sit++){
@@ -620,23 +620,39 @@ GeometryView::GeometryView() : View(GEOMETRY)
Surface *rect = new Surface;
scene.bg()->attach(rect);
// Geometry Scene foreground
Frame *border = new Frame(Frame::SHARP, Frame::THIN, Frame::NONE);
border->color = glm::vec4( COLOR_FRAME, 1.f );
scene.fg()->attach(border);
// selection box
// selection_box_ = new Box;
// selection_box_->visible_ = false;
// scene.ws()->attach(selection_box_);
// User interface foreground
Group *g = new Group;
Symbol *s = new Symbol(Symbol::CLOCK);
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);
circle->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
scene.fg()->attach(circle);
overlay_grid_ = new Symbol(Symbol::GRID);
overlay_grid_->scale_ = glm::vec3(1.f, 1.f, 1.f);
scene.fg()->attach(overlay_grid_);
overlay_grid_->visible_ = false;
Symbol *clock = new Symbol(Symbol::CLOCK);
clock->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
scene.fg()->attach(clock);
overlay_scaling_ = new Symbol(Symbol::SQUARE);
overlay_scaling_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
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
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
// proportional SCALING with SHIFT
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
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
if (UserInterface::manager().shiftModifier()) {
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
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
if (UserInterface::manager().shiftModifier()) {
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
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
if (UserInterface::manager().shiftModifier()) {
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] ) {
// 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)
glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), s->stored_status_->translation_);
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()) {
degrees = (degrees / 10) * 10;
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
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 << ")";
}
}
// // 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
s->touch();
@@ -977,13 +1018,22 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
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)
{
Cursor ret = View::drag(from, to);

15
View.h
View File

@@ -57,15 +57,16 @@ public:
virtual Cursor drag (glm::vec2, glm::vec2);
// 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>) {
return Cursor();
}
// test mouse over provided a point in screen coordinates and the picking point
virtual Cursor over (Source*, glm::vec2, std::pair<Node *, glm::vec2>) {
return Cursor();
}
// // test mouse over provided a point in screen coordinates and the picking point
// virtual Cursor over (Source*, glm::vec2, std::pair<Node *, glm::vec2>) {
// return Cursor();
// }
// accessible scene
Scene scene;
@@ -142,12 +143,14 @@ public:
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 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;
void terminate();
private:
Node *overlay_rotation_circle_;
Node *overlay_rotation_clock_;
Node *overlay_scaling_;
Node *overlay_grid_;
};

File diff suppressed because it is too large Load Diff