Kaydet (Commit) c2f95e69 authored tarafından Yousuf Philips's avatar Yousuf Philips Kaydeden (comit) Katarina Behrens

tdf#87794: Media Playback Panel

Change-Id: I2ad02ea031c2a1f558f76bd4c5dd816e400c5269
Reviewed-on: https://gerrit.libreoffice.org/27363Reviewed-by: 's avatarYousuf Philips <philipz85@hotmail.com>
Tested-by: 's avatarYousuf Philips <philipz85@hotmail.com>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 3c82f7d7
......@@ -75,6 +75,7 @@ endif
$(eval $(call gb_Library_add_exception_objects,avmedia,\
avmedia/source/framework/mediacontrol \
avmedia/source/framework/MediaControlBase \
avmedia/source/framework/mediaitem \
avmedia/source/framework/mediamisc \
avmedia/source/framework/mediaplayer \
......
......@@ -28,6 +28,7 @@
#include <vcl/toolbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/image.hxx>
#include <avmedia/MediaControlBase.hxx>
#define AVMEDIA_CONTROLOFFSET 6
......@@ -36,17 +37,9 @@ class ListBox;
namespace avmedia
{
enum MediaControlStyle
{
MEDIACONTROLSTYLE_SINGLELINE = 0,
MEDIACONTROLSTYLE_MULTILINE = 1
};
class MediaItem;
class MediaControl : public Control
class MediaControl : public Control, public MediaControlBase
{
public:
......@@ -64,15 +57,10 @@ protected:
virtual void execute( const MediaItem& rItem ) = 0;
virtual void Resize() override;
virtual void InitializeWidgets() override;
private:
void implUpdateToolboxes();
void implUpdateTimeSlider();
void implUpdateVolumeSlider();
void implUpdateTimeField( double fCurTime );
Image implGetImage( sal_Int32 nImageId ) const;
DECL_LINK_TYPED( implTimeHdl, Slider*, void );
DECL_LINK_TYPED( implTimeEndHdl, Slider*, void );
DECL_LINK_TYPED( implVolumeHdl, Slider*, void );
......@@ -80,19 +68,12 @@ private:
DECL_LINK_TYPED( implZoomSelectHdl, ListBox&, void );
DECL_LINK_TYPED(implTimeoutHdl, Idle *, void);
ImageList maImageList;
Idle maIdle;
MediaItem maItem;
VclPtr<ToolBox> maPlayToolBox;
VclPtr<Slider> maTimeSlider;
VclPtr<ToolBox> maMuteToolBox;
VclPtr<Slider> maVolumeSlider;
VclPtr<ToolBox> maZoomToolBox;
VclPtr<ListBox> mpZoomListBox;
VclPtr<Edit> maTimeEdit;
VclPtr<ToolBox> mpZoomToolBox;
Size maMinSize;
MediaControlStyle meControlStyle;
bool mbLocked;
MediaControlStyle meControlStyle;
};
}
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <avmedia/MediaControlBase.hxx>
#include <avmedia/mediawindow.hxx>
#include <avmedia/mediaplayer.hxx>
#include <vcl/edit.hxx>
#include <vcl/slider.hxx>
#include <vcl/toolbox.hxx>
#include <avmedia/mediaitem.hxx>
#include <svtools/miscopt.hxx>
#include <tools/time.hxx>
#include <vcl/toolbox.hxx>
#include "mediacontrol.hrc"
#include "helpids.hrc"
#include "mediamisc.hxx"
using ::rtl::OUString;
namespace avmedia {
MediaControlBase::MediaControlBase():
maImageList( SvtMiscOptions().AreCurrentSymbolsLarge() ? AVMEDIA_RESID( AVMEDIA_IMGLST_L ) : AVMEDIA_RESID( AVMEDIA_IMGLST ) )
{
}
void MediaControlBase::UpdateTimeField( MediaItem aMediaItem, double fTime )
{
if( !aMediaItem.getURL().isEmpty())
{
OUString aTimeString;
SvtSysLocale aSysLocale;
const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( fTime ) ) ) ) +
" / " +
rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( aMediaItem.getDuration() ) )) );
if( mpTimeEdit->GetText() != aTimeString )
mpTimeEdit->SetText( aTimeString );
}
}
void MediaControlBase::UpdateVolumeSlider( MediaItem aMediaItem )
{
if( aMediaItem.getURL().isEmpty() )
mpVolumeSlider->Disable();
else
{
mpVolumeSlider->Enable();
const sal_Int32 nVolumeDB = aMediaItem.getVolumeDB();
mpVolumeSlider->SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ),
static_cast< sal_Int32 >( 0 ) ) );
}
}
void MediaControlBase::UpdateTimeSlider( MediaItem aMediaItem )
{
if( aMediaItem.getURL().isEmpty() )
mpTimeSlider->Disable();
else
{
mpTimeSlider->Enable();
const double fDuration = aMediaItem.getDuration();
if( fDuration > 0.0 )
{
const double fTime = ::std::min( aMediaItem.getTime(), fDuration );
if( !mpTimeSlider->GetLineSize() )
mpTimeSlider->SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) );
if( !mpTimeSlider->GetPageSize() )
mpTimeSlider->SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) );
mpTimeSlider->SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) );
}
}
}
void MediaControlBase::InitializeWidgets()
{
mpPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, GetImage( AVMEDIA_IMG_PLAY ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), ToolBoxItemBits::CHECKABLE );
mpPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY, HID_AVMEDIA_TOOLBOXITEM_PLAY );
mpPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, GetImage( AVMEDIA_IMG_PAUSE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), ToolBoxItemBits::CHECKABLE );
mpPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE, HID_AVMEDIA_TOOLBOXITEM_PAUSE );
mpPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_STOP, GetImage( AVMEDIA_IMG_STOP ), OUString( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), ToolBoxItemBits::CHECKABLE );
mpPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_STOP, HID_AVMEDIA_TOOLBOXITEM_STOP );
mpPlayToolBox->InsertSeparator();
mpPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, GetImage( AVMEDIA_IMG_ENDLESS ), OUString( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) );
mpPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP, HID_AVMEDIA_TOOLBOXITEM_LOOP );
mpMuteToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, GetImage( AVMEDIA_IMG_MUTE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) );
mpMuteToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE, HID_AVMEDIA_TOOLBOXITEM_MUTE );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50 ) ), AVMEDIA_ZOOMLEVEL_50 );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100 ) ), AVMEDIA_ZOOMLEVEL_100 );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200 ) ), AVMEDIA_ZOOMLEVEL_200 );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_FIT ) ), AVMEDIA_ZOOMLEVEL_FIT );
mpZoomListBox->SetHelpId( HID_AVMEDIA_ZOOMLISTBOX );
const OUString aTimeText( " 00:00:00/00:00:00 " );
mpTimeEdit->SetText( aTimeText );
mpTimeEdit->SetUpdateMode( true );
mpTimeEdit->SetHelpId( HID_AVMEDIA_TIMEEDIT );
mpTimeEdit->Disable();
mpTimeEdit->Show();
mpVolumeSlider->SetRange( Range( AVMEDIA_DB_RANGE, 0 ) );
mpVolumeSlider->SetUpdateMode( true );
mpVolumeSlider->SetHelpId( HID_AVMEDIA_VOLUMESLIDER );
mpTimeSlider->SetRange( Range( 0, AVMEDIA_TIME_RANGE ) );
mpTimeSlider->SetUpdateMode( true );
mpTimeSlider->SetStyle(WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET);
}
void MediaControlBase::UpdateToolBoxes(MediaItem aMediaItem)
{
const bool bValidURL = !aMediaItem.getURL().isEmpty();
mpPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL );
mpPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL );
mpPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL );
mpPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL );
mpMuteToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL );
if( !bValidURL )
{
mpZoomListBox->Disable();
mpMuteToolBox->Disable();
}
else
{
mpPlayToolBox->Enable();
mpMuteToolBox->Enable();
if( MediaState::Play == aMediaItem.getState() )
{
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY );
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
}
else if( aMediaItem.getTime() > 0.0 && ( aMediaItem.getTime() < aMediaItem.getDuration() ) )
{
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE );
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
}
else
{
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP );
}
mpPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, aMediaItem.isLoop() );
mpMuteToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, aMediaItem.isMute() );
if( !mpZoomListBox->IsTravelSelect() && !mpZoomListBox->IsInDropDown() )
{
sal_uInt16 nSelectEntryPos ;
switch( aMediaItem.getZoom() )
{
case( css::media::ZoomLevel_ZOOM_1_TO_2 ):
nSelectEntryPos = AVMEDIA_ZOOMLEVEL_50;
break;
case( css::media::ZoomLevel_ORIGINAL ):
nSelectEntryPos = AVMEDIA_ZOOMLEVEL_100;
break;
case( css::media::ZoomLevel_ZOOM_2_TO_1 ):
nSelectEntryPos = AVMEDIA_ZOOMLEVEL_200;
break;
case( css::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ):
nSelectEntryPos = AVMEDIA_ZOOMLEVEL_FIT;
break;
case( css::media::ZoomLevel_FIT_TO_WINDOW ):
nSelectEntryPos = AVMEDIA_ZOOMLEVEL_SCALED;
break;
default:
nSelectEntryPos = AVMEDIA_ZOOMLEVEL_INVALID;
break;
}
if( nSelectEntryPos != AVMEDIA_ZOOMLEVEL_INVALID )
{
mpZoomListBox->Enable();
mpZoomListBox->SelectEntryPos( nSelectEntryPos );
}
else
mpZoomListBox->Disable();
}
}
}
void MediaControlBase::SelectPlayToolBoxItem( MediaItem& aExecItem, MediaItem aItem, sal_uInt16 nId)
{
switch( nId )
{
case AVMEDIA_TOOLBOXITEM_INSERT:
{
MediaFloater* pFloater = avmedia::getMediaFloater();
if( pFloater )
pFloater->dispatchCurrentURL();
}
break;
case AVMEDIA_TOOLBOXITEM_PLAY:
{
aExecItem.setState( MediaState::Play );
if( aItem.getTime() == aItem.getDuration() )
aExecItem.setTime( 0.0 );
else
aExecItem.setTime( aItem.getTime() );
}
break;
case AVMEDIA_TOOLBOXITEM_PAUSE:
{
aExecItem.setState( MediaState::Pause );
}
break;
case AVMEDIA_TOOLBOXITEM_STOP:
{
aExecItem.setState( MediaState::Stop );
aExecItem.setTime( 0.0 );
}
break;
case AVMEDIA_TOOLBOXITEM_MUTE:
{
aExecItem.setMute( !mpMuteToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) );
}
break;
case AVMEDIA_TOOLBOXITEM_LOOP:
{
aExecItem.setLoop( !mpPlayToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) );
}
break;
default:
break;
}
}
Image MediaControlBase::GetImage( sal_Int32 nImageId) const
{
return maImageList.GetImage( static_cast< sal_uInt16 >( nImageId ) );
}
}
\ No newline at end of file
......@@ -32,155 +32,77 @@
#include <sfx2/viewfrm.hxx>
#include <math.h>
#include <algorithm>
#define AVMEDIA_TIME_RANGE 2048
#define AVMEDIA_DB_RANGE -40
#define AVMEDIA_LINEINCREMENT 1.0
#define AVMEDIA_PAGEINCREMENT 10.0
#define AVMEDIA_TOOLBOXITEM_PLAY 0x0001
#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004
#define AVMEDIA_TOOLBOXITEM_STOP 0x0008
#define AVMEDIA_TOOLBOXITEM_MUTE 0x0010
#define AVMEDIA_TOOLBOXITEM_LOOP 0x0011
#define AVMEDIA_TOOLBOXITEM_ZOOM 0x0012
#define AVMEDIA_TOOLBOXITEM_OPEN 0x0014
#define AVMEDIA_TOOLBOXITEM_INSERT 0x0018
#define AVMEDIA_ZOOMLEVEL_50 0
#define AVMEDIA_ZOOMLEVEL_100 1
#define AVMEDIA_ZOOMLEVEL_200 2
#define AVMEDIA_ZOOMLEVEL_FIT 3
#define AVMEDIA_ZOOMLEVEL_SCALED 4
#define AVMEDIA_ZOOMLEVEL_INVALID 65535
#include <avmedia/MediaControlBase.hxx>
namespace avmedia
{
MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyle ) :
Control( pParent ),
maImageList( SvtMiscOptions().AreCurrentSymbolsLarge() ? AVMEDIA_RESID( AVMEDIA_IMGLST_L ) : AVMEDIA_RESID( AVMEDIA_IMGLST ) ),
MediaControlBase(),
maIdle( "avmedia MediaControl Idle" ),
maItem( 0, AVMediaSetMask::ALL ),
maPlayToolBox( VclPtr<ToolBox>::Create(this, WB_3DLOOK) ),
maTimeSlider( VclPtr<Slider>::Create(this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET) ),
maMuteToolBox( VclPtr<ToolBox>::Create(this, WB_3DLOOK) ),
maVolumeSlider( VclPtr<Slider>::Create(this, WB_HORZ | WB_DRAG | WB_SLIDERSET) ),
maZoomToolBox( VclPtr<ToolBox>::Create(this, WB_3DLOOK) ),
mpZoomListBox( VclPtr<ListBox>::Create( maZoomToolBox.get(), WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ),
maTimeEdit( VclPtr<Edit>::Create(this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK ) ),
meControlStyle( eControlStyle ),
mbLocked( false )
mbLocked( false ),
meControlStyle( eControlStyle )
{
const OUString aTimeText( " 00:00:00/00:00:00 " );
mpPlayToolBox = VclPtr<ToolBox>::Create(this, WB_3DLOOK) ;
mpTimeSlider = VclPtr<Slider>::Create(this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET) ;
mpMuteToolBox = VclPtr<ToolBox>::Create(this, WB_3DLOOK) ;
mpVolumeSlider = VclPtr<Slider>::Create(this, WB_HORZ | WB_DRAG | WB_SLIDERSET) ;
mpZoomToolBox = VclPtr<ToolBox>::Create(this, WB_3DLOOK) ;
mpZoomListBox = VclPtr<ListBox>::Create( mpZoomToolBox.get(), WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL | WB_3DLOOK ) ;
mpTimeEdit = VclPtr<Edit>::Create(this, WB_CENTER | WB_READONLY | WB_BORDER | WB_3DLOOK ) ;
SetBackground();
SetPaintTransparent( true );
SetParentClipMode( ParentClipMode::NoClip );
if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle )
{
maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, implGetImage( AVMEDIA_IMG_OPEN ), OUString( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) );
maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN );
InitializeWidgets();
maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, implGetImage( AVMEDIA_IMG_INSERT ), OUString( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) );
maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT, HID_AVMEDIA_TOOLBOXITEM_INSERT );
mpPlayToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
mpPlayToolBox->SetSizePixel( mpPlayToolBox->CalcWindowSizePixel() );
mpPlayToolBox->Show();
maMinSize = mpPlayToolBox->GetSizePixel();
maPlayToolBox->InsertSeparator();
}
else
{
mpZoomListBox->SetBackground();
mpTimeSlider->SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) );
mpTimeSlider->SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) );
mpTimeSlider->SetSizePixel( Size( 128, mpPlayToolBox->GetSizePixel().Height() ) );
mpTimeSlider->Show();
maMinSize.Width() += mpTimeSlider->GetSizePixel().Width();
maZoomToolBox->SetBackground();
maZoomToolBox->SetPaintTransparent( true );
maPlayToolBox->SetBackground();
maPlayToolBox->SetPaintTransparent( true );
maMuteToolBox->SetBackground();
maMuteToolBox->SetPaintTransparent( true );
}
maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_PLAY, implGetImage( AVMEDIA_IMG_PLAY ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PLAY ) ), ToolBoxItemBits::CHECKABLE );
maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_PLAY, HID_AVMEDIA_TOOLBOXITEM_PLAY );
maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_PAUSE, implGetImage( AVMEDIA_IMG_PAUSE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_PAUSE ) ), ToolBoxItemBits::CHECKABLE );
maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_PAUSE, HID_AVMEDIA_TOOLBOXITEM_PAUSE );
maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_STOP, implGetImage( AVMEDIA_IMG_STOP ), OUString( AVMEDIA_RESID( AVMEDIA_STR_STOP ) ), ToolBoxItemBits::CHECKABLE );
maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_STOP, HID_AVMEDIA_TOOLBOXITEM_STOP );
const OUString aTimeText( " 00:00:00/00:00:00 " );
mpTimeEdit->SetSizePixel( Size( mpTimeEdit->GetTextWidth( aTimeText ) + 8, mpPlayToolBox->GetSizePixel().Height() ) );
mpTimeEdit->SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() );
maMinSize.Width() += mpTimeEdit->GetSizePixel().Width();
maPlayToolBox->InsertSeparator();
mpMuteToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
mpMuteToolBox->SetSizePixel( mpMuteToolBox->CalcWindowSizePixel() );
mpMuteToolBox->Show();
maMinSize.Width() += mpMuteToolBox->GetSizePixel().Width();
maPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_LOOP, implGetImage( AVMEDIA_IMG_ENDLESS ), OUString( AVMEDIA_RESID( AVMEDIA_STR_ENDLESS ) ) );
maPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_LOOP, HID_AVMEDIA_TOOLBOXITEM_LOOP );
mpVolumeSlider->SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) );
mpVolumeSlider->SetSizePixel( Size( 48, mpPlayToolBox->GetSizePixel().Height() ) );
mpVolumeSlider->Show();
maMinSize.Width() += mpVolumeSlider->GetSizePixel().Width();
if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
maPlayToolBox->InsertSeparator();
maPlayToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
maPlayToolBox->SetSizePixel( maPlayToolBox->CalcWindowSizePixel() );
maPlayToolBox->Show();
maMinSize = maPlayToolBox->GetSizePixel();
maTimeSlider->SetSlideHdl( LINK( this, MediaControl, implTimeHdl ) );
maTimeSlider->SetEndSlideHdl( LINK( this, MediaControl, implTimeEndHdl ) );
maTimeSlider->SetRange( Range( 0, AVMEDIA_TIME_RANGE ) );
maTimeSlider->SetHelpId( HID_AVMEDIA_TIMESLIDER );
maTimeSlider->SetUpdateMode( true );
maTimeSlider->SetSizePixel( Size( 128, maPlayToolBox->GetSizePixel().Height() ) );
maTimeSlider->Show();
maMinSize.Width() += maTimeSlider->GetSizePixel().Width();
maTimeEdit->SetText( aTimeText );
maTimeEdit->SetUpdateMode( true );
maTimeEdit->SetSizePixel( Size( maTimeEdit->GetTextWidth( aTimeText ) + 8, maPlayToolBox->GetSizePixel().Height() ) );
maTimeEdit->SetControlBackground( Application::GetSettings().GetStyleSettings().GetWindowColor() );
maTimeEdit->SetHelpId( HID_AVMEDIA_TIMEEDIT );
maTimeEdit->Disable();
maTimeEdit->Show();
maMinSize.Width() += maTimeEdit->GetSizePixel().Width();
if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
maMuteToolBox->InsertSeparator();
maMuteToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_MUTE, implGetImage( AVMEDIA_IMG_MUTE ), OUString( AVMEDIA_RESID( AVMEDIA_STR_MUTE ) ) );
maMuteToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_MUTE, HID_AVMEDIA_TOOLBOXITEM_MUTE );
maMuteToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
maMuteToolBox->SetSizePixel( maMuteToolBox->CalcWindowSizePixel() );
maMuteToolBox->Show();
maMinSize.Width() += maMuteToolBox->GetSizePixel().Width();
maVolumeSlider->SetSlideHdl( LINK( this, MediaControl, implVolumeHdl ) );
maVolumeSlider->SetRange( Range( AVMEDIA_DB_RANGE, 0 ) );
maVolumeSlider->SetUpdateMode( true );
maVolumeSlider->SetHelpId( HID_AVMEDIA_VOLUMESLIDER );
maVolumeSlider->SetSizePixel( Size( 48, maPlayToolBox->GetSizePixel().Height() ) );
maVolumeSlider->Show();
maMinSize.Width() += maVolumeSlider->GetSizePixel().Width();
mpZoomListBox->SetSizePixel( Size( maTimeEdit->GetSizePixel().Width(), 260 ) );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_50 ) ), AVMEDIA_ZOOMLEVEL_50 );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_100 ) ), AVMEDIA_ZOOMLEVEL_100 );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_200 ) ), AVMEDIA_ZOOMLEVEL_200 );
mpZoomListBox->InsertEntry( OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM_FIT ) ), AVMEDIA_ZOOMLEVEL_FIT );
mpZoomListBox->SetSizePixel( Size( mpTimeEdit->GetSizePixel().Width(), 260 ) );
mpZoomListBox->SetSelectHdl( LINK( this, MediaControl, implZoomSelectHdl ) );
mpZoomListBox->SetHelpId( HID_AVMEDIA_ZOOMLISTBOX );
maZoomToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) );
maZoomToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM, HID_AVMEDIA_ZOOMLISTBOX );
mpZoomToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_ZOOM, OUString( AVMEDIA_RESID( AVMEDIA_STR_ZOOM ) ) );
mpZoomToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_ZOOM, HID_AVMEDIA_ZOOMLISTBOX );
maZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox );
maZoomToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
maZoomToolBox->SetSizePixel( maZoomToolBox->CalcWindowSizePixel() );
maZoomToolBox->Show();
maMinSize.Width() += maZoomToolBox->GetSizePixel().Width();
mpZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, mpZoomListBox );
mpZoomToolBox->SetSelectHdl( LINK( this, MediaControl, implSelectHdl ) );
mpZoomToolBox->SetSizePixel( mpZoomToolBox->CalcWindowSizePixel() );
mpZoomToolBox->Show();
maMinSize.Width() += mpZoomToolBox->GetSizePixel().Width();
if( MEDIACONTROLSTYLE_MULTILINE == meControlStyle )
{
maMinSize.Width() = 256;
maMinSize.Height() = ( maMinSize.Height() << 1 ) + AVMEDIA_CONTROLOFFSET;
mpZoomToolBox->SetBackground();
mpZoomToolBox->SetPaintTransparent( true );
}
maIdle.SetPriority( SchedulerPriority::LOW );
......@@ -188,86 +110,107 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl
maIdle.Start();
}
void MediaControl::InitializeWidgets()
{
if( MEDIACONTROLSTYLE_SINGLELINE != meControlStyle )
{
mpPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_OPEN, GetImage( AVMEDIA_IMG_OPEN ), OUString( AVMEDIA_RESID( AVMEDIA_STR_OPEN ) ) );
mpPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_OPEN, HID_AVMEDIA_TOOLBOXITEM_OPEN );
mpPlayToolBox->InsertItem( AVMEDIA_TOOLBOXITEM_INSERT, GetImage( AVMEDIA_IMG_INSERT ), OUString( AVMEDIA_RESID( AVMEDIA_STR_INSERT ) ) );
mpPlayToolBox->SetHelpId( AVMEDIA_TOOLBOXITEM_INSERT, HID_AVMEDIA_TOOLBOXITEM_INSERT );
mpPlayToolBox->InsertSeparator();
}
else
{
mpZoomListBox->SetBackground();
mpPlayToolBox->SetBackground();
mpPlayToolBox->SetPaintTransparent( true );
mpMuteToolBox->SetBackground();
mpMuteToolBox->SetPaintTransparent( true );
mpMuteToolBox->InsertSeparator();
}
avmedia::MediaControlBase::InitializeWidgets();
if( meControlStyle == MEDIACONTROLSTYLE_SINGLELINE )
mpPlayToolBox->InsertSeparator();
}
MediaControl::~MediaControl()
{
disposeOnce();
}
void MediaControl::dispose()
{
maZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, nullptr );
mpZoomToolBox->SetItemWindow( AVMEDIA_TOOLBOXITEM_ZOOM, nullptr );
mpZoomListBox.disposeAndClear();
maTimeEdit.disposeAndClear();
maZoomToolBox.disposeAndClear();
maVolumeSlider.disposeAndClear();
maMuteToolBox.disposeAndClear();
maTimeSlider.disposeAndClear();
maPlayToolBox.disposeAndClear();
mpTimeEdit.disposeAndClear();
mpZoomToolBox.disposeAndClear();
mpVolumeSlider.disposeAndClear();
mpMuteToolBox.disposeAndClear();
mpTimeSlider.disposeAndClear();
mpPlayToolBox.disposeAndClear();
Control::dispose();
}
const Size& MediaControl::getMinSizePixel() const
{
return maMinSize;
}
void MediaControl::Resize()
{
Point aPos( 0, 0 );
const sal_Int32 nPlayToolBoxWidth = maPlayToolBox->GetSizePixel().Width();
const sal_Int32 nMuteToolBoxWidth = maMuteToolBox->GetSizePixel().Width();
const sal_Int32 nVolumeSliderWidth = maVolumeSlider->GetSizePixel().Width();
const sal_Int32 nZoomToolBoxWidth = maZoomToolBox->GetSizePixel().Width();
const sal_Int32 nTimeEditWidth = maTimeEdit->GetSizePixel().Width();
const sal_Int32 nTimeSliderHeight = maTimeSlider->GetSizePixel().Height();
const sal_Int32 nPlayToolBoxWidth = mpPlayToolBox->GetSizePixel().Width();
const sal_Int32 nMuteToolBoxWidth = mpMuteToolBox->GetSizePixel().Width();
const sal_Int32 nVolumeSliderWidth = mpVolumeSlider->GetSizePixel().Width();
const sal_Int32 nZoomToolBoxWidth = mpZoomToolBox->GetSizePixel().Width();
const sal_Int32 nTimeEditWidth = mpTimeEdit->GetSizePixel().Width();
const sal_Int32 nTimeSliderHeight = mpTimeSlider->GetSizePixel().Height();
if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
{
const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - ( AVMEDIA_CONTROLOFFSET * 3 ) -
nPlayToolBoxWidth - nMuteToolBoxWidth - nVolumeSliderWidth - nTimeEditWidth - nZoomToolBoxWidth;
maPlayToolBox->SetPosSizePixel( aPos, maPlayToolBox->GetSizePixel() );
mpPlayToolBox->SetPosSizePixel( aPos, mpPlayToolBox->GetSizePixel() );
aPos.X() += nPlayToolBoxWidth;
maTimeSlider->SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
mpTimeSlider->SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET;
maTimeEdit->SetPosSizePixel( aPos, maTimeEdit->GetSizePixel() );
mpTimeEdit->SetPosSizePixel( aPos, mpTimeEdit->GetSizePixel() );
aPos.X() += nTimeEditWidth + AVMEDIA_CONTROLOFFSET;
maMuteToolBox->SetPosSizePixel( aPos, maMuteToolBox->GetSizePixel() );
mpMuteToolBox->SetPosSizePixel( aPos, mpMuteToolBox->GetSizePixel() );
aPos.X() += nMuteToolBoxWidth;
maVolumeSlider->SetPosSizePixel( aPos, maVolumeSlider->GetSizePixel() );
mpVolumeSlider->SetPosSizePixel( aPos, mpVolumeSlider->GetSizePixel() );
aPos.X() += nVolumeSliderWidth + AVMEDIA_CONTROLOFFSET;
maZoomToolBox->SetPosSizePixel( aPos, maZoomToolBox->GetSizePixel() );
mpZoomToolBox->SetPosSizePixel( aPos, mpZoomToolBox->GetSizePixel() );
}
else
{
const sal_Int32 nTimeSliderWidth = GetSizePixel().Width() - AVMEDIA_CONTROLOFFSET - nTimeEditWidth;
maTimeSlider->SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
mpTimeSlider->SetPosSizePixel( aPos, Size( nTimeSliderWidth, nTimeSliderHeight ) );
aPos.X() += nTimeSliderWidth + AVMEDIA_CONTROLOFFSET;
maTimeEdit->SetPosSizePixel( aPos, maTimeEdit->GetSizePixel() );
mpTimeEdit->SetPosSizePixel( aPos, mpTimeEdit->GetSizePixel() );
aPos.X() = 0;
aPos.Y() += nTimeSliderHeight + AVMEDIA_CONTROLOFFSET;
maPlayToolBox->SetPosSizePixel( aPos, maPlayToolBox->GetSizePixel() );
mpPlayToolBox->SetPosSizePixel( aPos, mpPlayToolBox->GetSizePixel() );
aPos.X() = GetSizePixel().Width() - nVolumeSliderWidth - nMuteToolBoxWidth - nZoomToolBoxWidth - AVMEDIA_CONTROLOFFSET;
maMuteToolBox->SetPosSizePixel( aPos, maMuteToolBox->GetSizePixel() );
mpMuteToolBox->SetPosSizePixel( aPos, mpMuteToolBox->GetSizePixel() );
aPos.X() += nMuteToolBoxWidth;
maVolumeSlider->SetPosSizePixel( aPos, maVolumeSlider->GetSizePixel() );
mpVolumeSlider->SetPosSizePixel( aPos, mpVolumeSlider->GetSizePixel() );
aPos.X() = GetSizePixel().Width() - nZoomToolBoxWidth;
maZoomToolBox->SetPosSizePixel( aPos, maZoomToolBox->GetSizePixel() );
mpZoomToolBox->SetPosSizePixel( aPos, mpZoomToolBox->GetSizePixel() );
}
}
......@@ -277,161 +220,20 @@ void MediaControl::setState( const MediaItem& rItem )
if( !mbLocked )
{
maItem.merge( rItem );
implUpdateToolboxes();
implUpdateTimeSlider();
implUpdateVolumeSlider();
implUpdateTimeField( maItem.getTime() );
}
}
void MediaControl::implUpdateToolboxes()
{
const bool bValidURL = !maItem.getURL().isEmpty();
maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_INSERT, bValidURL );
maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_PLAY, bValidURL );
maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_PAUSE, bValidURL );
maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_STOP, bValidURL );
maPlayToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_LOOP, bValidURL );
maMuteToolBox->EnableItem( AVMEDIA_TOOLBOXITEM_MUTE, bValidURL );
if( !bValidURL || !IsEnabled() )
{
mpZoomListBox->Disable();
if( MEDIACONTROLSTYLE_SINGLELINE == meControlStyle )
maPlayToolBox->Disable();
maMuteToolBox->Disable();
}
else
{
maPlayToolBox->Enable();
maMuteToolBox->Enable();
if( MediaState::Play == maItem.getState() )
{
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY );
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
}
else if( maItem.getTime() > 0.0 && ( maItem.getTime() < maItem.getDuration() ) )
{
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE );
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP, false );
}
else
{
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PLAY, false );
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_PAUSE, false );
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_STOP );
}
maPlayToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_LOOP, maItem.isLoop() );
maMuteToolBox->CheckItem( AVMEDIA_TOOLBOXITEM_MUTE, maItem.isMute() );
if( !mpZoomListBox->IsTravelSelect() && !mpZoomListBox->IsInDropDown() )
{
sal_uInt16 nSelectEntryPos ;
switch( maItem.getZoom() )
{
case( css::media::ZoomLevel_ZOOM_1_TO_2 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_50; break;
case( css::media::ZoomLevel_ORIGINAL ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_100; break;
case( css::media::ZoomLevel_ZOOM_2_TO_1 ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_200; break;
case( css::media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_FIT; break;
case( css::media::ZoomLevel_FIT_TO_WINDOW ): nSelectEntryPos = AVMEDIA_ZOOMLEVEL_SCALED; break;
default: nSelectEntryPos = AVMEDIA_ZOOMLEVEL_INVALID; break;
}
if( nSelectEntryPos != AVMEDIA_ZOOMLEVEL_INVALID )
{
mpZoomListBox->Enable();
mpZoomListBox->SelectEntryPos( nSelectEntryPos );
}
else
mpZoomListBox->Disable();
}
}
}
void MediaControl::implUpdateTimeSlider()
{
if( maItem.getURL().isEmpty() || !IsEnabled() )
maTimeSlider->Disable();
else
{
maTimeSlider->Enable();
const double fDuration = maItem.getDuration();
if( fDuration > 0.0 )
{
const double fTime = ::std::min( maItem.getTime(), fDuration );
if( !maTimeSlider->GetLineSize() )
maTimeSlider->SetLineSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_LINEINCREMENT / fDuration ) );
if( !maTimeSlider->GetPageSize() )
maTimeSlider->SetPageSize( static_cast< sal_uInt32 >( AVMEDIA_TIME_RANGE * AVMEDIA_PAGEINCREMENT / fDuration ) );
maTimeSlider->SetThumbPos( static_cast< sal_Int32 >( fTime / fDuration * AVMEDIA_TIME_RANGE ) );
}
}
}
void MediaControl::implUpdateVolumeSlider()
{
if( maItem.getURL().isEmpty() || !IsEnabled() )
maVolumeSlider->Disable();
else
{
maVolumeSlider->Enable();
const sal_Int32 nVolumeDB = maItem.getVolumeDB();
maVolumeSlider->SetThumbPos( ::std::min( ::std::max( nVolumeDB, static_cast< sal_Int32 >( AVMEDIA_DB_RANGE ) ),
static_cast< sal_Int32 >( 0 ) ) );
}
}
void MediaControl::implUpdateTimeField( double fCurTime )
{
if( !maItem.getURL().isEmpty() )
{
OUString aTimeString;
SvtSysLocale aSysLocale;
const LocaleDataWrapper& rLocaleData = aSysLocale.GetLocaleData();
aTimeString += rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( fCurTime ) ) ) ) +
" / " +
rLocaleData.getDuration( tools::Time( 0, 0, static_cast< sal_uInt32 >( floor( maItem.getDuration() ) )) );
if( maTimeEdit->GetText() != aTimeString )
maTimeEdit->SetText( aTimeString );
if( rItem.getURL().isEmpty() && meControlStyle == MEDIACONTROLSTYLE_SINGLELINE )
mpPlayToolBox->Disable();
UpdateToolBoxes( maItem );
UpdateTimeSlider( maItem );
UpdateVolumeSlider( maItem );
UpdateTimeField( maItem, maItem.getTime() );
}
}
Image MediaControl::implGetImage( sal_Int32 nImageId ) const
{
return maImageList.GetImage( static_cast< sal_uInt16 >( nImageId ) );
}
IMPL_LINK_TYPED( MediaControl, implTimeHdl, Slider*, p, void )
{
mbLocked = true;
maIdle.Stop();
implUpdateTimeField( p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE );
UpdateTimeField( maItem, p->GetThumbPos() * maItem.getDuration() / AVMEDIA_TIME_RANGE );
}
......@@ -462,75 +264,24 @@ IMPL_LINK_TYPED( MediaControl, implSelectHdl, ToolBox*, p, void )
if( p )
{
MediaItem aExecItem;
switch( p->GetCurItemId() )
if( p->GetCurItemId() == AVMEDIA_TOOLBOXITEM_OPEN )
{
case AVMEDIA_TOOLBOXITEM_OPEN:
{
OUString aURL;
if (::avmedia::MediaWindow::executeMediaURLDialog(
GetParent(), aURL, nullptr))
{
if( !::avmedia::MediaWindow::isMediaURL( aURL, ""/*TODO?*/, true ) )
::avmedia::MediaWindow::executeFormatErrorBox( this );
else
{
aExecItem.setURL( aURL, "", ""/*TODO?*/ );
aExecItem.setState( MediaState::Play );
}
}
}
break;
case AVMEDIA_TOOLBOXITEM_INSERT:
{
MediaFloater* pFloater = avmedia::getMediaFloater();
OUString aURL;
if( pFloater )
pFloater->dispatchCurrentURL();
}
break;
case AVMEDIA_TOOLBOXITEM_PLAY:
{
aExecItem.setState( MediaState::Play );
if( maItem.getTime() == maItem.getDuration() )
aExecItem.setTime( 0.0 );
if (MediaWindow::executeMediaURLDialog(
GetParent(), aURL, nullptr))
{
if( !MediaWindow::isMediaURL( aURL, ""/*TODO?*/, true ) )
MediaWindow::executeFormatErrorBox( this );
else
aExecItem.setTime( maItem.getTime() );
}
break;
case AVMEDIA_TOOLBOXITEM_PAUSE:
{
aExecItem.setState( MediaState::Pause );
}
break;
case AVMEDIA_TOOLBOXITEM_STOP:
{
aExecItem.setState( MediaState::Stop );
aExecItem.setTime( 0.0 );
}
break;
case AVMEDIA_TOOLBOXITEM_MUTE:
{
aExecItem.setMute( !maMuteToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) );
}
break;
case AVMEDIA_TOOLBOXITEM_LOOP:
{
aExecItem.setLoop( !maPlayToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) );
{
aExecItem.setURL( aURL, "", ""/*TODO?*/ );
aExecItem.setState( MediaState::Play );
}
}
break;
default:
break;
}
else
SelectPlayToolBoxItem( aExecItem, maItem, p->GetCurItemId() );
if( aExecItem.getMaskSet() != AVMediaSetMask::NONE )
execute( aExecItem );
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_AVMEDIA_MEDIACONTROLBASE_HXX
#define INCLUDED_AVMEDIA_MEDIACONTROLBASE_HXX
#include <svx/svxdllapi.h>
#include <vcl/edit.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/slider.hxx>
#include <avmedia/mediaitem.hxx>
#include <avmedia/mediawindow.hxx>
#define AVMEDIA_TIME_RANGE 2048
#define AVMEDIA_DB_RANGE -40
#define AVMEDIA_LINEINCREMENT 1.0
#define AVMEDIA_PAGEINCREMENT 10.0
#define AVMEDIA_TOOLBOXITEM_PLAY 0x0001
#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004
#define AVMEDIA_TOOLBOXITEM_STOP 0x0008
#define AVMEDIA_TOOLBOXITEM_MUTE 0x0010
#define AVMEDIA_TOOLBOXITEM_LOOP 0x0011
#define AVMEDIA_TOOLBOXITEM_ZOOM 0x0012
#define AVMEDIA_TOOLBOXITEM_OPEN 0x0014
#define AVMEDIA_TOOLBOXITEM_INSERT 0x0018
#define AVMEDIA_ZOOMLEVEL_50 0
#define AVMEDIA_ZOOMLEVEL_100 1
#define AVMEDIA_ZOOMLEVEL_200 2
#define AVMEDIA_ZOOMLEVEL_FIT 3
#define AVMEDIA_ZOOMLEVEL_SCALED 4
#define AVMEDIA_ZOOMLEVEL_INVALID 65535
namespace avmedia {
enum MediaControlStyle
{
MEDIACONTROLSTYLE_SINGLELINE = 0,
MEDIACONTROLSTYLE_MULTILINE = 1
};
class AVMEDIA_DLLPUBLIC MediaControlBase
{
public:
MediaControlBase();
virtual ~MediaControlBase(){};
protected:
VclPtr<ToolBox> mpPlayToolBox;
VclPtr<Slider> mpTimeSlider;
VclPtr<ToolBox> mpMuteToolBox;
VclPtr<Slider> mpVolumeSlider;
VclPtr<ListBox> mpZoomListBox;
VclPtr<Edit> mpTimeEdit;
Image GetImage( sal_Int32 nImageId ) const;
virtual void InitializeWidgets();
virtual void UpdateToolBoxes( MediaItem aMediaItem );
void UpdateVolumeSlider( MediaItem aMediaItem );
void UpdateTimeSlider( MediaItem aMediaItem );
void UpdateTimeField( MediaItem aMediaItem, double fTime );
void SelectPlayToolBoxItem( MediaItem& aExecItem, MediaItem aItem, sal_uInt16 nId);
private:
ImageList maImageList;
};
}
#endif
\ No newline at end of file
......@@ -398,6 +398,29 @@
</prop>
</node>
<node oor:name="MediaPlaybackPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Media Playback</value>
</prop>
<prop oor:name="Id" oor:type="xs:string">
<value>MediaPlaybackPanel</value>
</prop>
<prop oor:name="DeckId" oor:type="xs:string">
<value>PropertyDeck</value>
</prop>
<prop oor:name="ContextList">
<value oor:separator=";">
any, Media, visible ;
</value>
</prop>
<prop oor:name="ImplementationURL" oor:type="xs:string">
<value>private:resource/toolpanel/SvxPanelFactory/MediaPlaybackPanel</value>
</prop>
<prop oor:name="OrderIndex" oor:type="xs:int">
<value>100</value>
</prop>
</node>
<node oor:name="PageStylesPanel" oor:op="replace">
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Styles</value>
......
......@@ -41,6 +41,7 @@ $(eval $(call gb_Library_add_defs,svx,\
$(eval $(call gb_Library_set_precompiled_header,svx,$(SRCDIR)/svx/inc/pch/precompiled_svx))
$(eval $(call gb_Library_use_libraries,svx,\
avmedia\
basegfx \
sb \
comphelper \
......@@ -200,6 +201,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/sidebar/line/LinePropertyPanelBase \
svx/source/sidebar/line/LineWidthValueSet \
svx/source/sidebar/line/LineWidthPopup \
svx/source/sidebar/media/MediaPlaybackPanel \
svx/source/sidebar/possize/PosSizePropertyPanel \
svx/source/sidebar/possize/SidebarDialControl \
svx/source/sidebar/shapes/DefaultShapesPanel \
......
......@@ -45,6 +45,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
svx/uiconfig/ui/headfootformatpage \
svx/uiconfig/ui/imapdialog \
svx/uiconfig/ui/linkwarndialog \
svx/uiconfig/ui/mediaplayback \
svx/uiconfig/ui/namespacedialog \
svx/uiconfig/ui/optgridpage \
svx/uiconfig/ui/paralinespacingcontrol \
......
......@@ -26,6 +26,7 @@
#include "line/LinePropertyPanel.hxx"
#include "possize/PosSizePropertyPanel.hxx"
#include "shapes/DefaultShapesPanel.hxx"
#include "media/MediaPlaybackPanel.hxx"
#include "GalleryControl.hxx"
#include "EmptyPanel.hxx"
#include <sfx2/sidebar/SidebarPanelBase.hxx>
......@@ -172,6 +173,10 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
{
pControl = DefaultShapesPanel::Create(pParentWindow, xFrame);
}
else if (rsResourceURL.endsWith("/MediaPlaybackPanel"))
{
pControl = MediaPlaybackPanel::Create(pParentWindow, xFrame, pBindings);
}
else if (rsResourceURL.endsWith("/GalleryPanel"))
{
pControl.reset(VclPtr<GalleryControl>::Create(pBindings, pParentWindow));
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "MediaPlaybackPanel.hxx"
#include <vcl/outdev.hxx>
#include <avmedia/mediawindow.hxx>
#include <avmedia/mediaplayer.hxx>
#include <svtools/miscopt.hxx>
#include <avmedia/mediaitem.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/dispatch.hxx>
#include <avmedia/MediaControlBase.hxx>
using ::rtl::OUString;
using namespace avmedia;
namespace svx { namespace sidebar {
MediaPlaybackPanel::MediaPlaybackPanel (
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings)
: PanelLayout(pParent, "MediaPlaybackPanel", "svx/ui/mediaplayback.ui", rxFrame),
MediaControlBase(),
maMediaController(SID_AVMEDIA_TOOLBOX, *pBindings, *this),
maIdle("MediaPlaybackPanel"),
mpBindings(pBindings)
{
get(mpTimeEdit, "timeedit");
get(mpPlayToolBox, "playtoolbox");
get(mpMuteToolBox, "mutetoolbox");
get(mpTimeSlider, "timeslider");
get(mpVolumeSlider, "volumeslider");
get(mpZoomListBox, "zoombox");
Initialize();
}
VclPtr< vcl::Window > MediaPlaybackPanel::Create(
vcl::Window* pParent,
const Reference< XFrame >& rxFrame,
SfxBindings* pBindings)
{
if (pParent == nullptr)
throw lang::IllegalArgumentException("no parent Window given to MediaPlaybackPanel::Create", nullptr, 0);
if ( ! rxFrame.is())
throw lang::IllegalArgumentException("no XFrame given to MediaPlaybackPanel::Create", nullptr, 1);
if (pBindings == nullptr)
throw lang::IllegalArgumentException("no SfxBindings given to MediaPlaybackPanel::Create", nullptr, 2);
return VclPtr<MediaPlaybackPanel>::Create(
pParent,
rxFrame,
pBindings);
}
MediaPlaybackPanel::~MediaPlaybackPanel()
{
disposeOnce();
}
void MediaPlaybackPanel::Initialize()
{
InitializeWidgets();
mpVolumeSlider->SetSlideHdl(LINK(this, MediaPlaybackPanel, VolumeSlideHdl));
mpPlayToolBox->SetSelectHdl(LINK(this, MediaPlaybackPanel, PlayToolBoxSelectHdl));
mpMuteToolBox->SetSelectHdl(LINK(this, MediaPlaybackPanel, PlayToolBoxSelectHdl));
mpTimeSlider->SetSlideHdl(LINK(this, MediaPlaybackPanel, SeekHdl));
maIdle.SetPriority( SchedulerPriority::HIGHEST );
maIdle.SetIdleHdl( LINK( this, MediaPlaybackPanel, TimeoutHdl ) );
maIdle.Start();
mpBindings->Invalidate(SID_AVMEDIA_TOOLBOX);
}
void MediaPlaybackPanel::dispose()
{
mpTimeEdit.disposeAndClear();
PanelLayout::dispose();
}
void MediaPlaybackPanel::NotifyItemUpdate(
const sal_uInt16 nSID,
const SfxItemState eState,
const SfxPoolItem* pState,
const bool bIsEnabled)
{
(void)bIsEnabled;
if( nSID == SID_AVMEDIA_TOOLBOX )
{
if(eState >= SfxItemState::DEFAULT)
{
mpMediaItem.reset(pState ? static_cast< MediaItem* >(pState->Clone()) : nullptr);
Update();
}
}
}
void MediaPlaybackPanel::UpdateToolBoxes(MediaItem aMediaItem)
{
mpPlayToolBox->Disable();
avmedia::MediaControlBase::UpdateToolBoxes(aMediaItem);
}
void MediaPlaybackPanel::Update()
{
UpdateToolBoxes( *mpMediaItem );
UpdateTimeSlider( *mpMediaItem );
UpdateVolumeSlider( *mpMediaItem );
UpdateTimeField( *mpMediaItem, mpMediaItem->getTime() );
}
IMPL_LINK_NOARG_TYPED( MediaPlaybackPanel, VolumeSlideHdl, Slider*, void)
{
MediaItem aItem(SID_AVMEDIA_TOOLBOX);
aItem.setVolumeDB( static_cast< sal_Int16 > (mpVolumeSlider->GetThumbPos()));
mpBindings->GetDispatcher()->ExecuteList(SID_AVMEDIA_TOOLBOX, SfxCallMode::RECORD, { &aItem });
}
IMPL_LINK_NOARG_TYPED( MediaPlaybackPanel, SeekHdl, Slider*, void)
{
MediaItem aItem(SID_AVMEDIA_TOOLBOX);
aItem.setState( MediaState::Pause );
aItem.setTime( mpTimeSlider->GetThumbPos() * mpMediaItem->getDuration() / AVMEDIA_TIME_RANGE);
mpBindings->GetDispatcher()->ExecuteList(SID_AVMEDIA_TOOLBOX, SfxCallMode::RECORD, { &aItem });
mpBindings->Invalidate(SID_AVMEDIA_TOOLBOX);
}
IMPL_LINK_NOARG_TYPED( MediaPlaybackPanel, TimeoutHdl, Idle*, void)
{
mpBindings->Invalidate(SID_AVMEDIA_TOOLBOX);
}
IMPL_LINK_TYPED( MediaPlaybackPanel, PlayToolBoxSelectHdl, ToolBox*, pControl, void)
{
MediaItem aItem(SID_AVMEDIA_TOOLBOX);
switch(pControl->GetCurItemId())
{
case AVMEDIA_TOOLBOXITEM_PLAY:
{
aItem.setState( MediaState::Play );
if( mpMediaItem->getTime() == mpMediaItem->getDuration() )
aItem.setTime( 0.0 );
else
aItem.setTime( mpMediaItem->getTime());
}
break;
case AVMEDIA_TOOLBOXITEM_PAUSE:
{
aItem.setState( MediaState::Pause );
}
break;
case AVMEDIA_TOOLBOXITEM_STOP:
{
aItem.setState( MediaState::Stop );
aItem.setTime( 0.0 );
}
break;
case AVMEDIA_TOOLBOXITEM_MUTE:
{
aItem.setMute( !mpMuteToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_MUTE ) );
}
break;
case AVMEDIA_TOOLBOXITEM_LOOP:
{
aItem.setLoop( !mpPlayToolBox->IsItemChecked( AVMEDIA_TOOLBOXITEM_LOOP ) );
}
break;
default: break;
}
if(aItem.getMaskSet() != AVMediaSetMask::NONE)
{
mpBindings->GetDispatcher()->ExecuteList(SID_AVMEDIA_TOOLBOX, SfxCallMode::RECORD, { &aItem } );
mpBindings->Invalidate(SID_AVMEDIA_TOOLBOX);
}
}
} } // end of namespace svx::sidebar
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SD_SOURCE_SIDEBAR_MEDIAPLAYBACKPANEL_HXX
#define INCLUDED_SD_SOURCE_SIDEBAR_MEDIAPLAYBACKPANEL_HXX
#include <vcl/ctrl.hxx>
#include <com/sun/star/frame/XFrame.hpp>
#include <svx/sidebar/PanelLayout.hxx>
#include <vcl/layout.hxx>
#include <vcl/slider.hxx>
#include <vcl/toolbox.hxx>
#include <avmedia/mediaitem.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
#include <avmedia/MediaControlBase.hxx>
using namespace css;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;
namespace svx { namespace sidebar {
/** This panel provides media playback control in document
*/
class MediaPlaybackPanel
: public PanelLayout,
public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
public ::avmedia::MediaControlBase
{
public:
MediaPlaybackPanel (
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings);
static VclPtr<vcl::Window> Create(
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
SfxBindings* pBindings);
virtual ~MediaPlaybackPanel();
virtual void dispose() override;
protected:
virtual void UpdateToolBoxes(avmedia::MediaItem aMediaItem) override;
private:
std::unique_ptr< ::avmedia::MediaItem > mpMediaItem;
::sfx2::sidebar::ControllerItem maMediaController;
Idle maIdle;
SfxBindings* mpBindings;
void Initialize();
void Update();
virtual void NotifyItemUpdate( const sal_uInt16 nSID,
const SfxItemState eState,
const SfxPoolItem* pState,
const bool bIsEnabled) override;
DECL_LINK_TYPED(PlayToolBoxSelectHdl, ToolBox*, void);
DECL_LINK_TYPED(VolumeSlideHdl, Slider*, void);
DECL_LINK_TYPED(SeekHdl, Slider*, void);
DECL_LINK_TYPED(TimeoutHdl, Idle*, void);
};
} } // end of namespace svx::sidebar
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkGrid" id="MediaPlaybackPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="border_width">6</property>
<property name="column_spacing">7</property>
<property name="row_homogeneous">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Playback:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Seek:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Volume:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkScale" id="timeslider">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="round_digits">1</property>
<property name="digits">2</property>
<property name="draw_value">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="zoombox">
<property name="width_request">150</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">View</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="timeedit:border">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="editable">False</property>
<property name="xalign">0.5</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="playtoolbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkToolbar" id="mutetoolbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkScale" id="volumeslider">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="opacity">0.98999999999999999</property>
<property name="draw_value">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
</interface>
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