reimplemented zooming controls

This commit is contained in:
itsmattkc
2019-08-15 11:39:07 +10:00
parent b4529205b9
commit fb7c7f1bdb
15 changed files with 142 additions and 9 deletions
+18
View File
@@ -20,6 +20,8 @@
#include "renderer.h"
#include <QDebug>
RendererProcessor::RendererProcessor() :
started_(false)
{
@@ -41,6 +43,22 @@ QString RendererProcessor::Description()
return tr("A multi-threaded OpenGL hardware-accelerated node compositor.");
}
void RendererProcessor::Process(const rational &time)
{
// Ensure we have started
Start();
if (!started_) {
qWarning() << tr("An error occurred starting the Renderer node");
return;
}
}
void RendererProcessor::Release()
{
Stop();
}
void RendererProcessor::Start()
{
if (started_) {
+4
View File
@@ -43,6 +43,10 @@ public:
virtual QString Category() override;
virtual QString Description() override;
virtual void Process(const rational &time) override;
virtual void Release() override;
/**
* @brief Set parameters of the Renderer
*
+20 -4
View File
@@ -42,10 +42,8 @@ TimelinePanel::TimelinePanel(QWidget *parent) :
connect(view_->horizontalScrollBar(), SIGNAL(valueChanged(int)), ruler_, SLOT(SetScroll(int)));
connect(ruler_, SIGNAL(TimeChanged(const int64_t&)), view_, SLOT(SetTime(const int64_t&)));
// FIXME: Test code
ruler_->SetScale(90.0);
view_->SetScale(90.0);
// End test code
// FIXME Magic number
SetScale(90.0);
Retranslate();
}
@@ -78,6 +76,16 @@ TimelineView *TimelinePanel::view()
return view_;
}
void TimelinePanel::ZoomIn()
{
SetScale(scale_ * 2);
}
void TimelinePanel::ZoomOut()
{
SetScale(scale_ * 0.5);
}
void TimelinePanel::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
@@ -91,3 +99,11 @@ void TimelinePanel::Retranslate()
SetTitle(tr("Timeline"));
SetSubtitle(tr("(none)"));
}
void TimelinePanel::SetScale(double scale)
{
scale_ = scale;
ruler_->SetScale(scale_);
view_->SetScale(scale_);
}
+8
View File
@@ -41,6 +41,10 @@ public:
TimelineView* view();
virtual void ZoomIn() override;
virtual void ZoomOut() override;
protected:
virtual void changeEvent(QEvent* e) override;
@@ -49,9 +53,13 @@ signals:
private:
void Retranslate();
void SetScale(double scale);
TimelineView* view_;
TimeRuler* ruler_;
double scale_;
};
#endif // TIMELINE_PANEL_H
+10
View File
@@ -34,6 +34,16 @@ ViewerPanel::ViewerPanel(QWidget *parent) :
Retranslate();
}
void ViewerPanel::ZoomIn()
{
viewer_->SetScale(viewer_->scale() * 2);
}
void ViewerPanel::ZoomOut()
{
viewer_->SetScale(viewer_->scale() * 0.5);
}
void ViewerPanel::SetTexture(GLuint tex)
{
viewer_->SetTexture(tex);
+4
View File
@@ -34,6 +34,10 @@ class ViewerPanel : public PanelWidget {
public:
ViewerPanel(QWidget* parent);
virtual void ZoomIn() override;
virtual void ZoomOut() override;
public slots:
/**
* @brief Set the texture to draw and draw it
+8
View File
@@ -39,6 +39,14 @@ void PanelWidget::SetBorderVisible(bool enabled)
update();
}
void PanelWidget::ZoomIn()
{
}
void PanelWidget::ZoomOut()
{
}
void PanelWidget::SetTitle(const QString &t)
{
title_ = t;
+16
View File
@@ -46,6 +46,22 @@ public:
* @param enabled
*/
void SetBorderVisible(bool enabled);
/**
* @brief Called whenever this panel is focused and user uses "Zoom In" (either in menus or as a keyboard shortcut)
*
* This function is up to the Panel's interpretation of what the user intends to zoom into. Default behavior is a
* no-op.
*/
virtual void ZoomIn();
/**
* @brief Called whenever this panel is focused and user uses "Zoom Out" (either in menus or as a keyboard shortcut)
*
* This function is up to the Panel's interpretation of what the user intends to zoom out of. Default behavior is a
* no-op.
*/
virtual void ZoomOut();
protected:
/**
* @brief Set panel's title
+5 -1
View File
@@ -98,7 +98,11 @@ void TimelineView::SetScale(const double &scale)
QMapIterator<Block*, TimelineViewRect*> iterator(clip_items_);
while (iterator.hasNext()) {
iterator.value()->SetScale(scale_);
iterator.next();
if (iterator.value() != nullptr) {
iterator.value()->SetScale(scale_);
}
}
playhead_line_->SetScale(scale_);
+6 -1
View File
@@ -69,7 +69,12 @@ void TimeRuler::SetTextVisible(bool e)
update();
}
void TimeRuler::SetScale(double d)
const double &TimeRuler::scale()
{
return scale_;
}
void TimeRuler::SetScale(const double &d)
{
scale_ = d;
+2 -1
View File
@@ -35,7 +35,8 @@ public:
void SetTextVisible(bool e);
void SetScale(double d);
const double& scale();
void SetScale(const double& d);
void SetTimebase(const rational& r);
+10
View File
@@ -67,6 +67,16 @@ void ViewerWidget::SetTimebase(const rational &r)
controls_->SetTimebase(r);
}
const double &ViewerWidget::scale()
{
return ruler_->scale();
}
void ViewerWidget::SetScale(const double &scale_)
{
ruler_->SetScale(scale_);
}
void ViewerWidget::SetTexture(GLuint tex)
{
gl_widget_->SetTexture(tex);
+4
View File
@@ -46,6 +46,10 @@ public:
void SetTimebase(const rational& r);
const double& scale();
void SetScale(const double& scale_);
public slots:
/**
* @brief Set the texture to draw and draw it
+13 -2
View File
@@ -23,6 +23,7 @@
#include <QEvent>
#include "core.h"
#include "panel/panelmanager.h"
#include "tool/tool.h"
#include "ui/style/style.h"
#include "undo/undostack.h"
@@ -84,8 +85,8 @@ MainMenu::MainMenu(QWidget *parent) :
// VIEW MENU
//
view_menu_ = new Menu(this);
view_zoom_in_item_ = view_menu_->AddItem("zoomin", nullptr, nullptr, "=");
view_zoom_out_item_ = view_menu_->AddItem("zoomout", nullptr, nullptr, "-");
view_zoom_in_item_ = view_menu_->AddItem("zoomin", this, SLOT(ZoomInTriggered()), "=");
view_zoom_out_item_ = view_menu_->AddItem("zoomout", this, SLOT(ZoomOutTriggered()), "-");
view_increase_track_height_item_ = view_menu_->AddItem("vzoomin", nullptr, nullptr, "Ctrl+=");
view_decrease_track_height_item_ = view_menu_->AddItem("vzoomout", nullptr, nullptr, "Ctrl+-");
view_show_all_item_ = view_menu_->AddItem("showall", nullptr, nullptr, "\\");
@@ -333,6 +334,16 @@ void MainMenu::ToolsMenuAboutToShow()
tools_snapping_item_->setChecked(olive::core.snapping());
}
void MainMenu::ZoomInTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->ZoomIn();
}
void MainMenu::ZoomOutTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->ZoomOut();
}
void MainMenu::Retranslate()
{
// MenuShared is not a QWidget and therefore does not receive a LanguageEvent, we use MainMenu's to update it
+14
View File
@@ -60,6 +60,20 @@ private slots:
*/
void ToolsMenuAboutToShow();
/**
* @brief Slot for zooming in
*
* Finds the currently focused panel and sends it a "zoom in" signal
*/
void ZoomInTriggered();
/**
* @brief Slot for zooming out
*
* Finds the currently focused panel and sends it a "zoom out" signal
*/
void ZoomOutTriggered();
private:
/**
* @brief Set strings based on the current application language.