mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Completing the user actions in appearance view.
This commit is contained in:
@@ -316,6 +316,7 @@ set(VMIX_RSC_FILES
|
|||||||
./rsc/images/transparencygrid.png
|
./rsc/images/transparencygrid.png
|
||||||
./rsc/images/shadow.dds
|
./rsc/images/shadow.dds
|
||||||
./rsc/images/glow.dds
|
./rsc/images/glow.dds
|
||||||
|
./rsc/images/checker.dds
|
||||||
./rsc/images/shadow_perspective.dds
|
./rsc/images/shadow_perspective.dds
|
||||||
./rsc/mesh/disk.ply
|
./rsc/mesh/disk.ply
|
||||||
./rsc/mesh/circle.ply
|
./rsc/mesh/circle.ply
|
||||||
|
|||||||
@@ -75,20 +75,6 @@ void ImGuiVisitor::visit(Group &n)
|
|||||||
oss << "Position " << std::setprecision(3) << n.translation_.x << ", " << n.translation_.y;
|
oss << "Position " << std::setprecision(3) << n.translation_.x << ", " << n.translation_.y;
|
||||||
Action::manager().store(oss.str(), n.id());
|
Action::manager().store(oss.str(), n.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGuiToolkit::ButtonIcon(18, 9)){
|
|
||||||
n.rotation_.z = 0.f;
|
|
||||||
Action::manager().store("Angle 0.0", n.id());
|
|
||||||
}
|
|
||||||
ImGui::SameLine(0, 10);
|
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
|
||||||
ImGui::SliderAngle("Angle", &(n.rotation_.z), -180.f, 180.f) ;
|
|
||||||
if (ImGui::IsItemDeactivatedAfterEdit()) {
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << "Angle " << std::setprecision(3) << n.rotation_.z * 180.f / M_PI;
|
|
||||||
Action::manager().store(oss.str(), n.id());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGuiToolkit::ButtonIcon(3, 15)) {
|
if (ImGuiToolkit::ButtonIcon(3, 15)) {
|
||||||
n.scale_.x = 1.f;
|
n.scale_.x = 1.f;
|
||||||
n.scale_.y = 1.f;
|
n.scale_.y = 1.f;
|
||||||
@@ -108,6 +94,20 @@ void ImGuiVisitor::visit(Group &n)
|
|||||||
Action::manager().store(oss.str(), n.id());
|
Action::manager().store(oss.str(), n.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGuiToolkit::ButtonIcon(18, 9)){
|
||||||
|
n.rotation_.z = 0.f;
|
||||||
|
Action::manager().store("Angle 0.0", n.id());
|
||||||
|
}
|
||||||
|
ImGui::SameLine(0, 10);
|
||||||
|
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
|
ImGui::SliderAngle("Angle", &(n.rotation_.z), -180.f, 180.f) ;
|
||||||
|
if (ImGui::IsItemDeactivatedAfterEdit()) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Angle " << std::setprecision(3) << n.rotation_.z * 180.f / M_PI;
|
||||||
|
Action::manager().store(oss.str(), n.id());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
|
||||||
// spacing
|
// spacing
|
||||||
@@ -417,7 +417,8 @@ void ImGuiVisitor::visit (Source& s)
|
|||||||
s.processingShader()->accept(*this);
|
s.processingShader()->accept(*this);
|
||||||
|
|
||||||
// geometry direct control
|
// geometry direct control
|
||||||
s.groupNode(View::GEOMETRY)->accept(*this);
|
// s.groupNode(View::GEOMETRY)->accept(*this);
|
||||||
|
// s.groupNode((View::Mode) Settings::application.current_view)->accept(*this);
|
||||||
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|||||||
121
View.cpp
121
View.cpp
@@ -1710,8 +1710,9 @@ AppearanceView::AppearanceView() : View(APPEARANCE), index_source_(-1)
|
|||||||
restoreSettings();
|
restoreSettings();
|
||||||
|
|
||||||
// Scene background
|
// Scene background
|
||||||
Surface *rect = new Surface; // black : TODO transparency grid
|
backgroundpreview = new ImageSurface("images/checker.dds"); // black : TODO transparency grid
|
||||||
scene.bg()->attach(rect);
|
backgroundpreview->setTextureUV(glm::vec4(0.5f, 0.5f, 64.f, 64.f));
|
||||||
|
scene.bg()->attach(backgroundpreview);
|
||||||
surfacepreview = new Surface; // to attach source preview
|
surfacepreview = new Surface; // to attach source preview
|
||||||
surfacepreview->translation_.z = 0.01f;
|
surfacepreview->translation_.z = 0.01f;
|
||||||
scene.bg()->attach(surfacepreview);
|
scene.bg()->attach(surfacepreview);
|
||||||
@@ -1725,11 +1726,13 @@ AppearanceView::AppearanceView() : View(APPEARANCE), index_source_(-1)
|
|||||||
//
|
//
|
||||||
// point to show POSITION
|
// point to show POSITION
|
||||||
overlay_position_ = new Symbol(Symbol::SQUARE_POINT);
|
overlay_position_ = new Symbol(Symbol::SQUARE_POINT);
|
||||||
|
overlay_position_->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f );
|
||||||
overlay_position_->scale_ = glm::vec3(0.5f, 0.5f, 1.f);
|
overlay_position_->scale_ = glm::vec3(0.5f, 0.5f, 1.f);
|
||||||
scene.fg()->attach(overlay_position_);
|
scene.fg()->attach(overlay_position_);
|
||||||
overlay_position_->visible_ = false;
|
overlay_position_->visible_ = false;
|
||||||
// cross to show the axis for POSITION
|
// cross to show the axis for POSITION
|
||||||
overlay_position_cross_ = new Symbol(Symbol::CROSS);
|
overlay_position_cross_ = new Symbol(Symbol::CROSS);
|
||||||
|
overlay_position_cross_->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f );
|
||||||
overlay_position_cross_->rotation_ = glm::vec3(0.f, 0.f, M_PI_4);
|
overlay_position_cross_->rotation_ = glm::vec3(0.f, 0.f, M_PI_4);
|
||||||
overlay_position_cross_->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
overlay_position_cross_->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
||||||
scene.fg()->attach(overlay_position_cross_);
|
scene.fg()->attach(overlay_position_cross_);
|
||||||
@@ -1738,6 +1741,7 @@ AppearanceView::AppearanceView() : View(APPEARANCE), index_source_(-1)
|
|||||||
// with dark background
|
// with dark background
|
||||||
Group *g = new Group;
|
Group *g = new Group;
|
||||||
Symbol *s = new Symbol(Symbol::GRID);
|
Symbol *s = new Symbol(Symbol::GRID);
|
||||||
|
s->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f );
|
||||||
g->attach(s);
|
g->attach(s);
|
||||||
s = new Symbol(Symbol::SQUARE_POINT);
|
s = new Symbol(Symbol::SQUARE_POINT);
|
||||||
s->color = glm::vec4(0.f, 0.f, 0.f, 0.25f);
|
s->color = glm::vec4(0.f, 0.f, 0.f, 0.25f);
|
||||||
@@ -1750,11 +1754,13 @@ AppearanceView::AppearanceView() : View(APPEARANCE), index_source_(-1)
|
|||||||
overlay_scaling_grid_->visible_ = false;
|
overlay_scaling_grid_->visible_ = false;
|
||||||
// cross in the square for proportional SCALING
|
// cross in the square for proportional SCALING
|
||||||
overlay_scaling_cross_ = new Symbol(Symbol::CROSS);
|
overlay_scaling_cross_ = new Symbol(Symbol::CROSS);
|
||||||
|
overlay_scaling_cross_->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f );
|
||||||
overlay_scaling_cross_->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
overlay_scaling_cross_->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
||||||
scene.fg()->attach(overlay_scaling_cross_);
|
scene.fg()->attach(overlay_scaling_cross_);
|
||||||
overlay_scaling_cross_->visible_ = false;
|
overlay_scaling_cross_->visible_ = false;
|
||||||
// square to show the center of SCALING
|
// square to show the center of SCALING
|
||||||
overlay_scaling_ = new Symbol(Symbol::SQUARE);
|
overlay_scaling_ = new Symbol(Symbol::SQUARE);
|
||||||
|
overlay_scaling_->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f );
|
||||||
overlay_scaling_->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
overlay_scaling_->scale_ = glm::vec3(0.3f, 0.3f, 1.f);
|
||||||
scene.fg()->attach(overlay_scaling_);
|
scene.fg()->attach(overlay_scaling_);
|
||||||
overlay_scaling_->visible_ = false;
|
overlay_scaling_->visible_ = false;
|
||||||
@@ -1801,35 +1807,97 @@ int AppearanceView::size ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//void AppearanceView::selectAll()
|
||||||
|
//{
|
||||||
|
//// Mixer::selection().clear();
|
||||||
|
|
||||||
|
//// Mixer::manager().setCurrentIndex(index_source_);
|
||||||
|
|
||||||
|
//// if ( Mixer::manager().currentSource() == nullptr )
|
||||||
|
//// Mixer::manager().setCurrentNext();
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void AppearanceView::select(glm::vec2 A, glm::vec2 B)
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//std::pair<Node *, glm::vec2> AppearanceView::pick(glm::vec2 P)
|
||||||
|
//{
|
||||||
|
// // get picking from generic View
|
||||||
|
// std::pair<Node *, glm::vec2> pick = View::pick(P);
|
||||||
|
|
||||||
|
//// // picking visitor found nothing?
|
||||||
|
//// if ( pick.first == nullptr) {
|
||||||
|
|
||||||
|
|
||||||
|
//// Source *s = Mixer::manager().currentSource();
|
||||||
|
//// if (s != nullptr) {
|
||||||
|
|
||||||
|
//// pick = std::pair(s->rendersurface_, glm::vec2(0.f));
|
||||||
|
//// }
|
||||||
|
|
||||||
|
|
||||||
|
//// }
|
||||||
|
|
||||||
|
// return pick;
|
||||||
|
//}
|
||||||
|
|
||||||
void AppearanceView::draw()
|
void AppearanceView::draw()
|
||||||
{
|
{
|
||||||
|
int newindex = Mixer::manager().indexCurrentSource();
|
||||||
|
|
||||||
// did the current source change?
|
// did the current source change?
|
||||||
if (index_source_ != Mixer::manager().indexCurrentSource()) {
|
if (index_source_ != newindex) {
|
||||||
|
|
||||||
// another source is current
|
// if no source selected
|
||||||
index_source_ = Mixer::manager().indexCurrentSource();
|
if (newindex < 0) {
|
||||||
|
// is it because there is no source at all?
|
||||||
float scale = 1.f;
|
if (Mixer::manager().session()->numSource() < 1)
|
||||||
Source *s = Mixer::manager().currentSource();
|
// ok, nothing to display
|
||||||
if (s != nullptr) {
|
newindex = -1;
|
||||||
// update rendering frame to match current source AR
|
else {
|
||||||
scale = s->frame()->aspectRatio();
|
// if we have a valid index, do not change anything
|
||||||
|
// but make sure it is in the range of valid indices
|
||||||
surfacepreview->setTextureIndex( s->frame()->texture() );
|
newindex = CLAMP(index_source_, 0, Mixer::manager().session()->numSource());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
// another index is selected
|
||||||
|
if (index_source_ != newindex) {
|
||||||
|
index_source_ = newindex;
|
||||||
|
|
||||||
|
// reset
|
||||||
|
float scale = 1.f;
|
||||||
surfacepreview->setTextureIndex(0);
|
surfacepreview->setTextureIndex(0);
|
||||||
}
|
|
||||||
|
|
||||||
// update aspect ratio
|
// if its a valid index
|
||||||
for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) {
|
if (index_source_ > -1) {
|
||||||
(*node)->scale_.x = scale;
|
|
||||||
}
|
Mixer::manager().setCurrentIndex(index_source_);
|
||||||
for (NodeSet::iterator node = scene.fg()->begin(); node != scene.fg()->end(); node++) {
|
Source *s = Mixer::manager().currentSource();
|
||||||
(*node)->scale_.x = scale;
|
if (s != nullptr) {
|
||||||
|
// update rendering frame to match current source AR
|
||||||
|
scale = s->frame()->aspectRatio();
|
||||||
|
surfacepreview->setTextureIndex( s->frame()->texture() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// update aspect ratio
|
||||||
|
for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) {
|
||||||
|
(*node)->scale_.x = scale;
|
||||||
|
}
|
||||||
|
backgroundpreview->setTextureUV(glm::vec4(0.5f, 0.5f, 64.f * scale, 64.f));
|
||||||
|
for (NodeSet::iterator node = scene.fg()->begin(); node != scene.fg()->end(); node++) {
|
||||||
|
(*node)->scale_.x = scale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Shader::force_blending_opacity = true;
|
Shader::force_blending_opacity = true;
|
||||||
View::draw();
|
View::draw();
|
||||||
Shader::force_blending_opacity = false;
|
Shader::force_blending_opacity = false;
|
||||||
@@ -1925,7 +1993,7 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
T = glm::scale(T, s->stored_status_->scale_);
|
T = glm::scale(T, s->stored_status_->scale_);
|
||||||
corner = T * glm::vec4( corner, 0.f, 0.f );
|
corner = T * glm::vec4( corner, 0.f, 0.f );
|
||||||
ret.type = corner.x * corner.y > 0.f ? Cursor_ResizeNESW : Cursor_ResizeNWSE;
|
ret.type = corner.x * corner.y > 0.f ? Cursor_ResizeNESW : Cursor_ResizeNWSE;
|
||||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
info << "UV scale " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||||
info << " x " << sourceNode->scale_.y;
|
info << " x " << sourceNode->scale_.y;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1961,7 +2029,7 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
// show cursor depending on angle
|
// show cursor depending on angle
|
||||||
float c = tan(sourceNode->rotation_.z);
|
float c = tan(sourceNode->rotation_.z);
|
||||||
ret.type = ABS(c) > 1.f ? Cursor_ResizeNS : Cursor_ResizeEW;
|
ret.type = ABS(c) > 1.f ? Cursor_ResizeNS : Cursor_ResizeEW;
|
||||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
info << "UV scale " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||||
info << " x " << sourceNode->scale_.y;
|
info << " x " << sourceNode->scale_.y;
|
||||||
}
|
}
|
||||||
// picking on the BORDER RESIZING handles top or bottom
|
// picking on the BORDER RESIZING handles top or bottom
|
||||||
@@ -1996,7 +2064,7 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
// show cursor depending on angle
|
// show cursor depending on angle
|
||||||
float c = tan(sourceNode->rotation_.z);
|
float c = tan(sourceNode->rotation_.z);
|
||||||
ret.type = ABS(c) > 1.f ? Cursor_ResizeEW : Cursor_ResizeNS;
|
ret.type = ABS(c) > 1.f ? Cursor_ResizeEW : Cursor_ResizeNS;
|
||||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
info << "UV scale " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||||
info << " x " << sourceNode->scale_.y;
|
info << " x " << sourceNode->scale_.y;
|
||||||
}
|
}
|
||||||
// picking on the CENTRER SCALING handle
|
// picking on the CENTRER SCALING handle
|
||||||
@@ -2029,7 +2097,7 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
// show cursor depending on diagonal
|
// show cursor depending on diagonal
|
||||||
corner = glm::sign(sourceNode->scale_);
|
corner = glm::sign(sourceNode->scale_);
|
||||||
ret.type = (corner.x * corner.y) > 0.f ? Cursor_ResizeNWSE : Cursor_ResizeNESW;
|
ret.type = (corner.x * corner.y) > 0.f ? Cursor_ResizeNWSE : Cursor_ResizeNESW;
|
||||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
info << "UV scale " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||||
info << " x " << sourceNode->scale_.y;
|
info << " x " << sourceNode->scale_.y;
|
||||||
}
|
}
|
||||||
// picking anywhere but on a handle: user wants to move the source
|
// picking anywhere but on a handle: user wants to move the source
|
||||||
@@ -2064,7 +2132,7 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
overlay_position_->translation_.y = sourceNode->translation_.y;
|
overlay_position_->translation_.y = sourceNode->translation_.y;
|
||||||
overlay_position_->update(0);
|
overlay_position_->update(0);
|
||||||
// Show move cursor
|
// Show move cursor
|
||||||
info << "Position " << std::fixed << std::setprecision(3) << sourceNode->translation_.x;
|
info << "UV shift " << std::fixed << std::setprecision(3) << sourceNode->translation_.x;
|
||||||
info << ", " << sourceNode->translation_.y ;
|
info << ", " << sourceNode->translation_.y ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2114,4 +2182,3 @@ View::Cursor AppearanceView::drag (glm::vec2 from, glm::vec2 to)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
View.h
16
View.h
@@ -11,6 +11,7 @@ typedef std::list<Source *> SourceList;
|
|||||||
|
|
||||||
class SessionSource;
|
class SessionSource;
|
||||||
class Surface;
|
class Surface;
|
||||||
|
class Symbol;
|
||||||
|
|
||||||
class View
|
class View
|
||||||
{
|
{
|
||||||
@@ -216,11 +217,16 @@ private:
|
|||||||
SessionSource *transition_source_;
|
SessionSource *transition_source_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AppearanceView : public View
|
class AppearanceView : public View
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AppearanceView();
|
AppearanceView();
|
||||||
|
|
||||||
|
// select sources provided a start and end selection points in screen coordinates
|
||||||
|
// void select(glm::vec2, glm::vec2) override;
|
||||||
|
// void selectAll() override;
|
||||||
|
|
||||||
void draw () override;
|
void draw () override;
|
||||||
|
|
||||||
// void update (float dt) override;
|
// void update (float dt) override;
|
||||||
@@ -228,6 +234,7 @@ public:
|
|||||||
void resize (int) override;
|
void resize (int) override;
|
||||||
int size () override;
|
int size () 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 drag (glm::vec2, glm::vec2) override;
|
Cursor drag (glm::vec2, glm::vec2) override;
|
||||||
void terminate() override;
|
void terminate() override;
|
||||||
@@ -235,12 +242,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
int index_source_;
|
int index_source_;
|
||||||
|
Surface *backgroundpreview;
|
||||||
Surface *surfacepreview;
|
Surface *surfacepreview;
|
||||||
|
|
||||||
Node *overlay_position_;
|
Symbol *overlay_position_;
|
||||||
Node *overlay_position_cross_;
|
Symbol *overlay_position_cross_;
|
||||||
Node *overlay_scaling_;
|
Symbol *overlay_scaling_;
|
||||||
Node *overlay_scaling_cross_;
|
Symbol *overlay_scaling_cross_;
|
||||||
Node *overlay_scaling_grid_;
|
Node *overlay_scaling_grid_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
#define COLOR_HIGHLIGHT_SOURCE 1.f, 1.f, 1.f
|
#define COLOR_HIGHLIGHT_SOURCE 1.f, 1.f, 1.f
|
||||||
#define COLOR_TRANSITION_SOURCE 1.f, 0.5f, 1.f
|
#define COLOR_TRANSITION_SOURCE 1.f, 0.5f, 1.f
|
||||||
#define COLOR_TRANSITION_LINES 0.9f, 0.9f, 0.9f
|
#define COLOR_TRANSITION_LINES 0.9f, 0.9f, 0.9f
|
||||||
#define COLOR_APPEARANCE_SOURCE 0.0f, 0.9f, 0.9f
|
#define COLOR_APPEARANCE_SOURCE 0.9f, 0.9f, 0.1f
|
||||||
#define COLOR_FRAME 0.8f, 0.f, 0.8f
|
#define COLOR_FRAME 0.8f, 0.f, 0.8f
|
||||||
#define COLOR_LIMBO_CIRCLE 0.16f, 0.16f, 0.16f
|
#define COLOR_LIMBO_CIRCLE 0.16f, 0.16f, 0.16f
|
||||||
#define COLOR_SLIDER_CIRCLE 0.11f, 0.11f, 0.11f
|
#define COLOR_SLIDER_CIRCLE 0.11f, 0.11f, 0.11f
|
||||||
|
|||||||
Reference in New Issue
Block a user