Skip to content

Commit

Permalink
refactored cursors same as icons
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Mar 10, 2019
1 parent 8b9b688 commit f25f8e1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ MainWindow::MainWindow(QWidget *parent) :
first_show(true)
{
olive::icon::Initialize();
init_custom_cursors();
olive::cursor::Initialize();

open_debug_file();

Expand Down
2 changes: 1 addition & 1 deletion panels/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ void Timeline::set_tool() {
timeline_area->setCursor(Qt::IBeamCursor);
break;
case TIMELINE_TOOL_RAZOR:
timeline_area->setCursor(olive::Cursor_Razor);
timeline_area->setCursor(olive::cursor::Razor);
break;
case TIMELINE_TOOL_HAND:
timeline_area->setCursor(Qt::OpenHandCursor);
Expand Down
26 changes: 13 additions & 13 deletions ui/cursors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
#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 olive::cursor::LeftTrim;
QCursor olive::cursor::RightTrim;
QCursor olive::cursor::LeftRipple;
QCursor olive::cursor::RightRipple;
QCursor olive::cursor::Slip;
QCursor olive::cursor::Razor;

const int cursor_size = 24;

Expand All @@ -57,13 +57,13 @@ QCursor load_cursor(const QString& file, int hotX = -1, int hotY = -1, bool righ
return QCursor(pixmap, hotX, hotY);
}

void init_custom_cursors(){
void olive::cursor::Initialize(){
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");
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";
}
18 changes: 10 additions & 8 deletions ui/cursors.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@

#include <QCursor>

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;
namespace cursor {
extern QCursor LeftTrim;
extern QCursor RightTrim;
extern QCursor LeftRipple;
extern QCursor RightRipple;
extern QCursor Slip;
extern QCursor Razor;

void Initialize();
}
}

#endif // CURSORS_H
6 changes: 3 additions & 3 deletions ui/timelinewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(panel_timeline->tool == TIMELINE_TOOL_RIPPLE ? olive::Cursor_LeftRipple : 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(panel_timeline->tool == TIMELINE_TOOL_RIPPLE ? olive::Cursor_RightRipple : olive::Cursor_RightTrim);
setCursor(panel_timeline->tool == TIMELINE_TOOL_RIPPLE ? olive::cursor::RightRipple : olive::cursor::RightTrim);
}

} else {
Expand Down Expand Up @@ -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(olive::Cursor_Slip);
setCursor(olive::cursor::Slip);
} else {
unsetCursor();
}
Expand Down

0 comments on commit f25f8e1

Please sign in to comment.