mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-15 21:00:37 +02:00
.
This commit is contained in:
@@ -1,105 +0,0 @@
|
||||
|
||||
#ifndef PaintingArea_H
|
||||
#define PaintingArea_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
#include"Image/IntelliImage.h"
|
||||
#include <QPoint>
|
||||
#include <QWidget>
|
||||
|
||||
class PaintingArea : public QWidget
|
||||
{
|
||||
// Declares our class as a QObject which is the base class
|
||||
// for all Qt objects
|
||||
// QObjects handle events
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//create raster image 400*200
|
||||
PaintingArea(QWidget *parent = nullptr);
|
||||
PaintingArea(int width, int height, ImageType type, QWidget *parent = nullptr);
|
||||
|
||||
// Handles all events
|
||||
bool openImage(const QString &fileName);
|
||||
bool saveImage(const QString &fileName, const char *fileFormat);
|
||||
void setPenColor(const QColor &newColor);
|
||||
void setPenWidth(int newWidth);
|
||||
|
||||
// Has the image been modified since last save
|
||||
bool isModified() const { return modified; }
|
||||
QColor penColor() const { return myPenColor; }
|
||||
int penWidth() const { return myPenWidth; }
|
||||
|
||||
|
||||
QPixmap getAsPixmap();
|
||||
public slots:
|
||||
|
||||
// Events to handle
|
||||
void clearImage(int r, int g, int b);
|
||||
void activate(int a);
|
||||
|
||||
void setAlpha(int a);
|
||||
void getMoveUp(int a);
|
||||
void getMoveDown(int a);
|
||||
void getMoveRight(int a);
|
||||
void getMoveLeft(int a);
|
||||
void getMoveLayerUp();
|
||||
void getMoveLayerDown();
|
||||
//void setUp helper for konstruktor
|
||||
void setUp();
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
// Updates the painting area where we are painting
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
// Makes sure the area we are drawing on remains
|
||||
// as large as the widget
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
struct LayerObject{
|
||||
IntelliImage* image;
|
||||
int width;
|
||||
int height;
|
||||
int widthOffset;
|
||||
int heightOffset;
|
||||
int alpha=255;
|
||||
};
|
||||
|
||||
QImage* Canvas;
|
||||
int maxWidth;
|
||||
int maxHeight;
|
||||
|
||||
std::vector<LayerObject> layerStructure;
|
||||
int activeLayer=-1;
|
||||
|
||||
void assembleLayers(bool forSaving=false);
|
||||
|
||||
void drawLineTo(const QPoint &endPoint);
|
||||
void resizeImage(QImage *image_res, const QSize &newSize);
|
||||
|
||||
// Will be marked true or false depending on if
|
||||
// we have saved after a change
|
||||
bool modified=false;
|
||||
|
||||
// Marked true or false depending on if the user
|
||||
// is drawing
|
||||
bool scribbling;
|
||||
|
||||
// Holds the current pen width & color
|
||||
int myPenWidth;
|
||||
QColor myPenColor;
|
||||
|
||||
// Stores the image being drawn
|
||||
IntelliImage* image;
|
||||
|
||||
// Stores the location at the current mouse event
|
||||
QPoint lastPoint;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user