Commit a6c6729d authored by Boudewijn Rempt's avatar Boudewijn Rempt

The thing that has the assistants is not a manager but a canvas decoration

parent 22654578
......@@ -40,7 +40,7 @@
#include <kis_view2.h>
#include <kis_abstract_perspective_grid.h>
#include <kis_painting_assistants_manager.h>
#include <kis_painting_assistants_decoration.h>
KisRulerAssistantTool::KisRulerAssistantTool(KoCanvasBase * canvas)
: KisTool(canvas, KisCursor::arrowCursor()), m_canvas(dynamic_cast<KisCanvas2*>(canvas)),
......@@ -64,8 +64,8 @@ void KisRulerAssistantTool::activate(ToolActivation toolActivation, const QSet<K
// Add code here to initialize your tool when it got activated
KisTool::activate(toolActivation, shapes);
m_handles = m_canvas->view()->paintingAssistantManager()->handles();
m_canvas->view()->paintingAssistantManager()->setVisible(true);
m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
m_canvas->view()->paintingAssistantsDecoration()->setVisible(true);
m_canvas->updateCanvas();
m_handleDrag = 0;
m_internalMode = MODE_CREATION;
......@@ -122,7 +122,7 @@ void KisRulerAssistantTool::beginPrimaryAction(KoPointerEvent *event)
double minDist = 81.0;
QPointF mousePos = m_canvas->viewConverter()->documentToView(event->point);
foreach(KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantManager()->assistants()) {
foreach(KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantsDecoration()->assistants()) {
foreach(const KisPaintingAssistantHandleSP handle, m_handles) {
double dist = norm2(mousePos - m_canvas->viewConverter()->documentToView(*handle));
if (dist < minDist) {
......@@ -218,14 +218,14 @@ void KisRulerAssistantTool::beginPrimaryAction(KoPointerEvent *event)
// if (event->modifiers() & Qt::ShiftModifier) {
// m_handleDrag->uncache();
// m_handleDrag = m_handleDrag->split()[0];
// m_handles = m_canvas->view()->paintingAssistantManager()->handles();
// m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
// }
m_canvas->updateCanvas(); // TODO update only the relevant part of the canvas
return;
}
m_assistantDrag = 0;
foreach(KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantManager()->assistants()) {
foreach(KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantsDecoration()->assistants()) {
QPointF iconPosition = m_canvas->viewConverter()->documentToView(assistant->buttonPosition());
QRectF deleteRect(iconPosition - QPointF(32, 32), QSizeF(16, 16));
QRectF moveRect(iconPosition - QPointF(16, 16), QSizeF(32, 32));
......@@ -237,7 +237,7 @@ void KisRulerAssistantTool::beginPrimaryAction(KoPointerEvent *event)
}
if (deleteRect.contains(mousePos)) {
removeAssistant(assistant);
if(m_canvas->view()->paintingAssistantManager()->assistants().isEmpty()) {
if(m_canvas->view()->paintingAssistantsDecoration()->assistants().isEmpty()) {
m_internalMode = MODE_CREATION;
}
else
......@@ -294,7 +294,7 @@ void KisRulerAssistantTool::continuePrimaryAction(KoPointerEvent *event)
bool wasHiglightedNode = m_higlightedNode != 0;
QPointF mousep = m_canvas->viewConverter()->documentToView(event->point);
QList <KisPaintingAssistant*> pAssistant= m_canvas->view()->paintingAssistantManager()->assistants();
QList <KisPaintingAssistant*> pAssistant= m_canvas->view()->paintingAssistantsDecoration()->assistants();
foreach (KisPaintingAssistant* assistant, pAssistant) {
if(assistant->id() == "perspective") {
if ((m_higlightedNode = nodeNearPoint(assistant, mousep))) {
......@@ -321,7 +321,7 @@ void KisRulerAssistantTool::endPrimaryAction(KoPointerEvent *event)
if (!(event->modifiers() & Qt::ShiftModifier) && m_handleCombine) {
m_handleCombine->mergeWith(m_handleDrag);
m_handleCombine->uncache();
m_handles = m_canvas->view()->paintingAssistantManager()->handles();
m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
}
m_handleDrag = m_handleCombine = 0;
m_canvas->updateCanvas(); // TODO update only the relevant part of the canvas
......@@ -340,8 +340,8 @@ void KisRulerAssistantTool::endPrimaryAction(KoPointerEvent *event)
void KisRulerAssistantTool::addAssistant()
{
m_canvas->view()->paintingAssistantManager()->addAssistant(m_newAssistant);
m_handles = m_canvas->view()->paintingAssistantManager()->handles();
m_canvas->view()->paintingAssistantsDecoration()->addAssistant(m_newAssistant);
m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
KisAbstractPerspectiveGrid* grid = dynamic_cast<KisAbstractPerspectiveGrid*>(m_newAssistant);
if (grid) {
m_canvas->view()->resourceProvider()->addPerspectiveGrid(grid);
......@@ -356,8 +356,8 @@ void KisRulerAssistantTool::removeAssistant(KisPaintingAssistant* assistant)
if (grid) {
m_canvas->view()->resourceProvider()->removePerspectiveGrid(grid);
}
m_canvas->view()->paintingAssistantManager()->removeAssistant(assistant);
m_handles = m_canvas->view()->paintingAssistantManager()->handles();
m_canvas->view()->paintingAssistantsDecoration()->removeAssistant(assistant);
m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
}
......@@ -404,7 +404,7 @@ void KisRulerAssistantTool::paint(QPainter& _gc, const KoViewConverter &_convert
QPixmap iconDelete = koIcon("edit-delete").pixmap(16, 16);
QPixmap iconMove = koIcon("transform-move").pixmap(32, 32);
foreach(KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantManager()->assistants()) {
foreach(KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantsDecoration()->assistants()) {
if(assistant->id()=="perspective") {
assistant->findHandleLocation();
QPointF topMiddle, bottomMiddle, rightMiddle, leftMiddle;
......@@ -422,7 +422,7 @@ void KisRulerAssistantTool::paint(QPainter& _gc, const KoViewConverter &_convert
}
foreach(const KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantManager()->assistants()) {
foreach(const KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantsDecoration()->assistants()) {
QPointF iconDeletePos = _converter.documentToView(assistant->buttonPosition());
_gc.drawPixmap(iconDeletePos - QPointF(32, 32), iconDelete);
_gc.drawPixmap(iconDeletePos - QPointF(16, 16), iconMove);
......@@ -432,8 +432,8 @@ void KisRulerAssistantTool::paint(QPainter& _gc, const KoViewConverter &_convert
void KisRulerAssistantTool::removeAllAssistants()
{
m_canvas->view()->resourceProvider()->clearPerspectiveGrids();
m_canvas->view()->paintingAssistantManager()->removeAll();
m_handles = m_canvas->view()->paintingAssistantManager()->handles();
m_canvas->view()->paintingAssistantsDecoration()->removeAll();
m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
m_canvas->updateCanvas();
}
......@@ -500,7 +500,7 @@ void KisRulerAssistantTool::loadAssistants()
if (xml.name() == "assistant") {
if (assistant) {
if (assistant->handles().size() == assistant->numHandles()) {
m_canvas->view()->paintingAssistantManager()->addAssistant(assistant);
m_canvas->view()->paintingAssistantsDecoration()->addAssistant(assistant);
KisAbstractPerspectiveGrid* grid = dynamic_cast<KisAbstractPerspectiveGrid*>(assistant);
if (grid) {
m_canvas->view()->resourceProvider()->addPerspectiveGrid(grid);
......@@ -527,7 +527,7 @@ void KisRulerAssistantTool::loadAssistants()
if (errors) {
KMessageBox::sorry(0, i18n("Errors were encountered. Not all assistants were successfully loaded."));
}
m_handles = m_canvas->view()->paintingAssistantManager()->handles();
m_handles = m_canvas->view()->paintingAssistantsDecoration()->handles();
m_canvas->updateCanvas();
}
......@@ -553,7 +553,7 @@ void KisRulerAssistantTool::saveAssistants()
}
xml.writeEndElement();
xml.writeStartElement("assistants");
foreach(const KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantManager()->assistants()) {
foreach(const KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantsDecoration()->assistants()) {
xml.writeStartElement("assistant");
xml.writeAttribute("type", assistant->id());
xml.writeStartElement("handles");
......
......@@ -107,7 +107,7 @@ set(kritaui_LIB_SRCS
kis_model_index_converter.cpp
kis_model_index_converter_show_all.cpp
kis_painting_assistant.cc
kis_painting_assistants_manager.cc
kis_painting_assistants_decoration.cpp
kis_paintop_box.cc
kis_paintop_option.cpp
kis_paintop_options_model.cpp
......
......@@ -84,7 +84,7 @@
#include <kis_selection.h>
#include <kis_fill_painter.h>
#include <kis_document_undo_store.h>
#include <kis_painting_assistants_manager.h>
#include <kis_painting_assistants_decoration.h>
// Local
#include "kis_factory2.h"
......@@ -525,8 +525,8 @@ QList<KisPaintingAssistant*> KisDoc2::assistants()
foreach(KoView *v, documentPart()->views()) {
KisView2 *view = qobject_cast<KisView2*>(v);
if (view) {
KisPaintingAssistantsManager* assistantsmanager = view->paintingAssistantManager();
assistants.append(assistantsmanager->assistants());
KisPaintingAssistantsDecoration* assistantsDecoration = view->paintingAssistantsDecoration();
assistants.append(assistantsDecoration->assistants());
}
}
return assistants;
......
......@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_painting_assistants_manager.h"
#include "kis_painting_assistants_decoration.h"
#include <cfloat>
......@@ -29,7 +29,7 @@
#include "kis_painting_assistant.h"
#include <QPainter>
struct KisPaintingAssistantsManager::Private {
struct KisPaintingAssistantsDecoration::Private {
QList<KisPaintingAssistant*> assistants;
KToggleAction* toggleAssistant;
void updateAction() {
......@@ -37,33 +37,33 @@ struct KisPaintingAssistantsManager::Private {
}
};
KisPaintingAssistantsManager::KisPaintingAssistantsManager(KisView2* parent) :
KisCanvasDecoration("paintingAssistantsManager", i18n("Painting assistants"), parent),
KisPaintingAssistantsDecoration::KisPaintingAssistantsDecoration(KisView2* parent) :
KisCanvasDecoration("paintingAssistantsDecoration", i18n("Painting assistants"), parent),
d(new Private)
{
}
KisPaintingAssistantsManager::~KisPaintingAssistantsManager()
KisPaintingAssistantsDecoration::~KisPaintingAssistantsDecoration()
{
qDeleteAll(d->assistants.begin(), d->assistants.end());
delete d;
}
void KisPaintingAssistantsManager::addAssistant(KisPaintingAssistant* assistant)
void KisPaintingAssistantsDecoration::addAssistant(KisPaintingAssistant* assistant)
{
if (d->assistants.contains(assistant)) return;
d->assistants.push_back(assistant);
d->updateAction();
}
void KisPaintingAssistantsManager::removeAssistant(KisPaintingAssistant* assistant)
void KisPaintingAssistantsDecoration::removeAssistant(KisPaintingAssistant* assistant)
{
delete assistant;
d->assistants.removeAll(assistant);
d->updateAction();
}
void KisPaintingAssistantsManager::removeAll()
void KisPaintingAssistantsDecoration::removeAll()
{
foreach (KisPaintingAssistant* assistant, d->assistants) {
delete assistant;
......@@ -72,7 +72,7 @@ void KisPaintingAssistantsManager::removeAll()
d->updateAction();
}
QPointF KisPaintingAssistantsManager::adjustPosition(const QPointF& point, const QPointF& strokeBegin)
QPointF KisPaintingAssistantsDecoration::adjustPosition(const QPointF& point, const QPointF& strokeBegin)
{
if (d->assistants.empty()) return point;
if (d->assistants.count() == 1) {
......@@ -95,14 +95,14 @@ QPointF KisPaintingAssistantsManager::adjustPosition(const QPointF& point, const
return best;
}
void KisPaintingAssistantsManager::endStroke()
void KisPaintingAssistantsDecoration::endStroke()
{
foreach(KisPaintingAssistant* assistant, d->assistants) {
assistant->endStroke();
}
}
void KisPaintingAssistantsManager::setup(KActionCollection * collection)
void KisPaintingAssistantsDecoration::setup(KActionCollection * collection)
{
d->toggleAssistant = new KToggleAction(i18n("Show Painting Assistants"), this);
collection->addAction("view_toggle_painting_assistants", d->toggleAssistant);
......@@ -113,14 +113,14 @@ void KisPaintingAssistantsManager::setup(KActionCollection * collection)
d->updateAction();
}
void KisPaintingAssistantsManager::drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter,KisCanvas2* canvas)
void KisPaintingAssistantsDecoration::drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter,KisCanvas2* canvas)
{
foreach(KisPaintingAssistant* assistant, d->assistants) {
assistant->drawAssistant(gc, updateRect, converter,canvas);
}
}
QList<KisPaintingAssistantHandleSP> KisPaintingAssistantsManager::handles()
QList<KisPaintingAssistantHandleSP> KisPaintingAssistantsDecoration::handles()
{
QList<KisPaintingAssistantHandleSP> hs;
foreach(KisPaintingAssistant* assistant, d->assistants) {
......@@ -138,7 +138,7 @@ QList<KisPaintingAssistantHandleSP> KisPaintingAssistantsManager::handles()
return hs;
}
QList<KisPaintingAssistant*> KisPaintingAssistantsManager::assistants()
QList<KisPaintingAssistant*> KisPaintingAssistantsDecoration::assistants()
{
return d->assistants;
}
......@@ -31,11 +31,11 @@ class KActionCollection;
/**
* This class hold a list of painting assistants.
*/
class KRITAUI_EXPORT KisPaintingAssistantsManager : public KisCanvasDecoration
class KRITAUI_EXPORT KisPaintingAssistantsDecoration : public KisCanvasDecoration
{
public:
KisPaintingAssistantsManager(KisView2* parent);
~KisPaintingAssistantsManager();
KisPaintingAssistantsDecoration(KisView2* parent);
~KisPaintingAssistantsDecoration();
void addAssistant(KisPaintingAssistant* assistant);
void removeAssistant(KisPaintingAssistant* assistant);
void removeAll();
......
......@@ -87,8 +87,6 @@ public:
KisPaintopBox(KisView2* view, QWidget* parent, const char* name);
~KisPaintopBox();
private:
public slots:
void slotColorSpaceChanged(const KoColorSpace* colorSpace);
......
......@@ -104,7 +104,7 @@
#include "kis_mimedata.h"
#include "kis_node.h"
#include "kis_node_manager.h"
#include "kis_painting_assistants_manager.h"
#include "kis_painting_assistants_decoration.h"
#include <kis_paint_layer.h>
#include "kis_paintop_box.h"
#include "kis_print_job.h"
......@@ -166,7 +166,7 @@ public:
, imageManager(0)
, gridManager(0)
, perspectiveGridManager(0)
, paintingAssistantManager(0)
, paintingAssistantsDecoration(0)
, actionManager(0)
, mainWindow(0)
{
......@@ -187,7 +187,7 @@ public:
delete imageManager;
delete gridManager;
delete perspectiveGridManager;
delete paintingAssistantManager;
delete paintingAssistantsDecoration;
delete viewConverter;
delete statusBar;
delete actionManager;
......@@ -217,7 +217,7 @@ public:
KisGridManager *gridManager;
KisCanvasControlsManager *canvasControlsManager;
KisPerspectiveGridManager * perspectiveGridManager;
KisPaintingAssistantsManager *paintingAssistantManager;
KisPaintingAssistantsDecoration *paintingAssistantsDecoration;
BlockingUserInputEventFilter blockingEventFilter;
KisFlipbook *flipbook;
KisActionManager* actionManager;
......@@ -916,7 +916,7 @@ void KisView2::slotLoadingFinished()
// get the assistants and push them to the manager
QList<KisPaintingAssistant*> paintingAssistants = m_d->doc->preLoadedAssistants();
foreach (KisPaintingAssistant* assistant, paintingAssistants) {
m_d->paintingAssistantManager->addAssistant(assistant);
m_d->paintingAssistantsDecoration->addAssistant(assistant);
}
/**
......@@ -926,11 +926,11 @@ void KisView2::slotLoadingFinished()
m_d->zoomManager->zoomController()->setAspectMode(true);
if (m_d->viewConverter)
m_d->viewConverter->setZoomMode(KoZoomMode::ZOOM_PAGE);
if (m_d->paintingAssistantManager){
if (m_d->paintingAssistantsDecoration){
foreach(KisPaintingAssistant* assist, m_d->doc->preLoadedAssistants()){
m_d->paintingAssistantManager->addAssistant(assist);
m_d->paintingAssistantsDecoration->addAssistant(assist);
}
m_d->paintingAssistantManager->setVisible(true);
m_d->paintingAssistantsDecoration->setVisible(true);
}
updateGUI();
......@@ -982,9 +982,9 @@ void KisView2::createManagers()
m_d->perspectiveGridManager->setup(actionCollection());
m_d->canvas->addDecoration(m_d->perspectiveGridManager);
m_d->paintingAssistantManager = new KisPaintingAssistantsManager(this);
m_d->paintingAssistantManager->setup(actionCollection());
m_d->canvas->addDecoration(m_d->paintingAssistantManager);
m_d->paintingAssistantsDecoration = new KisPaintingAssistantsDecoration(this);
m_d->paintingAssistantsDecoration->setup(actionCollection());
m_d->canvas->addDecoration(m_d->paintingAssistantsDecoration);
m_d->canvasControlsManager = new KisCanvasControlsManager(this);
m_d->canvasControlsManager->setup(actionCollection());
......@@ -1149,9 +1149,9 @@ KisGridManager * KisView2::gridManager()
return m_d->gridManager;
}
KisPaintingAssistantsManager* KisView2::paintingAssistantManager()
KisPaintingAssistantsDecoration* KisView2::paintingAssistantsDecoration()
{
return m_d->paintingAssistantManager;
return m_d->paintingAssistantsDecoration;
}
QMainWindow* KisView2::qtMainWindow()
......
......@@ -45,14 +45,13 @@ class KisGridManager;
class KisImage;
class KisImageManager;
class KisNodeManager;
class KisPaintingAssistantsManager;
class KisPaintingAssistantsDecoration;
class KisPaintopBox;
class KisPerspectiveGridManager;
class KisSelectionManager;
class KisStatusBar;
class KisUndoAdapter;
class KisZoomManager;
class KisFavoriteResourceManager;
class KisPaintopBox;
class KisCanvasController;
class KisFlipbook;
......@@ -176,7 +175,7 @@ public:
KisGridManager * gridManager();
KisPerspectiveGridManager* perspectiveGridManager();
KisPaintingAssistantsManager* paintingAssistantManager();
KisPaintingAssistantsDecoration* paintingAssistantsDecoration();
/// disable and enable toolbar controls. used for disabling them during painting.
void enableControls();
......
......@@ -39,7 +39,7 @@
#include <kis_layer.h>
#include <kis_adjustment_layer.h>
#include <kis_layer_composition.h>
#include <kis_painting_assistants_manager.h>
#include <kis_painting_assistants_decoration.h>
#include "kis_doc2.h"
#include <string>
......
......@@ -53,7 +53,7 @@
#include "canvas/kis_canvas2.h"
#include "kis_cursor.h"
#include <kis_view2.h>
#include <kis_painting_assistants_manager.h>
#include <kis_painting_assistants_decoration.h>
#include "kis_painting_information_builder.h"
#include "kis_tool_freehand_helper.h"
#include "kis_recording_adapter.h"
......@@ -221,7 +221,7 @@ void KisToolFreehand::endPrimaryAction(KoPointerEvent *event)
endStroke();
if (m_assistant) {
static_cast<KisCanvas2*>(canvas())->view()->paintingAssistantManager()->endStroke();
static_cast<KisCanvas2*>(canvas())->view()->paintingAssistantsDecoration()->endStroke();
}
notifyModified();
......@@ -352,7 +352,7 @@ void KisToolFreehand::setAssistant(bool assistant)
QPointF KisToolFreehand::adjustPosition(const QPointF& point, const QPointF& strokeBegin)
{
if (m_assistant) {
QPointF ap = static_cast<KisCanvas2*>(canvas())->view()->paintingAssistantManager()->adjustPosition(point, strokeBegin);
QPointF ap = static_cast<KisCanvas2*>(canvas())->view()->paintingAssistantsDecoration()->adjustPosition(point, strokeBegin);
return (1.0 - m_magnetism) * point + m_magnetism * ap;
}
return point;
......
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