Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Tusooa Zhu
Krita
Commits
20782b33
Commit
20782b33
authored
Apr 15, 2007
by
Adrian Page
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement the 'actual pixels' zoom mode.
svn path=/trunk/koffice/; revision=654364
parent
7760ae06
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
155 additions
and
8 deletions
+155
-8
krita/ui/kis_view2.cpp
krita/ui/kis_view2.cpp
+2
-0
krita/ui/kis_zoom_manager.cc
krita/ui/kis_zoom_manager.cc
+5
-0
krita/ui/kis_zoom_manager.h
krita/ui/kis_zoom_manager.h
+8
-0
libs/flake/KoCanvasController_p.cpp
libs/flake/KoCanvasController_p.cpp
+6
-4
libs/kofficeui/KoZoomController.cpp
libs/kofficeui/KoZoomController.cpp
+25
-3
libs/kofficeui/KoZoomController.h
libs/kofficeui/KoZoomController.h
+12
-1
libs/kofficeui/tests/CMakeLists.txt
libs/kofficeui/tests/CMakeLists.txt
+12
-0
libs/kofficeui/tests/zoomcontroller_test.cpp
libs/kofficeui/tests/zoomcontroller_test.cpp
+50
-0
libs/kofficeui/tests/zoomcontroller_test.h
libs/kofficeui/tests/zoomcontroller_test.h
+35
-0
No files found.
krita/ui/kis_view2.cpp
View file @
20782b33
...
...
@@ -369,6 +369,8 @@ void KisView2::slotLoadingFinished()
m_d
->
statusBar
->
imageSizeChanged
(
img
->
width
(),
img
->
height
());
}
m_d
->
zoomManager
->
setDocumentResolution
(
img
->
xRes
(),
img
->
yRes
());
m_d
->
layerManager
->
layersUpdated
();
updateGUI
();
...
...
krita/ui/kis_zoom_manager.cc
View file @
20782b33
...
...
@@ -151,4 +151,9 @@ void KisZoomManager::slotZoomChanged(KoZoomMode::Mode mode, double zoom)
m_view
->
canvas
()
->
update
();
}
void
KisZoomManager
::
setDocumentResolution
(
double
xResolution
,
double
yResolution
)
{
m_zoomController
->
setDocumentResolution
(
xResolution
,
yResolution
);
}
#include "kis_zoom_manager.moc"
krita/ui/kis_zoom_manager.h
View file @
20782b33
...
...
@@ -53,6 +53,14 @@ public:
void
setup
(
KActionCollection
*
actionCollection
);
void
updateGUI
();
/**
* Set the document resolution in pixels per pt.
*
* @param xResolution resolution along x in pixels per point.
* @param yResolution resolution along y in pixels per point.
*/
void
setDocumentResolution
(
double
xResolution
,
double
yResolution
);
private
slots
:
void
slotZoomChanged
(
KoZoomMode
::
Mode
mode
,
double
zoom
);
...
...
libs/flake/KoCanvasController_p.cpp
View file @
20782b33
...
...
@@ -303,10 +303,12 @@ void Viewport::resetLayout()
resizeH
-=
moveY
;
moveY
=
0
;
}
if
(
m_parent
->
canvasMode
()
==
KoCanvasController
::
Infinite
)
m_canvas
->
setGeometry
(
0
,
0
,
viewW
,
viewH
);
else
m_canvas
->
setGeometry
(
moveX
,
moveY
,
resizeW
,
resizeH
);
if
(
m_canvas
)
{
if
(
m_parent
->
canvasMode
()
==
KoCanvasController
::
Infinite
)
m_canvas
->
setGeometry
(
0
,
0
,
viewW
,
viewH
);
else
m_canvas
->
setGeometry
(
moveX
,
moveY
,
resizeW
,
resizeH
);
}
// kDebug() << "View port geom: " << geometry() << endl;
// kDebug() << "Canvas widget geom: " << m_canvas->geometry() << endl;
...
...
libs/kofficeui/KoZoomController.cpp
View file @
20782b33
...
...
@@ -33,6 +33,8 @@ KoZoomController::KoZoomController(KoCanvasController *co, KoZoomHandler *zh, KA
:
m_canvasController
(
co
)
,
m_zoomHandler
(
zh
)
,
m_fitMargin
(
0
)
,
m_documentXResolution
(
1
)
,
m_documentYResolution
(
1
)
{
m_action
=
new
KoZoomAction
(
KoZoomMode
::
ZOOM_PIXELS
|
KoZoomMode
::
ZOOM_WIDTH
|
KoZoomMode
::
ZOOM_PAGE
,
i18n
(
"Zoom"
),
0
);
connect
(
m_action
,
SIGNAL
(
zoomChanged
(
KoZoomMode
::
Mode
,
double
)),
...
...
@@ -56,8 +58,9 @@ void KoZoomController::setZoom(double /*zoom*/)
{
}
void
KoZoomController
::
setZoomMode
(
KoZoomMode
/*
mode
*/
)
void
KoZoomController
::
setZoomMode
(
KoZoomMode
::
Mode
mode
)
{
setZoom
(
mode
,
1
);
}
void
KoZoomController
::
setPageSize
(
const
QSizeF
&
pageSize
)
...
...
@@ -78,6 +81,15 @@ void KoZoomController::setDocumentSize( const QSizeF &documentSize )
int
(
0.5
+
m_zoomHandler
->
documentToViewY
(
m_documentSize
.
height
()))
)
);
}
void
KoZoomController
::
setDocumentResolution
(
double
xResolution
,
double
yResolution
)
{
m_documentXResolution
=
xResolution
;
m_documentYResolution
=
yResolution
;
if
(
m_zoomHandler
->
zoomMode
()
==
KoZoomMode
::
ZOOM_PIXELS
)
setZoom
(
KoZoomMode
::
ZOOM_PIXELS
,
0
);
}
void
KoZoomController
::
setZoom
(
KoZoomMode
::
Mode
mode
,
double
zoom
)
{
m_zoomHandler
->
setZoomMode
(
mode
);
...
...
@@ -102,8 +114,18 @@ void KoZoomController::setZoom(KoZoomMode::Mode mode, double zoom)
m_action
->
setEffectiveZoom
(
zoom
);
}
m_zoomHandler
->
setZoom
(
zoom
);
emit
zoomChanged
(
mode
,
zoom
);
if
(
mode
==
KoZoomMode
::
ZOOM_PIXELS
)
{
m_zoomHandler
->
setZoomedResolution
(
m_documentXResolution
,
m_documentYResolution
);
zoom
=
m_zoomHandler
->
zoomFactorX
();
m_action
->
setEffectiveZoom
(
zoom
);
emit
zoomChanged
(
mode
,
zoom
);
}
else
{
m_zoomHandler
->
setZoom
(
zoom
);
emit
zoomChanged
(
mode
,
zoom
);
}
// Tell the canvasController that the zoom has changed
// Actually canvasController doesn't know about zoom, but the document in pixels
...
...
libs/kofficeui/KoZoomController.h
View file @
20782b33
...
...
@@ -67,7 +67,7 @@ public:
/// setter for the view to set the zoom and level.
void
setZoom
(
double
zoom
);
void
setZoomMode
(
KoZoomMode
mode
);
void
setZoomMode
(
KoZoomMode
::
Mode
mode
);
public
slots
:
/// every time the canvas changes content size, tell us. Note that the size is in pt.
...
...
@@ -81,6 +81,15 @@ public slots:
*/
void
setDocumentSize
(
const
QSizeF
&
documentSize
);
/**
* Set the document resolution in pixels per pt. This information is only
* required if the application uses the ZOOM_PIXELS ZoomMode.
*
* @param xResolution resolution along x in pixels per point.
* @param yResolution resolution along y in pixels per point.
*/
void
setDocumentResolution
(
double
xResolution
,
double
yResolution
);
/**
* Sets a fitting margin that is used when zooming to page size/width.
* Note that the fit margin is given in pixels.
...
...
@@ -117,6 +126,8 @@ private:
QSizeF
m_pageSize
;
QSizeF
m_documentSize
;
int
m_fitMargin
;
double
m_documentXResolution
;
double
m_documentYResolution
;
};
#endif
libs/kofficeui/tests/CMakeLists.txt
View file @
20782b33
...
...
@@ -15,6 +15,18 @@ target_link_libraries(zoomhandler_test ${KDE4_KDEUI_LIBS} kofficeui kofficecore
add_test
(
libs-kofficeui-zoomhandler_test zoomhandler_test
)
########### next target ###############
set
(
zoomcontroller_test_SRCS zoomcontroller_test.cpp
)
kde4_automoc
(
${
zoomcontroller_test_SRCS
}
)
kde4_add_executable
(
zoomcontroller_test RUN_UNINSTALLED
${
zoomcontroller_test_SRCS
}
)
target_link_libraries
(
zoomcontroller_test
${
KDE4_KDEUI_LIBS
}
kofficeui kofficecore
${
QT_QTTEST_LIBRARY
}
)
add_test
(
libs-kofficeui-zoomcontroller_test zoomcontroller_test
)
########### end ###############
endif
(
KDE4_BUILD_TESTS
)
libs/kofficeui/tests/zoomcontroller_test.cpp
0 → 100644
View file @
20782b33
/*
* Copyright (C) Adrian Page <adrian@pagenet.plus.com>, (C) 2007
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QTest>
#include <QCoreApplication>
#include <qtest_kde.h>
#include <kactioncollection.h>
#include <kdebug.h>
#include "KoCanvasController.h"
#include "KoZoomHandler.h"
#include "KoZoomController.h"
#include "KoGlobal.h"
#include "KoUnit.h"
#include "zoomcontroller_test.h"
void
zoomcontroller_test
::
testApi
()
{
KoZoomHandler
zoomHandler
;
KoZoomController
zoomController
(
new
KoCanvasController
(),
&
zoomHandler
,
new
KActionCollection
(
this
));
zoomHandler
.
setZoomAndResolution
(
100
,
123
,
456
);
zoomController
.
setDocumentResolution
(
50
,
60
);
zoomController
.
setZoomMode
(
KoZoomMode
::
ZOOM_PIXELS
);
QVERIFY
(
zoomHandler
.
zoomedResolutionX
()
==
50
);
QVERIFY
(
zoomHandler
.
zoomedResolutionY
()
==
60
);
}
QTEST_KDEMAIN
(
zoomcontroller_test
,
GUI
)
#include "zoomcontroller_test.moc"
libs/kofficeui/tests/zoomcontroller_test.h
0 → 100644
View file @
20782b33
/*
* Copyright (C) Adrian Page <adrian@pagenet.plus.com>, (C) 2007
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef ZOOMCONTROLLER_TEST_H
#define ZOOMCONTROLLER_TEST_H
#include <QtTest/QtTest>
class
zoomcontroller_test
:
public
QObject
{
Q_OBJECT
private
slots
:
// tests
void
testApi
();
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment