Draw borders arounds thumbnail.

Change-Id: Icaf9485d20c8e747d08371a1db5f4d7bee2d37bb
This commit is contained in:
Rafael Dominguez 2012-08-12 23:33:20 -04:30
parent e51dc25f45
commit 6050dad25f
4 changed files with 89 additions and 7 deletions

View file

@ -44,10 +44,18 @@ class Font;
class Window;
class ThumbnailView;
namespace basegfx {
class B2DPoint;
}
namespace drawinglayer {
namespace processor2d {
class BaseProcessor2D;
}
namespace primitive2d {
class BorderLinePrimitive2D;
}
}
struct ThumbnailItemAttributes
@ -109,6 +117,9 @@ public:
virtual void Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
const ThumbnailItemAttributes *pAttrs);
static drawinglayer::primitive2d::BorderLinePrimitive2D*
createBorderLine (const basegfx::B2DPoint &rStart, const basegfx::B2DPoint &rEnd);
private:
DECL_LINK (OnClick, CheckBox *);

View file

@ -12,6 +12,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <drawinglayer/attribute/fillbitmapattribute.hxx>
#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
@ -38,10 +39,10 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p
const ThumbnailItemAttributes *pAttrs)
{
int nCount = 0;
int nSeqSize = 3;
int nSeqSize = 7;
if (!maPreview2.IsEmpty())
++nSeqSize;
nSeqSize += 5;
BColor aFillColor = pAttrs->aFillColor;
Primitive2DSequence aSeq(nSeqSize);
@ -73,6 +74,21 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p
B2DVector(aImageSize.Width(),aImageSize.Height()),
false)
));
// draw thumbnail borders
float fWidth = aImageSize.Width()*fScaleX;
float fHeight = aImageSize.Height()*fScaleY;
float fPosX = aPos.getX()+35*fScaleX;
float fPosY = aPos.getY()+20*fScaleY;
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
B2DPoint(fPosX+fWidth,fPosY)));
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
B2DPoint(fPosX+fWidth,fPosY+fHeight)));
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
B2DPoint(fPosX,fPosY+fHeight)));
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
B2DPoint(fPosX,fPosY)));
}
aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D(
@ -83,6 +99,21 @@ void TemplateLocalViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *p
false)
));
// draw thumbnail borders
float fWidth = aImageSize.Width()*fScaleX;
float fHeight = aImageSize.Height()*fScaleY;
float fPosX = aPos.getX();
float fPosY = aPos.getY();
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
B2DPoint(fPosX+fWidth,fPosY)));
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
B2DPoint(fPosX+fWidth,fPosY+fHeight)));
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
B2DPoint(fPosX,fPosY+fHeight)));
aSeq[nCount++] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
B2DPoint(fPosX,fPosY)));
// Draw centered text below thumbnail
aPos = maTextPos;

View file

@ -12,6 +12,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <drawinglayer/attribute/fillbitmapattribute.hxx>
#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
@ -63,7 +64,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces
{
BColor aFillColor = pAttrs->aFillColor;
int nCount = maSubTitle.isEmpty() ? 3 : 4;
int nCount = maSubTitle.isEmpty() ? 7 : 8;
Primitive2DSequence aSeq(nCount);
// Draw background
@ -85,6 +86,21 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces
false)
));
// draw thumbnail borders
float fWidth = aImageSize.Width();
float fHeight = aImageSize.Height();
float fPosX = maPrev1Pos.getX();
float fPosY = maPrev1Pos.getY();
aSeq[2] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
B2DPoint(fPosX+fWidth,fPosY)));
aSeq[3] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
B2DPoint(fPosX+fWidth,fPosY+fHeight)));
aSeq[4] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
B2DPoint(fPosX,fPosY+fHeight)));
aSeq[5] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
B2DPoint(fPosX,fPosY)));
// Draw centered text below thumbnail
// Create the text primitive
@ -92,7 +108,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces
pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
double( maTextPos.X() ), double( maTextPos.Y() ) ) );
aSeq[2] = Primitive2DReference(
aSeq[6] = Primitive2DReference(
new TextSimplePortionPrimitive2D(aTitleMatrix,
maTitle,0,pAttrs->nMaxTextLenght,
std::vector< double >( ),
@ -106,7 +122,7 @@ void TemplateViewItem::Paint(drawinglayer::processor2d::BaseProcessor2D *pProces
pAttrs->aFontSize.getX()*SUBTITLE_SCALE_FACTOR, pAttrs->aFontSize.getY()*SUBTITLE_SCALE_FACTOR,
double( maSubTitlePos.X() ), double( maSubTitlePos.Y() ) ) );
aSeq[3] = Primitive2DReference(
aSeq[8] = Primitive2DReference(
new TextSimplePortionPrimitive2D(aSubTitleMatrix,
maSubTitle,0,pAttrs->nMaxTextLenght,
std::vector< double >( ),

View file

@ -35,6 +35,7 @@
#include <basegfx/vector/b2dsize.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <drawinglayer/attribute/fillbitmapattribute.hxx>
#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
@ -160,7 +161,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
const ThumbnailItemAttributes *pAttrs)
{
BColor aFillColor = pAttrs->aFillColor;
Primitive2DSequence aSeq(3);
Primitive2DSequence aSeq(7);
// Draw background
if ( mbSelected || mbHover )
@ -182,6 +183,21 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
false)
));
// draw thumbnail borders
float fWidth = aImageSize.Width();
float fHeight = aImageSize.Height();
float fPosX = maPrev1Pos.getX();
float fPosY = maPrev1Pos.getY();
aSeq[2] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY),
B2DPoint(fPosX+fWidth,fPosY)));
aSeq[3] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY),
B2DPoint(fPosX+fWidth,fPosY+fHeight)));
aSeq[4] = Primitive2DReference(createBorderLine(B2DPoint(fPosX+fWidth,fPosY+fHeight),
B2DPoint(fPosX,fPosY+fHeight)));
aSeq[5] = Primitive2DReference(createBorderLine(B2DPoint(fPosX,fPosY+fHeight),
B2DPoint(fPosX,fPosY)));
// Draw centered text below thumbnail
aPos = maTextPos;
@ -190,7 +206,7 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
double( aPos.X() ), double( aPos.Y() ) ) );
aSeq[2] = Primitive2DReference(
aSeq[6] = Primitive2DReference(
new TextSimplePortionPrimitive2D(aTextMatrix,
maTitle,0,pAttrs->nMaxTextLenght,
std::vector< double >( ),
@ -204,6 +220,14 @@ void ThumbnailViewItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProc
mpSelectBox->Paint(maDrawArea);
}
drawinglayer::primitive2d::BorderLinePrimitive2D*
ThumbnailViewItem::createBorderLine (const basegfx::B2DPoint &rStart, const basegfx::B2DPoint &rEnd)
{
return new BorderLinePrimitive2D(rStart,rEnd,0.5,0,0,0,0,0,0,
BColor(),Color(COL_BLACK).getBColor(),BColor(),
false,STYLE_SOLID);
}
IMPL_LINK (ThumbnailViewItem, OnClick, CheckBox*, )
{
mbSelected = mpSelectBox->GetState() == STATE_CHECK;