diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-30 07:42:21 +0200 |
---|---|---|
committer | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-30 07:45:23 +0200 |
commit | a4decedeb6dc15e2bbd26217ed9f49903847fa3c (patch) | |
tree | 431322b1cd4f0014b6c57703b5d3171209c656d5 /sd | |
parent | 580b1890d8985d4248b1d5d783ad379d64e82259 (diff) |
Impress Remote Dialog: avoid flickering when device selected.
Changing visibility of items (i.e. the pin box / deauthorise button)
whilst painting the ClientBox can cause extra Paint request to be fired,
essentially resulting in an infinite loop (although slightly slowed
down by going through a VCL timer). These repeated paints (and repeated
hide/showing) of items resulted in a rather ugly flickering, which
is now gone.
Change-Id: Ib6b22dd1b08f3be5d1f543cfbb27a1ed782b5720
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/dlg/RemoteDialogClientBox.cxx | 111 | ||||
-rw-r--r-- | sd/source/ui/dlg/RemoteDialogClientBox.hxx | 1 |
2 files changed, 61 insertions, 51 deletions
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx index f65145775121..f59347bf9b38 100644 --- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx +++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx @@ -84,7 +84,6 @@ ClientBox::ClientBox( Window* pParent, WinBits nStyle ) : m_aDeauthoriseButton.SetText( SD_RESSTR(STR_DEAUTHORISE_CLIENT) ); m_aDeauthoriseButton.SetClickHdl( LINK( this, ClientBox, DeauthoriseHdl ) ); - SetPaintTransparent( true ); SetPosPixel( Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ) ); long nIconHeight = 2*TOP_OFFSET + SMALL_ICON_SIZE; long nTitleHeight = 2*TOP_OFFSET + GetTextHeight(); @@ -245,15 +244,30 @@ void ClientBox::selectEntry( const long nPos ) } } + // We empty the pin box now too, just in case the user previously + // entered a pin, but then changed their selected device. + m_aPinBox.SetText( "" ); + if ( m_bHasActive ) + { + bool bAlreadyAuthorised = + m_vEntries[ m_nActive ]->m_pClientInfo->mbIsAlreadyAuthorised; + + if ( bAlreadyAuthorised ) + { + m_aDeauthoriseButton.GetFocus(); + } + else + { + m_aPinBox.GetFocus(); + } + } + if ( IsReallyVisible() ) { m_bNeedsRecalc = true; Invalidate(); } - // We empty the pin box now too, just in case the user previously - // entered a pin, but then changed their selected device. - m_aPinBox.SetText( "" ); guard.clear(); } @@ -317,43 +331,9 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry ) aPos.Y() += aTextHeight; if ( pEntry->m_bActive ) { - Size aSize = LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ), - MapMode( MAP_APPFONT ) ); - m_aPinBox.SetSizePixel( aSize ); - m_aDeauthoriseButton.SetSizePixel( m_aDeauthoriseButton.GetOptimalSize() ); - const Rectangle aRect( GetEntryRect( m_nActive ) ); - Size aBtnSize( m_aPinBox.GetSizePixel() ); - Point aBtnPos( aRect.Left(), - aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() ); - - bool bAlreadyAuthorised = pEntry->m_pClientInfo->mbIsAlreadyAuthorised; - - if ( !bAlreadyAuthorised ) - { - OUString sPinText(SD_RESSTR(STR_ENTER_PIN)); - DrawText( Rectangle( aBtnPos.X(), aBtnPos.Y(), rRect.Right(), rRect.Bottom() - TOP_OFFSET), - sPinText, 0 ); - - aBtnPos = Point( aRect.Left() + GetTextWidth( sPinText ), - aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() ); - } - m_aPinBox.SetPosPixel( aBtnPos ); - m_aPinBox.Show( !bAlreadyAuthorised ); - - aBtnPos.Move( 20, 0 ); - m_aDeauthoriseButton.SetPosPixel( aBtnPos ); - m_aDeauthoriseButton.Show( bAlreadyAuthorised ); - if ( bAlreadyAuthorised ) - { - m_aDeauthoriseButton.GetFocus(); - } - else - { - m_aPinBox.GetFocus(); - } - } - else - { + OUString sPinText(SD_RESSTR(STR_ENTER_PIN)); + DrawText( m_sPinTextRect, + sPinText, 0 ); } SetLineColor( Color( COL_LIGHTGRAY ) ); @@ -367,10 +347,48 @@ void ClientBox::RecalcAll() SetupScrollBar(); - if ( m_bHasActive ) + Size aPBSize = LogicToPixel( + Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ), + MapMode( MAP_APPFONT ) ); + m_aPinBox.SetSizePixel( aPBSize ); + m_aDeauthoriseButton.SetSizePixel( m_aDeauthoriseButton.GetOptimalSize() ); + + if ( !m_bHasActive ) + { + m_aPinBox.Show( false ); + m_aDeauthoriseButton.Show( false ); + } + else { Rectangle aEntryRect = GetEntryRect( m_nActive ); + Size aPinBoxSize( m_aPinBox.GetSizePixel() ); + Point aPos( aEntryRect.Left(), + aEntryRect.Bottom() - TOP_OFFSET - aPinBoxSize.Height() ); + + bool bAlreadyAuthorised = m_vEntries[ m_nActive ]->m_pClientInfo->mbIsAlreadyAuthorised; + + if ( !bAlreadyAuthorised ) + { + m_sPinTextRect = Rectangle( aPos.X(), aPos.Y(), + aEntryRect.Right(), + aEntryRect.Bottom() - TOP_OFFSET); + + OUString sPinText(SD_RESSTR(STR_ENTER_PIN)); + + aPos = Point( aEntryRect.Left() + GetTextWidth( sPinText ), + aEntryRect.Bottom() - TOP_OFFSET - aPinBoxSize.Height() ); + m_aPinBox.SetPosPixel( aPos ); + } + else + { + aPos += Point( 20, 0 ); + m_aDeauthoriseButton.SetPosPixel( aPos ); + } + + m_aPinBox.Show( !bAlreadyAuthorised ); + m_aDeauthoriseButton.Show( bAlreadyAuthorised ); + if ( m_bAdjustActive ) { m_bAdjustActive = false; @@ -475,15 +493,6 @@ void ClientBox::Paint( const Rectangle &/*rPaintRect*/ ) const ::osl::MutexGuard aGuard( m_entriesMutex ); - // It's easiest to disbale these and only reenable as appropriate in DrawRow - // -- both are shown in only certain situations, and e.g. if we've removed - // the last entry then the visibility of the deauthorise button won't be - // changed in the loop below, or when we select 0 entries then we - // won't run through the appropriate conditions which would otherwise - // set the visibility of the pin-box. - m_aDeauthoriseButton.Show( false ); - m_aPinBox.Show( false ); - typedef std::vector< TClientBoxEntry >::iterator ITER; for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex ) { diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.hxx b/sd/source/ui/dlg/RemoteDialogClientBox.hxx index 1d07cbdfa1b8..bcbf6214673d 100644 --- a/sd/source/ui/dlg/RemoteDialogClientBox.hxx +++ b/sd/source/ui/dlg/RemoteDialogClientBox.hxx @@ -103,6 +103,7 @@ class ClientBox: NumericBox m_aPinBox; PushButton m_aDeauthoriseButton; + Rectangle m_sPinTextRect; ScrollBar m_aScrollBar; |