mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-16 05:10:32 +02:00
scrolol ready
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
#include "QCloseEvent"
|
#include "QCloseEvent"
|
||||||
#include "QScrollBar"
|
#include "QScrollBar"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
// IntelliPhotoGui constructor
|
// IntelliPhotoGui constructor
|
||||||
IntelliPhotoGui::IntelliPhotoGui(){
|
IntelliPhotoGui::IntelliPhotoGui(){
|
||||||
// create Gui elements and lay them out
|
// create Gui elements and lay them out
|
||||||
@@ -19,7 +21,7 @@ IntelliPhotoGui::IntelliPhotoGui(){
|
|||||||
setIntelliStyle();
|
setIntelliStyle();
|
||||||
// Size the app
|
// Size the app
|
||||||
resize(600,600);
|
resize(600,600);
|
||||||
setDefaultToolValue();
|
setDefaultValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
// User tried to close the app
|
// User tried to close the app
|
||||||
@@ -118,6 +120,8 @@ void IntelliPhotoGui::slotChangeDim(){
|
|||||||
|
|
||||||
int height = IntelliInputDialog::getInt("New Canvas Size", "Height:", 600, 1, 50000, 1, &ok2);
|
int height = IntelliInputDialog::getInt("New Canvas Size", "Height:", 600, 1, 50000, 1, &ok2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Change dimension
|
// Change dimension
|
||||||
if (ok1&&ok2) {
|
if (ok1&&ok2) {
|
||||||
paintingArea->setLayerDimensions(width,height);
|
paintingArea->setLayerDimensions(width,height);
|
||||||
@@ -768,6 +772,7 @@ void IntelliPhotoGui::createGui(){
|
|||||||
mainLayout->addWidget(dimActive,13,2,1,2);
|
mainLayout->addWidget(dimActive,13,2,1,2);
|
||||||
mainLayout->addWidget(dimCanvas,14,2,1,2);
|
mainLayout->addWidget(dimCanvas,14,2,1,2);
|
||||||
mainLayout->setHorizontalSpacing(0);
|
mainLayout->setHorizontalSpacing(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::setIntelliStyle(){
|
void IntelliPhotoGui::setIntelliStyle(){
|
||||||
@@ -828,7 +833,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::setDefaultToolValue(){
|
void IntelliPhotoGui::setDefaultValues(){
|
||||||
slotEnterPressed();
|
slotEnterPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ bool maybeSave();
|
|||||||
bool saveFile(const QByteArray &fileFormat);
|
bool saveFile(const QByteArray &fileFormat);
|
||||||
|
|
||||||
//basic to set tool values to begin
|
//basic to set tool values to begin
|
||||||
void setDefaultToolValue();
|
void setDefaultValues();
|
||||||
|
|
||||||
// What we'll draw on
|
// What we'll draw on
|
||||||
PaintingArea* paintingArea;
|
PaintingArea* paintingArea;
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
|||||||
this->maxHeight = maxHeight;
|
this->maxHeight = maxHeight;
|
||||||
Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
|
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
|
// Roots the widget to the top left even if resized
|
||||||
setAttribute(Qt::WA_StaticContents);
|
setAttribute(Qt::WA_StaticContents);
|
||||||
|
|
||||||
@@ -265,12 +268,12 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){
|
|||||||
}
|
}
|
||||||
if(Tool == nullptr)
|
if(Tool == nullptr)
|
||||||
return;
|
return;
|
||||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset;
|
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset-offsetXDimension;
|
||||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset;
|
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset-offsetYDimension;
|
||||||
if(event->button() == Qt::LeftButton) {
|
if(event->button() == Qt::LeftButton) {
|
||||||
Tool->onMouseLeftPressed(x, y);
|
Tool->onMouseLeftPressed(x, y);
|
||||||
}else if(event->button() == Qt::RightButton) {
|
}else if(event->button() == Qt::RightButton) {
|
||||||
Tool->onMouseRightPressed(x, y);
|
Tool->onMouseRightPressed(x, y);
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -284,8 +287,8 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){
|
|||||||
}
|
}
|
||||||
if(Tool == nullptr)
|
if(Tool == nullptr)
|
||||||
return;
|
return;
|
||||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset;
|
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset-offsetXDimension;
|
||||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset;
|
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset-offsetYDimension;
|
||||||
Tool->onMouseMoved(x, y);
|
Tool->onMouseMoved(x, y);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -296,8 +299,8 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
|
|||||||
return;
|
return;
|
||||||
if(Tool == nullptr)
|
if(Tool == nullptr)
|
||||||
return;
|
return;
|
||||||
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset;
|
int x = event->x() - layerBundle[static_cast<size_t>(activeLayer)].widthOffset-offsetXDimension;
|
||||||
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset;
|
int y = event->y() - layerBundle[static_cast<size_t>(activeLayer)].heightOffset-offsetYDimension;
|
||||||
if(event->button() == Qt::LeftButton) {
|
if(event->button() == Qt::LeftButton) {
|
||||||
Tool->onMouseLeftReleased(x, y);
|
Tool->onMouseLeftReleased(x, y);
|
||||||
}else if(event->button() == Qt::RightButton) {
|
}else if(event->button() == Qt::RightButton) {
|
||||||
@@ -332,7 +335,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
|||||||
|
|
||||||
//calulate image here for scroll
|
//calulate image here for scroll
|
||||||
//Todo set offset in first to parameters and calulate them into mouse position
|
//Todo set offset in first to parameters and calulate them into mouse position
|
||||||
painter.drawImage(0, 0, *Canvas, 0, 0);
|
painter.drawImage(0, 0, *Canvas, -offsetXDimension, -offsetYDimension);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -222,6 +222,10 @@ void wheelEvent(QWheelEvent*event) override;
|
|||||||
void paintEvent(QPaintEvent*event) override;
|
void paintEvent(QPaintEvent*event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//offset for the displayable
|
||||||
|
int offsetXDimension;
|
||||||
|
int offsetYDimension;
|
||||||
|
|
||||||
void setLayerDimensions(int maxWidth, int maxHeight);
|
void setLayerDimensions(int maxWidth, int maxHeight);
|
||||||
void selectLayerUp();
|
void selectLayerUp();
|
||||||
void selectLayerDown();
|
void selectLayerDown();
|
||||||
|
|||||||
Reference in New Issue
Block a user