basics of zoom and scroll

This commit is contained in:
Jonas Mucke
2020-01-22 21:19:24 +01:00
parent 31553b2e94
commit 8e187ba6b3
5 changed files with 71 additions and 41 deletions

View File

@@ -18,7 +18,6 @@ IntelliPhotoGui::IntelliPhotoGui(){
setIntelliStyle();
// Size the app
resize(600,600);
showMaximized();
setDefaultToolValue();
}
@@ -550,6 +549,7 @@ void IntelliPhotoGui::createMenus(){
layerCreationMenu = new QMenu(tr("&Create new Layer"), this);
layerCreationMenu->addAction(actionCreateNewRasterLayer);
layerCreationMenu->addAction(actionCreateNewShapedLayer);
// Attach all actions to Layer
layerMenu = new QMenu(tr("&Layer"), this);
layerMenu->addMenu(layerCreationMenu);
@@ -626,7 +626,7 @@ void IntelliPhotoGui::createGui(){
// create Gui elements
// get and set max width and height
paintingArea = new PaintingArea(1280, 720);
paintingArea->DummyGui = this;
paintingArea->guiReference = this;
preview = QPixmap(":/Icons/Buttons/icons/circle-tool.svg");
CircleButton = new QPushButton();
@@ -740,8 +740,14 @@ void IntelliPhotoGui::createGui(){
QString String = QString("%1x%2").arg(paintingArea->Canvas->width()).arg(paintingArea->Canvas->height());
dimCanvas->setText(String);
ScrollArea = new QScrollArea(this);
ScrollArea->setBackgroundRole(QPalette::Dark);
ScrollArea->setWidget(paintingArea);
ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// set gui elements
mainLayout->addWidget(paintingArea,1,1,20,1);
mainLayout->addWidget(ScrollArea,1,1,20,1);
mainLayout->addWidget(CircleButton,1,2,1,1);
mainLayout->addWidget(FloodFillButton,1,3,1,1);
mainLayout->addWidget(LineButton,2,2,1,1);
@@ -846,7 +852,9 @@ void IntelliPhotoGui::UpdateGui(){
tmp.fill(Qt::transparent);
preview = preview.fromImage(tmp);
}
ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize * 2));
string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);

View File

@@ -14,6 +14,7 @@
#include <QTextEdit>
#include <QLabel>
#include <QLineEdit>
#include <QScrollArea>
#include "IntelliInputDialog.h"
//for unit testing
@@ -96,10 +97,11 @@ void slotSetInnerAlpha();
void slotResetTools();
private:
//setup functions for gui
void createActions();
void createMenus();
void createGui();
// Set the style of the GUI
void setIntelliStyle();
// Will check if changes have occurred since last save
@@ -107,13 +109,19 @@ bool maybeSave();
// Opens the Save dialog and saves
bool saveFile(const QByteArray &fileFormat);
//basic to set tool values to begin
void setDefaultToolValue();
// What we'll draw on
PaintingArea* paintingArea;
const QSize Buttonsize = QSize(35,35);
//used to display a preview of the active layer
QPixmap preview;
//size of all buttons
const QSize Buttonsize = QSize(35,35);
//buttons used for gui
QPushButton* CircleButton;
QPushButton* FloodFillButton;
QPushButton* LineButton;
@@ -121,35 +129,42 @@ QPushButton* PenButton;
QPushButton* PlainButton;
QPushButton* PolygonButton;
QPushButton* RectangleButton;
QLabel* WidthLine;
QLabel* innerAlphaLine;
QLineEdit* EditLineWidth;
QLineEdit* EditLineInnerAlpha;
QIntValidator* ValidatorLineWidth;
QIntValidator* ValidatorInnerAlpha;
QPushButton* FirstColorButton;
QPushButton* SecondColorButton;
QPushButton* SwitchColorButton;
QLabel* ActiveLayerLine;
QLabel* ActiveLayerImageLabel;
QPushButton* dimActive;
QPushButton* dimCanvas;
//labels used for gui
QLabel* WidthLine;
QLabel* innerAlphaLine;
QLabel* ActiveLayerLine;
QLabel* ActiveLayerImageLabel;
//scroll area to display canvas
QScrollArea* ScrollArea;
//line edits used for gui
QLineEdit* EditLineWidth;
QLineEdit* EditLineInnerAlpha;
//int validator used for gui
QIntValidator* ValidatorLineWidth;
QIntValidator* ValidatorInnerAlpha;
// The menu widgets
QMenu*saveAsMenu;
QMenu*fileMenu;
QMenu*renderMenu;
QMenu*optionMenu;
QMenu*layerCreationMenu;
QMenu*layerMenu;
QMenu*colorMenu;
QMenu*toolCreationMenu;
QMenu*toolSettingsMenu;
QMenu*toolMenu;
QMenu*helpMenu;
QMenu* saveAsMenu;
QMenu* fileMenu;
QMenu* renderMenu;
QMenu* optionMenu;
QMenu* layerCreationMenu;
QMenu* layerMenu;
QMenu* colorMenu;
QMenu* toolCreationMenu;
QMenu* toolSettingsMenu;
QMenu* toolMenu;
QMenu* helpMenu;
// All the actions that can occur
// meta image actions (need further modularisation)
@@ -175,7 +190,9 @@ QAction* actionCreatePolygonTool;
QAction* actionCreateFloodFillTool;
// dimension actions
QAction*actionChangeDim;
QAction* actionChangeDim;
QAction* actionSetWidth;
QAction* actionSetInnerAlpha;
// dialog actions
QAction* actionAboutDialog;
@@ -198,8 +215,7 @@ QAction* actionMoveLayerDown;
// Actions tied to specific file formats
QList<QAction*> actionSaveAs;
QAction* actionSetWidth;
QAction* actionSetInnerAlpha;
// main GUI elements
QWidget* centralGuiWidget;