Skip to content

Commit

Permalink
Add an 'Is timestamped?' column to the manual search result table
Browse files Browse the repository at this point in the history
Resolves #40
  • Loading branch information
jacquesh committed Aug 29, 2024
1 parent 34f910c commit 8f72113
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/foo_openlyrics.rc
Original file line number Diff line number Diff line change
Expand Up @@ -426,24 +426,24 @@ BEGIN
GROUPBOX "Playback",IDC_STATIC,6,114,148,50
END

IDD_MANUAL_SEARCH DIALOGEX 0, 0, 649, 281
IDD_MANUAL_SEARCH DIALOGEX 0, 0, 745, 281
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Search for lyrics"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDC_MANUALSEARCH_OK,479,260,50,14
PUSHBUTTON "Cancel",IDC_MANUALSEARCH_CANCEL,536,260,50,14
EDITTEXT IDC_MANUALSEARCH_TITLE,32,16,108,14,ES_AUTOHSCROLL
EDITTEXT IDC_MANUALSEARCH_ALBUM,175,16,89,14,ES_AUTOHSCROLL
EDITTEXT IDC_MANUALSEARCH_ARTIST,299,16,79,14,ES_AUTOHSCROLL
EDITTEXT IDC_MANUALSEARCH_ALBUM,207,16,108,14,ES_AUTOHSCROLL
EDITTEXT IDC_MANUALSEARCH_ARTIST,366,16,108,14,ES_AUTOHSCROLL
LTEXT "Title:",IDC_STATIC,12,18,15,8
LTEXT "Album:",IDC_STATIC,149,18,26,8
LTEXT "Artist:",IDC_STATIC,275,18,21,8
CONTROL "",IDC_MANUALSEARCH_RESULTLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,66,371,185
EDITTEXT IDC_MANUALSEARCH_PREVIEW,390,7,252,245,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
LTEXT "Album:",IDC_STATIC,180,18,26,8
LTEXT "Artist:",IDC_STATIC,342,18,21,8
CONTROL "",IDC_MANUALSEARCH_RESULTLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,66,467,185
EDITTEXT IDC_MANUALSEARCH_PREVIEW,486,7,252,245,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
LTEXT "Click 'Search' to start searching",IDC_MANUALSEARCH_PROGRESS,66,44,228,8
PUSHBUTTON "Search",IDC_MANUALSEARCH_SEARCH,7,41,50,14
PUSHBUTTON "Apply",IDC_MANUALSEARCH_APPLY,592,260,50,14
PUSHBUTTON "Apply",IDC_MANUALSEARCH_APPLY,688,260,50,14
END

