#define PLAYLIST_ENA_FLAG 0x04 /**< Is it enabled ? */
#define PLAYLIST_DEL_FLAG 0x08 /**< Autodelete ? */
#define PLAYLIST_RO_FLAG 0x10 /**< Write-enabled ? */
+#define PLAYLIST_REMOVE_FLAG 0x20 /**< Remove this item at the end */
/**
* playlist view
/* Helper to add an item */
struct playlist_add_t
{
- playlist_item_t *p_node;
- playlist_item_t *p_item;
+ int i_node;
+ int i_item;
int i_view;
int i_position;
};
FIND_ANYWHERE );
int i_index;
- i_current_view = VIEW_SIMPLE;
+ i_current_view = VIEW_CATEGORY;
playlist_ViewUpdate( p_playlist, i_current_view );
[o_outline_view setTarget: self];
var_Set( p_intf->p_vlc, "verbose", val );
/* Set defaul playlist view */
- p_sys->i_current_view = VIEW_SIMPLE;
+ p_sys->i_current_view = VIEW_CATEGORY;
p_sys->pp_plist = NULL;
p_sys->i_plist_entries = 0;
p_sys->b_need_update = VLC_FALSE;
case 'v':
switch( p_sys->i_current_view )
{
- case VIEW_SIMPLE:
- p_sys->i_current_view = VIEW_CATEGORY;
- break;
case VIEW_CATEGORY:
p_sys->i_current_view = VIEW_ALL;
break;
default:
- p_sys->i_current_view = VIEW_SIMPLE;
+ p_sys->i_current_view = VIEW_CATEGORY;
}
PlaylistRebuild( p_intf );
FindIndex( p_intf );
EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
EVT_TIMER(ID_CONTROLS_TIMER, Interface::OnControlsTimer)
+ EVT_TIMER(ID_SLIDER_TIMER, Interface::OnSliderTimer)
END_EVENT_TABLE()
/*****************************************************************************
SetupHotkeys();
m_controls_timer.SetOwner(this, ID_CONTROLS_TIMER);
+ m_slider_timer.SetOwner(this, ID_SLIDER_TIMER);
/* Start timer */
timer = new Timer( p_intf, this );
delete [] p_entries;
}
+void Interface::HideSlider(bool layout)
+{
+ ShowSlider(false, layout);
+}
+
+void Interface::ShowSlider(bool show, bool layout)
+{
+ int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
+
+ if (show)
+ {
+ //prevent the hide timers from hiding it now
+ m_slider_timer.Stop();
+ m_controls_timer.Stop();
+
+ slider_frame->Show();
+ frame_sizer->Show( slider_frame );
+ }
+ else
+ {
+ slider_frame->Hide();
+ frame_sizer->Hide( slider_frame );
+ }
+
+ if (layout)
+ {
+ frame_sizer->Layout();
+ if (size_to_video)
+ {
+ frame_sizer->Fit( this );
+ }
+ }
+}
+
+void Interface::HideDiscFrame(bool layout)
+{
+ ShowDiscFrame(false, layout);
+}
+
+void Interface::ShowDiscFrame(bool show, bool layout)
+{
+ int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
+
+ if (show)
+ {
+ //prevent the hide timer from hiding it now
+ m_controls_timer.Stop();
+
+ disc_frame->Show();
+ slider_sizer->Show( disc_frame );
+ }
+ else
+ {
+ disc_frame->Hide();
+ slider_sizer->Hide( disc_frame );
+ }
+
+ if (layout)
+ {
+ slider_sizer->Layout();
+ if (size_to_video)
+ {
+ slider_sizer->Fit( slider_frame );
+ }
+ }
+}
+
/*****************************************************************************
* Event Handlers.
*****************************************************************************/
int size_to_video = config_GetInt( p_intf, "wxwin-size-to-video" );
/* Hide slider and Disc Buttons */
- disc_frame->Hide();
- slider_sizer->Hide( disc_frame );
+ //postpone layout, we'll do it ourselves
+ HideDiscFrame(false);
+ HideSlider(false);
+
slider_sizer->Layout();
if (size_to_video)
{
slider_sizer->Fit( slider_frame );
}
+}
- slider_frame->Hide();
- frame_sizer->Hide( slider_frame );
- frame_sizer->Layout();
- if (size_to_video)
+void Interface::OnSliderTimer(wxTimerEvent& WXUNUSED(event))
{
- frame_sizer->Fit( this );
- }
+ HideSlider();
}
void Interface::OnMenuOpen(wxMenuEvent& event)
panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
#if (!wxCHECK_VERSION(2,5,0))
panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
+#else
+ panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
#endif
panel_sizer->Add( common_opt_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
p_view_menu = NULL;
p_sd_menu = SDMenu();
- i_current_view = VIEW_SIMPLE;
+ i_current_view = VIEW_CATEGORY;
b_changed_view = VLC_FALSE;
i_title_sorted = 0;
void Playlist::AppendItem( wxCommandEvent& event )
{
playlist_add_t *p_add = (playlist_add_t *)event.GetClientData();
+ playlist_item_t *p_item = NULL;
wxTreeItemId item,node;
- if( p_add->i_view != i_current_view || !p_add->p_node )
+ if( p_add->i_view != i_current_view )
{
goto update;
}
- node = FindItem( treectrl->GetRootItem(), p_add->p_node->input.i_id );
+ node = FindItem( treectrl->GetRootItem(), p_add->i_node );
if( !node.IsOk() )
{
goto update;
}
+ p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
+ if( !p_item )
+ goto update;
+
item = treectrl->AppendItem( node,
- wxL2U( p_add->p_item->input.psz_name ), -1,-1,
- new PlaylistItem( p_add->p_item ) );
- treectrl->SetItemImage( item, p_add->p_item->input.i_type );
+ wxL2U( p_item->input.psz_name ), -1,-1,
+ new PlaylistItem( p_item ) );
+ treectrl->SetItemImage( item, p_item->input.i_type );
- if( item.IsOk() && p_add->p_item->i_children == -1 )
+ if( item.IsOk() && p_item->i_children == -1 )
{
UpdateTreeItem( item );
}
/* FIXME : have a list of "should have" views */
p_view_menu->Append( FirstView_Event + VIEW_CATEGORY,
wxU(_("Normal") ) );
-/* p_view_menu->Append( FirstView_Event + VIEW_SIMPLE,
- wxU(_("Manually added") ) );
- p_view_menu->Append( FirstView_Event + VIEW_ALL,
- wxU(_("All items, unsorted") ) ); */
p_view_menu->Append( FirstView_Event + VIEW_S_AUTHOR,
wxU(_("Sorted by artist") ) );
if( p_intf->p_sys->p_input )
{
p_main_interface->slider->SetValue( 0 );
- b_slider_shown = VLC_FALSE;
- b_disc_shown = VLC_FALSE;
char *psz_now_playing = vlc_input_item_GetInfo(
p_intf->p_sys->p_input->input.p_item,
var_Get( p_input, "position", &pos );
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
- if( val.i_int > 0 && !b_disc_shown )
+ if( val.i_int > 0 && !p_main_interface->disc_menu_button->IsShown() )
{
- b_disc_shown = VLC_TRUE;
vlc_value_t val;
#define HELP_MENU N_("Menu")
wxU(_( HELP_NTR ) ) );
}
- p_main_interface->disc_frame->Show();
- p_main_interface->slider_sizer->Show(
- p_main_interface->disc_frame );
+ p_main_interface->ShowDiscFrame();
}
- if( pos.f_float > 0.0 )
- {
- /* Done like this, as it's the only way to know if the */
- /* slider has to be displayed */
-
- if( !b_slider_shown )
- {
- b_slider_shown = VLC_TRUE;
- p_main_interface->slider_frame->Show();
- p_main_interface->frame_sizer->Show(
- p_main_interface->slider_frame );
- p_main_interface->frame_sizer->Layout();
- if (size_to_video)
+ if( pos.f_float > 0.0 )
{
- p_main_interface->frame_sizer->Fit( p_main_interface );
- }
- }
+ /* Show the slider if it's position is significant */
+ p_main_interface->ShowSlider();
}
else
{
- if( b_slider_shown )
- {
- p_main_interface->slider_frame->Hide();
- p_main_interface->frame_sizer->Hide(
- p_main_interface->slider_frame );
-
- p_main_interface->frame_sizer->Layout();
- if (size_to_video)
- {
- p_main_interface->frame_sizer->Fit( p_main_interface );
- }
- }
+ p_main_interface->m_slider_timer.Start(1000, wxTIMER_ONE_SHOT);
}
- if( p_intf->p_sys->b_playing && b_slider_shown )
+ if( p_intf->p_sys->b_playing && p_main_interface->slider_frame->IsShown() )
{
/* Update the slider if the user isn't dragging it. */
if( p_intf->p_sys->b_slider_free )
}
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
- if( p_intf->p_sys->p_input->stream.b_seekable && !b_slider_shown )
+ if( p_intf->p_sys->p_input->stream.b_seekable &&
+ !p_main_interface->slider_frame->IsShown() )
{
/* Done like this because b_seekable is set slightly after
* the new input object is available. */
- b_slider_shown = VLC_TRUE;
- p_main_interface->slider_frame->Show();
- p_main_interface->frame_sizer->Show(
- p_main_interface->slider_frame );
- p_main_interface->frame_sizer->Layout();
- p_main_interface->frame_sizer->Fit( p_main_interface );
+ p_main_interface->ShowSlider();
}
if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
{
enum{
ID_CONTROLS_TIMER,
+ ID_SLIDER_TIMER,
};
class DialogsProvider;
virtual void Notify();
private:
+ //use wxWindow::IsShown instead
+ //vlc_bool_t b_slider_shown;
+ //vlc_bool_t b_disc_shown;
intf_thread_t *p_intf;
Interface *p_main_interface;
vlc_bool_t b_init;
int i_old_playing_status;
int i_old_rate;
- vlc_bool_t b_slider_shown;
- vlc_bool_t b_disc_shown;
};
wxBoxSizer *frame_sizer;
wxStatusBar *statusbar;
+ void HideSlider(bool layout = true);
+ void ShowSlider(bool show = true, bool layout = true);
+
wxSlider *slider;
wxWindow *slider_frame;
wxBoxSizer *slider_sizer;
wxPanel *extra_frame;
+ void HideDiscFrame(bool layout = true);
+ void ShowDiscFrame(bool show = true, bool layout = true);
+
wxPanel *disc_frame;
wxBoxSizer *disc_sizer;
wxBitmapButton *disc_menu_button;
#endif
wxTimer m_controls_timer;
+ wxTimer m_slider_timer;
private:
void SetupHotkeys();
/* Event handlers (these functions should _not_ be virtual) */
void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
+ void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
void OnExit( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event );
/* SAP annnounces must only contain one SDP */
sdp_t *p_sdp;
- playlist_item_t *p_item;
+ int i_item_id;
+// playlist_item_t *p_item;
};
struct services_discovery_sys_t
if( mdate() - p_sd->p_sys->pp_announces[i]->i_last > i_timeout )
{
struct sap_announce_t *p_announce;
+ playlist_item_t * p_item;
p_announce = p_sd->p_sys->pp_announces[i];
- msg_Dbg( p_sd, "Time out for %s, deleting (%i/%i)",
- p_announce->p_item->input.psz_name,
- i , p_sd->p_sys->i_announces );
-
/* Remove the playlist item */
p_playlist = vlc_object_find( p_sd, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{
- playlist_Delete( p_playlist, p_announce->p_item->input.i_id );
+ p_item = playlist_ItemGetById( p_playlist,
+ p_announce->i_item_id );
+ if( !p_item ) continue;
+
+ msg_Dbg( p_sd, "Time out for %s, deleting (%i/%i)",
+ p_item->input.psz_name,
+ i , p_sd->p_sys->i_announces );
+
+ playlist_Delete( p_playlist, p_announce->i_item_id );
vlc_object_release( p_playlist );
}
p_sap->i_last = mdate();
p_sap->i_hash = i_hash;
p_sap->p_sdp = p_sdp;
- p_sap->p_item = NULL;
+ p_sap->i_item_id = -1;
/* Create the playlist item here */
p_item = playlist_ItemNew( p_sd, p_sap->p_sdp->psz_uri, psz_value );
vlc_object_release( p_playlist );
- p_sap->p_item = p_item;
+ p_sap->i_item_id = p_item->input.i_id;
TAB_APPEND( p_sd->p_sys->i_announces,
p_sd->p_sys->pp_announces, p_sap );
return VLC_EGENERIC;
}
- if( p_announce->p_item )
+ if( p_announce->i_item_id > -1 )
{
- playlist_LockDelete( p_playlist, p_announce->p_item->input.i_id );
+ playlist_LockDelete( p_playlist, p_announce->i_item_id );
}
for( i = 0; i< p_sd->p_sys->i_announces; i++)
{
playlist_NodeAppend( p_playlist, VIEW_CATEGORY, p_item,
p_playlist->p_general );
- p_add->p_item = p_item;
- p_add->p_node = p_playlist->p_general;
+ p_add->i_item = p_item->input.i_id;
+ p_add->i_node = p_playlist->p_general->input.i_id;
p_add->i_view = VIEW_CATEGORY;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val );
p_view = playlist_ViewFind( p_playlist, VIEW_ALL );
playlist_ItemAddParent( p_item, VIEW_ALL, p_view->p_root );
- /* Also add the item to the "simple" view */
- p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
-
- if( b_end == VLC_TRUE )
- {
- playlist_NodeAppend( p_playlist, VIEW_SIMPLE,p_item,
- p_view->p_root );
- p_add->p_item = p_item;
- p_add->p_node = p_view->p_root;
- p_add->i_view = VIEW_SIMPLE;
- val.p_address = p_add;
- var_Set( p_playlist, "item-append", val );
- }
- else
- {
- playlist_NodeInsert( p_playlist, VIEW_SIMPLE,p_item,
- p_view->p_root, i_pos );
- }
-
-
/* FIXME : Update sorted views */
if( p_playlist->i_index >= i_pos )
{
p_playlist->request.b_request = VLC_TRUE;
/* FIXME ... */
- p_playlist->request.i_view = VIEW_SIMPLE;
+ p_playlist->request.i_view = VIEW_CATEGORY;
p_playlist->request.p_node = p_view->p_root;
p_playlist->request.p_item = p_item;
/* TODO: Handle modes */
playlist_NodeAppend( p_playlist, i_view, p_item, p_parent );
- p_add->p_item = p_item;
- p_add->p_node = p_parent;
+ p_add->i_item = p_item->input.i_id;
+ p_add->i_node = p_parent->input.i_id;
p_add->i_view = i_view;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val );
{
return p_playlist->pp_all_items[i];
}
-
return NULL;
}
int playlist_Delete( playlist_t * p_playlist, int i_id )
{
int i, i_top, i_bottom;
+ vlc_bool_t b_flag = VLC_FALSE;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i );
}
-
/* Check if it is the current item */
if( p_playlist->status.p_item == p_item )
{
/* Hack we don't call playlist_Control for lock reasons */
p_playlist->status.i_status = PLAYLIST_STOPPED;
p_playlist->request.b_request = VLC_TRUE;
- p_playlist->status.p_item = NULL;
+// p_playlist->status.p_item = NULL;
+ msg_Info( p_playlist, "stopping playback" );
+ b_flag = VLC_TRUE;
}
msg_Info( p_playlist, "deleting playlist item `%s'",
/* TODO : Update views */
- playlist_ItemDelete( p_item );
+ if( b_flag == VLC_FALSE )
+ playlist_ItemDelete( p_item );
+ else
+ p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
return VLC_SUCCESS;
}
p_playlist->pp_all_items = 0;
playlist_ViewInsert( p_playlist, VIEW_CATEGORY, TITLE_CATEGORY );
- playlist_ViewInsert( p_playlist, VIEW_SIMPLE, TITLE_SIMPLE );
playlist_ViewInsert( p_playlist, VIEW_ALL, TITLE_ALL );
p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
/* Set startup status
* We set to simple view on startup for interfaces that don't do
* anything */
- p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
- p_playlist->status.i_view = VIEW_SIMPLE;
+ p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
+ p_playlist->status.i_view = VIEW_CATEGORY;
p_playlist->status.p_item = NULL;
p_playlist->status.p_node = p_view->p_root;
p_playlist->request.b_request = VLC_FALSE;
i_vout_destroyed_date = 0;
i_sout_destroyed_date = 0;
+ if( p_playlist->status.p_item->i_flags
+ & PLAYLIST_REMOVE_FLAG )
+ {
+ playlist_ItemDelete( p_item );
+ p_playlist->status.p_item = NULL;
+ }
+
continue;
}
/* This input is dying, let him do */
playlist_NodeAppend( p_playlist, i_view, p_item, p_parent );
}
- p_add->p_node = p_parent;
- p_add->p_item = p_item;
+ p_add->i_node = p_parent ? p_parent->input.i_id : -1;
+ p_add->i_item = p_item->input.i_id;
p_add->i_view = i_view;
val.p_address = p_add;
var_Set( p_playlist, "item-append", val);
{
REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i );
}
-
playlist_ItemDelete( p_root );
}
return VLC_SUCCESS;