123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- #include "MKVInfo.h"
- #include "api__in_mkv.h"
- #include "../nu/ListView.h"
- #include "../nu/AutoWide.h"
- #include "resource.h"
- #include "main.h"
- #include <strsafe.h>
- enum
- {
- COLUMN_TRACK_TYPE = 0,
- COLUMN_CODEC_NAME = 1,
- COLUMN_CODEC_ID = 2,
- COLUMN_DESCRIPTION = 3,
- COLUMN_STREAM_NAME = 4,
- COLUMN_LANGUAGE = 5,
- };
- #if 0
- static INT_PTR CALLBACK InfoDialog_Metadata(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- nsavi::Metadata *metadata = (nsavi::Metadata *)lParam;
- SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam);
- W_ListView list_view(hwndDlg, IDC_TRACKLIST);
- list_view.AddCol(L"Field", 100);
- list_view.AddCol(L"FOURCC", 75);
- list_view.AddCol(L"Value", 250);
- nsavi::Info *info;
- if (metadata->GetInfo(&info) == nsavi::READ_OK)
- {
- int n=0;
- for (nsavi::Info::const_iterator itr = info->begin();itr!=info->end();itr++)
- {
- const wchar_t *field_name = FindKnownName(known_fields, sizeof(known_fields)/sizeof(known_fields[0]), itr->first);
- wchar_t fourcc[5] = {0};
- MakeStringFromFOURCC(fourcc, itr->first);
- if (field_name)
- n= list_view.AppendItem(field_name, 0);
- else
- n= list_view.AppendItem(fourcc, 0);
- list_view.SetItemText(n, 1, fourcc);
- list_view.SetItemText(n, 2, AutoWide(itr->second, CP_UTF8));
- }
- }
- }
- return 1;
- }
- return 0;
- }
- #endif
- static INT_PTR CALLBACK InfoDialog_Tracks(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- MKVInfo *metadata = (MKVInfo *)lParam;
- SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam);
- W_ListView list_view(hwndDlg, IDC_TRACKLIST);
- list_view.AddCol(WASABI_API_LNGSTRINGW(IDS_COLUMN_TRACK_TYPE), 100);
- list_view.AddCol(WASABI_API_LNGSTRINGW(IDS_COLUMN_CODEC_NAME), 100);
- list_view.AddCol(WASABI_API_LNGSTRINGW(IDS_COLUMN_CODEC_ID), 75);
- list_view.AddCol(WASABI_API_LNGSTRINGW(IDS_COLUMN_DESCRIPTION), 100);
- list_view.AddCol(WASABI_API_LNGSTRINGW(IDS_COLUMN_STREAM_NAME), 100);
- list_view.AddCol(WASABI_API_LNGSTRINGW(IDS_COLUMN_LANGUAGE), 50);
- const nsmkv::Tracks *tracks = metadata->GetTracks();
- if (tracks)
- {
- const nsmkv::TrackEntry *track_entry;
- size_t i=0;
- while (track_entry = tracks->EnumTrack(i++))
- {
- int n;
- switch(track_entry->track_type)
- {
- case mkv_track_type_audio:
- {
- n = list_view.AppendItem(WASABI_API_LNGSTRINGW(IDS_TYPE_AUDIO), 0);
- }
- break;
- case mkv_track_type_video:
- {
- n = list_view.AppendItem(WASABI_API_LNGSTRINGW(IDS_TYPE_VIDEO), 0);
- }
- break;
- case mkv_track_type_subtitle:
- {
- n = list_view.AppendItem(WASABI_API_LNGSTRINGW(IDS_TYPE_SUBTITLE), 0);
- }
- break;
- default:
- {
- wchar_t track_type[64] = {0};
- StringCchPrintf(track_type, 64, L"%X", track_entry->track_type);
- n = list_view.AppendItem(track_type, 0);
- }
- break;
- }
- if (track_entry->codec_id)
- list_view.SetItemText(n, COLUMN_CODEC_ID, AutoWide(track_entry->codec_id, CP_UTF8));
- if (track_entry->codec_name)
- {
- list_view.SetItemText(n, COLUMN_CODEC_NAME, AutoWide(track_entry->codec_name, CP_UTF8));
- }
- else
- {
- // TODO: enumerate through a list of known codecs
- if (track_entry->codec_id)
- list_view.SetItemText(n, COLUMN_CODEC_NAME, AutoWide(track_entry->codec_id, CP_UTF8));
- }
- if (track_entry->name)
- {
- list_view.SetItemText(n, COLUMN_STREAM_NAME, AutoWide(track_entry->name, CP_UTF8));
- }
- if (track_entry->language && stricmp(track_entry->language, "und"))
- {
- list_view.SetItemText(n, COLUMN_LANGUAGE, AutoWide(track_entry->language, CP_UTF8));
- }
- }
- }
-
- }
- return 1;
- case WM_SIZE:
- {
- RECT r;
- GetClientRect(hwndDlg, &r);
- SetWindowPos(GetDlgItem(hwndDlg, IDC_TRACKLIST), HWND_TOP, r.left, r.top, r.right, r.bottom, SWP_NOACTIVATE);
- }
- break;
- }
- return 0;
- }
- struct InfoDialogContext
- {
- MKVInfo *metadata;
- HWND active_tab;
- };
- static VOID WINAPI OnSelChanged(HWND hwndDlg, HWND hwndTab, InfoDialogContext *context)
- {
- if (context->active_tab)
- {
- DestroyWindow(context->active_tab);
- }
- int selection = TabCtrl_GetCurSel(hwndTab);
- switch(selection)
- {
- case 0:
- context->active_tab = WASABI_API_CREATEDIALOGPARAMW(IDD_TRACKS, hwndDlg, InfoDialog_Tracks, (LPARAM)context->metadata);
-
- break;
- case 1:
- // context->active_tab = WASABI_API_CREATEDIALOGPARAMW(IDD_TRACKS, hwndDlg, InfoDialog_Metadata, (LPARAM)context->metadata);
- break;
- }
- RECT r;
- GetWindowRect(hwndTab,&r);
- TabCtrl_AdjustRect(hwndTab,FALSE,&r);
- MapWindowPoints(NULL,hwndDlg,(LPPOINT)&r,2);
- SetWindowPos(context->active_tab,HWND_TOP,r.left,r.top,r.right-r.left,r.bottom-r.top,SWP_NOACTIVATE);
- ShowWindow(context->active_tab, SW_SHOWNA);
- if (GetFocus() != hwndTab)
- {
- SetFocus(context->active_tab);
- }
- }
- INT_PTR CALLBACK InfoDialog(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_INITDIALOG:
- {
- HWND hwndTab = GetDlgItem(hwndDlg,IDC_TAB1);
- InfoDialogContext *context = (InfoDialogContext *)calloc(1, sizeof(InfoDialogContext));
- context->metadata = (MKVInfo *)lParam;
- context->active_tab = 0;
- SetWindowLongPtr(hwndDlg,GWLP_USERDATA, (LPARAM)context);
- TCITEMW tie;
- tie.mask = TCIF_TEXT;
- tie.pszText = WASABI_API_LNGSTRINGW(IDS_TAB_TRACKS);
- SendMessageW(hwndTab, TCM_INSERTITEMW, 0, (LPARAM)&tie);
- OnSelChanged(hwndDlg, hwndTab, context);
- }
- return 1;
- case WM_DESTROY:
- {
- InfoDialogContext *context = (InfoDialogContext *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- free(context);
- }
- break;
- case WM_NOTIFY:
- {
- LPNMHDR lpn = (LPNMHDR) lParam;
- if (lpn && lpn->code==TCN_SELCHANGE)
- {
- InfoDialogContext *context = (InfoDialogContext *)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
- OnSelChanged(hwndDlg,GetDlgItem(hwndDlg,IDC_TAB1),context);
- }
- }
- break;
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDOK:
- {
- EndDialog(hwndDlg,0);
- }
- break;
- case IDCANCEL:
- {
- EndDialog(hwndDlg,1);
- }
- break;
- }
- break;
- }
- return 0;
- }
|