PopupSort_Event,
PopupDel_Event,
PopupInfo_Event,
+ PopupAddNode_Event,
SearchText_Event,
Search_Event,
EVT_MENU( PopupSort_Event, Playlist::OnPopupSort)
EVT_MENU( PopupDel_Event, Playlist::OnPopupDel)
EVT_MENU( PopupInfo_Event, Playlist::OnPopupInfo)
+ EVT_MENU( PopupAddNode_Event, Playlist::OnPopupAddNode)
/* Tree control events */
EVT_TREE_ITEM_ACTIVATED( TreeCtrl_Event, Playlist::OnActivateItem )
EVT_TREE_KEY_DOWN( -1, Playlist::OnKeyDown )
+ EVT_TREE_BEGIN_DRAG( TreeCtrl_Event, Playlist::OnDragItemBegin )
+ EVT_TREE_END_DRAG( TreeCtrl_Event, Playlist::OnDragItemEnd )
EVT_CONTEXT_MENU( Playlist::OnPopup )
node_popup->Append( PopupSort_Event, wxU(_("Sort this branch")) );
node_popup->Append( PopupDel_Event, wxU(_("Delete")) );
node_popup->Append( PopupInfo_Event, wxU(_("Info")) );
+ node_popup->Append( PopupAddNode_Event, wxU(_("Add node")) );
item_popup = new wxMenu;
item_popup->Append( PopupPlay_Event, wxU(_("Play")) );
msg_Warn( p_intf, "not implemented" );
}
+void Playlist::OnDragItemBegin( wxTreeEvent& event )
+{
+ event.Allow();
+ draged_tree_item = event.GetItem();
+}
+
+void Playlist::OnDragItemEnd( wxTreeEvent& event )
+{
+ wxTreeItemId dest_tree_item = event.GetItem();
+
+ /* check that we're not trying to move a node into one of it's children */
+ wxTreeItemId parent = dest_tree_item;
+ while( parent != treectrl->GetRootItem() )
+ {
+ if( draged_tree_item == parent ) return;
+ parent = treectrl->GetItemParent( parent );
+ }
+
+ if( draged_tree_item != dest_tree_item )
+ {
+ LockPlaylist( p_intf->p_sys, p_playlist );
+
+ PlaylistItem *p_wxdrageditem =
+ (PlaylistItem *)treectrl->GetItemData( draged_tree_item );
+ PlaylistItem *p_wxdestitem =
+ (PlaylistItem *)treectrl->GetItemData( dest_tree_item );
+
+ playlist_item_t *p_drageditem =
+ playlist_ItemGetById(p_playlist, p_wxdrageditem->i_id );
+ playlist_item_t *p_destitem =
+ playlist_ItemGetById(p_playlist, p_wxdestitem->i_id );
+
+ if( p_destitem->i_children == -1 )
+ /* this is a leaf */
+ {
+ parent = treectrl->GetItemParent( dest_tree_item );
+ PlaylistItem *p_parent =
+ (PlaylistItem *)treectrl->GetItemData( parent );
+ playlist_item_t *p_destitem2 =
+ playlist_ItemGetById( p_playlist, p_parent->i_id );
+ int i;
+ for( i = 0; i < p_destitem2->i_children; i++ )
+ {
+ if( p_destitem2->pp_children[i] == p_destitem ) break;
+ }
+ playlist_TreeMove( p_playlist, p_drageditem, p_destitem2,
+ i, i_current_view );
+ }
+ else
+ /* this is a node */
+ {
+ playlist_TreeMove( p_playlist, p_drageditem, p_destitem,
+ 0, i_current_view );
+ }
+ UnlockPlaylist( p_intf->p_sys, p_playlist );
+ Rebuild( VLC_TRUE );
+ }
+}
+
/**********************************************************************
* Menu
**********************************************************************/
UnlockPlaylist( p_intf->p_sys, p_playlist );
}
+void Playlist::OnPopupAddNode( wxCommandEvent& event )
+{
+ wxTextEntryDialog text( NULL, wxU(_( "Please enter node name" )),
+ wxU(_( "Add node" )), wxU(_( "New node" )) );
+ if( text.ShowModal() != wxID_OK ) return;
+
+ char *psz_name = wxFromLocale( text.GetValue() );
+
+ LockPlaylist( p_intf->p_sys, p_playlist );
+
+ PlaylistItem *p_wxitem;
+ playlist_item_t *p_item;
+
+ p_wxitem = (PlaylistItem *)treectrl->GetItemData( i_wx_popup_item );
+
+ p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );
+
+ playlist_NodeCreate( p_playlist, 0, psz_name, p_item );
+
+ UnlockPlaylist( p_intf->p_sys, p_playlist );
+ Rebuild( VLC_TRUE );
+
+ wxLocaleFree( psz_name );
+}
+
/*****************************************************************************
* Custom events management
playlist_add_t *p_add = (playlist_add_t *)malloc(sizeof( playlist_add_t));
memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
- if( p_playlist_dialog->i_items_to_append++ > 50 )
+ if( ++p_playlist_dialog->i_items_to_append >= 50 )
{
/* Too many items waiting to be added, it will be quicker to rebuild
* the whole playlist */