merged cursors #522
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 359 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 358 KiB |
|
After Width: | Height: | Size: 358 KiB |
@@ -1,6 +1,13 @@
|
||||
<RCC>
|
||||
<qresource prefix="/cursors">
|
||||
<file>left_side.png</file>
|
||||
<file>right_side.png</file>
|
||||
<file>1_left.svg</file>
|
||||
<file>1_right.svg</file>
|
||||
<file>2.svg</file>
|
||||
<file>3_left.svg</file>
|
||||
<file>3_right.svg</file>
|
||||
<file>4.svg</file>
|
||||
<file>5.svg</file>
|
||||
<file>5b.svg</file>
|
||||
<file>5c.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -36,6 +36,7 @@
|
||||
#include "ui/resizablescrollbar.h"
|
||||
#include "ui/audiomonitor.h"
|
||||
#include "ui/flowlayout.h"
|
||||
#include "ui/cursors.h"
|
||||
#include "mainwindow.h"
|
||||
#include "debug.h"
|
||||
|
||||
@@ -1706,7 +1707,7 @@ void Timeline::deselect() {
|
||||
}
|
||||
|
||||
long getFrameFromScreenPoint(double zoom, int x) {
|
||||
long f = qCeil(double(x) / zoom);
|
||||
long f = qRound(double(x) / zoom);
|
||||
if (f < 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1714,7 +1715,7 @@ long getFrameFromScreenPoint(double zoom, int x) {
|
||||
}
|
||||
|
||||
int getScreenPointFromFrame(double zoom, long frame) {
|
||||
return qFloor(double(frame)*zoom);
|
||||
return qRound(double(frame)*zoom);
|
||||
}
|
||||
|
||||
long Timeline::getTimelineFrameFromScreenPoint(int x) {
|
||||
@@ -2039,9 +2040,11 @@ void Timeline::set_tool() {
|
||||
creating = false;
|
||||
switch (tool) {
|
||||
case TIMELINE_TOOL_EDIT:
|
||||
case TIMELINE_TOOL_RAZOR:
|
||||
timeline_area->setCursor(Qt::IBeamCursor);
|
||||
break;
|
||||
case TIMELINE_TOOL_RAZOR:
|
||||
timeline_area->setCursor(olive::Cursor_Razor);
|
||||
break;
|
||||
case TIMELINE_TOOL_HAND:
|
||||
timeline_area->setCursor(Qt::OpenHandCursor);
|
||||
break;
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||