Add 45-multiple degree adjustment for line, arrow and marker tools (#439)

* Add 45-multiple degree adjustment for line, arrow and marker tools

* Adjustment: Ctrl press is checked + widened functionality for two-point tools
This commit is contained in:
Nikolai Oplachko
2019-03-31 13:38:31 +03:00
committed by Dharkael
parent bd83eea7af
commit b42f1cf01d
13 changed files with 99 additions and 35 deletions

View File

@@ -52,7 +52,7 @@ CaptureWidget::CaptureWidget(const uint id, const QString &savePath,
bool fullScreen, QWidget *parent) :
QWidget(parent), m_mouseIsClicked(false), m_rightClick(false),
m_newSelection(false), m_grabbing(false), m_captureDone(false),
m_previewEnabled(true), m_activeButton(nullptr),
m_previewEnabled(true), m_adjustmentButtonPressed(false), m_activeButton(nullptr),
m_activeTool(nullptr), m_toolWidget(nullptr),
m_mouseOverHandle(SelectionWidget::NO_SIDE), m_id(id)
{
@@ -398,7 +398,11 @@ void CaptureWidget::mouseMoveEvent(QMouseEvent *e) {
}
} else if (m_mouseIsClicked && m_activeTool) {
// drawing with a tool
m_activeTool->drawMove(e->pos());
if (m_adjustmentButtonPressed) {
m_activeTool->drawMoveWithAdjustment(e->pos());
} else {
m_activeTool->drawMove(e->pos());
}
update();
// Hides the buttons under the mouse. If the mouse leaves, it shows them.
if (m_buttonHandler->buttonsAreInside()) {
@@ -494,6 +498,14 @@ void CaptureWidget::keyPressEvent(QKeyEvent *e) {
m_context.selection = extendedRect(&newGeometry);
m_buttonHandler->updatePosition(m_selection->geometry());
update();
} else if (e->key() == Qt::Key_Control) {
m_adjustmentButtonPressed = true;
}
}
void CaptureWidget::keyReleaseEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Control) {
m_adjustmentButtonPressed = false;
}
}