mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-06 16:00:00 +01:00
Various UserInterface bugfixes.
This commit is contained in:
@@ -100,7 +100,6 @@ Handles::Handles(Type type) : Node(), type_(type)
|
||||
else {
|
||||
// handle_ = new LineSquare(color, int ( 2.1f * Rendering::manager().DPIScale()) );
|
||||
handle_ = new Mesh("mesh/border_handles_overlay.ply");
|
||||
// handle_->scale_ = glm::vec3( 0.05f, 0.05f, 1.f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -174,7 +173,11 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
}
|
||||
else if ( type_ == ROTATE ){
|
||||
// one icon in top right corner
|
||||
vec = modelview * glm::vec4(1.12f, 1.12f, 0.f, 1.f);
|
||||
// 1. Fixed displacement by (0.12,0.12) along the rotation..
|
||||
ctm = GlmToolkit::transform(glm::vec4(0.f), rot, glm::vec3(1.f));
|
||||
vec = ctm * glm::vec4(0.12f, 0.12f, 0.f, 1.f);
|
||||
// 2. ..from the top right corner (1,1)
|
||||
vec = ( modelview * glm::vec4(1.f, 1.f, 0.f, 1.f) ) + vec;
|
||||
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||
handle_->draw( ctm, projection );
|
||||
}
|
||||
|
||||
@@ -74,41 +74,30 @@ void PickingVisitor::visit(Handles &n)
|
||||
if (!n.visible_)
|
||||
return;
|
||||
|
||||
// TODO fixme !
|
||||
|
||||
// apply inverse transform to the point of interest
|
||||
glm::vec4 P = glm::inverse(modelview_) * glm::vec4( point_, 0.f, 1.f );
|
||||
|
||||
// get the bounding box of a handle
|
||||
GlmToolkit::AxisAlignedBoundingBox bb = n.handle()->bbox();
|
||||
|
||||
// test picking depending on type of handle
|
||||
bool picked = false;
|
||||
// test by distance to the corners (more tolerant than bbox)
|
||||
if ( n.type() == Handles::RESIZE ) {
|
||||
// 4 corners
|
||||
picked = ( bb.translated(glm::vec3(+1.f, +1.f, 0.f)).contains( glm::vec3(P) ) ||
|
||||
bb.translated(glm::vec3(+1.f, -1.f, 0.f)).contains( glm::vec3(P) ) ||
|
||||
bb.translated(glm::vec3(-1.f, +1.f, 0.f)).contains( glm::vec3(P) ) ||
|
||||
bb.translated(glm::vec3(-1.f, -1.f, 0.f)).contains( glm::vec3(P) ) );
|
||||
picked = ( glm::length(glm::vec2(+1.f, +1.f)-glm::vec2(P)) < 0.05f ||
|
||||
glm::length(glm::vec2(+1.f, -1.f)- glm::vec2(P)) < 0.05f ||
|
||||
glm::length(glm::vec2(-1.f, +1.f)- glm::vec2(P)) < 0.05f ||
|
||||
glm::length(glm::vec2(-1.f, -1.f)- glm::vec2(P)) < 0.05f );
|
||||
}
|
||||
else if ( n.type() == Handles::RESIZE_H ){
|
||||
// left & right
|
||||
picked = ( bb.translated(glm::vec3(+1.f, 0.f, 0.f)).contains( glm::vec3(P) ) ||
|
||||
bb.translated(glm::vec3(-1.f, 0.f, 0.f)).contains( glm::vec3(P) ) );
|
||||
picked = ( glm::length(glm::vec2(+1.f, 0.f)- glm::vec2(P)) < 0.05f ||
|
||||
glm::length(glm::vec2(-1.f, 0.f)- glm::vec2(P)) < 0.05f );
|
||||
}
|
||||
else if ( n.type() == Handles::RESIZE_V ){
|
||||
// top & bottom
|
||||
picked = ( bb.translated(glm::vec3(0.f, +1.f, 0.f)).contains( glm::vec3(P) ) ||
|
||||
bb.translated(glm::vec3(0.f, -1.f, 0.f)).contains( glm::vec3(P) ) );
|
||||
picked = ( glm::length(glm::vec2(0.f, +1.f)- glm::vec2(P)) < 0.05f ||
|
||||
glm::length(glm::vec2(0.f, -1.f)- glm::vec2(P)) < 0.05f );
|
||||
}
|
||||
else if ( n.type() == Handles::ROTATE ){
|
||||
// Picking Rotation icon
|
||||
glm::vec4 pos = modelview_ * glm::vec4(1.08f, 1.08f, 0.f, 1.f);
|
||||
glm::mat4 ctm = GlmToolkit::transform(glm::vec3(pos), glm::vec3(0.f), glm::vec3(1.f));
|
||||
glm::vec4 P = glm::inverse(ctm) * glm::vec4( point_, 0.f, 1.f );
|
||||
|
||||
bb = n.handle()->bbox();
|
||||
picked = bb.contains( glm::vec3(P) );
|
||||
picked = glm::length(glm::vec2(+1.1f, +1.1f)- glm::vec2(P)) < 0.1f;
|
||||
}
|
||||
|
||||
if ( picked )
|
||||
|
||||
@@ -341,7 +341,7 @@ void UserInterface::handleMouse()
|
||||
//
|
||||
// LEFT Mouse button
|
||||
//
|
||||
if ( ImGui::IsMouseDragging(ImGuiMouseButton_Left, 10.0f) )
|
||||
if ( ImGui::IsMouseDragging(ImGuiMouseButton_Left, 5.0f) )
|
||||
{
|
||||
if (current)
|
||||
{
|
||||
@@ -640,13 +640,17 @@ void ToolBox::Render()
|
||||
|
||||
}
|
||||
|
||||
//static void Square(ImGuiSizeCallbackData* data) {
|
||||
// data->DesiredSize.x = data->DesiredSize.y = (data->DesiredSize.x > data->DesiredSize.y ? data->DesiredSize.x : data->DesiredSize.y); }
|
||||
|
||||
void UserInterface::RenderPreview()
|
||||
{
|
||||
struct CustomConstraints // Helper functions for aspect-ratio constraints
|
||||
{
|
||||
static void AspectRatio(ImGuiSizeCallbackData* data) { float *ar = (float*) data->UserData; data->DesiredSize.x = (*ar * data->CurrentSize.y) - 70.f; }
|
||||
|
||||
static void AspectRatio(ImGuiSizeCallbackData* data) {
|
||||
float *ar = (float*) data->UserData;
|
||||
data->DesiredSize.y = (data->CurrentSize.x / (*ar)) + 35.f;
|
||||
}
|
||||
};
|
||||
|
||||
FrameBuffer *output = Mixer::manager().session()->frame();
|
||||
@@ -661,7 +665,6 @@ void UserInterface::RenderPreview()
|
||||
|
||||
ImVec2 imagesize ( width, width / ar);
|
||||
ImGui::Image((void*)(intptr_t)output->texture(), imagesize);
|
||||
// ImGui::Image((void*)(intptr_t)output->texture(), imagesize, ImVec2(0.f, 1.f), ImVec2(1.f, 0.f));
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
@@ -684,7 +687,7 @@ void UserInterface::RenderMediaPlayer()
|
||||
ImGui::SetNextWindowPos(ImVec2(200, 200), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(350, 300), ImVec2(FLT_MAX, FLT_MAX));
|
||||
if ( !ImGui::Begin(IMGUI_TITLE_MEDIAPLAYER, &Settings::application.media_player, ImGuiWindowFlags_NoScrollbar) || !show)
|
||||
if ( !ImGui::Begin(IMGUI_TITLE_MEDIAPLAYER, &Settings::application.media_player, ImGuiWindowFlags_NoScrollbar) || !show)
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
@@ -694,11 +697,19 @@ void UserInterface::RenderMediaPlayer()
|
||||
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
|
||||
ImVec2 imagesize ( width, width / mp->aspectRatio());
|
||||
ImVec2 tooltip_pos = ImGui::GetCursorScreenPos();
|
||||
ImGui::Image((void*)(uintptr_t)mp->texture(), imagesize);
|
||||
ImVec2 draw_pos = ImGui::GetCursorScreenPos();
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SameLine(-1);
|
||||
ImGui::Text(" %s %d x %d\n Framerate %.2f / %.2f", mp->codec().c_str(), mp->width(), mp->height(), mp->updateFrameRate() , mp->frameRate() );
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->AddRectFilled(tooltip_pos, ImVec2(tooltip_pos.x + width, tooltip_pos.y + 2.f * ImGui::GetTextLineHeightWithSpacing()), IM_COL32(55, 55, 55, 200));
|
||||
|
||||
ImGui::SetCursorScreenPos(tooltip_pos);
|
||||
ImGui::Text(" %s %d x %d\n Framerate %.2f / %.2f", mp->codec().c_str(), mp->width(), mp->height(), mp->updateFrameRate() , mp->frameRate() );
|
||||
|
||||
}
|
||||
ImGui::SetCursorScreenPos(draw_pos);
|
||||
|
||||
if (mp->duration() != GST_CLOCK_TIME_NONE) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user