-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental features: zoom and drag view (adressing #34)
- Loading branch information
1 parent
9e3d0c9
commit ff3196b
Showing
16 changed files
with
230 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-FileCopyrightText: 2024 Valentin Bruch <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-or-later OR AGPL-3.0-or-later | ||
|
||
#ifndef DRAGTOOL_H | ||
#define DRAGTOOL_H | ||
|
||
#include <QPointF> | ||
#include <cmath> | ||
|
||
#include "src/drawing/tool.h" | ||
|
||
/** Experimental: DragTool for dragging view */ | ||
class DragTool : public Tool | ||
{ | ||
QPointF reference_point; | ||
static constexpr int skip_events = 3; | ||
int event_counter = skip_events - 1; | ||
|
||
public: | ||
DragTool(const int device = AnyDevice) noexcept : Tool(DragViewTool, device) | ||
{ | ||
} | ||
DragTool(const DragTool &other) noexcept : Tool(DragViewTool, other.device()) | ||
{ | ||
} | ||
~DragTool() {} | ||
const QPointF &reference() const noexcept { return reference_point; } | ||
void setReference(const QPointF &pos) noexcept { reference_point = pos; } | ||
QPointF dragTo(const QPointF target, const bool force) noexcept | ||
{ | ||
if (force || ++event_counter >= skip_events) | ||
event_counter = 0; | ||
else | ||
return QPointF(); | ||
return reference_point - target; | ||
} | ||
}; | ||
|
||
#endif // DRAGTOOL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.