mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 03:09:57 +01:00
Cleanup GUI and user feedback with crop in AppearanceView.
This commit is contained in:
@@ -483,7 +483,7 @@ void SessionLoader::visit (Source& s)
|
|||||||
s.groupNode(View::APPEARANCE)->accept(*this);
|
s.groupNode(View::APPEARANCE)->accept(*this);
|
||||||
|
|
||||||
xmlCurrent_ = sourceNode->FirstChildElement("Crop");
|
xmlCurrent_ = sourceNode->FirstChildElement("Crop");
|
||||||
s.texturesurface_->accept(*this);
|
s.renderingSurface()->accept(*this);
|
||||||
|
|
||||||
xmlCurrent_ = sourceNode->FirstChildElement("Blending");
|
xmlCurrent_ = sourceNode->FirstChildElement("Blending");
|
||||||
s.blendingShader()->accept(*this);
|
s.blendingShader()->accept(*this);
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ void SessionVisitor::visit (Source& s)
|
|||||||
|
|
||||||
xmlCurrent_ = xmlDoc_->NewElement("Crop");
|
xmlCurrent_ = xmlDoc_->NewElement("Crop");
|
||||||
sourceNode->InsertEndChild(xmlCurrent_);
|
sourceNode->InsertEndChild(xmlCurrent_);
|
||||||
s.texturesurface_->accept(*this);
|
s.renderingSurface()->accept(*this);
|
||||||
|
|
||||||
xmlCurrent_ = xmlDoc_->NewElement( "Blending" );
|
xmlCurrent_ = xmlDoc_->NewElement( "Blending" );
|
||||||
sourceNode->InsertEndChild(xmlCurrent_);
|
sourceNode->InsertEndChild(xmlCurrent_);
|
||||||
|
|||||||
7
Source.h
7
Source.h
@@ -69,6 +69,9 @@ public:
|
|||||||
// a Source has a shader used to render in fbo
|
// a Source has a shader used to render in fbo
|
||||||
inline Shader *renderingShader () const { return renderingshader_; }
|
inline Shader *renderingShader () const { return renderingshader_; }
|
||||||
|
|
||||||
|
// a Source has a surface used to draw images
|
||||||
|
inline Surface *renderingSurface () const { return texturesurface_; }
|
||||||
|
|
||||||
// the rendering shader always have an image processing shader
|
// the rendering shader always have an image processing shader
|
||||||
inline ImageProcessingShader *processingShader () const { return processingshader_; }
|
inline ImageProcessingShader *processingShader () const { return processingshader_; }
|
||||||
|
|
||||||
@@ -138,8 +141,6 @@ public:
|
|||||||
|
|
||||||
virtual glm::ivec2 icon () const { return glm::ivec2(12, 11); }
|
virtual glm::ivec2 icon () const { return glm::ivec2(12, 11); }
|
||||||
|
|
||||||
// surface to draw on
|
|
||||||
Surface *texturesurface_;
|
|
||||||
protected:
|
protected:
|
||||||
// name
|
// name
|
||||||
std::string name_;
|
std::string name_;
|
||||||
@@ -171,6 +172,8 @@ protected:
|
|||||||
// blendingshader provides mixing controls
|
// blendingshader provides mixing controls
|
||||||
ImageShader *blendingshader_;
|
ImageShader *blendingshader_;
|
||||||
|
|
||||||
|
// surface to draw on
|
||||||
|
Surface *texturesurface_;
|
||||||
|
|
||||||
// mode for display
|
// mode for display
|
||||||
Mode mode_;
|
Mode mode_;
|
||||||
|
|||||||
92
View.cpp
92
View.cpp
@@ -830,8 +830,7 @@ void showContextMenu(View::Mode m, const char* label)
|
|||||||
if (output) scale.x = output->aspectRatio() / s->frame()->aspectRatio();
|
if (output) scale.x = output->aspectRatio() / s->frame()->aspectRatio();
|
||||||
}
|
}
|
||||||
else if ( m == View::APPEARANCE ) {
|
else if ( m == View::APPEARANCE ) {
|
||||||
glm::vec2 crop = s->frame()->projectionArea();
|
scale = s->renderingSurface()->scale_;
|
||||||
scale = glm::vec3( crop, 1.f);
|
|
||||||
}
|
}
|
||||||
s->group(m)->scale_ = scale;
|
s->group(m)->scale_ = scale;
|
||||||
s->group(m)->rotation_.z = 0;
|
s->group(m)->rotation_.z = 0;
|
||||||
@@ -1781,30 +1780,31 @@ AppearanceView::AppearanceView() : View(APPEARANCE), edit_source_(nullptr), need
|
|||||||
// Horizontal axis
|
// Horizontal axis
|
||||||
horizontal_line_ = new Mesh("mesh/h_line.ply");
|
horizontal_line_ = new Mesh("mesh/h_line.ply");
|
||||||
horizontal_line_->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
horizontal_line_->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
||||||
horizontal_line_->translation_ = glm::vec3(0.f, 1.1f, 0.0f);
|
horizontal_line_->translation_ = glm::vec3(0.f, 1.12f, 0.0f);
|
||||||
horizontal_line_->scale_.x = 1.0f;
|
horizontal_line_->scale_.x = 1.0f;
|
||||||
horizontal_line_->scale_.y = 3.0f;
|
horizontal_line_->scale_.y = 3.0f;
|
||||||
scene.bg()->attach(horizontal_line_);
|
scene.bg()->attach(horizontal_line_);
|
||||||
Mesh *mark = new Mesh("mesh/h_mark.ply");
|
show_horizontal_scale_ = false;
|
||||||
mark->translation_ = glm::vec3(0.f, 1.1f, 0.0f);
|
horizontal_mark_ = new Mesh("mesh/h_mark.ply");
|
||||||
mark->scale_ = glm::vec3(2.5f, -2.5f, 0.0f);
|
horizontal_mark_->translation_ = glm::vec3(0.f, 1.12f, 0.0f);
|
||||||
mark->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
horizontal_mark_->scale_ = glm::vec3(2.5f, -2.5f, 0.0f);
|
||||||
scene.bg()->attach(mark);
|
horizontal_mark_->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
||||||
|
scene.bg()->attach(horizontal_mark_);
|
||||||
// vertical axis
|
// vertical axis
|
||||||
vertical_line_ = new Group;
|
vertical_line_ = new Group;
|
||||||
Mesh *line = new Mesh("mesh/h_line.ply");
|
Mesh *line = new Mesh("mesh/h_line.ply");
|
||||||
line->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
line->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
||||||
line->translation_ = glm::vec3(-0.1f, 0.0f, 0.0f);
|
line->translation_ = glm::vec3(-0.12f, 0.0f, 0.0f);
|
||||||
line->scale_.x = 1.0f;
|
line->scale_.x = 1.0f;
|
||||||
line->scale_.y = 3.0f;
|
line->scale_.y = 3.0f;
|
||||||
line->rotation_.z = M_PI_2;
|
line->rotation_.z = M_PI_2;
|
||||||
vertical_line_->attach(line);
|
vertical_line_->attach(line);
|
||||||
mark = new Mesh("mesh/h_mark.ply");
|
vertical_mark_ = new Mesh("mesh/h_mark.ply");
|
||||||
mark->translation_ = glm::vec3(-0.1f, 0.0f, 0.0f);
|
vertical_mark_->translation_ = glm::vec3(-0.12f, 0.0f, 0.0f);
|
||||||
mark->scale_ = glm::vec3(2.5f, -2.5f, 0.0f);
|
vertical_mark_->scale_ = glm::vec3(2.5f, -2.5f, 0.0f);
|
||||||
mark->rotation_.z = M_PI_2;
|
vertical_mark_->rotation_.z = M_PI_2;
|
||||||
mark->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
vertical_mark_->shader()->color = glm::vec4( COLOR_TRANSITION_LINES, 0.9f );
|
||||||
vertical_line_->attach(mark);
|
vertical_line_->attach(vertical_mark_);
|
||||||
scene.bg()->attach(vertical_line_);
|
scene.bg()->attach(vertical_line_);
|
||||||
|
|
||||||
// surface to show the texture of the source
|
// surface to show the texture of the source
|
||||||
@@ -1816,11 +1816,11 @@ AppearanceView::AppearanceView() : View(APPEARANCE), edit_source_(nullptr), need
|
|||||||
//
|
//
|
||||||
// crop icons
|
// crop icons
|
||||||
crop_horizontal_ = new Symbol(Symbol::CROP);
|
crop_horizontal_ = new Symbol(Symbol::CROP);
|
||||||
crop_horizontal_->translation_ = glm::vec3(1.0f, 1.1f, 0.f);
|
crop_horizontal_->translation_ = glm::vec3(1.0f, 1.12f, 0.f);
|
||||||
scene.fg()->attach(crop_horizontal_);
|
scene.fg()->attach(crop_horizontal_);
|
||||||
crop_vertical_ = new Symbol(Symbol::CROP);
|
crop_vertical_ = new Symbol(Symbol::CROP);
|
||||||
crop_vertical_->rotation_.z = M_PI_2;
|
crop_vertical_->rotation_.z = M_PI_2;
|
||||||
crop_vertical_->translation_ = glm::vec3(-1.1f, -1.0f, 0.f);
|
crop_vertical_->translation_ = glm::vec3(-1.12f, -1.0f, 0.f);
|
||||||
scene.fg()->attach(crop_vertical_);
|
scene.fg()->attach(crop_vertical_);
|
||||||
|
|
||||||
// User interface foreground
|
// User interface foreground
|
||||||
@@ -2049,7 +2049,7 @@ void AppearanceView::adjustBackground()
|
|||||||
// foreground
|
// foreground
|
||||||
crop_horizontal_->translation_.x = image_crop_area.x;
|
crop_horizontal_->translation_.x = image_crop_area.x;
|
||||||
crop_vertical_->translation_.y = -image_crop_area.y;
|
crop_vertical_->translation_.y = -image_crop_area.y;
|
||||||
crop_vertical_->translation_.x = -image_original_width - 0.1f;
|
crop_vertical_->translation_.x = -image_original_width - 0.12f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2099,15 +2099,33 @@ void AppearanceView::draw()
|
|||||||
Shader::force_blending_opacity = false;
|
Shader::force_blending_opacity = false;
|
||||||
|
|
||||||
if (edit_source_ != nullptr){
|
if (edit_source_ != nullptr){
|
||||||
|
|
||||||
// force to redraw the frame of the edit source (even if source is not visible)
|
// force to redraw the frame of the edit source (even if source is not visible)
|
||||||
DrawVisitor dv(edit_source_->frames_[mode_], Rendering::manager().Projection(), true);
|
DrawVisitor dv(edit_source_->frames_[mode_], Rendering::manager().Projection(), true);
|
||||||
scene.accept(dv);
|
scene.accept(dv);
|
||||||
|
|
||||||
|
if (show_horizontal_scale_) {
|
||||||
|
int n = static_cast<int>( edit_source_->frame()->aspectRatio() / 0.2f );
|
||||||
|
static glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), glm::vec3( 0.2f, 0.f, 0.f));
|
||||||
|
DrawVisitor dv(horizontal_mark_, Rendering::manager().Projection());
|
||||||
|
dv.loop(n + 1, T);
|
||||||
|
scene.accept(dv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_vertical_scale_) {
|
||||||
|
static glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), glm::vec3( 0.f, -0.2f, 0.f));
|
||||||
|
DrawVisitor dv(vertical_mark_, Rendering::manager().Projection());
|
||||||
|
dv.loop(6, T);
|
||||||
|
scene.accept(dv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_vertical_scale_ = false;
|
||||||
|
show_horizontal_scale_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick)
|
View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pair<Node *, glm::vec2> pick)
|
||||||
{
|
{
|
||||||
|
std::ostringstream info;
|
||||||
View::Cursor ret = Cursor();
|
View::Cursor ret = Cursor();
|
||||||
|
|
||||||
// grab coordinates in scene-View reference frame
|
// grab coordinates in scene-View reference frame
|
||||||
@@ -2115,6 +2133,7 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
glm::vec3 scene_to = Rendering::manager().unProject(to, scene.root()->transform_);
|
glm::vec3 scene_to = Rendering::manager().unProject(to, scene.root()->transform_);
|
||||||
glm::vec3 scene_translation = scene_to - scene_from;
|
glm::vec3 scene_translation = scene_to - scene_from;
|
||||||
|
|
||||||
|
|
||||||
// Not grabbing a source
|
// Not grabbing a source
|
||||||
if (!s) {
|
if (!s) {
|
||||||
// work on the edited source
|
// work on the edited source
|
||||||
@@ -2122,27 +2141,50 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
|
|
||||||
// picking on the resizing handles in the corners
|
// picking on the resizing handles in the corners
|
||||||
if ( pick.first == crop_horizontal_ ) {
|
if ( pick.first == crop_horizontal_ ) {
|
||||||
// crop horizontally
|
|
||||||
float max_width = edit_source_->frame()->aspectRatio();
|
float max_width = edit_source_->frame()->aspectRatio();
|
||||||
edit_source_->texturesurface_->scale_.x = CLAMP(scene_to.x, 0.2f, max_width) / max_width;
|
// discretized scaling with ALT
|
||||||
|
float val = scene_to.x;
|
||||||
|
if (UserInterface::manager().altModifier()) {
|
||||||
|
val = ROUND(val, 5.f);
|
||||||
|
show_horizontal_scale_ = true;
|
||||||
|
}
|
||||||
|
// crop horizontally
|
||||||
|
edit_source_->texturesurface_->scale_.x = CLAMP(val, 0.2f, max_width) / max_width;
|
||||||
edit_source_->touch();
|
edit_source_->touch();
|
||||||
// update background and frame
|
// update background and frame
|
||||||
adjustBackground();
|
adjustBackground();
|
||||||
// cursor indication
|
// cursor indication
|
||||||
|
info << "Crop " << std::fixed << std::setprecision(3) << max_width * edit_source_->texturesurface_->scale_.x;
|
||||||
|
info << " x " << edit_source_->texturesurface_->scale_.y;
|
||||||
ret.type = Cursor_ResizeEW;
|
ret.type = Cursor_ResizeEW;
|
||||||
}
|
}
|
||||||
if ( pick.first == crop_vertical_ ) {
|
if ( pick.first == crop_vertical_ ) {
|
||||||
|
float max_width = edit_source_->frame()->aspectRatio();
|
||||||
|
float val = -scene_to.y;
|
||||||
|
// discretized scaling with ALT
|
||||||
|
if (UserInterface::manager().altModifier()) {
|
||||||
|
val = ROUND(val, 5.f);
|
||||||
|
show_vertical_scale_ = true;
|
||||||
|
}
|
||||||
// crop vertically
|
// crop vertically
|
||||||
edit_source_->texturesurface_->scale_.y = -1.f * CLAMP(scene_to.y, -1.f, -0.2f);
|
edit_source_->texturesurface_->scale_.y = CLAMP(val, 0.2f, 1.0f);
|
||||||
edit_source_->touch();
|
edit_source_->touch();
|
||||||
// update background and frame
|
// update background and frame
|
||||||
adjustBackground();
|
adjustBackground();
|
||||||
// cursor indication
|
// cursor indication
|
||||||
|
info << "Crop " << std::fixed << std::setprecision(3) << max_width * edit_source_->texturesurface_->scale_.x ;
|
||||||
|
info << " x " << edit_source_->texturesurface_->scale_.y;
|
||||||
ret.type = Cursor_ResizeNS;
|
ret.type = Cursor_ResizeNS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
// store action in history
|
||||||
|
current_action_ = edit_source_->name() + ": " + info.str();
|
||||||
|
current_id_ = edit_source_->id();
|
||||||
|
|
||||||
|
// update cursor
|
||||||
|
ret.info = info.str();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Group *sourceNode = s->group(mode_); // groups_[View::APPEARANCE]
|
Group *sourceNode = s->group(mode_); // groups_[View::APPEARANCE]
|
||||||
@@ -2156,7 +2198,6 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
glm::vec3 source_scaling = glm::vec3(source_to) / glm::vec3(source_from);
|
glm::vec3 source_scaling = glm::vec3(source_to) / glm::vec3(source_from);
|
||||||
|
|
||||||
// which manipulation to perform?
|
// which manipulation to perform?
|
||||||
std::ostringstream info;
|
|
||||||
if (pick.first) {
|
if (pick.first) {
|
||||||
// which corner was picked ?
|
// which corner was picked ?
|
||||||
glm::vec2 corner = glm::round(pick.second);
|
glm::vec2 corner = glm::round(pick.second);
|
||||||
@@ -2178,7 +2219,6 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
|
|||||||
// convert source position in corner reference frame
|
// convert source position in corner reference frame
|
||||||
glm::vec4 center = scene_to_corner_transform * glm::vec4( s->stored_status_->translation_, 1.f);
|
glm::vec4 center = scene_to_corner_transform * glm::vec4( s->stored_status_->translation_, 1.f);
|
||||||
|
|
||||||
|
|
||||||
// picking on the resizing handles in the corners
|
// picking on the resizing handles in the corners
|
||||||
if ( pick.first == s->handles_[mode_][Handles::RESIZE] ) {
|
if ( pick.first == s->handles_[mode_][Handles::RESIZE] ) {
|
||||||
|
|
||||||
|
|||||||
4
View.h
4
View.h
@@ -252,7 +252,11 @@ private:
|
|||||||
Surface *backgroundchecker_;
|
Surface *backgroundchecker_;
|
||||||
Frame *backgroundframe_;
|
Frame *backgroundframe_;
|
||||||
Mesh *horizontal_line_;
|
Mesh *horizontal_line_;
|
||||||
|
Mesh *horizontal_mark_;
|
||||||
|
bool show_horizontal_scale_;
|
||||||
Group *vertical_line_;
|
Group *vertical_line_;
|
||||||
|
Mesh *vertical_mark_;
|
||||||
|
bool show_vertical_scale_;
|
||||||
Symbol *crop_horizontal_;
|
Symbol *crop_horizontal_;
|
||||||
Symbol *crop_vertical_;
|
Symbol *crop_vertical_;
|
||||||
Symbol *overlay_position_;
|
Symbol *overlay_position_;
|
||||||
|
|||||||
Reference in New Issue
Block a user