KShare/cropeditor/cropscene.hpp

85 lines
2.3 KiB
C++
Raw Normal View History

2017-04-23 15:05:48 +02:00
#ifndef CROPSCENE_HPP
#define CROPSCENE_HPP
2017-05-05 23:59:39 +02:00
#include <QFont>
2017-04-23 15:05:48 +02:00
#include <QGraphicsRectItem>
#include <QGraphicsScene>
2017-04-29 12:08:02 +02:00
#include <QGraphicsSceneContextMenuEvent>
2017-04-23 15:05:48 +02:00
#include <QGraphicsSceneMouseEvent>
#include <QKeyEvent>
2017-05-02 19:49:33 +02:00
#include <QMenu>
#include <functional>
class CropScene;
#include <cropeditor/drawing/drawitem.hpp>
2017-05-05 23:59:39 +02:00
class CropScene : public QGraphicsScene {
Q_OBJECT
2017-06-14 23:34:58 +02:00
public:
CropScene(QObject *parent, QPixmap pixmap);
~CropScene();
QPen &pen();
QBrush &brush();
QFont &font();
void setDrawingSelection(QString name, std::function<DrawItem *()> drawAction);
QPixmap pixmap() {
return _pixmap;
}
QGraphicsPolygonItem *polyItm() {
return polyItem;
}
QGraphicsRectItem *selRect() {
return rect;
}
void hide();
void show();
void setVisible(bool visible);
QPointF cursorPosition() {
return cursorPos;
}
2017-06-14 23:34:58 +02:00
public slots:
void fontAsk();
2017-06-14 23:34:58 +02:00
signals:
void closedWithRect(QRect rect);
2017-06-14 23:34:58 +02:00
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override;
void mousePressEvent(QGraphicsSceneMouseEvent *e) override;
2017-06-27 00:27:04 +02:00
void wheelEvent(QGraphicsSceneWheelEvent *event) override; // WHEEEEEEL
void contextMenuEvent(QGraphicsSceneContextMenuEvent *e) override;
void keyReleaseEvent(QKeyEvent *e) override;
2017-06-14 23:34:58 +02:00
private:
void updateMag();
2017-06-27 00:27:04 +02:00
void initMagnifierGrid();
void addDrawingAction(QMenu &menu, QString name, std::function<DrawItem *()> item);
void done(bool notEsc);
bool fullscreen;
QPointF cursorPos;
std::function<DrawItem *()> drawingSelectionMaker;
QFlags<Qt::MouseButton> prevButtons;
QPixmap _pixmap;
QGraphicsRectItem *rect = nullptr;
QGraphicsPixmapItem *magnifier = nullptr;
QGraphicsRectItem *magnifierBox = nullptr;
QGraphicsTextItem *magnifierHint = nullptr;
QGraphicsRectItem *magnifierHintBox = nullptr;
QPointF initPos;
QPen _pen;
QBrush _brush;
QFont _font;
QGraphicsPolygonItem *polyItem = nullptr;
DrawItem *drawingSelection = nullptr;
QMenu menu;
QString drawingName = "None";
QAction *display;
QList<QGraphicsRectItem *> gridRectsX;
QList<QGraphicsRectItem *> gridRectsY;
QGraphicsPolygonItem *cursorItem = nullptr;
2017-04-23 15:05:48 +02:00
};
#endif // CROPSCENE_HPP