Switch transition selection pane to use an icon-based ValueSet.

Also enlarge the (rather ugly) sample icons.

Change-Id: I6d64613b71ee015bf775a7c720c5b9a4ea464bab
Reviewed-on: https://gerrit.libreoffice.org/19892
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
Michael Meeks
2015-11-10 11:29:54 +00:00
parent cc920bc27a
commit 5de806fbd2
9 changed files with 123 additions and 111 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -89,7 +89,7 @@ WB_NONEFIELD There is a NoSelection field which can be selected if
is selected. This field shows the text which is specified is selected. This field shows the text which is specified
by SetText() respectively no one, if no text was set. With by SetText() respectively no one, if no text was set. With
SetNoSelection() the selection can be disabled. SetNoSelection() the selection can be disabled.
WB_VSCROLL A scroolbar will be always shown. The visible number of WB_VSCROLL A scrollbar will be always shown. The visible number of
lines have to be specified with SetLineCount() if this lines have to be specified with SetLineCount() if this
flag is set. flag is set.
WB_BORDER A border will be drawn around the window. WB_BORDER A border will be drawn around the window.

View File

@@ -52,6 +52,9 @@
#include <algorithm> #include <algorithm>
#define TRANSITION_THUMB_WIDTH 64
#define TRANSITION_THUMB_HEIGHT 40
using namespace ::com::sun::star; using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
@@ -358,6 +361,28 @@ void lcl_FillSoundListBox(
namespace sd namespace sd
{ {
class TransitionPane : public ValueSet
{
public:
TransitionPane( vcl::Window *pParent ) :
ValueSet( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER |
WB_ITEMBORDER | WB_FLATVALUESET | WB_VSCROLL )
{
EnableFullItemMode( false );
set_hexpand( true );
set_vexpand( true );
SetExtraSpacing( 2 );
SetItemWidth( TRANSITION_THUMB_WIDTH );
SetItemHeight( TRANSITION_THUMB_HEIGHT );
}
virtual ~TransitionPane() { disposeOnce(); }
virtual Size GetOptimalSize() const
{
return LogicToPixel(Size(70, 88), MAP_APPFONT);
}
};
// SlideTransitionPane // SlideTransitionPane
SlideTransitionPane::SlideTransitionPane( SlideTransitionPane::SlideTransitionPane(
Window * pParent, Window * pParent,
@@ -373,7 +398,6 @@ SlideTransitionPane::SlideTransitionPane(
mbIsMainViewChangePending( false ), mbIsMainViewChangePending( false ),
maLateInitTimer() maLateInitTimer()
{ {
get(mpLB_SLIDE_TRANSITIONS, "transitions_list");
get(mpFT_VARIANT, "variant_label"); get(mpFT_VARIANT, "variant_label");
get(mpLB_VARIANT, "variant_list"); get(mpLB_VARIANT, "variant_list");
get(mpFT_SPEED, "speed_label"); get(mpFT_SPEED, "speed_label");
@@ -388,8 +412,11 @@ SlideTransitionPane::SlideTransitionPane(
get(mpPB_PLAY, "play"); get(mpPB_PLAY, "play");
get(mpCB_AUTO_PREVIEW, "auto_preview"); get(mpCB_AUTO_PREVIEW, "auto_preview");
mpLB_SLIDE_TRANSITIONS->set_width_request(mpLB_SLIDE_TRANSITIONS->approximate_char_width() * 16); VclPtr<VclAlignment> xAlign;
mpLB_SLIDE_TRANSITIONS->SetDropDownLineCount(4); get(xAlign, "transitions_icons");
mpVS_TRANSITION_ICONS = VclPtr<TransitionPane>::Create(xAlign);
mpVS_TRANSITION_ICONS->Show();
mpLB_VARIANT->SetDropDownLineCount(4); mpLB_VARIANT->SetDropDownLineCount(4);
@@ -399,9 +426,9 @@ SlideTransitionPane::SlideTransitionPane(
if( mxModel.is()) if( mxModel.is())
mxView.set( mxModel->getCurrentController(), uno::UNO_QUERY ); mxView.set( mxModel->getCurrentController(), uno::UNO_QUERY );
// fill list box of slide transitions // dummy list box of slide transitions for startup.
mpLB_SLIDE_TRANSITIONS->InsertEntry( SD_RESSTR( STR_SLIDETRANSITION_NONE ), Image( BitmapEx( "sd/cmd/transition-none.png" ) ) ); mpVS_TRANSITION_ICONS->InsertItem( 0, Image( BitmapEx( "sd/cmd/transition-none.png" ) ),
m_aTransitionLBToSet.push_back( "" ); SD_RESSTR( STR_SLIDETRANSITION_NONE ) );
// set defaults // set defaults
mpCB_AUTO_PREVIEW->Check(); // automatic preview on mpCB_AUTO_PREVIEW->Check(); // automatic preview on
@@ -413,7 +440,7 @@ SlideTransitionPane::SlideTransitionPane(
mpPB_APPLY_TO_ALL->SetClickHdl( LINK( this, SlideTransitionPane, ApplyToAllButtonClicked )); mpPB_APPLY_TO_ALL->SetClickHdl( LINK( this, SlideTransitionPane, ApplyToAllButtonClicked ));
mpPB_PLAY->SetClickHdl( LINK( this, SlideTransitionPane, PlayButtonClicked )); mpPB_PLAY->SetClickHdl( LINK( this, SlideTransitionPane, PlayButtonClicked ));
mpLB_SLIDE_TRANSITIONS->SetSelectHdl( LINK( this, SlideTransitionPane, TransitionSelected )); mpVS_TRANSITION_ICONS->SetSelectHdl( LINK( this, SlideTransitionPane, TransitionSelected ));
mpLB_VARIANT->SetSelectHdl( LINK( this, SlideTransitionPane, VariantListBoxSelected )); mpLB_VARIANT->SetSelectHdl( LINK( this, SlideTransitionPane, VariantListBoxSelected ));
mpLB_SPEED->SetSelectHdl( LINK( this, SlideTransitionPane, SpeedListBoxSelected )); mpLB_SPEED->SetSelectHdl( LINK( this, SlideTransitionPane, SpeedListBoxSelected ));
@@ -442,7 +469,7 @@ void SlideTransitionPane::dispose()
{ {
maLateInitTimer.Stop(); maLateInitTimer.Stop();
removeListener(); removeListener();
mpLB_SLIDE_TRANSITIONS.clear(); mpVS_TRANSITION_ICONS.disposeAndClear();
mpFT_VARIANT.clear(); mpFT_VARIANT.clear();
mpLB_VARIANT.clear(); mpLB_VARIANT.clear();
mpFT_SPEED.clear(); mpFT_SPEED.clear();
@@ -540,61 +567,18 @@ void SlideTransitionPane::updateControls()
// detect current slide effect // detect current slide effect
if( aEffect.mbEffectAmbiguous ) if( aEffect.mbEffectAmbiguous )
mpLB_SLIDE_TRANSITIONS->SetNoSelection(); {
SAL_WARN( "sd.transitions", "Unusual, ambiguous transition effect" );
mpVS_TRANSITION_ICONS->SetNoSelection();
}
else else
{ {
// ToDo: That 0 is "no transition" is documented nowhere except in the // ToDo: That 0 is "no transition" is documented nowhere except in the
// CTOR of sdpage // CTOR of sdpage
if( aEffect.mnType == 0 ) if( aEffect.mnType == 0 )
mpLB_SLIDE_TRANSITIONS->SelectEntryPos( 0 ); mpVS_TRANSITION_ICONS->SetNoSelection();
else else
{ updateVariants( getPresetOffset( aEffect ) );
int nEntry = LISTBOX_ENTRY_NOTFOUND;
const sd::TransitionPresetList& rPresetList = sd::TransitionPreset::getTransitionPresetList();
sd::TransitionPresetPtr pFound;
for( auto aIt: rPresetList )
{
if( aEffect.operator==( *aIt ))
{
pFound = aIt;
// This function can be called before LateInit, with m_aSetToTransitionLBIndex
// not set up properly. In that case nEntry will stay as
// LISTBOX_ENTRY_NOTFOUND. But in that case we will be called soon again, I think.
if( m_aSetToTransitionLBIndex.find( aIt->getSetId() ) != m_aSetToTransitionLBIndex.end() )
nEntry = m_aSetToTransitionLBIndex[aIt->getSetId()];
break;
}
}
mpLB_VARIANT->Clear();
if( nEntry == LISTBOX_ENTRY_NOTFOUND )
{
mpLB_SLIDE_TRANSITIONS->SetNoSelection();
mpLB_VARIANT->Enable( false );
}
else
{
// Fill in the variant listbox
for( auto aIt: rPresetList )
{
if( aIt->getSetId().equals( pFound->getSetId() ) )
{
if( !aIt->getVariantLabel().isEmpty() )
{
mpLB_VARIANT->InsertEntry( aIt->getVariantLabel() );
if( aEffect.operator==( *aIt ))
mpLB_VARIANT->SelectEntryPos( mpLB_VARIANT->GetEntryCount()-1 );
}
}
}
if( mpLB_VARIANT->GetEntryCount() == 0 )
mpLB_VARIANT->Enable( false );
else
mpLB_VARIANT->Enable();
mpLB_SLIDE_TRANSITIONS->SelectEntryPos( nEntry );
}
}
} }
if( aEffect.mbDurationAmbiguous ) if( aEffect.mbDurationAmbiguous )
@@ -664,7 +648,7 @@ void SlideTransitionPane::updateControls()
void SlideTransitionPane::updateControlState() void SlideTransitionPane::updateControlState()
{ {
mpLB_SLIDE_TRANSITIONS->Enable( mbHasSelection ); mpVS_TRANSITION_ICONS->Enable( mbHasSelection );
mpLB_VARIANT->Enable( mbHasSelection && mpLB_VARIANT->GetEntryCount() > 0 ); mpLB_VARIANT->Enable( mbHasSelection && mpLB_VARIANT->GetEntryCount() > 0 );
mpLB_SPEED->Enable( mbHasSelection ); mpLB_SPEED->Enable( mbHasSelection );
mpLB_SOUND->Enable( mbHasSelection ); mpLB_SOUND->Enable( mbHasSelection );
@@ -765,16 +749,19 @@ impl::TransitionEffect SlideTransitionPane::getTransitionEffectFromControls() co
aResult.setAllAmbiguous(); aResult.setAllAmbiguous();
// check first (aResult might be overwritten) // check first (aResult might be overwritten)
if( mpLB_SLIDE_TRANSITIONS->IsEnabled() && if( mpVS_TRANSITION_ICONS->IsEnabled() &&
mpLB_SLIDE_TRANSITIONS->GetSelectEntryCount() > 0 ) !mpVS_TRANSITION_ICONS->IsNoSelection() &&
mpVS_TRANSITION_ICONS->GetSelectItemId() > 0 )
{ {
const sd::TransitionPresetList& rPresetList = sd::TransitionPreset::getTransitionPresetList(); const sd::TransitionPresetList& rPresetList = sd::TransitionPreset::getTransitionPresetList();
auto aSelected = rPresetList.begin();
std::advance( aSelected, mpVS_TRANSITION_ICONS->GetSelectItemId() - 1);
int nVariant = 0; int nVariant = 0;
bool bFound = false; bool bFound = false;
for( auto aIter: rPresetList ) for( auto aIter: rPresetList )
{ {
if( aIter->getSetId().equals(m_aTransitionLBToSet[mpLB_SLIDE_TRANSITIONS->GetSelectEntryPos()]) ) if( aIter->getSetId() == (*aSelected)->getSetId() )
{ {
if( mpLB_VARIANT->GetSelectEntryPos() == nVariant) if( mpLB_VARIANT->GetSelectEntryPos() == nVariant)
{ {
@@ -1004,35 +991,71 @@ IMPL_LINK_NOARG_TYPED(SlideTransitionPane, PlayButtonClicked, Button*, void)
playCurrentEffect(); playCurrentEffect();
} }
IMPL_LINK_NOARG_TYPED(SlideTransitionPane, TransitionSelected, ListBox&, void) IMPL_LINK_NOARG_TYPED(SlideTransitionPane, TransitionSelected, ValueSet *, void)
{ {
mpLB_VARIANT->Clear(); updateVariants( mpVS_TRANSITION_ICONS->GetSelectItemId() - 1 );
applyToSelectedPages();
}
if( mpLB_SLIDE_TRANSITIONS->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND) /// Returns an offset into the list of transition presets
return; size_t SlideTransitionPane::getPresetOffset( const impl::TransitionEffect &rEffect )
{
if( mpLB_SLIDE_TRANSITIONS->GetSelectEntryPos() > 0) const sd::TransitionPresetList& rPresetList =
{ sd::TransitionPreset::getTransitionPresetList();
const sd::TransitionPresetList& rPresetList = sd::TransitionPreset::getTransitionPresetList(); sd::TransitionPresetPtr pFound;
size_t nIdx = 0;
for( auto aIt: rPresetList ) for( auto aIt: rPresetList )
{ {
if( m_aSetToTransitionLBIndex[aIt->getSetId()] == mpLB_SLIDE_TRANSITIONS->GetSelectEntryPos() ) if( rEffect.operator==( *aIt ))
mpLB_VARIANT->InsertEntry( aIt->getVariantLabel() ); break;
} nIdx++;
} }
return nIdx;
}
if( mpLB_VARIANT->GetEntryCount() == 0 ) /// we use an integer offset into the list of transition presets
void SlideTransitionPane::updateVariants( size_t nPresetOffset )
{
const sd::TransitionPresetList& rPresetList = sd::TransitionPreset::getTransitionPresetList();
mpLB_VARIANT->Clear();
mpVS_TRANSITION_ICONS->SetNoSelection();
if( nPresetOffset >= rPresetList.size() )
{ {
mpLB_VARIANT->Enable( false ); mpLB_VARIANT->Enable( false );
} }
else else
{ {
mpLB_VARIANT->Enable(); auto pFound = rPresetList.begin();
mpLB_VARIANT->SelectEntryPos( 0 ); std::advance( pFound, nPresetOffset );
// Fill in the variant listbox
size_t nFirstItem = 0, nItem = 1;
for( auto aIt: rPresetList )
{
if( aIt->getSetId().equals( (*pFound)->getSetId() ) )
{
if (!nFirstItem)
nFirstItem = nItem;
if( !aIt->getVariantLabel().isEmpty() )
{
mpLB_VARIANT->InsertEntry( aIt->getVariantLabel() );
if( *pFound == aIt )
mpLB_VARIANT->SelectEntryPos( mpLB_VARIANT->GetEntryCount()-1 );
}
}
nItem++;
} }
applyToSelectedPages(); if( mpLB_VARIANT->GetEntryCount() == 0 )
mpLB_VARIANT->Enable( false );
else
mpLB_VARIANT->Enable();
// item has the id of the first transition from this set.
mpVS_TRANSITION_ICONS->SelectItem( nFirstItem );
}
} }
IMPL_LINK_NOARG_TYPED(SlideTransitionPane, AdvanceSlideRadioButtonToggled, RadioButton&, void) IMPL_LINK_NOARG_TYPED(SlideTransitionPane, AdvanceSlideRadioButtonToggled, RadioButton&, void)
@@ -1086,6 +1109,7 @@ IMPL_LINK_NOARG_TYPED(SlideTransitionPane, LateInitCallback, Timer *, void)
{ {
const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList(); const TransitionPresetList& rPresetList = TransitionPreset::getTransitionPresetList();
size_t nPresetOffset = 0;
for( auto aIter: rPresetList ) for( auto aIter: rPresetList )
{ {
TransitionPresetPtr pPreset = aIter; TransitionPresetPtr pPreset = aIter;
@@ -1095,32 +1119,32 @@ IMPL_LINK_NOARG_TYPED(SlideTransitionPane, LateInitCallback, Timer *, void)
if( m_aNumVariants.find( pPreset->getSetId() ) == m_aNumVariants.end() ) if( m_aNumVariants.find( pPreset->getSetId() ) == m_aNumVariants.end() )
{ {
OUString sImageName("sd/cmd/transition-" + pPreset->getSetId() + ".png"); OUString sImageName("sd/cmd/transition-" + pPreset->getSetId() + ".png");
BitmapEx aIcon( sImageName );
if ( aIcon.IsEmpty() ) // need a fallback
aIcon = BitmapEx( "sd/cmd/transition-none.png" );
mpLB_SLIDE_TRANSITIONS->InsertEntry( sLabel, Image( BitmapEx( sImageName) ) ); mpVS_TRANSITION_ICONS->InsertItem( nPresetOffset + 1, Image( aIcon ), sLabel );
m_aTransitionLBToSet.push_back( pPreset->getSetId() );
assert( m_aTransitionLBToSet.size() == static_cast<size_t>( mpLB_SLIDE_TRANSITIONS->GetEntryCount() ) );
m_aNumVariants[ pPreset->getSetId() ] = 1; m_aNumVariants[ pPreset->getSetId() ] = 1;
m_aSetToTransitionLBIndex[ aIter->getSetId() ] = mpLB_SLIDE_TRANSITIONS->GetEntryCount() - 1;
} }
else else
{ {
m_aNumVariants[ pPreset->getSetId() ]++; m_aNumVariants[ pPreset->getSetId() ]++;
} }
} }
nPresetOffset++;
} }
for( int i = 0; i < mpLB_SLIDE_TRANSITIONS->GetEntryCount(); ++i ) SAL_INFO( "sd.transitions", "Item transition offsets in ValueSet:");
SAL_INFO("sd.transitions", i << ":" << mpLB_SLIDE_TRANSITIONS->GetEntry( i ) << " (" << m_aTransitionLBToSet[i] << ")"); for( size_t i = 0; i < mpVS_TRANSITION_ICONS->GetItemCount(); ++i )
SAL_INFO( "sd.transitions", i << ":" << mpVS_TRANSITION_ICONS->GetItemId( i ) );
nPresetOffset = 0;
SAL_INFO( "sd.transitions", "Transition presets by offsets:");
for( auto aIter: rPresetList ) for( auto aIter: rPresetList )
{ {
SAL_INFO("sd.transitions", SAL_INFO( "sd.transitions ", nPresetOffset++ << " " <<
aIter->getPresetId() << ": " << aIter->getPresetId() << ": " << aIter->getSetId() );
m_aSetToTransitionLBIndex[ aIter->getSetId() ] <<
" (" << mpLB_SLIDE_TRANSITIONS->GetEntry( m_aSetToTransitionLBIndex[ aIter->getSetId() ] ) << ")" );
} }
updateSoundList(); updateSoundList();

View File

@@ -29,6 +29,7 @@
#include <vcl/fixed.hxx> #include <vcl/fixed.hxx>
#include <vcl/button.hxx> #include <vcl/button.hxx>
#include <vcl/field.hxx> #include <vcl/field.hxx>
#include <svtools/valueset.hxx>
#include <svx/sidebar/PanelLayout.hxx> #include <svx/sidebar/PanelLayout.hxx>
#include <sfx2/sidebar/ControlFactory.hxx> #include <sfx2/sidebar/ControlFactory.hxx>
#include <com/sun/star/drawing/XDrawView.hpp> #include <com/sun/star/drawing/XDrawView.hpp>
@@ -69,6 +70,8 @@ public:
private: private:
void updateControls(); void updateControls();
void updateControlState(); void updateControlState();
void updateVariants(size_t nPresetOffset);
size_t getPresetOffset(const impl::TransitionEffect &rEffect);
void updateSoundList(); void updateSoundList();
void openSoundFileDialog(); void openSoundFileDialog();
@@ -90,20 +93,20 @@ private:
DECL_LINK_TYPED( PlayButtonClicked, Button*, void ); DECL_LINK_TYPED( PlayButtonClicked, Button*, void );
DECL_LINK_TYPED( AutoPreviewClicked, Button*, void ); DECL_LINK_TYPED( AutoPreviewClicked, Button*, void );
DECL_LINK_TYPED( TransitionSelected, ListBox&, void ); DECL_LINK_TYPED( TransitionSelected, ValueSet *, void );
DECL_LINK_TYPED( AdvanceSlideRadioButtonToggled, RadioButton&, void ); DECL_LINK_TYPED( AdvanceSlideRadioButtonToggled, RadioButton&, void );
DECL_LINK_TYPED( AdvanceTimeModified, Edit&, void ); DECL_LINK_TYPED( AdvanceTimeModified, Edit&, void );
DECL_LINK_TYPED( VariantListBoxSelected, ListBox&, void ); DECL_LINK_TYPED( VariantListBoxSelected, ListBox&, void );
DECL_LINK_TYPED( SpeedListBoxSelected, ListBox&, void ); DECL_LINK_TYPED( SpeedListBoxSelected, ListBox&, void );
DECL_LINK_TYPED( SoundListBoxSelected, ListBox&, void ); DECL_LINK_TYPED( SoundListBoxSelected, ListBox&, void );
DECL_LINK_TYPED( LoopSoundBoxChecked, Button*, void ); DECL_LINK_TYPED( LoopSoundBoxChecked, Button*, void );
DECL_LINK_TYPED(EventMultiplexerListener, tools::EventMultiplexerEvent&, void); DECL_LINK_TYPED( EventMultiplexerListener, tools::EventMultiplexerEvent&, void );
DECL_LINK_TYPED(LateInitCallback, Timer *, void); DECL_LINK_TYPED(LateInitCallback, Timer *, void);
ViewShellBase & mrBase; ViewShellBase & mrBase;
SdDrawDocument * mpDrawDoc; SdDrawDocument * mpDrawDoc;
VclPtr<ListBox> mpLB_SLIDE_TRANSITIONS; VclPtr<ValueSet> mpVS_TRANSITION_ICONS;
VclPtr<FixedText> mpFT_VARIANT; VclPtr<FixedText> mpFT_VARIANT;
VclPtr<ListBox> mpLB_VARIANT; VclPtr<ListBox> mpLB_VARIANT;
VclPtr<FixedText> mpFT_SPEED; VclPtr<FixedText> mpFT_SPEED;
@@ -129,12 +132,6 @@ private:
tSoundListType maSoundList; tSoundListType maSoundList;
mutable OUString maCurrentSoundFile; mutable OUString maCurrentSoundFile;
// Map from TransitionSets (as in Effects.xcu) to mpLB_SLIDE_TRANSITIONS entry index.
std::map< OUString, int > m_aSetToTransitionLBIndex;
// The reverse mapping: TransitionSets id of each entry in mpLB_SLIDE_TRANSITIONS.
std::vector< OUString > m_aTransitionLBToSet;
// How many variants each transition set has // How many variants each transition set has
std::map< OUString, int > m_aNumVariants; std::map< OUString, int > m_aNumVariants;

View File

@@ -25,21 +25,12 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child> <child>
<object class="GtkAlignment" id="alignment3"> <object class="GtkAlignment" id="transitions_icons">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child> <child/>
<object class="GtkTreeView" id="transitions_list:border">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>