merged cursors #522

This commit is contained in:
itsmattkc
2019-03-09 17:21:22 +11:00
parent 653abf8042
commit 8cf3bd46a1
16 changed files with 99565 additions and 22 deletions
+34 -14
View File
@@ -20,30 +20,50 @@
#include "cursors.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QPixmap>
#include <QSvgRenderer>
#include <QPainter>
#include <QCursor>
#include <QDebug>
QCursor olive::Cursor_LeftTrim;
QCursor olive::Cursor_RightTrim;
QCursor olive::Cursor_LeftRipple;
QCursor olive::Cursor_RightRipple;
QCursor olive::Cursor_Slip;
QCursor olive::Cursor_Razor;
QCursor load_cursor(const QString& file, int hotX, int hotY, const bool& right_aligned){
// load specified file into a pixmap
QPixmap temp(file);
const int cursor_size = 24;
// set cursor's horizontal hotspot
if (right_aligned) {
hotX = temp.width() - hotX;
}
QCursor load_cursor(const QString& file, int hotX = -1, int hotY = -1, bool right_aligned = false){
// load specified file into a pixmap
QSvgRenderer renderer(file);
// return cursor
return QCursor(temp, hotX, hotY);
int cursor_size_dpiaware = cursor_size * QApplication::desktop()->devicePixelRatio();
QPixmap pixmap(cursor_size_dpiaware, cursor_size_dpiaware);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
renderer.render(&painter, pixmap.rect());
// set cursor's horizontal hotspot
if (right_aligned) {
hotX = pixmap.width() - hotX;
}
// return cursor
return QCursor(pixmap, hotX, hotY);
}
void init_custom_cursors(){
qInfo() << "Initializing custom cursors";
olive::Cursor_LeftTrim = load_cursor(":/cursors/left_side.png", 0, -1, false);
olive::Cursor_RightTrim = load_cursor(":/cursors/right_side.png", 0, -1, true);
qInfo() << "Finished initializing custom cursors";
qInfo() << "Initializing custom cursors";
olive::Cursor_LeftTrim = load_cursor(":/cursors/1_left.svg");
olive::Cursor_RightTrim = load_cursor(":/cursors/1_right.svg");
olive::Cursor_LeftRipple = load_cursor(":/cursors/3_left.svg");
olive::Cursor_RightRipple = load_cursor(":/cursors/3_right.svg");
olive::Cursor_Slip = load_cursor(":/cursors/4.svg");
olive::Cursor_Razor = load_cursor(":/cursors/5.svg");
qInfo() << "Finished initializing custom cursors";
}
+4
View File
@@ -28,6 +28,10 @@ void init_custom_cursors();
namespace olive{
extern QCursor Cursor_LeftTrim;
extern QCursor Cursor_RightTrim;
extern QCursor Cursor_LeftRipple;
extern QCursor Cursor_RightRipple;
extern QCursor Cursor_Slip;
extern QCursor Cursor_Razor;
}
#endif // CURSORS_H
+3 -3
View File
@@ -2653,9 +2653,9 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
if (found) {
if (panel_timeline->trim_type == TRIM_IN) { // if we're trimming an IN point
setCursor(olive::Cursor_LeftTrim);
setCursor(panel_timeline->tool == TIMELINE_TOOL_RIPPLE ? olive::Cursor_LeftRipple : olive::Cursor_LeftTrim);
} else { // if we're trimming an OUT point
setCursor(olive::Cursor_RightTrim);
setCursor(panel_timeline->tool == TIMELINE_TOOL_RIPPLE ? olive::Cursor_RightRipple : olive::Cursor_RightTrim);
}
} else {
@@ -2691,7 +2691,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
// we're not currently performing any slipping, all we do here is set the cursor if mouse is hovering over a
// cursor
if (getClipIndexFromCoords(panel_timeline->cursor_frame, panel_timeline->cursor_track) > -1) {
setCursor(Qt::SizeHorCursor);
setCursor(olive::Cursor_Slip);
} else {
unsetCursor();
}