| 78 | #define E(cmd) cmd; if (GLenum err = glGetError()) throw OpenGlException(#cmd, err) |
| 79 | |
| 80 | VideoDisplay::VideoDisplay(wxToolBar *toolbar, bool freeSize, wxComboBox *zoomBox, wxWindow *parent, agi::Context *c) |
| 81 | : wxGLCanvas(parent, -1, attribList) |
| 82 | , autohideTools(OPT_GET("Tool/Visual/Autohide")) |
| 83 | , con(c) |
| 84 | , zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125) |
| 85 | , toolBar(toolbar) |
| 86 | , zoomBox(zoomBox) |
| 87 | , freeSize(freeSize) |
| 88 | , retina_helper(std::make_unique<RetinaHelper>(this)) |
| 89 | , scale_factor(retina_helper->GetScaleFactor()) |
| 90 | , scale_factor_connection(retina_helper->AddScaleFactorListener([=, this](int new_scale_factor) { |
| 91 | double new_zoom = zoomValue * new_scale_factor / scale_factor; |
| 92 | scale_factor = new_scale_factor; |
| 93 | SetZoom(new_zoom); |
| 94 | })) |
| 95 | { |
| 96 | zoomBox->SetValue(fmt_wx("%g%%", zoomValue * 100.)); |
| 97 | zoomBox->Bind(wxEVT_COMBOBOX, &VideoDisplay::SetZoomFromBox, this); |
| 98 | zoomBox->Bind(wxEVT_TEXT_ENTER, &VideoDisplay::SetZoomFromBoxText, this); |
| 99 | |
| 100 | con->videoController->Bind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this); |
| 101 | connections = agi::signal::make_vector({ |
| 102 | con->project->AddVideoProviderListener(&VideoDisplay::UpdateSize, this), |
| 103 | con->videoController->AddARChangeListener(&VideoDisplay::UpdateSize, this), |
| 104 | }); |
| 105 | |
| 106 | Bind(wxEVT_PAINT, std::bind(&VideoDisplay::Render, this)); |
| 107 | Bind(wxEVT_SIZE, &VideoDisplay::OnSizeEvent, this); |
| 108 | Bind(wxEVT_CONTEXT_MENU, &VideoDisplay::OnContextMenu, this); |
| 109 | Bind(wxEVT_ENTER_WINDOW, &VideoDisplay::OnMouseEvent, this); |
| 110 | Bind(wxEVT_CHAR_HOOK, &VideoDisplay::OnKeyDown, this); |
| 111 | Bind(wxEVT_LEAVE_WINDOW, &VideoDisplay::OnMouseLeave, this); |
| 112 | Bind(wxEVT_LEFT_DCLICK, &VideoDisplay::OnMouseEvent, this); |
| 113 | Bind(wxEVT_LEFT_DOWN, &VideoDisplay::OnMouseEvent, this); |
| 114 | Bind(wxEVT_LEFT_UP, &VideoDisplay::OnMouseEvent, this); |
| 115 | Bind(wxEVT_MOTION, &VideoDisplay::OnMouseEvent, this); |
| 116 | Bind(wxEVT_MOUSEWHEEL, &VideoDisplay::OnMouseWheel, this); |
| 117 | |
| 118 | SetCursor(wxNullCursor); |
| 119 | |
| 120 | c->videoDisplay = this; |
| 121 | |
| 122 | con->videoController->JumpToFrame(con->videoController->GetFrameN()); |
| 123 | |
| 124 | SetLayoutDirection(wxLayout_LeftToRight); |
| 125 | } |
| 126 | |
| 127 | VideoDisplay::~VideoDisplay () { |
| 128 | Unload(); |
nothing calls this directly
no test coverage detected