IDD_BULK_SEARCH DIALOGEX 0, 0, 309, 176
Expand Down Expand Up @@ -477,7 +477,7 @@ BEGIN
IDD_MANUAL_SEARCH, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 642
RIGHTMARGIN, 738
TOPMARGIN, 7
BOTTOMMARGIN, 274
END
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void OpenLyricsVersion::get_about_message(pfc::string_base & out)
"- Add an auto-edit for removing surrounding whitespace from lyrics lines\n"
" - This is enabled by default for auto-application to new lyrics\n"
" - The new default will only apply to new OpenLyrics users\n"
"- Add an 'Is timestamped?' column to the manual search result table\n"
"- Update the foobar2000 SDK to version 20230913\n"
"- Change default local file name format to replace invalid characters\n"
" - Applies to new users only. Existing users' settings won't be changed\n"
Expand Down
25 changes: 24 additions & 1 deletion src/ui_lyric_manual_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static const GUID GUID_CFG_TITLE_COLUMN_WIDTH = { 0x18d967fe, 0xad07, 0x464c, {
static const GUID GUID_CFG_ALBUM_COLUMN_WIDTH = { 0x7ac61807, 0x57a2, 0x4880, { 0xba, 0x6d, 0xb2, 0x35, 0xf9, 0x88, 0x5a, 0x60 } };
static const GUID GUID_CFG_ARTIST_COLUMN_WIDTH = { 0xdebf2d4e, 0xfb93, 0x4a3f, { 0xb6, 0x3e, 0x84, 0x3f, 0x89, 0xa9, 0x86, 0xba } };
static const GUID GUID_CFG_SOURCE_COLUMN_WIDTH = { 0x44350ccb, 0xf62a, 0x4d47, { 0x9a, 0xeb, 0x5a, 0x7a, 0xc4, 0xce, 0x75, 0xa1 } };
static const GUID GUID_CFG_TIMESTAMPED_COLUMN_WIDTH = { 0xe99dc1c7, 0x7224, 0x4b4d, { 0x8e, 0xd1, 0x90, 0xae, 0x51, 0xbb, 0x6b, 0xa2 } };

// Without enforcing a minimum width, we could end up with columns being 0px wide
// (either as a result of user resizing or a bug that breaks the width persistence).
Expand All @@ -30,6 +31,7 @@ static cfg_int_t<int> cfg_title_column_width(GUID_CFG_TITLE_COLUMN_WIDTH, 160);
static cfg_int_t<int> cfg_album_column_width(GUID_CFG_ALBUM_COLUMN_WIDTH, 160);
static cfg_int_t<int> cfg_artist_column_width(GUID_CFG_ARTIST_COLUMN_WIDTH, 128);
static cfg_int_t<int> cfg_source_column_width(GUID_CFG_SOURCE_COLUMN_WIDTH, 96);
static cfg_int_t<int> cfg_timestamped_column_width(GUID_CFG_TIMESTAMPED_COLUMN_WIDTH, 96);

class ManualLyricSearch : public CDialogImpl<ManualLyricSearch>
{
Expand Down Expand Up @@ -131,6 +133,14 @@ BOOL ManualLyricSearch::OnInitDialog(CWindow /*parent*/, LPARAM /*clientData*/)
LRESULT source_index = SendDlgItemMessage(IDC_MANUALSEARCH_RESULTLIST, LVM_INSERTCOLUMN, 3, (LPARAM)&source_column);
assert(source_index >= 0);

LVCOLUMN timestamped_column = {};
timestamped_column.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH;
timestamped_column.fmt = LVCFMT_LEFT;
timestamped_column.pszText = _T("Is timestamped?");
timestamped_column.cx = std::max(MIN_COLUMN_WIDTH_PX, cfg_timestamped_column_width.get_value());
LRESULT timestamped_index = SendDlgItemMessage(IDC_MANUALSEARCH_RESULTLIST, LVM_INSERTCOLUMN, 4, (LPARAM)&timestamped_column);
assert(timestamped_index >= 0);

SetDlgItemText(IDC_MANUALSEARCH_PROGRESS, _T("Searching..."));
SendDlgItemMessage(IDC_MANUALSEARCH_RESULTLIST, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);

Expand Down Expand Up @@ -176,6 +186,10 @@ void ManualLyricSearch::OnDestroyDialog()
assert(std::tstring_view(column_data.pszText) == _T("Source"));
cfg_source_column_width = column_data.cx;

ListView_GetColumn(GetDlgItem(IDC_MANUALSEARCH_RESULTLIST), 4, &column_data);
assert(std::tstring_view(column_data.pszText) == _T("Is timestamped?"));
cfg_timestamped_column_width = column_data.cx;

m_child_abort.abort();
if(m_child_search.has_value())
{
Expand Down Expand Up @@ -213,7 +227,7 @@ static int CALLBACK column_sort_fn(LPARAM lparam1, LPARAM lparam2, LPARAM sort_d
case 0: return order_factor * item1->title.compare(item2->title);
case 1: return order_factor * item1->album.compare(item2->album);
case 2: return order_factor * item1->artist.compare(item2->artist);
case 3:
case 3: // Source
{
LyricSourceBase* source1 = LyricSourceBase::get(item1->source_id);
LyricSourceBase* source2 = LyricSourceBase::get(item2->source_id);
Expand All @@ -227,6 +241,7 @@ static int CALLBACK column_sort_fn(LPARAM lparam1, LPARAM lparam2, LPARAM sort_d
return -1;
}
} break;
case 4: return order_factor * (int(item1->IsTimestamped()) - int(item2->IsTimestamped()));

default:
LOG_ERROR("Unexpected sort column index %d", sort_column_index);
Expand Down Expand Up @@ -484,6 +499,14 @@ LRESULT ManualLyricSearch::OnTimer(WPARAM)
LRESULT source_success = SendDlgItemMessageW(IDC_MANUALSEARCH_RESULTLIST, LVM_SETITEMTEXT, item_index, (LPARAM)&subitem_source);
assert(source_success);

LVITEM subitem_timestamped = {};
subitem_timestamped.mask = LVIF_TEXT;
subitem_timestamped.iItem = item_index;
subitem_timestamped.iSubItem = 4;
subitem_timestamped.pszText = const_cast<TCHAR*>(lyrics.IsTimestamped() ? _T("Yes") : _T("No"));
LRESULT timestamped_success = SendDlgItemMessageW(IDC_MANUALSEARCH_RESULTLIST, LVM_SETITEMTEXT, item_index, (LPARAM)&subitem_timestamped);
assert(timestamped_success);

bool is_first_entry = (m_all_lyrics.size() == 1);
if(is_first_entry)
{
Expand Down

0 comments on commit 8f72113

Please sign in to comment.