Merge pull request #203 from olive-editor/resizablebars

Zoom can now be adjusted by resizing the scroll bars
This commit is contained in:
itsmattkc
2018-12-26 18:44:38 +11:00
committed by GitHub
16 changed files with 2384 additions and 2166 deletions
+242 -240
View File
@@ -1,240 +1,242 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-05-11T10:31:59
#
#-------------------------------------------------
QT += core gui multimedia opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
mac {
TARGET = Olive
}
!mac {
TARGET = olive-editor
}
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp \
panels/project.cpp \
panels/effectcontrols.cpp \
panels/viewer.cpp \
panels/timeline.cpp \
ui/sourcetable.cpp \
dialogs/aboutdialog.cpp \
ui/timelinewidget.cpp \
project/media.cpp \
project/footage.cpp \
project/sequence.cpp \
project/clip.cpp \
playback/playback.cpp \
playback/audio.cpp \
io/config.cpp \
dialogs/newsequencedialog.cpp \
ui/viewerwidget.cpp \
ui/viewercontainer.cpp \
dialogs/exportdialog.cpp \
ui/collapsiblewidget.cpp \
panels/panels.cpp \
playback/cacher.cpp \
io/exportthread.cpp \
ui/timelineheader.cpp \
io/previewgenerator.cpp \
ui/labelslider.cpp \
dialogs/preferencesdialog.cpp \
ui/audiomonitor.cpp \
project/undo.cpp \
ui/scrollarea.cpp \
ui/comboboxex.cpp \
ui/colorbutton.cpp \
dialogs/replaceclipmediadialog.cpp \
ui/fontcombobox.cpp \
ui/checkboxex.cpp \
ui/keyframeview.cpp \
ui/texteditex.cpp \
dialogs/demonotice.cpp \
project/marker.cpp \
dialogs/speeddialog.cpp \
dialogs/mediapropertiesdialog.cpp \
io/crc32.cpp \
project/projectmodel.cpp \
io/loadthread.cpp \
dialogs/loaddialog.cpp \
debug.cpp \
io/path.cpp \
effects/internal/linearfadetransition.cpp \
effects/internal/transformeffect.cpp \
effects/internal/solideffect.cpp \
effects/internal/texteffect.cpp \
effects/internal/timecodeeffect.cpp \
effects/internal/audionoiseeffect.cpp \
effects/internal/paneffect.cpp \
effects/internal/toneeffect.cpp \
effects/internal/volumeeffect.cpp \
effects/internal/crossdissolvetransition.cpp \
effects/internal/shakeeffect.cpp \
effects/internal/exponentialfadetransition.cpp \
effects/internal/logarithmicfadetransition.cpp \
effects/internal/cornerpineffect.cpp \
io/math.cpp \
io/qpainterwrapper.cpp \
project/effect.cpp \
project/transition.cpp \
project/effectrow.cpp \
project/effectfield.cpp \
effects/internal/cubetransition.cpp \
project/effectgizmo.cpp \
io/clipboard.cpp \
dialogs/stabilizerdialog.cpp \
io/avtogl.cpp \
ui/sourceiconview.cpp \
project/sourcescommon.cpp
HEADERS += \
mainwindow.h \
panels/project.h \
panels/effectcontrols.h \
panels/viewer.h \
panels/timeline.h \
ui/sourcetable.h \
dialogs/aboutdialog.h \
ui/timelinewidget.h \
project/media.h \
project/footage.h \
project/sequence.h \
project/clip.h \
playback/playback.h \
playback/audio.h \
io/config.h \
dialogs/newsequencedialog.h \
ui/viewerwidget.h \
ui/viewercontainer.h \
dialogs/exportdialog.h \
ui/collapsiblewidget.h \
panels/panels.h \
playback/cacher.h \
io/exportthread.h \
ui/timelinetools.h \
ui/timelineheader.h \
io/previewgenerator.h \
ui/labelslider.h \
dialogs/preferencesdialog.h \
ui/audiomonitor.h \
project/undo.h \
ui/scrollarea.h \
ui/comboboxex.h \
ui/colorbutton.h \
dialogs/replaceclipmediadialog.h \
ui/fontcombobox.h \
ui/checkboxex.h \
ui/keyframeview.h \
ui/texteditex.h \
dialogs/demonotice.h \
project/marker.h \
project/selection.h \
dialogs/speeddialog.h \
dialogs/mediapropertiesdialog.h \
io/crc32.h \
project/projectmodel.h \
io/loadthread.h \
dialogs/loaddialog.h \
debug.h \
io/path.h \
effects/internal/transformeffect.h \
effects/internal/solideffect.h \
effects/internal/texteffect.h \
effects/internal/timecodeeffect.h \
effects/internal/audionoiseeffect.h \
effects/internal/paneffect.h \
effects/internal/toneeffect.h \
effects/internal/volumeeffect.h \
effects/internal/shakeeffect.h \
effects/internal/linearfadetransition.h \
effects/internal/crossdissolvetransition.h \
effects/internal/exponentialfadetransition.h \
effects/internal/logarithmicfadetransition.h \
effects/internal/cornerpineffect.h \
io/math.h \
io/qpainterwrapper.h \
project/effect.h \
project/transition.h \
project/effectrow.h \
project/effectfield.h \
effects/internal/cubetransition.h \
project/effectgizmo.h \
io/clipboard.h \
dialogs/stabilizerdialog.h \
io/avtogl.h \
ui/sourceiconview.h \
project/sourcescommon.h
FORMS += \
mainwindow.ui \
panels/effectcontrols.ui \
panels/viewer.ui \
panels/timeline.ui \
dialogs/aboutdialog.ui \
dialogs/newsequencedialog.ui \
dialogs/exportdialog.ui \
dialogs/preferencesdialog.ui \
dialogs/demonotice.ui
win32 {
RC_FILE = icons/resources.rc
LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32
}
mac {
LIBS += -L/usr/local/lib -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample
ICON = icons/olive.icns
INCLUDEPATH = /usr/local/include
}
unix:!mac {
CONFIG += link_pkgconfig
PKGCONFIG += libavutil libavformat libavcodec libavfilter libswscale libswresample
}
RESOURCES += \
icons/icons.qrc
unix:!mac {
metainfo.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.appdata.xml
metainfo.path = $$PREFIX/share/metainfo
desktop.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.desktop
desktop.path = $$PREFIX/share/applications
mime.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.xml
mime.path = $$PREFIX/share/mime/packages
icon16.files = $$PWD/packaging/linux/icons/16x16/org.olivevideoeditor.Olive.png
icon16.path = $$PREFIX/share/icons/hicolor/16x16/apps
icon32.files = $$PWD/packaging/linux/icons/32x32/org.olivevideoeditor.Olive.png
icon32.path = $$PREFIX/share/icons/hicolor/32x32/apps
icon48.files = $$PWD/packaging/linux/icons/48x48/org.olivevideoeditor.Olive.png
icon48.path = $$PREFIX/share/icons/hicolor/48x48/apps
icon64.files = $$PWD/packaging/linux/icons/64x64/org.olivevideoeditor.Olive.png
icon64.path = $$PREFIX/share/icons/hicolor/64x64/apps
icon128.files = $$PWD/packaging/linux/icons/128x128/org.olivevideoeditor.Olive.png
icon128.path = $$PREFIX/share/icons/hicolor/128x128/apps
icon256.files = $$PWD/packaging/linux/icons/256x256/org.olivevideoeditor.Olive.png
icon256.path = $$PREFIX/share/icons/hicolor/256x256/apps
icon512.files = $$PWD/packaging/linux/icons/512x512/org.olivevideoeditor.Olive.png
icon512.path = $$PREFIX/share/icons/hicolor/512x512/apps
icon1024.files = $$PWD/packaging/linux/icons/1024x1024/org.olivevideoeditor.Olive.png
icon1024.path = $$PREFIX/share/icons/hicolor/1024x1024/apps
INSTALLS += metainfo desktop mime icon16 icon32 icon48 icon64 icon128 icon256 icon512 icon1024
}
#-------------------------------------------------
#
# Project created by QtCreator 2018-05-11T10:31:59
#
#-------------------------------------------------
QT += core gui multimedia opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
mac {
TARGET = Olive
}
!mac {
TARGET = olive-editor
}
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp \
panels/project.cpp \
panels/effectcontrols.cpp \
panels/viewer.cpp \
panels/timeline.cpp \
ui/sourcetable.cpp \
dialogs/aboutdialog.cpp \
ui/timelinewidget.cpp \
project/media.cpp \
project/footage.cpp \
project/sequence.cpp \
project/clip.cpp \
playback/playback.cpp \
playback/audio.cpp \
io/config.cpp \
dialogs/newsequencedialog.cpp \
ui/viewerwidget.cpp \
ui/viewercontainer.cpp \
dialogs/exportdialog.cpp \
ui/collapsiblewidget.cpp \
panels/panels.cpp \
playback/cacher.cpp \
io/exportthread.cpp \
ui/timelineheader.cpp \
io/previewgenerator.cpp \
ui/labelslider.cpp \
dialogs/preferencesdialog.cpp \
ui/audiomonitor.cpp \
project/undo.cpp \
ui/scrollarea.cpp \
ui/comboboxex.cpp \
ui/colorbutton.cpp \
dialogs/replaceclipmediadialog.cpp \
ui/fontcombobox.cpp \
ui/checkboxex.cpp \
ui/keyframeview.cpp \
ui/texteditex.cpp \
dialogs/demonotice.cpp \
project/marker.cpp \
dialogs/speeddialog.cpp \
dialogs/mediapropertiesdialog.cpp \
io/crc32.cpp \
project/projectmodel.cpp \
io/loadthread.cpp \
dialogs/loaddialog.cpp \
debug.cpp \
io/path.cpp \
effects/internal/linearfadetransition.cpp \
effects/internal/transformeffect.cpp \
effects/internal/solideffect.cpp \
effects/internal/texteffect.cpp \
effects/internal/timecodeeffect.cpp \
effects/internal/audionoiseeffect.cpp \
effects/internal/paneffect.cpp \
effects/internal/toneeffect.cpp \
effects/internal/volumeeffect.cpp \
effects/internal/crossdissolvetransition.cpp \
effects/internal/shakeeffect.cpp \
effects/internal/exponentialfadetransition.cpp \
effects/internal/logarithmicfadetransition.cpp \
effects/internal/cornerpineffect.cpp \
io/math.cpp \
io/qpainterwrapper.cpp \
project/effect.cpp \
project/transition.cpp \
project/effectrow.cpp \
project/effectfield.cpp \
effects/internal/cubetransition.cpp \
project/effectgizmo.cpp \
io/clipboard.cpp \
dialogs/stabilizerdialog.cpp \
io/avtogl.cpp \
ui/resizablescrollbar.cpp \
ui/sourceiconview.cpp \
project/sourcescommon.cpp
HEADERS += \
mainwindow.h \
panels/project.h \
panels/effectcontrols.h \
panels/viewer.h \
panels/timeline.h \
ui/sourcetable.h \
dialogs/aboutdialog.h \
ui/timelinewidget.h \
project/media.h \
project/footage.h \
project/sequence.h \
project/clip.h \
playback/playback.h \
playback/audio.h \
io/config.h \
dialogs/newsequencedialog.h \
ui/viewerwidget.h \
ui/viewercontainer.h \
dialogs/exportdialog.h \
ui/collapsiblewidget.h \
panels/panels.h \
playback/cacher.h \
io/exportthread.h \
ui/timelinetools.h \
ui/timelineheader.h \
io/previewgenerator.h \
ui/labelslider.h \
dialogs/preferencesdialog.h \
ui/audiomonitor.h \
project/undo.h \
ui/scrollarea.h \
ui/comboboxex.h \
ui/colorbutton.h \
dialogs/replaceclipmediadialog.h \
ui/fontcombobox.h \
ui/checkboxex.h \
ui/keyframeview.h \
ui/texteditex.h \
dialogs/demonotice.h \
project/marker.h \
project/selection.h \
dialogs/speeddialog.h \
dialogs/mediapropertiesdialog.h \
io/crc32.h \
project/projectmodel.h \
io/loadthread.h \
dialogs/loaddialog.h \
debug.h \
io/path.h \
effects/internal/transformeffect.h \
effects/internal/solideffect.h \
effects/internal/texteffect.h \
effects/internal/timecodeeffect.h \
effects/internal/audionoiseeffect.h \
effects/internal/paneffect.h \
effects/internal/toneeffect.h \
effects/internal/volumeeffect.h \
effects/internal/shakeeffect.h \
effects/internal/linearfadetransition.h \
effects/internal/crossdissolvetransition.h \
effects/internal/exponentialfadetransition.h \
effects/internal/logarithmicfadetransition.h \
effects/internal/cornerpineffect.h \
io/math.h \
io/qpainterwrapper.h \
project/effect.h \
project/transition.h \
project/effectrow.h \
project/effectfield.h \
effects/internal/cubetransition.h \
project/effectgizmo.h \
io/clipboard.h \
dialogs/stabilizerdialog.h \
io/avtogl.h \
ui/resizablescrollbar.h \
ui/sourceiconview.h \
project/sourcescommon.h
FORMS += \
mainwindow.ui \
panels/effectcontrols.ui \
panels/viewer.ui \
panels/timeline.ui \
dialogs/aboutdialog.ui \
dialogs/newsequencedialog.ui \
dialogs/exportdialog.ui \
dialogs/preferencesdialog.ui \
dialogs/demonotice.ui
win32 {
RC_FILE = icons/resources.rc
LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32
}
mac {
LIBS += -L/usr/local/lib -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample
ICON = icons/olive.icns
INCLUDEPATH = /usr/local/include
}
unix:!mac {
CONFIG += link_pkgconfig
PKGCONFIG += libavutil libavformat libavcodec libavfilter libswscale libswresample
}
RESOURCES += \
icons/icons.qrc
unix:!mac {
metainfo.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.appdata.xml
metainfo.path = $$PREFIX/share/metainfo
desktop.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.desktop
desktop.path = $$PREFIX/share/applications
mime.files = $$PWD/packaging/linux/org.olivevideoeditor.Olive.xml
mime.path = $$PREFIX/share/mime/packages
icon16.files = $$PWD/packaging/linux/icons/16x16/org.olivevideoeditor.Olive.png
icon16.path = $$PREFIX/share/icons/hicolor/16x16/apps
icon32.files = $$PWD/packaging/linux/icons/32x32/org.olivevideoeditor.Olive.png
icon32.path = $$PREFIX/share/icons/hicolor/32x32/apps
icon48.files = $$PWD/packaging/linux/icons/48x48/org.olivevideoeditor.Olive.png
icon48.path = $$PREFIX/share/icons/hicolor/48x48/apps
icon64.files = $$PWD/packaging/linux/icons/64x64/org.olivevideoeditor.Olive.png
icon64.path = $$PREFIX/share/icons/hicolor/64x64/apps
icon128.files = $$PWD/packaging/linux/icons/128x128/org.olivevideoeditor.Olive.png
icon128.path = $$PREFIX/share/icons/hicolor/128x128/apps
icon256.files = $$PWD/packaging/linux/icons/256x256/org.olivevideoeditor.Olive.png
icon256.path = $$PREFIX/share/icons/hicolor/256x256/apps
icon512.files = $$PWD/packaging/linux/icons/512x512/org.olivevideoeditor.Olive.png
icon512.path = $$PREFIX/share/icons/hicolor/512x512/apps
icon1024.files = $$PWD/packaging/linux/icons/1024x1024/org.olivevideoeditor.Olive.png
icon1024.path = $$PREFIX/share/icons/hicolor/1024x1024/apps
INSTALLS += metainfo desktop mime icon16 icon32 icon48 icon64 icon128 icon256 icon512 icon1024
}
+1
View File
@@ -43,6 +43,7 @@ EffectControls::EffectControls(QWidget *parent) :
ui->label_2->setVisible(false);
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), ui->headers, SLOT(set_scroll(int)));
connect(ui->horizontalScrollBar, SIGNAL(resize_move(double)), ui->keyframeView, SLOT(resize_move(double)));
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), ui->keyframeView, SLOT(set_x_scroll(int)));
connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), ui->keyframeView, SLOT(set_y_scroll(int)));
connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), ui->scrollArea->verticalScrollBar(), SLOT(setValue(int)));
+8 -3
View File
@@ -71,8 +71,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>477</height>
<width>189</width>
<height>483</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
@@ -502,7 +502,7 @@
</widget>
</item>
<item>
<widget class="QScrollBar" name="horizontalScrollBar">
<widget class="ResizableScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>0</number>
</property>
@@ -543,6 +543,11 @@
<header>panels/effectcontrols.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResizableScrollBar</class>
<extends>QScrollBar</extends>
<header>ui/resizablescrollbar.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
+1187 -1187
View File
File diff suppressed because it is too large Load Diff
+20 -5
View File
@@ -108,6 +108,7 @@ Timeline::Timeline(QWidget *parent) :
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(setScroll(int)));
connect(ui->videoScrollbar, SIGNAL(valueChanged(int)), ui->video_area, SLOT(setScroll(int)));
connect(ui->audioScrollbar, SIGNAL(valueChanged(int)), ui->audio_area, SLOT(setScroll(int)));
connect(ui->horizontalScrollBar, SIGNAL(resize_move(double)), this, SLOT(resize_move(double)));
update_sequence();
}
@@ -423,6 +424,7 @@ void Timeline::repaint_timeline() {
if (sequence != NULL
&& !ui->horizontalScrollBar->isSliderDown()
&& !ui->horizontalScrollBar->is_resizing()
&& panel_sequence_viewer->playing
&& !zoom_just_changed) {
// auto scroll
@@ -449,7 +451,7 @@ void Timeline::repaint_timeline() {
if (sequence != NULL) {
long sequenceEndFrame = sequence->getEndFrame();
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequenceEndFrame, (ui->editAreas->width()/2));
set_sb_max();
if (last_frame != sequence->playhead) {
ui->audio_monitor->update();
@@ -473,7 +475,11 @@ void Timeline::select_all() {
}
}
repaint_timeline();
}
}
}
void Timeline::resizeEvent(QResizeEvent *event) {
if (sequence != NULL) set_sb_max();
}
void Timeline::delete_in_out(bool ripple) {
@@ -570,7 +576,8 @@ void Timeline::set_zoom_value(double v) {
repaint_timeline();
// TODO find a way to gradually move towards target_scroll instead of just centering it?
center_scroll_to_playhead(ui->horizontalScrollBar, zoom, sequence->playhead);
if (!ui->horizontalScrollBar->is_resizing())
center_scroll_to_playhead(ui->horizontalScrollBar, zoom, sequence->playhead);
}
void Timeline::set_zoom(bool in) {
@@ -1400,7 +1407,7 @@ void Timeline::deselect() {
}
long getFrameFromScreenPoint(double zoom, int x) {
long f = qCeil((float) x / zoom);
long f = qCeil((float) x / zoom);
if (f < 0) {
return 0;
}
@@ -1408,7 +1415,7 @@ long getFrameFromScreenPoint(double zoom, int x) {
}
int getScreenPointFromFrame(double zoom, long frame) {
return (int) qFloor(frame*zoom);
return (int) qFloor(frame*zoom);
}
long Timeline::getTimelineFrameFromScreenPoint(int x) {
@@ -1573,6 +1580,14 @@ void Timeline::transition_menu_select(QAction* a) {
ui->toolTransitionButton->setChecked(true);
}
void Timeline::resize_move(double z) {
set_zoom_value(zoom * z);
}
void Timeline::set_sb_max() {
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequence->getEndFrame(), ui->editAreas->width() - getScreenPointFromFrame(zoom, 200));
}
void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions) {
ca->append(new MoveClipAction(c, iin, iout, iclip_in, itrack));
+6 -1
View File
@@ -186,6 +186,8 @@ public:
int transition_tool_side;
Ui::Timeline *ui;
void resizeEvent(QResizeEvent *event);
public slots:
void repaint_timeline();
@@ -223,13 +225,16 @@ private slots:
void transition_menu_select(QAction*);
void resize_move(double d);
private:
void set_zoom_value(double v);
QVector<QPushButton*> tool_buttons;
void decheck_tool_buttons(QObject* sender);
void set_tool(int tool);
long last_frame;
int scroll;
int scroll;
void set_sb_max();
int default_track_height;
};
+6 -1
View File
@@ -456,7 +456,7 @@
</widget>
</item>
<item>
<widget class="QScrollBar" name="horizontalScrollBar">
<widget class="ResizableScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>0</number>
</property>
@@ -506,6 +506,11 @@
<header>ui/audiomonitor.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResizableScrollBar</class>
<extends>QScrollBar</extends>
<header>ui/resizablescrollbar.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../icons/icons.qrc"/>
+653 -622
View File
File diff suppressed because it is too large Load Diff
+105 -99
View File
@@ -1,99 +1,105 @@
#ifndef VIEWER_H
#define VIEWER_H
#include <QDockWidget>
#include <QTimer>
class Timeline;
class ViewerWidget;
class Media;
struct Sequence;
namespace Ui {
class Viewer;
}
bool frame_rate_is_droppable(float rate);
long timecode_to_frame(const QString& s, int view, double frame_rate);
QString frame_to_timecode(long f, int view, double frame_rate);
class Viewer : public QDockWidget
{
Q_OBJECT
public:
explicit Viewer(QWidget *parent = 0);
~Viewer();
bool is_focused();
void set_main_sequence();
void set_media(Media *m);
void compose();
void set_playpause_icon(bool play);
void update_playhead_timecode(long p);
void update_end_timecode();
void update_header_zoom();
void update_viewer();
void clear_inout_point();
void set_in_point();
void set_out_point();
void set_zoom(bool in);
// playback functions
void go_to_start();
void previous_frame();
void next_frame();
void seek(long p);
void toggle_play();
void play();
void pause();
void go_to_end();
bool playing;
long playhead_start;
qint64 start_msecs;
QTimer playback_updater;
bool just_played;
void cue_recording(long start, long end, int track);
void uncue_recording();
bool is_recording_cued();
long recording_start;
long recording_end;
int recording_track;
void reset_all_audio();
void update_parents();
ViewerWidget* viewer_widget;
Media* media;
Sequence* seq;
Ui::Viewer *ui;
public slots:
void play_wake();
private slots:
void on_pushButton_clicked();
void on_pushButton_5_clicked();
void on_pushButton_2_clicked();
void on_pushButton_4_clicked();
void on_pushButton_3_clicked();
void update_playhead();
void timer_update();
void recording_flasher_update();
private:
void clean_created_seq();
void set_sequence(bool main, Sequence* s);
bool main_sequence;
bool created_sequence;
long cached_end_frame;
QString panel_name;
double minimum_zoom;
bool cue_recording_internal;
QTimer recording_flasher;
};
#endif // VIEWER_H
#ifndef VIEWER_H
#define VIEWER_H
#include <QDockWidget>
#include <QTimer>
class Timeline;
class ViewerWidget;
class Media;
struct Sequence;
namespace Ui {
class Viewer;
}
bool frame_rate_is_droppable(float rate);
long timecode_to_frame(const QString& s, int view, double frame_rate);
QString frame_to_timecode(long f, int view, double frame_rate);
class Viewer : public QDockWidget
{
Q_OBJECT
public:
explicit Viewer(QWidget *parent = 0);
~Viewer();
bool is_focused();
void set_main_sequence();
void set_media(Media *m);
void compose();
void set_playpause_icon(bool play);
void update_playhead_timecode(long p);
void update_end_timecode();
void update_header_zoom();
void update_viewer();
void clear_inout_point();
void set_in_point();
void set_out_point();
void set_zoom(bool in);
// playback functions
void go_to_start();
void previous_frame();
void next_frame();
void seek(long p);
void toggle_play();
void play();
void pause();
void go_to_end();
bool playing;
long playhead_start;
qint64 start_msecs;
QTimer playback_updater;
bool just_played;
void cue_recording(long start, long end, int track);
void uncue_recording();
bool is_recording_cued();
long recording_start;
long recording_end;
int recording_track;
void reset_all_audio();
void update_parents();
ViewerWidget* viewer_widget;
Media* media;
Sequence* seq;
Ui::Viewer *ui;
void resizeEvent(QResizeEvent *event);
public slots:
void play_wake();
private slots:
void on_pushButton_clicked();
void on_pushButton_5_clicked();
void on_pushButton_2_clicked();
void on_pushButton_4_clicked();
void on_pushButton_3_clicked();
void update_playhead();
void timer_update();
void recording_flasher_update();
void zoom_update(int i);
void resize_move(double d);
private:
void clean_created_seq();
void set_sequence(bool main, Sequence* s);
bool main_sequence;
bool created_sequence;
long cached_end_frame;
QString panel_name;
double minimum_zoom;
void set_zoom_value(double d);
void set_sb_max();
bool cue_recording_internal;
QTimer recording_flasher;
};
#endif // VIEWER_H
+12 -7
View File
@@ -55,7 +55,7 @@
<widget class="TimelineHeader" name="headers" native="true"/>
</item>
<item>
<widget class="QScrollBar" name="horizontalScrollBar">
<widget class="ResizableScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>0</number>
</property>
@@ -229,6 +229,17 @@
</widget>
</widget>
<customwidgets>
<customwidget>
<class>TimelineHeader</class>
<extends>QWidget</extends>
<header>ui/timelineheader.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ResizableScrollBar</class>
<extends>QScrollBar</extends>
<header>ui/resizablescrollbar.h</header>
</customwidget>
<customwidget>
<class>ViewerContainer</class>
<extends>QWidget</extends>
@@ -240,12 +251,6 @@
<extends>QLabel</extends>
<header>ui/labelslider.h</header>
</customwidget>
<customwidget>
<class>TimelineHeader</class>
<extends>QWidget</extends>
<header>ui/timelineheader.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../icons/icons.qrc"/>
+4
View File
@@ -189,6 +189,10 @@ void KeyframeView::draw_keyframe(QPainter &p, int type, int x, int y, bool darke
}
}
void KeyframeView::resize_move(double d) {
header->update_zoom(header->get_zoom()*d);
}
void KeyframeView::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton) {
int row_index = -1;
+2 -1
View File
@@ -23,6 +23,7 @@ public:
public slots:
void set_x_scroll(int);
void set_y_scroll(int);
void resize_move(double d);
private:
long adjust_row_keyframe(EffectRow* row, long time);
QVector<EffectRow*> selected_rows;
@@ -38,7 +39,7 @@ private:
bool mousedown;
bool dragging;
bool keys_selected;
bool select_rect;
bool select_rect;
bool keyframeIsSelected(EffectRow* row, int keyframe);
+104
View File
@@ -0,0 +1,104 @@
#include "resizablescrollbar.h"
#include <QMouseEvent>
#include <QStyle>
#include <QStyleOptionSlider>
#include "debug.h"
#define RESIZE_HANDLE_SIZE 10
ResizableScrollBar::ResizableScrollBar(QWidget *parent) :
QScrollBar(parent),
resize_init(false),
resize_proc(false)
{
setMouseTracking(true);
}
bool ResizableScrollBar::is_resizing() {
return resize_proc;
}
void ResizableScrollBar::resizeEvent(QResizeEvent *event) {
setPageStep(event->size().width());
}
void ResizableScrollBar::mousePressEvent(QMouseEvent *e) {
if (resize_init) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
resize_proc = true;
resize_start = e->pos().x();
resize_start_max = maximum();
resize_start_width = sr.width();
} else {
QScrollBar::mousePressEvent(e);
}
}
void ResizableScrollBar::mouseMoveEvent(QMouseEvent *e) {
QStyleOptionSlider opt;
initStyleOption(&opt);
QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarSlider, this);
QRect gr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
QStyle::SC_ScrollBarGroove, this);
if (resize_proc) {
int diff = (e->pos().x() - resize_start);
if (resize_top) diff = -diff;
double scale = double(sr.width())/double(sr.width()+diff);
if (!qIsInf(scale) && !qIsNull(scale)) {
emit resize_move(scale);
resize_start = e->pos().x();
if (resize_top) {
int slider_min = gr.x();
int slider_max = gr.right() - (sr.width()+diff);
int val = QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x() - slider_min, slider_max - slider_min, opt.upsideDown);
setValue(val);
} else {
setValue(qRound(value() * scale));
}
}
} else {
bool new_resize_init = false;
if ((orientation() == Qt::Horizontal && e->pos().x() > sr.left()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.left()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.top()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.top()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = true;
} else if ((orientation() == Qt::Horizontal && e->pos().x() > sr.right()-RESIZE_HANDLE_SIZE && e->pos().x() < sr.right()+RESIZE_HANDLE_SIZE)
|| (orientation() == Qt::Vertical && e->pos().y() > sr.bottom()-RESIZE_HANDLE_SIZE && e->pos().y() < sr.bottom()+RESIZE_HANDLE_SIZE)) {
new_resize_init = true;
resize_top = false;
}
if (resize_init != new_resize_init) {
if (new_resize_init) {
setCursor(Qt::SizeHorCursor);
} else {
unsetCursor();
}
resize_init = new_resize_init;
}
QScrollBar::mouseMoveEvent(e);
}
}
void ResizableScrollBar::mouseReleaseEvent(QMouseEvent *e) {
if (resize_proc) {
resize_proc = false;
} else {
QScrollBar::mouseReleaseEvent(e);
}
}
+29
View File
@@ -0,0 +1,29 @@
#ifndef RESIZABLESCROLLBAR_H
#define RESIZABLESCROLLBAR_H
#include <QScrollBar>
class ResizableScrollBar : public QScrollBar
{
Q_OBJECT
public:
ResizableScrollBar(QWidget * parent = 0);
bool is_resizing();
signals:
void resize_move(double i);
protected:
void resizeEvent(QResizeEvent *event) override;
void mousePressEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
private:
bool resize_init;
bool resize_proc;
int resize_start;
bool resize_top;
int resize_start_max;
int resize_start_width;
};
#endif // RESIZABLESCROLLBAR_H
+4
View File
@@ -410,3 +410,7 @@ void TimelineHeader::show_context_menu(const QPoint &pos) {
contextMenu.addAction(&clear_in_out);
contextMenu.exec(mapToGlobal(pos));
}
void TimelineHeader::resized_scroll_listener(double d) {
update_zoom(zoom * d);
}
+1
View File
@@ -30,6 +30,7 @@ public slots:
void set_scroll(int);
void set_visible_in(long i);
void show_context_menu(const QPoint &pos);
void resized_scroll_listener(double d);
protected:
void paintEvent(QPaintEvent*);