Added selection highlight layer to view.
This commit is contained in:
@@ -19,6 +19,7 @@ set (glabels_sources
|
||||
FieldMenu.cpp
|
||||
FieldMenuItem.cpp
|
||||
File.cpp
|
||||
Handles.cpp
|
||||
Help.cpp
|
||||
LabelModel.cpp
|
||||
LabelModelObject.cpp
|
||||
@@ -27,10 +28,11 @@ set (glabels_sources
|
||||
MainWindow.cpp
|
||||
MergeField.cpp
|
||||
MergeRecord.cpp
|
||||
NewLabelDialog.cpp
|
||||
Outline.cpp
|
||||
TemplatePicker.cpp
|
||||
TemplatePickerItem.cpp
|
||||
TextNode.cpp
|
||||
NewLabelDialog.cpp
|
||||
SimplePreview.cpp
|
||||
View.cpp
|
||||
XmlLabel.cpp
|
||||
|
||||
@@ -0,0 +1,440 @@
|
||||
/* Handles.cpp
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Handles.h"
|
||||
|
||||
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
const double handlePixels = 7;
|
||||
const double handleOutlineWidthPixels = 1;
|
||||
|
||||
const QColor handleFillColor( 0, 192, 0, 96 );
|
||||
const QColor handleOutlineColor( 0, 0, 0, 192 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle Constructor
|
||||
///
|
||||
glabels::Handle::Handle( LabelModelObject* owner )
|
||||
: mOwner(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Handle Destructor
|
||||
///
|
||||
glabels::Handle::~Handle()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Handle at x,y
|
||||
///
|
||||
void glabels::Handle::drawAt( QPainter* painter, double x, double y ) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->translate( x, y );
|
||||
painter->resetTransform();
|
||||
|
||||
painter->setPen( QPen( handleOutlineColor, handleOutlineWidthPixels ) );
|
||||
painter->setBrush( handleFillColor );
|
||||
|
||||
painter->drawRect( -handlePixels/2, -handlePixels/2, handlePixels, handlePixels );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create Handle path at x,y
|
||||
///
|
||||
QPainterPath glabels::Handle::pathAt( QPainter *painter, double x, double y ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
QTransform transform = painter->transform();
|
||||
double sx = 1/transform.m11();
|
||||
double sy = 1/transform.m22();
|
||||
|
||||
path.addRect( -sx*handlePixels/2, -sy*handlePixels/2, sx*handlePixels, sy*handlePixels );
|
||||
path.translate( x, y );
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Constructor
|
||||
///
|
||||
glabels::HandleNorth::HandleNorth( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Destructor
|
||||
///
|
||||
glabels::HandleNorth::~HandleNorth()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleNorth
|
||||
///
|
||||
void glabels::HandleNorth::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Path
|
||||
///
|
||||
QPainterPath glabels::HandleNorth::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Constructor
|
||||
///
|
||||
glabels::HandleNorthEast::HandleNorthEast( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Destructor
|
||||
///
|
||||
glabels::HandleNorthEast::~HandleNorthEast()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleNorthEast
|
||||
///
|
||||
void glabels::HandleNorthEast::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Path
|
||||
///
|
||||
QPainterPath glabels::HandleNorthEast::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Constructor
|
||||
///
|
||||
glabels::HandleEast::HandleEast( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Destructor
|
||||
///
|
||||
glabels::HandleEast::~HandleEast()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleEast
|
||||
///
|
||||
void glabels::HandleEast::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Path
|
||||
///
|
||||
QPainterPath glabels::HandleEast::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Constructor
|
||||
///
|
||||
glabels::HandleSouthEast::HandleSouthEast( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Destructor
|
||||
///
|
||||
glabels::HandleSouthEast::~HandleSouthEast()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleSouthEast
|
||||
///
|
||||
void glabels::HandleSouthEast::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Path
|
||||
///
|
||||
QPainterPath glabels::HandleSouthEast::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Constructor
|
||||
///
|
||||
glabels::HandleSouth::HandleSouth( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Destructor
|
||||
///
|
||||
glabels::HandleSouth::~HandleSouth()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleSouth
|
||||
///
|
||||
void glabels::HandleSouth::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Path
|
||||
///
|
||||
QPainterPath glabels::HandleSouth::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Constructor
|
||||
///
|
||||
glabels::HandleSouthWest::HandleSouthWest( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Destructor
|
||||
///
|
||||
glabels::HandleSouthWest::~HandleSouthWest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleSouthWest
|
||||
///
|
||||
void glabels::HandleSouthWest::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Path
|
||||
///
|
||||
QPainterPath glabels::HandleSouthWest::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Constructor
|
||||
///
|
||||
glabels::HandleWest::HandleWest( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Destructor
|
||||
///
|
||||
glabels::HandleWest::~HandleWest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleWest
|
||||
///
|
||||
void glabels::HandleWest::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Path
|
||||
///
|
||||
QPainterPath glabels::HandleWest::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Constructor
|
||||
///
|
||||
glabels::HandleNorthWest::HandleNorthWest( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Destructor
|
||||
///
|
||||
glabels::HandleNorthWest::~HandleNorthWest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleNorthWest
|
||||
///
|
||||
void glabels::HandleNorthWest::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Path
|
||||
///
|
||||
QPainterPath glabels::HandleNorthWest::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Constructor
|
||||
///
|
||||
glabels::HandleP1::HandleP1( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Destructor
|
||||
///
|
||||
glabels::HandleP1::~HandleP1()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleP1
|
||||
///
|
||||
void glabels::HandleP1::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Path
|
||||
///
|
||||
QPainterPath glabels::HandleP1::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Constructor
|
||||
///
|
||||
glabels::HandleP2::HandleP2( LabelModelObject* owner )
|
||||
: Handle(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Destructor
|
||||
///
|
||||
glabels::HandleP2::~HandleP2()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw HandleP2
|
||||
///
|
||||
void glabels::HandleP2::draw( QPainter* painter ) const
|
||||
{
|
||||
drawAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Path
|
||||
///
|
||||
QPainterPath glabels::HandleP2::path( QPainter* painter ) const
|
||||
{
|
||||
return pathAt( painter, mOwner->w()/2, 0 );
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
/* Handles.h
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef glabels_Handles_h
|
||||
#define glabels_Handles_h
|
||||
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class LabelModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Handle Base Class
|
||||
///
|
||||
class Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
protected:
|
||||
Handle( LabelModelObject* owner );
|
||||
public:
|
||||
virtual ~Handle();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const = 0;
|
||||
virtual QPainterPath path( QPainter* painter ) const = 0;
|
||||
protected:
|
||||
void drawAt( QPainter* painter, double x, double y ) const;
|
||||
QPainterPath pathAt( QPainter* painter, double x, double y ) const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Protected Data
|
||||
////////////////////////////
|
||||
protected:
|
||||
LabelModelObject* mOwner;
|
||||
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorth Class
|
||||
///
|
||||
class HandleNorth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorth( LabelModelObject* owner );
|
||||
virtual ~HandleNorth();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthEast Class
|
||||
///
|
||||
class HandleNorthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorthEast( LabelModelObject* owner );
|
||||
virtual ~HandleNorthEast();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleEast Class
|
||||
///
|
||||
class HandleEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleEast( LabelModelObject* owner );
|
||||
virtual ~HandleEast();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthEast Class
|
||||
///
|
||||
class HandleSouthEast : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouthEast( LabelModelObject* owner );
|
||||
virtual ~HandleSouthEast();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouth Class
|
||||
///
|
||||
class HandleSouth : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouth( LabelModelObject* owner );
|
||||
virtual ~HandleSouth();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleSouthWest Class
|
||||
///
|
||||
class HandleSouthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleSouthWest( LabelModelObject* owner );
|
||||
virtual ~HandleSouthWest();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleWest Class
|
||||
///
|
||||
class HandleWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleWest( LabelModelObject* owner );
|
||||
virtual ~HandleWest();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleNorthWest Class
|
||||
///
|
||||
class HandleNorthWest : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleNorthWest( LabelModelObject* owner );
|
||||
virtual ~HandleNorthWest();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleP1 Class
|
||||
///
|
||||
class HandleP1 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleP1( LabelModelObject* owner );
|
||||
virtual ~HandleP1();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// HandleP2 Class
|
||||
///
|
||||
class HandleP2 : public Handle
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
HandleP2( LabelModelObject* owner );
|
||||
virtual ~HandleP2();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
virtual void draw( QPainter* painter ) const;
|
||||
virtual QPainterPath path( QPainter* painter ) const;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // glabels_Handles_h
|
||||
@@ -32,6 +32,15 @@ namespace glabels
|
||||
///
|
||||
LabelModelBoxObject::LabelModelBoxObject( QObject* parent ) : LabelModelObject(parent)
|
||||
{
|
||||
mHandles << new HandleNorthWest( this );
|
||||
mHandles << new HandleNorth( this );
|
||||
mHandles << new HandleNorthEast( this );
|
||||
mHandles << new HandleEast( this );
|
||||
mHandles << new HandleSouthEast( this );
|
||||
mHandles << new HandleSouth( this );
|
||||
mHandles << new HandleSouthWest( this );
|
||||
mHandles << new HandleWest( this );
|
||||
|
||||
/* TODO: initialize default line and fill poperties. */
|
||||
}
|
||||
|
||||
@@ -41,6 +50,11 @@ namespace glabels
|
||||
///
|
||||
LabelModelBoxObject::~LabelModelBoxObject()
|
||||
{
|
||||
foreach( Handle* handle, mHandles )
|
||||
{
|
||||
delete handle;
|
||||
}
|
||||
mHandles.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace glabels
|
||||
mShadowOpacity = 0.5;
|
||||
|
||||
mSelectedFlag = false;
|
||||
|
||||
mOutline = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -924,5 +926,31 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw selection highlights
|
||||
///
|
||||
void LabelModelObject::drawSelectionHighlight( QPainter* painter ) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->translate( mX0, mY0 );
|
||||
painter->setTransform( mMatrix, true );
|
||||
|
||||
if ( mOutline )
|
||||
{
|
||||
mOutline->draw( painter );
|
||||
}
|
||||
|
||||
foreach( Handle* handle, mHandles )
|
||||
{
|
||||
handle->draw( painter );
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include "ColorNode.h"
|
||||
#include "TextNode.h"
|
||||
#include "BarcodeStyle.h"
|
||||
|
||||
class QGraphicsItem;
|
||||
#include "Handles.h"
|
||||
#include "Outline.h"
|
||||
|
||||
|
||||
namespace glabels
|
||||
@@ -393,6 +393,7 @@ namespace glabels
|
||||
///////////////////////////////////////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter, bool inEditor, MergeRecord* record ) const;
|
||||
void drawSelectionHighlight( QPainter* painter ) const;
|
||||
|
||||
protected:
|
||||
virtual void drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const = 0;
|
||||
@@ -416,6 +417,9 @@ namespace glabels
|
||||
double mShadowOpacity;
|
||||
ColorNode mShadowColorNode;
|
||||
|
||||
QList<Handle*> mHandles;
|
||||
Outline* mOutline;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Private Members
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/* Outline.cpp
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Outline.h"
|
||||
|
||||
|
||||
#include "LabelModelObject.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
const double outlineWidthPixels = 2;
|
||||
const QColor outlineColor( 0, 0, 0, 192 );
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Outline Constructor
|
||||
///
|
||||
glabels::Outline::Outline( LabelModelObject* owner )
|
||||
: mOwner(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Outline Destructor
|
||||
///
|
||||
glabels::Outline::~Outline()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Outline
|
||||
///
|
||||
void glabels::Outline::draw( QPainter* painter ) const
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QPen pen( outlineColor, outlineWidthPixels, Qt::DotLine );
|
||||
pen.setCosmetic( true );
|
||||
painter->setPen( pen );
|
||||
painter->setBrush( Qt::NoBrush );
|
||||
|
||||
painter->drawRect( 0, 0, mOwner->w(), mOwner->h() );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Create Outline path
|
||||
///
|
||||
QPainterPath glabels::Outline::path( QPainter *painter ) const
|
||||
{
|
||||
QPainterPath path;
|
||||
|
||||
path.addRect( 0, 0, mOwner->w(), mOwner->h() );
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Outline.h
|
||||
*
|
||||
* Copyright (C) 2013 Jim Evins <evins@snaught.com>
|
||||
*
|
||||
* This file is part of gLabels-qt.
|
||||
*
|
||||
* gLabels-qt is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* gLabels-qt is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with gLabels-qt. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef glabels_Outline_h
|
||||
#define glabels_Outline_h
|
||||
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
||||
|
||||
namespace glabels
|
||||
{
|
||||
|
||||
class LabelModelObject;
|
||||
|
||||
|
||||
///
|
||||
/// Outline Base Class
|
||||
///
|
||||
class Outline
|
||||
{
|
||||
////////////////////////////
|
||||
// Lifecycle Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
Outline( LabelModelObject* owner );
|
||||
virtual ~Outline();
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Drawing Methods
|
||||
////////////////////////////
|
||||
public:
|
||||
void draw( QPainter* painter ) const;
|
||||
QPainterPath path( QPainter* painter ) const;
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// Private Data
|
||||
////////////////////////////
|
||||
private:
|
||||
LabelModelObject* mOwner;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // glabels_Outline_h
|
||||
@@ -289,6 +289,7 @@ glabels::View::paintEvent( QPaintEvent* event )
|
||||
drawMarkupLayer( &painter );
|
||||
drawObjectsLayer( &painter );
|
||||
drawFgLayer( &painter );
|
||||
drawHighlightLayer( &painter );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,3 +663,23 @@ glabels::View::drawFgLayer( QPainter* painter )
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Draw Highlight Layer
|
||||
///
|
||||
void
|
||||
glabels::View::drawHighlightLayer( QPainter* painter )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
foreach ( LabelModelObject* object, mModel->objectList() )
|
||||
{
|
||||
if ( object->isSelected() )
|
||||
{
|
||||
object->drawSelectionHighlight( painter );
|
||||
}
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user