mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 20:30:32 +02:00
Merge branch 'dev-scrollbar' into dev-history
This commit is contained in:
@@ -37,7 +37,7 @@ LayerObject::LayerObject(const LayerObject& layer){
|
||||
}
|
||||
|
||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
||||
: QWidget(parent){
|
||||
: QLabel(parent){
|
||||
this->Tool = nullptr;
|
||||
this->setLayerDimensions(maxWidth, maxHeight);
|
||||
|
||||
@@ -75,6 +75,9 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
||||
this->maxHeight = maxHeight;
|
||||
Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
|
||||
|
||||
this->offsetXDimension = maxWidth/2;
|
||||
this->offsetYDimension = maxHeight/2;
|
||||
|
||||
// Roots the widget to the top left even if resized
|
||||
setAttribute(Qt::WA_StaticContents);
|
||||
|
||||
@@ -151,7 +154,7 @@ void PaintingArea::setPolygon(int idx){
|
||||
delete this->Tool;
|
||||
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
|
||||
isSettingPolygon = true;
|
||||
this->DummyGui->setToolWidth(5);
|
||||
this->guiReference->setToolWidth(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +216,7 @@ void PaintingArea::moveActiveLayer(int idx){
|
||||
}else if(idx==-1) {
|
||||
this->selectLayerDown();
|
||||
}
|
||||
DummyGui->UpdateGui();
|
||||
guiReference->UpdateGui();
|
||||
historyadd();
|
||||
}
|
||||
|
||||
@@ -305,12 +308,12 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){
|
||||
}
|
||||
if(Tool == nullptr)
|
||||
return;
|
||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset;
|
||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset;
|
||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset-offsetXDimension;
|
||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset-offsetYDimension;
|
||||
if(event->button() == Qt::LeftButton) {
|
||||
Tool->onMouseLeftPressed(x, y);
|
||||
Tool->onMouseLeftPressed(x, y);
|
||||
}else if(event->button() == Qt::RightButton) {
|
||||
Tool->onMouseRightPressed(x, y);
|
||||
Tool->onMouseRightPressed(x, y);
|
||||
}
|
||||
update();
|
||||
}
|
||||
@@ -324,8 +327,8 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){
|
||||
}
|
||||
if(Tool == nullptr)
|
||||
return;
|
||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset;
|
||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset;
|
||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset-offsetXDimension;
|
||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset-offsetYDimension;
|
||||
Tool->onMouseMoved(x, y);
|
||||
update();
|
||||
}
|
||||
@@ -336,8 +339,8 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
|
||||
return;
|
||||
if(Tool == nullptr)
|
||||
return;
|
||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset;
|
||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset;
|
||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset-offsetXDimension;
|
||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset-offsetYDimension;
|
||||
if(event->button() == Qt::LeftButton) {
|
||||
Tool->onMouseLeftReleased(x, y);
|
||||
}else if(event->button() == Qt::RightButton) {
|
||||
@@ -362,11 +365,17 @@ void PaintingArea::wheelEvent(QWheelEvent*event){
|
||||
// The QPaintEvent is sent to widgets that need to
|
||||
// update themselves
|
||||
void PaintingArea::paintEvent(QPaintEvent*event){
|
||||
this->setFixedSize(QSize(maxWidth*2,maxHeight*2));
|
||||
this->drawLayers();
|
||||
|
||||
QPainter painter(this);
|
||||
QRect dirtyRec = event->rect();
|
||||
painter.drawImage(dirtyRec, *Canvas, dirtyRec);
|
||||
QPainter painter(this);
|
||||
|
||||
//insert zoom factor here
|
||||
painter.scale(1,1);
|
||||
|
||||
//calulate image here for scroll
|
||||
//Todo set offset in first to parameters and calulate them into mouse position
|
||||
painter.drawImage(0, 0, *Canvas, -offsetXDimension, -offsetYDimension);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QPoint>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QLabel>
|
||||
#include "Image/IntelliImage.h"
|
||||
#include "Image/IntelliRasterImage.h"
|
||||
#include "Image/IntelliShapedImage.h"
|
||||
@@ -53,7 +54,7 @@ struct LayerObject {
|
||||
/*!
|
||||
* \brief The PaintingArea class manages the methods and stores information about the current painting area, which is the currently opened project
|
||||
*/
|
||||
class PaintingArea : public QWidget
|
||||
class PaintingArea : public QLabel
|
||||
{
|
||||
friend UnitTest;
|
||||
// Declares our class as a QObject which is the base class
|
||||
@@ -250,11 +251,16 @@ void wheelEvent(QWheelEvent*event) override;
|
||||
void paintEvent(QPaintEvent*event) override;
|
||||
|
||||
private:
|
||||
//offset for the displayable
|
||||
int offsetXDimension;
|
||||
int offsetYDimension;
|
||||
|
||||
void selectLayerUp();
|
||||
void selectLayerDown();
|
||||
IntelliTool* copyActiveTool();
|
||||
|
||||
QImage* Canvas;
|
||||
QImage ScaledCanvas;
|
||||
int maxWidth;
|
||||
int maxHeight;
|
||||
|
||||
@@ -262,7 +268,7 @@ bool isSettingPolygon = false;
|
||||
|
||||
IntelliRenderSettings renderSettings;
|
||||
IntelliTool* Tool;
|
||||
IntelliPhotoGui* DummyGui;
|
||||
IntelliPhotoGui* guiReference;
|
||||
|
||||
std::vector<LayerObject> layerBundle;
|
||||
int activeLayer = -1;
|
||||
|
||||
Reference in New Issue
Block a user