mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
scrolol ready
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "QCloseEvent"
|
||||
#include "QScrollBar"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
// IntelliPhotoGui constructor
|
||||
IntelliPhotoGui::IntelliPhotoGui(){
|
||||
// create Gui elements and lay them out
|
||||
@@ -19,7 +21,7 @@ IntelliPhotoGui::IntelliPhotoGui(){
|
||||
setIntelliStyle();
|
||||
// Size the app
|
||||
resize(600,600);
|
||||
setDefaultToolValue();
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
|
||||
// Change dimension
|
||||
if (ok1&&ok2) {
|
||||
paintingArea->setLayerDimensions(width,height);
|
||||
@@ -768,6 +772,7 @@ void IntelliPhotoGui::createGui(){
|
||||
mainLayout->addWidget(dimActive,13,2,1,2);
|
||||
mainLayout->addWidget(dimCanvas,14,2,1,2);
|
||||
mainLayout->setHorizontalSpacing(0);
|
||||
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::setIntelliStyle(){
|
||||
@@ -828,7 +833,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::setDefaultToolValue(){
|
||||
void IntelliPhotoGui::setDefaultValues(){
|
||||
slotEnterPressed();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ bool maybeSave();
|
||||
bool saveFile(const QByteArray &fileFormat);
|
||||
|
||||
//basic to set tool values to begin
|
||||
void setDefaultToolValue();
|
||||
void setDefaultValues();
|
||||
|
||||
// What we'll draw on
|
||||
PaintingArea* paintingArea;
|
||||
|
||||
@@ -54,6 +54,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);
|
||||
|
||||
@@ -265,12 +268,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();
|
||||
}
|
||||
@@ -284,8 +287,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();
|
||||
}
|
||||
@@ -296,8 +299,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) {
|
||||
@@ -332,7 +335,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
||||
|
||||
//calulate image here for scroll
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@@ -222,6 +222,10 @@ void wheelEvent(QWheelEvent*event) override;
|
||||
void paintEvent(QPaintEvent*event) override;
|
||||
|
||||
private:
|
||||
//offset for the displayable
|
||||
int offsetXDimension;
|
||||
int offsetYDimension;
|
||||
|
||||
void setLayerDimensions(int maxWidth, int maxHeight);
|
||||
void selectLayerUp();
|
||||
void selectLayerDown();
|
||||
|
||||
Reference in New Issue
Block a user