Add ability to load custom cursors. Add custom cursor to left / right

clip position editing.

Revert white space edits in timelinewidget.
This commit is contained in:
alexmitchell
2019-02-05 16:08:18 +10:30
parent 749c4d8ff8
commit 3fe8660c5e
8 changed files with 371 additions and 314 deletions
+22
View File
@@ -0,0 +1,22 @@
#include "cursors.h"
#include <QPixmap>
#include <QCursor>
#include <QDebug>
QCursor OLIVE_CURSORS::left_arrow;
QCursor OLIVE_CURSORS::right_arrow;
QCursor load_cursor(QString file, const int hotX, const int hotY, const bool right_aligend){
int hotoutX;
QPixmap temp = QPixmap(file);
right_aligend? hotoutX = temp.width() : hotoutX = hotX;
return QCursor(temp,hotoutX,hotY);
}
void initCustomCursors(){
qInfo() << "Loading Custom Cursors";
OLIVE_CURSORS::left_arrow = load_cursor(":/cursors/Cursor_Left_Arrow.png", 0,-1, false);
OLIVE_CURSORS::right_arrow = load_cursor(":/cursors/Cursor_Right_Arrow.png", 0,-1, true);
}
+13
View File
@@ -0,0 +1,13 @@
#ifndef CURSORS_H
#define CURSORS_H
#include <QCursor>
void initCustomCursors();
namespace OLIVE_CURSORS{
extern QCursor left_arrow;
extern QCursor right_arrow;
}
#endif // CURSORS_H
+10
View File
@@ -23,6 +23,7 @@
#include "mainwindow.h"
#include "ui/rectangleselect.h"
#include "playback/playback.h"
#include "ui/cursors.h"
#include "debug.h"
#include "project/effect.h"
@@ -1986,6 +1987,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
long mouse_frame_lower = panel_timeline->getTimelineFrameFromScreenPoint(pos.x()-lim)-1;
long mouse_frame_upper = panel_timeline->getTimelineFrameFromScreenPoint(pos.x()+lim)+1;
bool found = false;
bool left_arrow_cursor = false;
bool right_arrow_cursor = false;
bool cursor_contains_clip = false;
int closeness = INT_MAX;
int min_track = INT_MAX;
@@ -2017,6 +2020,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
panel_timeline->trim_in_point = true;
closeness = nc;
found = true;
left_arrow_cursor = true;
}
}
if (c->timeline_out > mouse_frame_lower && c->timeline_out < mouse_frame_upper) {
@@ -2026,6 +2030,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
panel_timeline->trim_in_point = false;
closeness = nc;
found = true;
right_arrow_cursor = true;
}
}
if (panel_timeline->tool == TIMELINE_TOOL_POINTER) {
@@ -2064,6 +2069,11 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
QToolTip::showText(mapToGlobal(event->pos()), "HOVER OVER CLIP");
}*/
if (found) {
if (right_arrow_cursor && !panel_timeline->trim_in_point){
setCursor(OLIVE_CURSORS::right_arrow);
}else if (left_arrow_cursor && panel_timeline->trim_in_point){
setCursor(OLIVE_CURSORS::left_arrow);
}else
setCursor(Qt::SizeHorCursor);
} else {
panel_timeline->trim_target = -1;