X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fcontent_menu.cc;h=642457d933e0f64aa99b8cc05388b48478ca4806;hb=15235c0d2fad7e916cda5b2d6ce79c4e9a38c4f9;hp=78b6469a043249605873dff4889175e8183ca2d6;hpb=c64b6891f6e28c1a7f11871d3dcccdfe75944644;p=dcpomatic.git diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 78b6469a0..642457d93 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -137,7 +137,7 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList _views = v; int const N = _cpl_menu->GetMenuItemCount(); - for (int i = 1; i <= N; ++i) { + for (int i = DCPOMATIC_CPL_MENU; i < DCPOMATIC_CPL_MENU + N; ++i) { _cpl_menu->Delete (i); } @@ -520,15 +520,11 @@ ContentMenu::cpl_selected (wxCommandEvent& ev) DCPOMATIC_ASSERT (dcp); auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true); - DCPOMATIC_ASSERT (ev.GetId() > 0); - DCPOMATIC_ASSERT (ev.GetId() <= int (cpls.size())); - auto i = cpls.begin (); - for (int j = 0; j < ev.GetId() - 1; ++j) { - ++i; - } + DCPOMATIC_ASSERT(ev.GetId() >= DCPOMATIC_CPL_MENU); + DCPOMATIC_ASSERT(ev.GetId() < int(DCPOMATIC_CPL_MENU + cpls.size())); + dcp->set_cpl(cpls[ev.GetId() - DCPOMATIC_CPL_MENU]->id()); - dcp->set_cpl ((*i)->id ()); auto film = _film.lock (); DCPOMATIC_ASSERT (film); JobManager::instance()->add (make_shared(film, dcp)); @@ -548,12 +544,13 @@ ContentMenu::auto_crop () DCPOMATIC_ASSERT (film); auto const content = _content.front(); auto const current_crop = content->video->actual_crop(); + auto const video_size_guess = content->video->size().get_value_or(dcp::Size(1998, 1080)); _viewer.set_crop_guess( dcpomatic::Rect( - static_cast(std::max(0, crop.left - current_crop.left)) / content->video->size().width, - static_cast(std::max(0, crop.top - current_crop.top)) / content->video->size().height, - 1.0f - (static_cast(std::max(0, crop.left - current_crop.left + crop.right - current_crop.right)) / content->video->size().width), - 1.0f - (static_cast(std::max(0, crop.top - current_crop.top + crop.bottom - current_crop.bottom)) / content->video->size().height) + static_cast(std::max(0, crop.left - current_crop.left)) / video_size_guess.width, + static_cast(std::max(0, crop.top - current_crop.top)) / video_size_guess.height, + 1.0f - (static_cast(std::max(0, crop.left - current_crop.left + crop.right - current_crop.right)) / video_size_guess.width), + 1.0f - (static_cast(std::max(0, crop.top - current_crop.top + crop.bottom - current_crop.bottom)) / video_size_guess.height) )); };