Commit aac97d1d authored by Jan Hambrecht's avatar Jan Hambrecht

Prepare for an infinite canvas mode in the canvas controller.

The methods centerCanvas and isCanvasCentered got replaced by
setCanvasMode and canvasMode which are setters/getters for the
CanvasMode enum. Possible modes are Centered, AlignLeft, Infinite
as of now. Centered and AlignLeft map to the old centered/uncentered
behaviour, Infinite is not implemented yet.


svn path=/trunk/koffice/; revision=648567
parent 7bfbe91e
......@@ -38,9 +38,9 @@
class KoCanvasController::Private
{
public:
Private() : canvas(0), centerCanvas(true), toolOptionWidget(0), margin(0) {}
Private() : canvas(0), canvasMode( Centered ), toolOptionWidget(0), margin(0) {}
KoCanvasBase * canvas;
bool centerCanvas;
CanvasMode canvasMode;
QWidget * toolOptionWidget;
int margin; // The viewport margin around the document
QSize documentSize;
......@@ -141,14 +141,14 @@ int KoCanvasController::visibleWidth() const {
return qMin(width1, width2);
}
bool KoCanvasController::isCanvasCentered() const {
return m_d->centerCanvas;
void KoCanvasController::setCanvasMode( CanvasMode mode )
{
m_d->canvasMode = mode;
}
void KoCanvasController::centerCanvas(bool centered)
KoCanvasController::CanvasMode KoCanvasController::canvasMode() const
{
Q_UNUSED( centered );
m_d->centerCanvas = true;
return m_d->canvasMode;
}
int KoCanvasController::canvasOffsetX() const {
......
......@@ -56,6 +56,12 @@ class KoCanvasBase;
class FLAKE_EXPORT KoCanvasController : public QAbstractScrollArea {
Q_OBJECT
public:
enum CanvasMode {
AlignLeft, ///< canvas is left aligned if smaller than the viewport
Centered, ///< canvas is centered if smaller than the viewport
Infinite ///< canvas is never smaller than the viewport
};
/**
* Constructor.
* @param parent the parent this widget will belong to
......@@ -105,18 +111,13 @@ public:
int canvasOffsetY() const;
/**
* Set the canvas to be displayed centered in this widget.
* In the case that the canvas widget is smaller then this one the canvas will be centered
* and a contrasting color used for the background.
* @param centered center canvas if true, or aligned to the left (LTR) if false.
* Centered is the default value.
*/
void centerCanvas(bool centered);
/**
* return the canvas centering value.
* @return the canvas centering value
* Sets the how the canvas behaves if the zoomed document becomes smaller than the viewport.
* @param mode the new canvas mode, CanvasMode::Centered is the default value
*/
bool isCanvasCentered() const;
void setCanvasMode( CanvasMode mode );
/// Returns the current canvas mode
CanvasMode canvasMode() const;
/// Reimplemented from QObject
virtual bool eventFilter(QObject* watched, QEvent* event);
......
......@@ -299,7 +299,7 @@ void Viewport::resetLayout()
if ( marginBottom > 0 ) resizeH = viewH - marginBottom;
}
if(!m_parent->isCanvasCentered()) {
if( m_parent->canvasMode() == KoCanvasController::AlignLeft ) {
resizeH -= moveY;
moveY = 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment