summaryrefslogtreecommitdiff
path: root/svx/source/gallery2/galctrl.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-05-07 13:53:03 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-19 10:10:05 +0100
commit5c346ec8521b0f137273e5055fc19eee37a20169 (patch)
tree4b28c5d79c78ddcf8509ca04224996df80740567 /svx/source/gallery2/galctrl.cxx
parent0b9bf62d3ddfe3fd1ed9ec4cc8eddf23793ee932 (diff)
Resolves: #i122231# Buffered content for gallery themes
better graphical preparation (currently BMP_SCALE_BESTQUALITY, but can be changed in a single place now if wanted) (cherry picked from commit d32f1d358dcd2574d8ae6cd19da01b7311ef5926) Conflicts: svx/inc/svx/galtheme.hxx svx/source/gallery2/galctrl.cxx svx/source/gallery2/galtheme.cxx Change-Id: I80879ca472c784f764126676046c1388e1167652
Diffstat (limited to 'svx/source/gallery2/galctrl.cxx')
-rw-r--r--svx/source/gallery2/galctrl.cxx410
1 files changed, 289 insertions, 121 deletions
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index 2aacbaab4539..3e085395ba77 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -325,82 +325,158 @@ void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
if( nId && mpTheme )
{
- SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
+ const Rectangle& rRect = rUDEvt.GetRect();
+ const Size aSize(rRect.GetWidth(), rRect.GetHeight());
+ BitmapEx aBitmapEx;
+ Size aPreparedSize;
+ String aItemTextTitle;
+ String aItemTextPath;
- if( pObj )
- {
- const Rectangle& rRect = rUDEvt.GetRect();
- OutputDevice* pDev = rUDEvt.GetDevice();
- Graphic aGraphic;
- bool bTransparent(false);
+ mpTheme->GetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aPreparedSize, aItemTextTitle, aItemTextPath);
- if( pObj->IsThumbBitmap() )
- {
- BitmapEx aBitmapEx;
+ bool bNeedToCreate(aBitmapEx.IsEmpty());
- if( pObj->GetObjKind() == SGA_OBJ_SOUND )
- {
- Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
+ if(!bNeedToCreate && !aItemTextTitle.Len())
+ {
+ bNeedToCreate = true;
+ }
- aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
- aBitmapEx = BitmapEx(aTemp);
- }
- else
- {
- aBitmapEx = pObj->GetThumbBmp();
- bTransparent = aBitmapEx.IsTransparent();
- }
+ if(!bNeedToCreate && aPreparedSize != aSize)
+ {
+ bNeedToCreate = true;
+ }
- if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
- {
- aBitmapEx.Dither( BMP_DITHER_FLOYD );
- }
+ if(bNeedToCreate)
+ {
+ SgaObject* pObj = mpTheme->AcquireObject(nId - 1);
- aGraphic = aBitmapEx;
- }
- else
+ if(pObj)
{
- aGraphic = pObj->GetThumbMtf();
- bTransparent = true;
+ aBitmapEx = pObj->createPreviewBitmapEx(aSize);
+ aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
+
+ mpTheme->SetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
+ mpTheme->ReleaseObject(pObj);
}
+ }
- Size aSize( aGraphic.GetSizePixel( pDev ) );
+ if(!aBitmapEx.IsEmpty())
+ {
+ const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ const Point aPos(
+ ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
+ OutputDevice* pDev = rUDEvt.GetDevice();
- if ( aSize.Width() && aSize.Height() )
+ if(aBitmapEx.IsTransparent())
{
- if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
- {
- const double fBmpWH = (double) aSize.Width() / aSize.Height();
- const double fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
-
- // Bitmap an Thumbgroesse anpassen
- if ( fBmpWH < fThmpWH )
- {
- aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
- aSize.Height()= rRect.GetHeight();
- }
- else
- {
- aSize.Width() = rRect.GetWidth();
- aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
- }
- }
-
- const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
- ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
-
- if(bTransparent)
- {
- // draw checkered background for full rectangle.
- drawTransparenceBackground(*pDev, rRect.TopLeft(), rRect.GetSize());
- }
-
- aGraphic.Draw( pDev, aPos, aSize );
+ // draw checkered background for full rectangle.
+ drawTransparenceBackground(*pDev, rRect.TopLeft(), rRect.GetSize());
}
- SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
- mpTheme->ReleaseObject( pObj );
+ pDev->DrawBitmapEx(aPos, aBitmapEx);
}
+
+ SetItemText(nId, aItemTextTitle);
+
+ //SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
+ //
+ //if( pObj )
+ //{
+ // const Rectangle& rRect = rUDEvt.GetRect();
+ // const Size aSize(rRect.GetWidth(), rRect.GetHeight());
+ // const BitmapEx aBitmapEx(pObj->createPreviewBitmapEx(aSize));
+ // const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ //
+ // if(!aBitmapEx.IsEmpty())
+ // {
+ // const Point aPos(
+ // ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ // ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
+ // OutputDevice* pDev = rUDEvt.GetDevice();
+ //
+ // if(aBitmapEx.IsTransparent())
+ // {
+ // // draw checkered background
+ // drawTransparenceBackground(*pDev, aPos, aBitmapExSizePixel);
+ // }
+ //
+ // pDev->DrawBitmapEx(aPos, aBitmapEx);
+ // }
+ //
+ // //const Rectangle& rRect = rUDEvt.GetRect();
+ // //OutputDevice* pDev = rUDEvt.GetDevice();
+ // //Graphic aGraphic;
+ // //bool bTransparent(false);
+ // //
+ // //if( pObj->IsThumbBitmap() )
+ // //{
+ // // BitmapEx aBitmapEx;
+ // //
+ // // if( pObj->GetObjKind() == SGA_OBJ_SOUND )
+ // // {
+ // // Bitmap aTemp = pObj->GetThumbBmp().GetBitmap();
+ // //
+ // // aTemp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
+ // // aBitmapEx = BitmapEx(aTemp);
+ // // }
+ // // else
+ // // {
+ // // aBitmapEx = pObj->GetThumbBmp();
+ // // bTransparent = aBitmapEx.IsTransparent();
+ // // }
+ // //
+ // // if( ( pDev->GetBitCount() <= 8 ) && ( aBitmapEx.GetBitCount() >= 8 ) )
+ // // {
+ // // aBitmapEx.Dither( BMP_DITHER_FLOYD );
+ // // }
+ // //
+ // // aGraphic = aBitmapEx;
+ // //}
+ // //else
+ // //{
+ // // aGraphic = pObj->GetThumbMtf();
+ // // bTransparent = true;
+ // //}
+ // //
+ // //Size aSize( aGraphic.GetSizePixel( pDev ) );
+ // //
+ // //if ( aSize.Width() && aSize.Height() )
+ // //{
+ // // if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
+ // // {
+ // // Point aNewPos;
+ // // const double fBmpWH = (double) aSize.Width() / aSize.Height();
+ // // const double fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
+ // //
+ // // // Bitmap an Thumbgroesse anpassen
+ // // if ( fBmpWH < fThmpWH )
+ // // {
+ // // aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
+ // // aSize.Height()= rRect.GetHeight();
+ // // }
+ // // else
+ // // {
+ // // aSize.Width() = rRect.GetWidth();
+ // // aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
+ // // }
+ // // }
+ // //
+ // // const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
+ // // ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
+ // //
+ // // if(bTransparent)
+ // // {
+ // // // draw checkered background
+ // // drawTransparenceBackground(*pDev, aPos, aSize);
+ // // }
+ // //
+ // // aGraphic.Draw( pDev, aPos, aSize );
+ // //}
+ //
+ // SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE) );
+ // mpTheme->ReleaseObject( pObj );
+ //}
}
}
@@ -550,79 +626,171 @@ void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, sa
if( mpTheme && ( mnCurRow < mpTheme->GetObjectCount() ) )
{
- SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
+ const Size aSize(rRect.GetHeight(), rRect.GetHeight());
+ BitmapEx aBitmapEx;
+ Size aPreparedSize;
+ String aItemTextTitle;
+ String aItemTextPath;
- if( pObj )
+ mpTheme->GetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aPreparedSize, aItemTextTitle, aItemTextPath);
+
+ bool bNeedToCreate(aBitmapEx.IsEmpty());
+
+ if(!bNeedToCreate && GALLERY_BRWBOX_TITLE == nColumnId && !aItemTextTitle.Len())
+ {
+ bNeedToCreate = true;
+ }
+
+ if(!bNeedToCreate && GALLERY_BRWBOX_PATH == nColumnId && !aItemTextPath.Len())
+ {
+ bNeedToCreate = true;
+ }
+
+ if(!bNeedToCreate && aPreparedSize != aSize)
{
- const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
+ bNeedToCreate = true;
+ }
- if( GALLERY_BRWBOX_TITLE == nColumnId )
+ if(bNeedToCreate)
+ {
+ SgaObject* pObj = mpTheme->AcquireObject(mnCurRow);
+
+ if(pObj)
{
- Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
- GraphicObject aGrfObj;
- bool bTransparent(false);
+ aBitmapEx = pObj->createPreviewBitmapEx(aSize);
+ aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_TITLE);
+ aItemTextPath = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GALLERY_ITEM_PATH);
- if( pObj->GetObjKind() == SGA_OBJ_SOUND )
- {
- aGrfObj = Graphic( BitmapEx( GAL_RES( RID_SVXBMP_GALLERY_MEDIA ) ) );
- }
- else if( pObj->IsThumbBitmap() )
- {
- const BitmapEx aBitmapEx(pObj->GetThumbBmp());
+ mpTheme->SetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
+ mpTheme->ReleaseObject(pObj);
+ }
+ }
- bTransparent = aBitmapEx.IsTransparent();
- aGrfObj = Graphic(aBitmapEx);
- }
- else
- {
- aGrfObj = Graphic( pObj->GetThumbMtf() );
- bTransparent = true;
- }
+ const long nTextPosY(rRect.Top() + ((rRect.GetHeight() - rDev.GetTextHeight()) >> 1));
- Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
+ if(GALLERY_BRWBOX_TITLE == nColumnId)
+ {
+ if(!aBitmapEx.IsEmpty())
+ {
+ const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ const Point aPos(
+ ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
- if( aSize.Width() && aSize.Height() )
+ if(aBitmapEx.IsTransparent())
{
- if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
- {
- const double fBmpWH = (double) aSize.Width() / aSize.Height();
- const double fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
-
- // Bitmap an Thumbgroesse anpassen
- if ( fBmpWH < fThmpWH )
- {
- aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
- aSize.Height()= aOutputRect.GetHeight();
- }
- else
- {
- aSize.Width() = aOutputRect.GetWidth();
- aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
- }
- }
-
- aSize.Width() = std::max( aSize.Width(), 4L );
- aSize.Height() = std::max( aSize.Height(), 4L );
-
- const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
- ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
-
- if(bTransparent)
- {
- // draw checkered background
- drawTransparenceBackground(rDev, aPos, aSize);
- }
-
- aGrfObj.Draw( &rDev, aPos, aSize );
+ // draw checkered background
+ drawTransparenceBackground(rDev, aPos, aBitmapExSizePixel);
}
- rDev.DrawText( Point( aOutputRect.Right() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
+ rDev.DrawBitmapEx(aPos, aBitmapEx);
}
- else if( GALLERY_BRWBOX_PATH == nColumnId )
- rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
- mpTheme->ReleaseObject( pObj );
+ rDev.DrawText(Point(rRect.Left() + rRect.GetHeight() + 6, nTextPosY), aItemTextTitle);
+ }
+ else if(GALLERY_BRWBOX_PATH == nColumnId)
+ {
+ rDev.DrawText(Point(rRect.Left(), nTextPosY), aItemTextPath);
}
+
+
+ //SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
+ //
+ //if( pObj )
+ //{
+ // const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
+ //
+ // if( GALLERY_BRWBOX_TITLE == nColumnId )
+ // {
+ // const Size aSize(rRect.GetHeight(), rRect.GetHeight());
+ // const BitmapEx aBitmapEx(pObj->createPreviewBitmapEx(aSize));
+ // const Size aBitmapExSizePixel(aBitmapEx.GetSizePixel());
+ //
+ // if(!aBitmapEx.IsEmpty())
+ // {
+ // const Point aPos(
+ // ((aSize.Width() - aBitmapExSizePixel.Width()) >> 1) + rRect.Left(),
+ // ((aSize.Height() - aBitmapExSizePixel.Height()) >> 1) + rRect.Top());
+ //
+ // if(aBitmapEx.IsTransparent())
+ // {
+ // // draw checkered background
+ // drawTransparenceBackground(rDev, aPos, aBitmapExSizePixel);
+ // }
+ //
+ // rDev.DrawBitmapEx(aPos, aBitmapEx);
+ // }
+ //
+ //
+ // //Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
+ // //GraphicObject aGrfObj;
+ // //bool bTransparent(false);
+ // //
+ // //if( pObj->GetObjKind() == SGA_OBJ_SOUND )
+ // //{
+ // // aGrfObj = Graphic( BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) ) );
+ // //}
+ // //else if( pObj->IsThumbBitmap() )
+ // //{
+ // // const BitmapEx aBitmapEx(pObj->GetThumbBmp());
+ // //
+ // // bTransparent = aBitmapEx.IsTransparent();
+ // // aGrfObj = Graphic(aBitmapEx);
+ // //}
+ // //else
+ // //{
+ // // aGrfObj = Graphic( pObj->GetThumbMtf() );
+ // // bTransparent = true;
+ // //}
+ // //
+ // //Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
+ // //
+ // //if( aSize.Width() && aSize.Height() )
+ // //{
+ // // if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
+ // // {
+ // // Point aNewPos;
+ // // const double fBmpWH = (double) aSize.Width() / aSize.Height();
+ // // const double fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
+ // //
+ // // // Bitmap an Thumbgroesse anpassen
+ // // if ( fBmpWH < fThmpWH )
+ // // {
+ // // aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
+ // // aSize.Height()= aOutputRect.GetHeight();
+ // // }
+ // // else
+ // // {
+ // // aSize.Width() = aOutputRect.GetWidth();
+ // // aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
+ // // }
+ // // }
+ // //
+ // // aSize.Width() = Max( aSize.Width(), 4L );
+ // // aSize.Height() = Max( aSize.Height(), 4L );
+ // //
+ // // const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
+ // // ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
+ // //
+ // // if(bTransparent)
+ // // {
+ // // // draw checkered background
+ // // drawTransparenceBackground(rDev, aPos, aSize);
+ // // }
+ // //
+ // // aGrfObj.Draw( &rDev, aPos, aSize );
+ // //}
+ //
+ // // aOutputRect.Right() is here rRect.Left() + rRect.GetHeight()
+ // rDev.DrawText( Point( rRect.Left() + rRect.GetHeight() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
+ // }
+ // else if( GALLERY_BRWBOX_PATH == nColumnId )
+ // {
+ // rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
+ // }
+ //
+ // mpTheme->ReleaseObject( pObj );
+ //}
}
rDev.Pop();