📄 mainfrm.cpp
字号:
#define PROGRESS_TIMER 20#define PROGRESS_REFRESH_MS 100void CALLBACK EXPORT ProgressTimer(HWND , UINT , UINT nID , DWORD ){ u32 now; if (nID != PROGRESS_TIMER) return; WinGPAC *app = GetApp(); CMainFrame *pFrame = (CMainFrame *) app->m_pMainWnd; /*shutdown*/ if (!pFrame) return; now = gf_term_get_time_in_ms(app->m_term); if (!now) return; if (app->can_seek && !pFrame->m_Sliders.m_grabbed) { if (now >= app->max_duration + 100) { if (gf_term_get_option(app->m_term, GF_OPT_IS_FINISHED)) { pFrame->m_pPlayList->PlayNext(); } /*if no IsOver go on forever*/ } else { if (!app->m_reset) pFrame->m_Sliders.m_PosSlider.SetPos(now); } }}void CMainFrame::SetProgTimer(Bool bOn) { if (bOn) SetTimer(PROGRESS_TIMER, PROGRESS_REFRESH_MS, ProgressTimer); else KillTimer(PROGRESS_TIMER);}LONG CMainFrame::Open(WPARAM wParam, LPARAM lParam){ Bool do_pause; WinGPAC *app = GetApp(); CString txt, url; m_bStartupFile = FALSE; txt = "Osmo4 - "; txt += m_pPlayList->GetDisplayName(); url = m_pPlayList->GetURL(); m_Address.m_Address.SetWindowText(url); SetWindowText(txt); if (app->start_mode==1) do_pause = 1; else if (app->start_mode==2) do_pause = 0; else do_pause = /*!app->m_AutoPlay*/0; gf_term_connect_from_time(app->m_term, (LPCSTR) url, app->m_reconnect_time, do_pause); app->m_reconnect_time = 0; app->start_mode = 0; app->UpdatePlayButton(); nb_viewpoints = 0; return 1; }LONG CMainFrame::NewInstanceOpened(WPARAM wParam, LPARAM lParam){ Bool queue_only = 0; char *url = (char *) static_gpac_get_url(); if (!strnicmp(url, "-queue ", 7)) { queue_only = 1; url += 7; } m_pPlayList->QueueURL(url); m_pPlayList->RefreshList(); if (!queue_only) m_pPlayList->PlayNext(); return 1;}void CMainFrame::ForwardMessage(){ const MSG *msg = GetCurrentMessage(); m_pWndView->SendMessage(msg->message, msg->wParam, msg->lParam);}void CMainFrame::OnSysKeyUp(UINT , UINT , UINT ) { ForwardMessage(); }void CMainFrame::OnSysKeyDown(UINT , UINT , UINT ) { ForwardMessage(); }void CMainFrame::OnChar(UINT , UINT , UINT ) { ForwardMessage(); }void CMainFrame::OnKeyDown(UINT , UINT , UINT ) { ForwardMessage(); }void CMainFrame::OnKeyUp(UINT , UINT , UINT ) { ForwardMessage(); }void CMainFrame::OnLButtonDown(UINT , CPoint ) { ForwardMessage(); }void CMainFrame::OnLButtonDblClk(UINT , CPoint ) { ForwardMessage(); }void CMainFrame::OnLButtonUp(UINT , CPoint ) { ForwardMessage(); }void CMainFrame::OnDropFiles(HDROP hDropInfo) { u32 i, count; WinGPAC *app = GetApp(); char fileName[MAX_PATH]; count = ::DragQueryFile(hDropInfo, 0xFFFFFFFF, NULL, 0); if (!count) return; /*if playing and sub d&d, open sub in current presentation*/ if (app->m_isopen && (count==1)) { ::DragQueryFile(hDropInfo, 0, fileName, MAX_PATH); char *ext = strrchr(fileName, '.'); if (ext && ( !stricmp(ext, ".srt") || !stricmp(ext, ".sub") || !stricmp(ext, ".ttxt") || !stricmp(ext, ".xml") ) ) { AddSubtitle(fileName, 1); return; } } if (count==1) m_pPlayList->Truncate(); else m_pPlayList->Clear(); for (i=0; i<count; i++) { ::DragQueryFile (hDropInfo, i, fileName, MAX_PATH); m_pPlayList->QueueURL(fileName); } m_pPlayList->RefreshList(); m_pPlayList->PlayNext();}void CALLBACK EXPORT ConsoleTimer(HWND , UINT , UINT , DWORD ){ CMainFrame *pFrame = (CMainFrame *) GetApp()->m_pMainWnd; pFrame->m_wndStatusBar.GetStatusBarCtrl().SetIcon(2, NULL); pFrame->KillTimer(pFrame->m_timer_on); pFrame->m_timer_on = 0; pFrame->m_wndStatusBar.SetPaneText(1, "Ready");}#define CONSOLE_DISPLAY_TIME 1000LONG CMainFrame::OnConsoleMessage(WPARAM wParam, LPARAM lParam){ if (m_timer_on) KillTimer(m_timer_on); if (console_err>=0) { m_wndStatusBar.GetStatusBarCtrl().SetIcon(2, m_icomessage); m_wndStatusBar.SetPaneText(1, console_message); } else { char msg[5000]; m_wndStatusBar.GetStatusBarCtrl().SetIcon(2, m_icoerror); sprintf(msg, "%s (%s)", console_message, console_service); m_wndStatusBar.SetPaneText(1, msg); } m_timer_on = SetTimer(10, wParam ? wParam : CONSOLE_DISPLAY_TIME, ConsoleTimer); return 0;}BOOL CMainFrame::DestroyWindow() { if (GetApp()->m_isopen) KillTimer(PROGRESS_TIMER); /*signal close to prevent callbacks but don't close, this is done in ExitInstance (otherwise there's a deadlock happening not sure why yet)*/// GetApp()->m_open = 0; return CFrameWnd::DestroyWindow();}void CMainFrame::OnViewOriginal() { WinGPAC *gpac = GetApp(); gf_term_set_option(gpac->m_term, GF_OPT_ORIGINAL_VIEW, 1); OnSetSize(gpac->orig_width, gpac->orig_height);}void CMainFrame::SetFullscreen() { WinGPAC *gpac = GetApp(); if (!m_bFullScreen) {// GetWindowRect(&backup_wnd_rc); if (gf_term_set_option(gpac->m_term, GF_OPT_FULLSCREEN, 1) == GF_OK) m_bFullScreen = 1; } else { if (gf_term_set_option(gpac->m_term, GF_OPT_FULLSCREEN, 0) == GF_OK) m_bFullScreen = 0;// SetWindowPos(NULL, backup_wnd_rc.left, backup_wnd_rc.top, backup_wnd_rc.right-backup_wnd_rc.left, backup_wnd_rc.bottom-backup_wnd_rc.top, SWP_NOZORDER); }}void CMainFrame::OnViewFullscreen() { SetFullscreen();}void CMainFrame::OnArKeep() { gf_term_set_option(GetApp()->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); m_aspect_ratio = GF_ASPECT_RATIO_KEEP;}void CMainFrame::OnArFill() { gf_term_set_option(GetApp()->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); m_aspect_ratio = GF_ASPECT_RATIO_FILL_SCREEN;}void CMainFrame::OnAr43() { gf_term_set_option(GetApp()->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); m_aspect_ratio = GF_ASPECT_RATIO_4_3;}void CMainFrame::OnAr169() { gf_term_set_option(GetApp()->m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); m_aspect_ratio = GF_ASPECT_RATIO_16_9;}void CMainFrame::OnUpdateAr169(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_aspect_ratio == GF_ASPECT_RATIO_16_9);}void CMainFrame::OnUpdateAr43(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_aspect_ratio == GF_ASPECT_RATIO_4_3);}void CMainFrame::OnUpdateArFill(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_aspect_ratio == GF_ASPECT_RATIO_FILL_SCREEN);}void CMainFrame::OnUpdateArKeep(CCmdUI* pCmdUI) { pCmdUI->SetCheck(m_aspect_ratio == GF_ASPECT_RATIO_KEEP);}void CMainFrame::OnUpdateNavigate(CCmdUI* pCmdUI){ BOOL enable; WinGPAC *app = GetApp(); pCmdUI->Enable(FALSE); if (!app->m_isopen) return; u32 type = gf_term_get_option(app->m_term, GF_OPT_NAVIGATION_TYPE); enable = type ? TRUE : FALSE; if (pCmdUI->m_nID==ID_NAV_RESET) { pCmdUI->Enable(TRUE); return; } u32 mode = gf_term_get_option(app->m_term, GF_OPT_NAVIGATION); /*common 2D/3D modes*/ if (pCmdUI->m_nID==ID_NAVIGATE_NONE) { pCmdUI->Enable(enable); pCmdUI->SetCheck(mode ? 0 : 1); } else if (pCmdUI->m_nID==ID_NAVIGATE_EXAM) { pCmdUI->Enable(enable); pCmdUI->SetCheck((mode==GF_NAVIGATE_EXAMINE) ? 1 : 0); } else if (pCmdUI->m_nID==ID_NAVIGATE_SLIDE) { pCmdUI->Enable(enable); pCmdUI->SetCheck((mode==GF_NAVIGATE_SLIDE) ? 1 : 0); } if (type==GF_NAVIGATE_TYPE_2D) return; pCmdUI->Enable(enable); if (pCmdUI->m_nID==ID_NAVIGATE_WALK) pCmdUI->SetCheck((mode==GF_NAVIGATE_WALK) ? 1 : 0); else if (pCmdUI->m_nID==ID_NAVIGATE_FLY) pCmdUI->SetCheck((mode==GF_NAVIGATE_FLY) ? 1 : 0); else if (pCmdUI->m_nID==ID_NAVIGATE_PAN) pCmdUI->SetCheck((mode==GF_NAVIGATE_PAN) ? 1 : 0); else if (pCmdUI->m_nID==ID_NAVIGATE_VR) pCmdUI->SetCheck((mode==GF_NAVIGATE_VR) ? 1 : 0); else if (pCmdUI->m_nID==ID_NAVIGATE_GAME) pCmdUI->SetCheck((mode==GF_NAVIGATE_GAME) ? 1 : 0);}void CMainFrame::SetNavigate(u32 mode){ WinGPAC *app = GetApp(); gf_term_set_option(app->m_term, GF_OPT_NAVIGATION, mode);}void CMainFrame::OnNavigateNone() { SetNavigate(GF_NAVIGATE_NONE); }void CMainFrame::OnNavigateWalk() { SetNavigate(GF_NAVIGATE_WALK); }void CMainFrame::OnNavigateFly() { SetNavigate(GF_NAVIGATE_FLY); }void CMainFrame::OnNavigateExam() { SetNavigate(GF_NAVIGATE_EXAMINE); }void CMainFrame::OnNavigateSlide() { SetNavigate(GF_NAVIGATE_SLIDE); }void CMainFrame::OnNavigatePan() { SetNavigate(GF_NAVIGATE_PAN); }void CMainFrame::OnNavigateOrbit() { SetNavigate(GF_NAVIGATE_ORBIT); }void CMainFrame::OnNavigateVR() { SetNavigate(GF_NAVIGATE_VR); }void CMainFrame::OnNavigateGame() { SetNavigate(GF_NAVIGATE_GAME); }void CMainFrame::OnNavigateReset(){ WinGPAC *app = GetApp(); gf_term_set_option(app->m_term, GF_OPT_NAVIGATION_TYPE, 0);}LONG CMainFrame::OnNavigate(WPARAM /*wParam*/, LPARAM /*lParam*/){ WinGPAC *gpac = GetApp(); if (gf_term_is_supported_url(gpac->m_term, gpac->m_navigate_url, 1, gpac->m_NoMimeFetch)) { char *str = gf_url_concatenate(m_pPlayList->GetURL(), gpac->m_navigate_url); if (str) { m_pPlayList->Truncate(); m_pPlayList->QueueURL(str); free(str); m_pPlayList->RefreshList(); m_pPlayList->PlayNext(); return 0; } } if (m_bFullScreen) { SetFullscreen(); m_bRestoreFS = 1; } console_message = gpac->m_navigate_url; console_err = GF_OK; PostMessage(WM_CONSOLEMSG); ShellExecute(NULL, "open", (LPCSTR) gpac->m_navigate_url, NULL, NULL, SW_SHOWNORMAL); return 0;}void CMainFrame::OnFileProp() { if (!m_pProps) { m_pProps = new CFileProps(this); m_pProps->Create(this); } m_pProps->ShowWindow(SW_SHOW);}void CMainFrame::OnUpdateFileProp(CCmdUI* pCmdUI) { pCmdUI->Enable(GetApp()->m_isopen); }void CMainFrame::OnConfigure() { if (!m_pOpt) { m_pOpt = new COptions(this); m_pOpt->Create(this); } m_pOpt->ShowWindow(SW_SHOW);}void CMainFrame::OnShortcuts() { MessageBox( "Open File: Ctrl + O\n" "Open URL: Ctrl + U\n" "Reload File: Ctrl + R\n" "Pause/Resume File: Ctrl + P\n" "Step by Step: Ctrl + S\n" "Seek +5%: Alt + left arrow\n" "Seek -5%: Alt + right arrow\n" "Seek +1min: Alt + up arrow\n" "Seek -1min: Alt + down arrow\n" "Fullscreen On/Off: Alt+Return or Escape\n" "\n" "Show Properties: Ctrl + I\n" "Show Playlist: Ctrl + V\n" "Next Playlist Item: Ctrl + right arrow\n" "Previous Playlist Item: Ctrl + left arrow\n" "\n" "Aspect Ratio Normal: Ctrl + 1\n" "Aspect Ratio Fill: Ctrl + 2\n" "Aspect Ratio 4/3: Ctrl + 3\n" "Aspect Ratio 16/9: Ctrl + 4\n" , "Shortcuts Available on Osmo4", MB_OK);}void CMainFrame::OnNavInfo() { MessageBox( "* Walk & Fly modes:\n" "\tH move: H pan - V move: Z-translate - V move+CTRL or Wheel: V pan - Right Click (Walk only): Jump\n" "\tleft/right: H pan - left/right+CTRL: H translate - up/down: Z-translate - up/down+CTRL: V pan\n" "* Pan mode:\n" "\tH move: H pan - V move: V pan - V move+CTRL or Wheel: Z-translate\n" "\tleft/right: H pan - left/right+CTRL: H translate - up/down: V pan - up/down+CTRL: Z-translate\n" "* Slide mode:\n" "\tH move: H translate - V move: V translate - V move+CTRL or Wheel: Z-translate\n" "\tleft/right: H translate - left/right+CTRL: H pan - up/down: V translate - up/down+CTRL: Z-translate\n" "* Examine & Orbit mode:\n" "\tH move: Y-Axis rotate - H move+CTRL: Z-Axis rotate - V move: X-Axis rotate - V move+CTRL or Wheel: Z-translate\n" "\tleft/right: Y-Axis rotate - left/right+CTRL: H translate - up/down: X-Axis rotate - up/down+CTRL: Y-translate\n" "* VR mode:\n" "\tH move: H pan - V move: V pan - V move+CTRL or Wheel: Camera Zoom\n" "\tleft/right: H pan - up/down: V pan - up/down+CTRL: Camera Zoom\n" "* Game mode (press END to escape):\n" "\tH move: H pan - V move: V pan\n" "\tleft/right: H translate - up/down: Z-translate\n" "\n" "* All 3D modes: CTRL+PGUP/PGDOWN will zoom in/out camera (field of view) \n" "\n" "*Slide Mode in 2D:\n" "\tH move: H translate - V move: V translate - V move+CTRL: zoom\n" "\tleft/right: H translate - up/down: V translate - up/down+CTRL: zoom\n" "*Examine Mode in 2D (3D renderer only):\n" "\tH move: Y-Axis rotate - V move: X-Axis rotate\n" "\tleft/right: Y-Axis rotate - up/down: X-Axis rotate\n" "\n" "HOME: reset navigation to last viewpoint (2D or 3D navigation)\n" "SHIFT key in all modes: fast movement\n" , "3D navigation keys (\'H\'orizontal and \'V\'ertical) used in GPAC", MB_OK);}void CMainFrame::BuildViewList(){ WinGPAC *app = GetApp(); if (!app->m_isopen) return; /*THIS IS HARCODED FROM THE MENU LAYOUT */ CMenu *pMenu = GetMenu()->GetSubMenu(1)->GetSubMenu(0); while (pMenu->GetMenuItemCount()) pMenu->DeleteMenu(0, MF_BYPOSITION); s32 id = ID_VP_0; nb_viewpoints = 0; while (1) { const char *szName; Bool bound; GF_Err e = gf_term_get_viewpoint(app->m_term, nb_viewpoints+1, &szName, &bound); if (e) break; if (szName) { pMenu->AppendMenu(MF_ENABLED, id+nb_viewpoints, szName); } else { char szLabel[1024]; sprintf(szLabel, "Viewpoint #%d", nb_viewpoints+1); pMenu->AppendMenu(MF_ENABLED, id+nb_viewpoints, szLabel); } nb_viewpoints++; if (nb_viewpoints==ID_VP_19-ID_VP_0) break; }}void CMainFrame::BuildStreamList(Bool reset_only){ u32 nb_subs; CMenu *pSelect; WinGPAC *app = GetApp(); pSelect = GetMenu()->GetSubMenu(2)->GetSubMenu(0); /*THIS IS HARCODED FROM THE MENU LAYOUT */ CMenu *pMenu = pSelect->GetSubMenu(0); while (pMenu->GetMenuItemCount()) pMenu->DeleteMenu(0, MF_BYPOSITION); pMenu = pSelect->GetSubMenu(1); while (pMenu->GetMenuItemCount()) pMenu->DeleteMenu(0, MF_BYPOSITION); pMenu = pSelect->GetSubMenu(2); while (pMenu->GetMenuItemCount()) pMenu->DeleteMenu(0, MF_BYPOSITION); if (reset_only) { m_bFirstStreamQuery = 1; return; } if (!app->m_isopen || !gf_term_get_option(app->m_term, GF_OPT_CAN_SELECT_STREAMS)) return; GF_ObjectManager *root_od = gf_term_get_root_object(app->m_term); if (!root_od) return; u32 count = gf_term_get_object_count(app->m_term, root_od); nb_subs = 0; for (u32 i=0; i<count; i++) { char szLabel[1024]; ODInfo info; GF_ObjectManager *odm = gf_term_get_object(app->m_term, root_od, i); if (!odm) return; if (gf_term_get_object_info(app->m_term, odm, &info) != GF_OK) break; if (info.owns_service) { char *szName = strrchr(info.service_url, '\\'); if (!szName) szName = strrchr(info.service_url, '/'); if (!szName) szName = (char *) info.service_url; else szName += 1; strcpy(szLabel, szName); szName = strrchr(szLabel, '.'); if (szName) szName[0] = 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -