Commit 4c640001 authored by Clément Stenac's avatar Clément Stenac

Support interaction in skins2

parent 6d273994
......@@ -29,6 +29,7 @@
#include "../src/dialogs.hpp"
#include "cmd_change_skin.hpp"
#include <vlc_interaction.h>
template<int TYPE = 0> class CmdDialogs;
......@@ -127,5 +128,36 @@ class CmdDialogs: public CmdGeneric
virtual string getType() const { return "dialog"; }
};
class CmdInteraction: public CmdGeneric
{
public:
CmdInteraction( intf_thread_t *pIntf, interaction_dialog_t *
p_dialog ): CmdGeneric( pIntf ), m_pDialog( p_dialog )
{}
virtual ~CmdInteraction() {}
/// This method does the real job of the command
virtual void execute()
{
if( m_pDialog->i_type == INTERACT_PROGRESS )
{
/// \todo Handle progress in the interface
}
else
{
/// Get the dialogs provider
Dialogs *pDialogs = Dialogs::instance( getIntf() );
if( pDialogs == NULL )
{
return;
}
pDialogs->showInteraction( m_pDialog );
}
}
virtual string getType() const { return "interaction"; }
private:
interaction_dialog_t *m_pDialog;
};
#endif
......@@ -336,3 +336,18 @@ void Dialogs::showPopupMenu( bool bShow )
}
}
void Dialogs::showInteraction( interaction_dialog_t *p_dialog )
{
intf_dialog_args_t *p_arg =
(intf_dialog_args_t *)malloc( sizeof(intf_dialog_args_t) );
memset( p_arg, 0, sizeof(intf_dialog_args_t) );
p_arg->p_dialog = p_dialog;
p_arg->p_intf = getIntf();
if( m_pProvider && m_pProvider->pf_show_dialog )
{
m_pProvider->pf_show_dialog( m_pProvider, INTF_DIALOG_INTERACTION,
0, p_arg );
}
}
......@@ -28,6 +28,7 @@
#include "skin_common.hpp"
#include <string>
struct interaction_dialog_t ;
// Dialogs provider
class Dialogs: public SkinObject
......@@ -88,6 +89,9 @@ class Dialogs: public SkinObject
/// Show the popup menu
void showPopupMenu( bool bShow );
/// Show an interaction dialog
void showInteraction( interaction_dialog_t * );
private:
// Private because it's a singleton
Dialogs( intf_thread_t *pIntf );
......
......@@ -38,6 +38,7 @@
#include "../commands/cmd_quit.hpp"
#include "../commands/cmd_resize.hpp"
#include "../commands/cmd_vars.hpp"
#include "../commands/cmd_dialogs.hpp"
#include "../utils/var_bool.hpp"
#include <sstream>
......@@ -140,6 +141,11 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
// Called when our skins2 demux wants us to load a new skin
var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
// Called when we have an interaction dialog to display
var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( pIntf, "interaction", onInteraction, this );
pIntf->b_interaction = VLC_TRUE;
// Callbacks for vout requests
getIntf()->pf_request_window = &getWindow;
getIntf()->pf_release_window = &releaseWindow;
......@@ -483,6 +489,19 @@ int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
return VLC_SUCCESS;
}
int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam )
{
VlcProc *pThis = (VlcProc*)pParam;
interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
pQueue->push( CmdGenericPtr( pCmd ) );
return VLC_SUCCESS;
}
void VlcProc::updateStreamName( playlist_t *p_playlist )
{
......
......@@ -183,6 +183,11 @@ class VlcProc: public SkinObject
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
/// Callback for interaction variable
static int onInteraction( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
/// Callback to request a vout window
static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
int *pXHint, int *pYHint,
......
......@@ -1206,8 +1206,15 @@ void Interface::OnInteraction( wxCommandEvent& event )
p_arg->p_dialog = p_dialog;
p_arg->p_intf = p_intf;
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION,
0, p_arg );
if( p_dialog->i_type == INTERACT_PROGRESS )
{
/// \todo Handle progress in the interface
}
else
{
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION,
0, p_arg );
}
}
static int InteractCallback( vlc_object_t *p_this,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment