From 55387c0f182ea57b1d8e898d78074c89caed01be Mon Sep 17 00:00:00 2001 From: Reupen Shah Date: Thu, 27 Feb 2020 21:09:39 +0000 Subject: [PATCH] Update mmh and fbh This updates mmh and fbh, and makes changes required for the updated `mmh::Permutation` class. --- fbh | 2 +- foo_ui_columns/buttons_config_droptarget.cpp | 2 +- foo_ui_columns/filter.cpp | 2 +- foo_ui_columns/filter_items.cpp | 4 +-- foo_ui_columns/ng_playlist/ng_playlist.cpp | 4 +-- .../ng_playlist/ng_playlist_droptarget.cpp | 34 ++++++++++++------- mmh | 2 +- 7 files changed, 29 insertions(+), 21 deletions(-) diff --git a/fbh b/fbh index d1f621134..a8a67de9e 160000 --- a/fbh +++ b/fbh @@ -1 +1 @@ -Subproject commit d1f6211342edc7f061c8151ef3c6e6c39e2ba377 +Subproject commit a8a67de9ece69341ef950a2fd15c3fd5243f6415 diff --git a/foo_ui_columns/buttons_config_droptarget.cpp b/foo_ui_columns/buttons_config_droptarget.cpp index 83f058fb5..ea68b5c56 100644 --- a/foo_ui_columns/buttons_config_droptarget.cpp +++ b/foo_ui_columns/buttons_config_droptarget.cpp @@ -167,7 +167,7 @@ HRESULT STDMETHODCALLTYPE ButtonsToolbar::ConfigParam::ButtonsList::ButtonsListD mmh::Permutation perm(button_count); for (t_size i = old_index; i != new_index; i += step) - perm.swap_items(i, i + step); + std::swap(perm[i], perm[i + step]); mmh::destructive_reorder(m_button_list_view->m_param.m_buttons, perm); diff --git a/foo_ui_columns/filter.cpp b/foo_ui_columns/filter.cpp index fe91ff972..ca8e987a9 100644 --- a/foo_ui_columns/filter.cpp +++ b/foo_ui_columns/filter.cpp @@ -316,7 +316,7 @@ void FilterPanel::get_windows(pfc::list_base_t& windows) } mmh::Permutation permutation(windows.get_count()); mmh::sort_get_permutation(indices.get_ptr(), permutation, (pfc::compare_t), true, false); - windows.reorder(permutation.get_ptr()); + windows.reorder(permutation.data()); } } diff --git a/foo_ui_columns/filter_items.cpp b/foo_ui_columns/filter_items.cpp index 6f5b5c676..e7c3b1233 100644 --- a/foo_ui_columns/filter_items.cpp +++ b/foo_ui_columns/filter_items.cpp @@ -438,9 +438,9 @@ void FilterPanel::notify_sort_column(t_size index, bool b_descending, bool b_sel ++nodes; mmh::sort_get_permutation(nodes, sort_permuation, Node::g_compare_ptr_with_node, false, b_descending, true); - m_nodes.reorder_partial(1, sort_permuation.get_ptr(), node_count - 1); + m_nodes.reorder_partial(1, sort_permuation.data(), node_count - 1); - reorder_items_partial(1, sort_permuation.get_ptr(), node_count - 1); + reorder_items_partial(1, sort_permuation.data(), node_count - 1); ensure_visible(get_focus_item()); size_t field_index; diff --git a/foo_ui_columns/ng_playlist/ng_playlist.cpp b/foo_ui_columns/ng_playlist/ng_playlist.cpp index 7977411ef..ddb2260b5 100644 --- a/foo_ui_columns/ng_playlist/ng_playlist.cpp +++ b/foo_ui_columns/ng_playlist/ng_playlist.cpp @@ -499,9 +499,9 @@ void PlaylistView::notify_sort_column(t_size index, bool b_descending, bool b_se for (n = 0; n < count2; n++) { order2[source_indices[n]] = source_indices[order[n]]; } - m_playlist_api->activeplaylist_reorder_items(order2.get_ptr(), count); + m_playlist_api->activeplaylist_reorder_items(order2.data(), count); } else - m_playlist_api->activeplaylist_reorder_items(order.get_ptr(), count); + m_playlist_api->activeplaylist_reorder_items(order.data(), count); // if (!selection_only) { diff --git a/foo_ui_columns/ng_playlist/ng_playlist_droptarget.cpp b/foo_ui_columns/ng_playlist/ng_playlist_droptarget.cpp index d3adda162..e925dc057 100644 --- a/foo_ui_columns/ng_playlist/ng_playlist_droptarget.cpp +++ b/foo_ui_columns/ng_playlist/ng_playlist_droptarget.cpp @@ -232,7 +232,7 @@ HRESULT STDMETHODCALLTYPE PlaylistViewDropTarget::Drop( if (p_playlist->m_dragging) { dropped_data.to_handles(data, false, p_playlist->get_wnd()); pfc::list_t selection; - mmh::Permutation permutation_move; + std::vector permutation_move; t_size active_playlist = playlist_api->get_active_playlist(); @@ -240,23 +240,31 @@ HRESULT STDMETHODCALLTYPE PlaylistViewDropTarget::Drop( selection.set_size(playlist_api->playlist_get_item_count(p_playlist->m_dragging_initial_playlist)); pfc::bit_array_var_table bitsel(selection.get_ptr(), selection.get_count()); playlist_api->playlist_get_selection_mask(p_playlist->m_dragging_initial_playlist, bitsel); - permutation_move.set_size(selection.get_count()); + permutation_move.resize(selection.get_count()); + ranges::iota(permutation_move, size_t{}); if (p_playlist->m_dragging_initial_playlist == active_playlist) { if (*pdwEffect == DROPEFFECT_MOVE) { - pfc::list_t indices; - indices.prealloc(data.get_count()); - t_size count = selection.get_count(); //, counter=0; - for (t_size i = 0; i < count; i++) + t_size count = selection.get_count(); + size_t counter{}; + for (t_size i = 0; i < count; i++) { if (selection[i]) { - indices.add_item(i); + permutation_move.insert(permutation_move.begin() + idx + counter, i); + ++counter; } - permutation_move.insert_items(indices, idx); - selection.insert_items_repeat(false, indices.get_count(), idx); - permutation_move.remove_mask( - pfc::bit_array_table(selection.get_ptr(), selection.get_count())); - } else + } + + selection.insert_items_repeat(false, counter, idx); + + for (size_t i{selection.get_size()}; i; --i) { + const auto index = i - 1; + if (selection[index]) { + permutation_move.erase(permutation_move.begin() + index); + } + } + } else { selection.insert_items_repeat(false, data.get_count(), idx); + } } else if (*pdwEffect == DROPEFFECT_MOVE) playlist_api->playlist_undo_backup(p_playlist->m_dragging_initial_playlist); } @@ -266,7 +274,7 @@ HRESULT STDMETHODCALLTYPE PlaylistViewDropTarget::Drop( if (p_playlist->m_dragging && p_playlist->m_dragging_initial_playlist == active_playlist && *pdwEffect == DROPEFFECT_MOVE) { - playlist_api->activeplaylist_reorder_items(permutation_move.get_ptr(), permutation_move.get_size()); + playlist_api->activeplaylist_reorder_items(permutation_move.data(), permutation_move.size()); } else { playlist_api->activeplaylist_clear_selection(); t_size index_insert = playlist_api->activeplaylist_insert_items(idx, data, pfc::bit_array_true()); diff --git a/mmh b/mmh index 473c94cf6..7b2b692c5 160000 --- a/mmh +++ b/mmh @@ -1 +1 @@ -Subproject commit 473c94cf63b175a4c180abc0aff591c2353bbe6a +Subproject commit 7b2b692c5d43f0c21a71d6dc9f96851775b80284