mirror of
https://github.com/MaurycyLiebner/enve.git
synced 2024-12-18 14:42:02 +00:00
Compare commits
7 Commits
a55a5470b5
...
ab466faa5b
Author | SHA1 | Date | |
---|---|---|---|
|
ab466faa5b | ||
|
0d47901a43 | ||
|
bd58a62764 | ||
|
c8390880f6 | ||
|
e7497a9cc5 | ||
|
6630d4d8bc | ||
|
740ef0dac3 |
@ -155,6 +155,8 @@ public:
|
|||||||
|
|
||||||
void fitCanvasToSize();
|
void fitCanvasToSize();
|
||||||
void resetTransormation();
|
void resetTransormation();
|
||||||
|
void zoomInView();
|
||||||
|
void zoomOutView();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CANVASWINDOW_H
|
#endif // CANVASWINDOW_H
|
||||||
|
@ -70,6 +70,22 @@ void CanvasWindow::fitCanvasToSize() {
|
|||||||
mViewTransform.scale(minScale, minScale);
|
mViewTransform.scale(minScale, minScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasWindow::zoomInView() {
|
||||||
|
if(!mCurrentCanvas) return;
|
||||||
|
const auto canvasSize = mCurrentCanvas->getCanvasSize();
|
||||||
|
mViewTransform.translate(canvasSize.width()*0.5, canvasSize.height()*0.5);
|
||||||
|
mViewTransform.scale(1.1, 1.1);
|
||||||
|
mViewTransform.translate(-canvasSize.width()*0.5, -canvasSize.height()*0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanvasWindow::zoomOutView() {
|
||||||
|
if(!mCurrentCanvas) return;
|
||||||
|
const auto canvasSize = mCurrentCanvas->getCanvasSize();
|
||||||
|
mViewTransform.translate(canvasSize.width()*0.5, canvasSize.height()*0.5);
|
||||||
|
mViewTransform.scale(0.9, 0.9);
|
||||||
|
mViewTransform.translate(-canvasSize.width()*0.5, -canvasSize.height()*0.5);
|
||||||
|
}
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
bool CanvasWindow::event(QEvent *e) {
|
bool CanvasWindow::event(QEvent *e) {
|
||||||
|
@ -606,6 +606,53 @@ void MainWindow::setupMenuBar() {
|
|||||||
|
|
||||||
mViewMenu = mMenuBar->addMenu(tr("View", "MenuBar"));
|
mViewMenu = mMenuBar->addMenu(tr("View", "MenuBar"));
|
||||||
|
|
||||||
|
const auto ViewTransformMenu = mViewMenu->addMenu(
|
||||||
|
tr("Views","MenuBar_View"));
|
||||||
|
|
||||||
|
mZoomInMenu = ViewTransformMenu->addAction(
|
||||||
|
tr("Zoom In", "MenuBar_Views"));
|
||||||
|
mZoomInMenu->setShortcut(Qt::Key_Plus);
|
||||||
|
connect(mZoomInMenu, &QAction::triggered,
|
||||||
|
this, [](){
|
||||||
|
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
|
||||||
|
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
|
||||||
|
if (!cwTarget) return;
|
||||||
|
cwTarget->zoomInView();
|
||||||
|
});
|
||||||
|
|
||||||
|
mZoomOutMenu = ViewTransformMenu->addAction(
|
||||||
|
tr("Zoom Out", "MenuBar_Views"));
|
||||||
|
mZoomOutMenu->setShortcut(Qt::Key_Minus);
|
||||||
|
connect(mZoomOutMenu, &QAction::triggered,
|
||||||
|
this, [](){
|
||||||
|
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
|
||||||
|
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
|
||||||
|
if (!cwTarget) return;
|
||||||
|
cwTarget->zoomOutView();
|
||||||
|
});
|
||||||
|
|
||||||
|
mFitViewMenu = ViewTransformMenu->addAction(
|
||||||
|
tr("Fit to Canvas", "MenuBar_Views"));
|
||||||
|
mFitViewMenu->setShortcut(Qt::Key_0);
|
||||||
|
connect(mFitViewMenu, &QAction::triggered,
|
||||||
|
this, [](){
|
||||||
|
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
|
||||||
|
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
|
||||||
|
if (!cwTarget) return;
|
||||||
|
cwTarget->fitCanvasToSize();
|
||||||
|
});
|
||||||
|
|
||||||
|
mResetZoomMenu = ViewTransformMenu->addAction(
|
||||||
|
tr("Reset Zoom", "MenuBar_Views"));
|
||||||
|
mResetZoomMenu->setShortcut(Qt::Key_1);
|
||||||
|
connect(mResetZoomMenu, &QAction::triggered,
|
||||||
|
this, [](){
|
||||||
|
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
|
||||||
|
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
|
||||||
|
if (!cwTarget) return;
|
||||||
|
cwTarget->resetTransormation();
|
||||||
|
});
|
||||||
|
|
||||||
const auto filteringMenu = mViewMenu->addMenu(
|
const auto filteringMenu = mViewMenu->addMenu(
|
||||||
tr("Filtering", "MenuBar_View"));
|
tr("Filtering", "MenuBar_View"));
|
||||||
|
|
||||||
|
@ -282,6 +282,11 @@ private:
|
|||||||
//
|
//
|
||||||
ActionButton *mActionNewEmptyPaintFrame;
|
ActionButton *mActionNewEmptyPaintFrame;
|
||||||
QAction *mActionNewEmptyPaintFrameAct;
|
QAction *mActionNewEmptyPaintFrameAct;
|
||||||
|
//
|
||||||
|
QAction *mResetZoomMenu;
|
||||||
|
QAction *mZoomInMenu;
|
||||||
|
QAction *mZoomOutMenu;
|
||||||
|
QAction *mFitViewMenu;
|
||||||
//
|
//
|
||||||
QAction *mNoneQuality;
|
QAction *mNoneQuality;
|
||||||
QAction *mLowQuality;
|
QAction *mLowQuality;
|
||||||
|
Loading…
Reference in New Issue
Block a user