Skip to content

Commit

Permalink
Merge pull request #295 from reupen/update-permutation
Browse files Browse the repository at this point in the history
Update mmh and fbh
  • Loading branch information
reupen authored Feb 27, 2020
2 parents bb2dec1 + 55387c0 commit c79d5c2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion fbh
Submodule fbh updated 1 files
+3 −3 sort.h
2 changes: 1 addition & 1 deletion foo_ui_columns/buttons_config_droptarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion foo_ui_columns/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void FilterPanel::get_windows(pfc::list_base_t<FilterPanel*>& windows)
}
mmh::Permutation permutation(windows.get_count());
mmh::sort_get_permutation(indices.get_ptr(), permutation, (pfc::compare_t<t_size, t_size>), true, false);
windows.reorder(permutation.get_ptr());
windows.reorder(permutation.data());
}
}

Expand Down
4 changes: 2 additions & 2 deletions foo_ui_columns/filter_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions foo_ui_columns/ng_playlist/ng_playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
34 changes: 21 additions & 13 deletions foo_ui_columns/ng_playlist/ng_playlist_droptarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,31 +232,39 @@ HRESULT STDMETHODCALLTYPE PlaylistViewDropTarget::Drop(
if (p_playlist->m_dragging) {
dropped_data.to_handles(data, false, p_playlist->get_wnd());
pfc::list_t<bool> selection;
mmh::Permutation permutation_move;
std::vector<size_t> permutation_move;

t_size active_playlist = playlist_api->get_active_playlist();

if (p_playlist->m_dragging) {
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<t_size, pfc::alloc_fast_aggressive> 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);
}
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion mmh
Submodule mmh updated 6 files
+2 −0 mmh.vcxproj
+2 −0 mmh.vcxproj.filters
+52 −0 pfc_interop.h
+46 −47 sort.h
+3 −0 stdafx.h
+39 −0 type_traits.h

0 comments on commit c79d5c2

Please sign in to comment.