mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
Fix Mouse coordinates HI DPI under OSX (& various compilation warnings)
This commit is contained in:
@@ -49,14 +49,14 @@
|
||||
// local statics
|
||||
static GstGLContext *global_gl_context = NULL;
|
||||
static GstGLDisplay *global_display = NULL;
|
||||
static guintptr global_window_handle = 0;
|
||||
//static guintptr global_window_handle = 0;
|
||||
|
||||
static void glfw_error_callback(int error, const char* description)
|
||||
{
|
||||
Log::Error("Glfw Error %d: %s", error, description);
|
||||
}
|
||||
|
||||
static void WindowRefreshCallback( GLFWwindow* window )
|
||||
static void WindowRefreshCallback( GLFWwindow* )
|
||||
{
|
||||
Rendering::manager().Draw();
|
||||
}
|
||||
@@ -128,6 +128,8 @@ bool Rendering::Init()
|
||||
glViewport(0, 0, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
main_window_attributes_.clear_color = glm::vec3(COLOR_BGROUND);
|
||||
|
||||
Log::Info("viewport %d x %d", main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
|
||||
// Gstreamer link to context
|
||||
g_setenv ("GST_GL_API", "opengl3", FALSE);
|
||||
gst_init (NULL, NULL);
|
||||
@@ -339,6 +341,9 @@ glm::vec3 Rendering::unProject(glm::vec2 screen_coordinate, glm::mat4 modelview)
|
||||
{
|
||||
glm::vec3 coordinates = glm::vec3( screen_coordinate.x, main_window_attributes_.viewport.y - screen_coordinate.y, 0.f);
|
||||
glm::vec4 viewport = glm::vec4( 0.f, 0.f, main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
|
||||
Log::Info("unproject %d x %d", main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
|
||||
glm::vec3 point = glm::unProject(coordinates, modelview, Projection(), viewport);
|
||||
|
||||
return point;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// gobal static list of all sources
|
||||
SourceList Source::sources_;
|
||||
|
||||
Source::Source(std::string name = "") : name_("")
|
||||
Source::Source(std::string name) : name_("")
|
||||
{
|
||||
// set a name
|
||||
rename(name);
|
||||
|
||||
2
Source.h
2
Source.h
@@ -23,7 +23,7 @@ class Source
|
||||
public:
|
||||
// create a source and add it to the list
|
||||
// only subclasses of sources can actually be instanciated
|
||||
Source(std::string name);
|
||||
Source(std::string name = "");
|
||||
virtual ~Source();
|
||||
|
||||
// manipulate name of source
|
||||
|
||||
@@ -159,6 +159,10 @@ void UserInterface::handleMouse()
|
||||
{
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
glm::vec2 mousepos(io.MousePos.x * io.DisplayFramebufferScale.y, io.MousePos.y* io.DisplayFramebufferScale.x);
|
||||
static glm::vec2 mouseclic[2];
|
||||
mouseclic[ImGuiMouseButton_Left] = glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Left].x * io.DisplayFramebufferScale.y, io.MouseClickedPos[ImGuiMouseButton_Left].y* io.DisplayFramebufferScale.x);
|
||||
mouseclic[ImGuiMouseButton_Right] = glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Right].x * io.DisplayFramebufferScale.y, io.MouseClickedPos[ImGuiMouseButton_Right].y* io.DisplayFramebufferScale.x);
|
||||
|
||||
// if not on any window
|
||||
if ( !ImGui::IsAnyWindowHovered() && !ImGui::IsAnyWindowFocused() )
|
||||
@@ -178,7 +182,7 @@ void UserInterface::handleMouse()
|
||||
if ( ImGui::IsMouseDragging(ImGuiMouseButton_Right, 10.0f) )
|
||||
{
|
||||
// right mouse drag => drag current view
|
||||
Mixer::manager().currentView()->drag( glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Right].x, io.MouseClickedPos[ImGuiMouseButton_Right].y), glm::vec2(io.MousePos.x, io.MousePos.y));
|
||||
Mixer::manager().currentView()->drag( mouseclic[ImGuiMouseButton_Right], mousepos);
|
||||
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll);
|
||||
}
|
||||
@@ -188,12 +192,8 @@ void UserInterface::handleMouse()
|
||||
if ( ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
|
||||
|
||||
// TODO CONTEXT MENU
|
||||
// Log::Info("Right Mouse press (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
|
||||
|
||||
glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y),
|
||||
Mixer::manager().currentView()->scene.root()->transform_ );
|
||||
|
||||
Log::Info(" (%.1f,%.1f)", point.x, point.y);
|
||||
// glm::vec3 point = Rendering::manager().unProject(mousepos, Mixer::manager().currentView()->scene.root()->transform_ );
|
||||
|
||||
|
||||
}
|
||||
@@ -208,7 +208,7 @@ void UserInterface::handleMouse()
|
||||
if (current)
|
||||
{
|
||||
// drag current source
|
||||
Mixer::manager().currentView()->grab( glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Left].x, io.MouseClickedPos[ImGuiMouseButton_Left].y), glm::vec2(io.MousePos.x, io.MousePos.y), current);
|
||||
Mixer::manager().currentView()->grab( mouseclic[ImGuiMouseButton_Left], mousepos, current);
|
||||
|
||||
}
|
||||
else {
|
||||
@@ -224,7 +224,7 @@ void UserInterface::handleMouse()
|
||||
else if ( ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
||||
|
||||
// get coordinate in world view of mouse cursor
|
||||
glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y));
|
||||
glm::vec3 point = Rendering::manager().unProject(mousepos);
|
||||
|
||||
// picking visitor traverses the scene
|
||||
PickingVisitor pv(point);
|
||||
@@ -239,18 +239,7 @@ void UserInterface::handleMouse()
|
||||
}
|
||||
else if ( ImGui::IsMouseReleased(ImGuiMouseButton_Left) )
|
||||
{
|
||||
// Log::Info("Mouse press (%.1f,%.1f)", io.MousePos.x, io.MousePos.y);
|
||||
// glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y));
|
||||
// // Log::Info(" (%.1f,%.1f)", point.x, point.y);
|
||||
// PickingVisitor pv(point);
|
||||
// Mixer::manager().currentView()->scene.accept(pv);
|
||||
|
||||
// if (pv.picked().empty())
|
||||
// Mixer::manager().unsetCurrentSource();
|
||||
// else
|
||||
// Mixer::manager().setCurrentSource(pv.picked().back());
|
||||
|
||||
// // Log::Info(" %d picked", pv.picked().size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
6
View.h
6
View.h
@@ -34,9 +34,9 @@ public:
|
||||
~MixingView();
|
||||
|
||||
void draw () override;
|
||||
void zoom (float factor);
|
||||
void drag (glm::vec2 from, glm::vec2 to);
|
||||
void grab (glm::vec2 from, glm::vec2 to, Source *s);
|
||||
void zoom (float factor) override;
|
||||
void drag (glm::vec2 from, glm::vec2 to) override;
|
||||
void grab (glm::vec2 from, glm::vec2 to, Source *s) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user